Message ID | 1449602993-6047-1-git-send-email-viktorin@rehivetech.com (mailing list archive) |
---|---|
State | Rejected, archived |
Headers |
Return-Path: <dev-bounces@dpdk.org> X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 321A7559C; Tue, 8 Dec 2015 20:30:46 +0100 (CET) Received: from wes1-so2.wedos.net (wes1-so2.wedos.net [46.28.106.16]) by dpdk.org (Postfix) with ESMTP id 04E82559C for <dev@dpdk.org>; Tue, 8 Dec 2015 20:30:45 +0100 (CET) Received: from pcviktorin.fit.vutbr.cz (pcviktorin.fit.vutbr.cz [147.229.13.147]) by wes1-so2.wedos.net (Postfix) with ESMTPSA id 3pFWnc4rW7zTB; Tue, 8 Dec 2015 20:30:44 +0100 (CET) From: Jan Viktorin <viktorin@rehivetech.com> To: dev@dpdk.org Date: Tue, 8 Dec 2015 20:29:53 +0100 Message-Id: <1449602993-6047-1-git-send-email-viktorin@rehivetech.com> X-Mailer: git-send-email 2.6.3 Subject: [dpdk-dev] [[RFC PATCH]] lib/ether: fix 16-bit unaligned access X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK <dev.dpdk.org> List-Unsubscribe: <http://dpdk.org/ml/options/dev>, <mailto:dev-request@dpdk.org?subject=unsubscribe> List-Archive: <http://dpdk.org/ml/archives/dev/> List-Post: <mailto:dev@dpdk.org> List-Help: <mailto:dev-request@dpdk.org?subject=help> List-Subscribe: <http://dpdk.org/ml/listinfo/dev>, <mailto:dev-request@dpdk.org?subject=subscribe> Errors-To: dev-bounces@dpdk.org Sender: "dev" <dev-bounces@dpdk.org> |
Commit Message
Jan Viktorin
Dec. 8, 2015, 7:29 p.m. UTC
Hello,
I was looking at some warnings generated during ARM build. I can see
53 warnings for my build based on v2.2.0-rc3, spread among:
app/test-pmd/{flowgen,icmpecho,txonly}.c
app/test/{packet_burst_generator,test_hash_functions,test_thash}.c
lib/librte_ether/rte_ether.h
drivers/net/bonding/rte_eth_bond_pmd.c
lib/librte_acl/{acl_gen,acl_run}.c
lib/librte_eal/linuxapp/eal/{eal_interrupts,eal_pci_vfio_mp_sync}.c
lib/librte_hash/rte_cuckoo_hash.c
lib/librte_ip_frag/rte_ipv4_reassembly.c
lib/librte_sched/{rte_bitmap.h,rte_sched.c}
I think, some of them are false-positives. In this RFC patch I tried to fix
only the rte_ether.h which uses the unaligned_uint16_t data type. I didn't
test it as it is just the first kick to solve more of those warns.
Regards
Jan
(I considered to not add the cover-letter as this is just a single small patch.
I hope it does not matter a lot. Is there any convention how to do this?)
---
This commit removes warning reported when building for ARMv7 target.
Signed-off-by: Jan Viktorin <viktorin@rehivetech.com>
---
lib/librte_ether/rte_ether.h | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
Comments
On Tue, 8 Dec 2015 20:29:53 +0100 Jan Viktorin <viktorin@rehivetech.com> wrote: > Hello, > > I was looking at some warnings generated during ARM build. I can see > 53 warnings for my build based on v2.2.0-rc3, spread among: > > app/test-pmd/{flowgen,icmpecho,txonly}.c > app/test/{packet_burst_generator,test_hash_functions,test_thash}.c > lib/librte_ether/rte_ether.h > drivers/net/bonding/rte_eth_bond_pmd.c > lib/librte_acl/{acl_gen,acl_run}.c > lib/librte_eal/linuxapp/eal/{eal_interrupts,eal_pci_vfio_mp_sync}.c > lib/librte_hash/rte_cuckoo_hash.c > lib/librte_ip_frag/rte_ipv4_reassembly.c > lib/librte_sched/{rte_bitmap.h,rte_sched.c} > > I think, some of them are false-positives. In this RFC patch I tried to fix > only the rte_ether.h which uses the unaligned_uint16_t data type. I didn't > test it as it is just the first kick to solve more of those warns. > > Regards > Jan > > (I considered to not add the cover-letter as this is just a single small patch. > I hope it does not matter a lot. Is there any convention how to do this?) > --- > This commit removes warning reported when building for ARMv7 target. > > Signed-off-by: Jan Viktorin <viktorin@rehivetech.com> > --- > lib/librte_ether/rte_ether.h | 5 ++--- > 1 file changed, 2 insertions(+), 3 deletions(-) > > diff --git a/lib/librte_ether/rte_ether.h b/lib/librte_ether/rte_ether.h > index 07c17d7..ba8a80a 100644 > --- a/lib/librte_ether/rte_ether.h > +++ b/lib/librte_ether/rte_ether.h > @@ -175,10 +175,9 @@ static inline int is_multicast_ether_addr(const struct ether_addr *ea) > */ > static inline int is_broadcast_ether_addr(const struct ether_addr *ea) > { > - const unaligned_uint16_t *ea_words = (const unaligned_uint16_t *)ea; > + const uint32_t *ea_words = (const uint32_t *)ea; > > - return (ea_words[0] == 0xFFFF && ea_words[1] == 0xFFFF && > - ea_words[2] == 0xFFFF); > + return ea_words[0] == 0xFFFFFFFF && (ea_words[1] & 0x0FFFF) == 0x0FFFF; The problem with that is that it assumes little-endian.
2015-12-08 20:29, Jan Viktorin: > (I considered to not add the cover-letter as this is just a single small patch. > I hope it does not matter a lot. Is there any convention how to do this?) The main interest of splitting patches or adding a cover letter it to have a place to explain the changes. When you have several changes, they deserve several patches to provide an accurate explanation. In such case, you may need a cover letter to describe the global idea of the series. A cover letter is also helpful for mail threading and acking all the series. When you have only one change, one email is enough. John, should we add this explanation in the contributing guide?
On Tue, 8 Dec 2015 12:02:54 -0800 Stephen Hemminger <stephen@networkplumber.org> wrote: > On Tue, 8 Dec 2015 20:29:53 +0100 > Jan Viktorin <viktorin@rehivetech.com> wrote: > > > Hello, > > > > I was looking at some warnings generated during ARM build. I can see > > 53 warnings for my build based on v2.2.0-rc3, spread among: > > > > app/test-pmd/{flowgen,icmpecho,txonly}.c > > app/test/{packet_burst_generator,test_hash_functions,test_thash}.c > > lib/librte_ether/rte_ether.h > > drivers/net/bonding/rte_eth_bond_pmd.c > > lib/librte_acl/{acl_gen,acl_run}.c > > lib/librte_eal/linuxapp/eal/{eal_interrupts,eal_pci_vfio_mp_sync}.c > > lib/librte_hash/rte_cuckoo_hash.c > > lib/librte_ip_frag/rte_ipv4_reassembly.c > > lib/librte_sched/{rte_bitmap.h,rte_sched.c} > > > > I think, some of them are false-positives. In this RFC patch I tried to fix > > only the rte_ether.h which uses the unaligned_uint16_t data type. I didn't > > test it as it is just the first kick to solve more of those warns. > > > > Regards > > Jan > > > > (I considered to not add the cover-letter as this is just a single small patch. > > I hope it does not matter a lot. Is there any convention how to do this?) > > --- > > This commit removes warning reported when building for ARMv7 target. > > > > Signed-off-by: Jan Viktorin <viktorin@rehivetech.com> > > --- > > lib/librte_ether/rte_ether.h | 5 ++--- > > 1 file changed, 2 insertions(+), 3 deletions(-) > > > > diff --git a/lib/librte_ether/rte_ether.h b/lib/librte_ether/rte_ether.h > > index 07c17d7..ba8a80a 100644 > > --- a/lib/librte_ether/rte_ether.h > > +++ b/lib/librte_ether/rte_ether.h > > @@ -175,10 +175,9 @@ static inline int is_multicast_ether_addr(const struct ether_addr *ea) > > */ > > static inline int is_broadcast_ether_addr(const struct ether_addr *ea) > > { > > - const unaligned_uint16_t *ea_words = (const unaligned_uint16_t *)ea; > > + const uint32_t *ea_words = (const uint32_t *)ea; > > > > - return (ea_words[0] == 0xFFFF && ea_words[1] == 0xFFFF && > > - ea_words[2] == 0xFFFF); > > + return ea_words[0] == 0xFFFFFFFF && (ea_words[1] & 0x0FFFF) == 0x0FFFF; > > The problem with that is that it assumes little-endian. Well, true. But there is another issue that I considered just after left for home today :). The ether_addr can be unaligned in memory easily (as it comes in the Ethernet frame). Another false-positive... So the original code is correct. The fix would be to mute the compiler here. The solution is probably to enable RTE_ARCH_STRICT_ALIGN in the defconfig_arm-armv7a-linuxapp-gcc. This will probably solve more unaligned false-positives. Regards Jan
On Tue, 08 Dec 2015 21:30:03 +0100 Thomas Monjalon <thomas.monjalon@6wind.com> wrote: > 2015-12-08 20:29, Jan Viktorin: > > (I considered to not add the cover-letter as this is just a single small patch. > > I hope it does not matter a lot. Is there any convention how to do this?) > > The main interest of splitting patches or adding a cover letter it to have > a place to explain the changes. When you have several changes, they deserve > several patches to provide an accurate explanation. In such case, you may > need a cover letter to describe the global idea of the series. A cover letter > is also helpful for mail threading and acking all the series. > When you have only one change, one email is enough. That's good. Should there be a way how to separate the "inline-cover" and the commit? > > John, should we add this explanation in the contributing guide?
2015-12-08 21:55, Jan Viktorin: > On Tue, 08 Dec 2015 21:30:03 +0100 > Thomas Monjalon <thomas.monjalon@6wind.com> wrote: > > > 2015-12-08 20:29, Jan Viktorin: > > > (I considered to not add the cover-letter as this is just a single small patch. > > > I hope it does not matter a lot. Is there any convention how to do this?) > > > > The main interest of splitting patches or adding a cover letter it to have > > a place to explain the changes. When you have several changes, they deserve > > several patches to provide an accurate explanation. In such case, you may > > need a cover letter to describe the global idea of the series. A cover letter > > is also helpful for mail threading and acking all the series. > > When you have only one change, one email is enough. > > That's good. Should there be a way how to separate the "inline-cover" > and the commit? Do you mean how add a comment which won't be in the git tree? You can put whatever between the 3 dashes and the diff.
On Tue, 08 Dec 2015 21:57:33 +0100 Thomas Monjalon <thomas.monjalon@6wind.com> wrote: > 2015-12-08 21:55, Jan Viktorin: > > On Tue, 08 Dec 2015 21:30:03 +0100 > > Thomas Monjalon <thomas.monjalon@6wind.com> wrote: > > > > > 2015-12-08 20:29, Jan Viktorin: > > > > (I considered to not add the cover-letter as this is just a single small patch. > > > > I hope it does not matter a lot. Is there any convention how to do this?) > > > > > > The main interest of splitting patches or adding a cover letter it to have > > > a place to explain the changes. When you have several changes, they deserve > > > several patches to provide an accurate explanation. In such case, you may > > > need a cover letter to describe the global idea of the series. A cover letter > > > is also helpful for mail threading and acking all the series. > > > When you have only one change, one email is enough. > > > > That's good. Should there be a way how to separate the "inline-cover" > > and the commit? > > Do you mean how add a comment which won't be in the git tree? > You can put whatever between the 3 dashes and the diff. > Exactly. When I was writing this message, I decided to put the "cover" first and the commit log after the 3 dashes. It was more logical to me...
diff --git a/lib/librte_ether/rte_ether.h b/lib/librte_ether/rte_ether.h index 07c17d7..ba8a80a 100644 --- a/lib/librte_ether/rte_ether.h +++ b/lib/librte_ether/rte_ether.h @@ -175,10 +175,9 @@ static inline int is_multicast_ether_addr(const struct ether_addr *ea) */ static inline int is_broadcast_ether_addr(const struct ether_addr *ea) { - const unaligned_uint16_t *ea_words = (const unaligned_uint16_t *)ea; + const uint32_t *ea_words = (const uint32_t *)ea; - return (ea_words[0] == 0xFFFF && ea_words[1] == 0xFFFF && - ea_words[2] == 0xFFFF); + return ea_words[0] == 0xFFFFFFFF && (ea_words[1] & 0x0FFFF) == 0x0FFFF; } /**