Message ID | 20230619091215.2731541-3-arnd@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2869702vqr; Mon, 19 Jun 2023 02:23:33 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4rY5uUt9LrLoPq9BkiZqhdUSDkz6wT9S28dq+5iBP1IoLwaK2kveCCFr/txH6+6PdoGJSm X-Received: by 2002:a17:902:d48b:b0:1b5:642e:139d with SMTP id c11-20020a170902d48b00b001b5642e139dmr2444935plg.10.1687166613365; Mon, 19 Jun 2023 02:23:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687166613; cv=none; d=google.com; s=arc-20160816; b=slaqnPa8cf0mGtmwb0arwC8xTT0u5/+ITsHlCClcrbRg3aMfw6YxeCSrxv73LwhC0F ykSn/+SWqxBBXtUC7VQ6F+2i6A6CVOFWXqW0kdvRAX+ytffrdVR1kmD+EEiRsx6mqdC3 DXfqbdPoBnxXr+07CQxDIXAIW/V1gYeE789VGovwlHgK7Jb3/XkCo7jmGO7xbMNVMI7p 3Pc4aOxMOG6qZmxZzJlb7ziGtNKJtcV4yWyT1kDpKeQDYH2IG1Xd96xGrUd7cTl/wrhK 2FWCvCKsdsceGo5O9W0wTkXXVZF6P8rzzRjpqY2rnrrkxVl0LL6qL2OIOa1UBZi4vwaL 5tyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ImijP6fkgxXQpIWLLiEA2jzAwSFm/o2t17cgxp11D6s=; b=Zg0yO50QPEjCA5P7ef1FFzKcd669ay3k3JHUN76XBvwhPYh3CL2ZZImjPlWLsJfLQp 7M+DJNMbeREU3iUZMJXbCs89vw2iHYcanNIjvs8N6fJRJzLY2z+yjG6L4lTxfMAU7B8g pRaGaOATv5TxN0C/eIDtgkirS37a73fuUiFdgxDDDunjZJLymee/LMOP+suXZ1xFEJO2 99f/P3Zw4coo3D3rMjmBnLc5RluamrLbSwDgjl+Qfu5kXm7A/BHIymJtZNy5THX84kYB JBXBKwREzPM2hRojR9c8JO2VnwaHaofEvHQmLi8BKmq3QlOyEpJwGDGdAcTlGJbgH4tD RmCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VRznDpGm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j15-20020a170902da8f00b001aaf7a9d7aasi16775159plx.126.2023.06.19.02.23.20; Mon, 19 Jun 2023 02:23:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VRznDpGm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231199AbjFSJMw (ORCPT <rfc822;duw91626@gmail.com> + 99 others); Mon, 19 Jun 2023 05:12:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43196 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231238AbjFSJMq (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 19 Jun 2023 05:12:46 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5FB7110E for <linux-kernel@vger.kernel.org>; Mon, 19 Jun 2023 02:12:44 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id CE2BA60204 for <linux-kernel@vger.kernel.org>; Mon, 19 Jun 2023 09:12:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0E9ABC433C0; Mon, 19 Jun 2023 09:12:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1687165963; bh=qxfUKz7rm5GuWEeyfp0weQ2JFwovXXhOCgww3LgVweQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VRznDpGmTl7br3LipdSczF4mjvDiVoU4H2w2jIJzeS2NRj6AyAwmHlptSVRvcDNws MS/kogBoz3+GM69Yg/gzsaYVzgbvU3wj1NkYzX41lODZQyu4F9SGzuB+Al1FodFnMU /BMOQGUCPcpsjORuvNY6D3TpKkbsaBCWzNHN790KzY37Z4+qrDwsS4ixfn1G74C2qq uYVDCLqZQwTRZ2fWWOlQmZ3gf6rzj/tycq0H34Qom908ygXhnbKf/gePAR+LKkVD7p vSrcHmoTHx21hnmhZS81Ee1PBuGjDLa1bx/rJkkpJxsV8nIYTUmPxy7d+23reaTtUu S5g7ojolXdVnw== From: Arnd Bergmann <arnd@kernel.org> To: Edward Cree <ecree.xilinx@gmail.com>, Martin Habets <habetsm.xilinx@gmail.com>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com> Cc: Arnd Bergmann <arnd@arndb.de>, netdev@vger.kernel.org, linux-net-drivers@amd.com, linux-kernel@vger.kernel.org Subject: [PATCH 3/3] sfc: selftest: fix struct packing Date: Mon, 19 Jun 2023 11:12:11 +0200 Message-Id: <20230619091215.2731541-3-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230619091215.2731541-1-arnd@kernel.org> References: <20230619091215.2731541-1-arnd@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769122418567631335?= X-GMAIL-MSGID: =?utf-8?q?1769122418567631335?= |
Series |
[1/3,v2] sfc: add CONFIG_INET dependency for TC offload
|
|
Commit Message
Arnd Bergmann
June 19, 2023, 9:12 a.m. UTC
From: Arnd Bergmann <arnd@arndb.de> Three of the sfc drivers define a packed loopback_payload structure with an ethernet header followed by an IP header. However, the kernel definition of iphdr specifies that this is 4-byte aligned, causing a W=1 warning: net/ethernet/sfc/siena/selftest.c:46:15: error: field ip within 'struct efx_loopback_payload' is less aligned than 'struct iphdr' and is usually due to 'struct efx_loopback_payload' being packed, which can lead to unaligned accesses [-Werror,-Wunaligned-access] struct iphdr ip; As the iphdr packing is not easily changed without breaking other code, change the three structures to use a local definition instead. Signed-off-by: Arnd Bergmann <arnd@arndb.de> --- drivers/net/ethernet/sfc/falcon/selftest.c | 21 ++++++++++++++++++++- drivers/net/ethernet/sfc/selftest.c | 21 ++++++++++++++++++++- drivers/net/ethernet/sfc/siena/selftest.c | 21 ++++++++++++++++++++- 3 files changed, 60 insertions(+), 3 deletions(-)
Comments
On 19/06/2023 10:12, Arnd Bergmann wrote: > From: Arnd Bergmann <arnd@arndb.de> > > Three of the sfc drivers define a packed loopback_payload structure with an > ethernet header followed by an IP header. However, the kernel definition > of iphdr specifies that this is 4-byte aligned, causing a W=1 warning: > > net/ethernet/sfc/siena/selftest.c:46:15: error: field ip within 'struct efx_loopback_payload' is less aligned than 'struct iphdr' and is usually due to 'struct efx_loopback_payload' being packed, which can lead to unaligned accesses [-Werror,-Wunaligned-access] > struct iphdr ip; > > As the iphdr packing is not easily changed without breaking other code, > change the three structures to use a local definition instead. > > Signed-off-by: Arnd Bergmann <arnd@arndb.de> Duplicating the definition isn't the prettiest thing in the world; it'd do for a quick fix if needed but I assume W=1 warnings aren't blocking anyone, so maybe defer this one for now and I'll follow up soon with a rewrite that fixes this more cleanly? My idea is to drop the __packed from the containing struct, make efx_begin_loopback() copy the layers separately, and efx_loopback_rx_packet() similarly do something less direct than casting the packet data to the struct. But I don't insist on it; if you want this fix in immediately then I'm okay with that too. > --- > drivers/net/ethernet/sfc/falcon/selftest.c | 21 ++++++++++++++++++++- > drivers/net/ethernet/sfc/selftest.c | 21 ++++++++++++++++++++- > drivers/net/ethernet/sfc/siena/selftest.c | 21 ++++++++++++++++++++- > 3 files changed, 60 insertions(+), 3 deletions(-) > > diff --git a/drivers/net/ethernet/sfc/falcon/selftest.c b/drivers/net/ethernet/sfc/falcon/selftest.c > index 6a454ac6f8763..fb7fcd27a33a5 100644 > --- a/drivers/net/ethernet/sfc/falcon/selftest.c > +++ b/drivers/net/ethernet/sfc/falcon/selftest.c > @@ -40,7 +40,26 @@ > */ > struct ef4_loopback_payload { > struct ethhdr header; > - struct iphdr ip; > + struct { > +#if defined(__LITTLE_ENDIAN_BITFIELD) > + __u8 ihl:4, > + version:4; > +#elif defined (__BIG_ENDIAN_BITFIELD) > + __u8 version:4, > + ihl:4; > +#else > +#error "Please fix <asm/byteorder.h>" > +#endif > + __u8 tos; > + __be16 tot_len; > + __be16 id; > + __be16 frag_off; > + __u8 ttl; > + __u8 protocol; > + __sum16 check; > + __be32 saddr; > + __be32 daddr; > + } __packed ip; /* unaligned struct iphdr */ > struct udphdr udp; > __be16 iteration; > char msg[64]; > diff --git a/drivers/net/ethernet/sfc/selftest.c b/drivers/net/ethernet/sfc/selftest.c > index 3c5227afd4977..440a57953779c 100644 > --- a/drivers/net/ethernet/sfc/selftest.c > +++ b/drivers/net/ethernet/sfc/selftest.c > @@ -43,7 +43,26 @@ > */ > struct efx_loopback_payload { > struct ethhdr header; > - struct iphdr ip; > + struct { > +#if defined(__LITTLE_ENDIAN_BITFIELD) > + __u8 ihl:4, > + version:4; > +#elif defined (__BIG_ENDIAN_BITFIELD) > + __u8 version:4, > + ihl:4; > +#else > +#error "Please fix <asm/byteorder.h>" > +#endif > + __u8 tos; > + __be16 tot_len; > + __be16 id; > + __be16 frag_off; > + __u8 ttl; > + __u8 protocol; > + __sum16 check; > + __be32 saddr; > + __be32 daddr; > + } __packed ip; /* unaligned struct iphdr */ > struct udphdr udp; > __be16 iteration; > char msg[64]; > diff --git a/drivers/net/ethernet/sfc/siena/selftest.c b/drivers/net/ethernet/sfc/siena/selftest.c > index 07715a3d6beab..b8a8b0495f661 100644 > --- a/drivers/net/ethernet/sfc/siena/selftest.c > +++ b/drivers/net/ethernet/sfc/siena/selftest.c > @@ -43,7 +43,26 @@ > */ > struct efx_loopback_payload { > struct ethhdr header; > - struct iphdr ip; > + struct { > +#if defined(__LITTLE_ENDIAN_BITFIELD) > + __u8 ihl:4, > + version:4; > +#elif defined (__BIG_ENDIAN_BITFIELD) > + __u8 version:4, > + ihl:4; > +#else > +#error "Please fix <asm/byteorder.h>" > +#endif > + __u8 tos; > + __be16 tot_len; > + __be16 id; > + __be16 frag_off; > + __u8 ttl; > + __u8 protocol; > + __sum16 check; > + __be32 saddr; > + __be32 daddr; > + } __packed ip; /* unaligned struct iphdr */ > struct udphdr udp; > __be16 iteration; > char msg[64]; >
On Mon, Jun 19, 2023, at 12:25, Edward Cree wrote: > On 19/06/2023 10:12, Arnd Bergmann wrote: >> From: Arnd Bergmann <arnd@arndb.de> >> >> Three of the sfc drivers define a packed loopback_payload structure with an >> ethernet header followed by an IP header. However, the kernel definition >> of iphdr specifies that this is 4-byte aligned, causing a W=1 warning: >> >> net/ethernet/sfc/siena/selftest.c:46:15: error: field ip within 'struct efx_loopback_payload' is less aligned than 'struct iphdr' and is usually due to 'struct efx_loopback_payload' being packed, which can lead to unaligned accesses [-Werror,-Wunaligned-access] >> struct iphdr ip; >> >> As the iphdr packing is not easily changed without breaking other code, >> change the three structures to use a local definition instead. >> >> Signed-off-by: Arnd Bergmann <arnd@arndb.de> > > Duplicating the definition isn't the prettiest thing in the world; it'd > do for a quick fix if needed but I assume W=1 warnings aren't blocking > anyone, so maybe defer this one for now and I'll follow up soon with a > rewrite that fixes this more cleanly? My idea is to drop the __packed > from the containing struct, make efx_begin_loopback() copy the layers > separately, and efx_loopback_rx_packet() similarly do something less > direct than casting the packet data to the struct. > > But I don't insist on it; if you want this fix in immediately then I'm > okay with that too. > >> --- >> drivers/net/ethernet/sfc/falcon/selftest.c | 21 ++++++++++++++++++++- >> drivers/net/ethernet/sfc/selftest.c | 21 ++++++++++++++++++++- >> drivers/net/ethernet/sfc/siena/selftest.c | 21 ++++++++++++++++++++- >> 3 files changed, 60 insertions(+), 3 deletions(-) >> >> diff --git a/drivers/net/ethernet/sfc/falcon/selftest.c b/drivers/net/ethernet/sfc/falcon/selftest.c >> index 6a454ac6f8763..fb7fcd27a33a5 100644 >> --- a/drivers/net/ethernet/sfc/falcon/selftest.c >> +++ b/drivers/net/ethernet/sfc/falcon/selftest.c >> @@ -40,7 +40,26 @@ >> */ >> struct ef4_loopback_payload { >> struct ethhdr header; >> - struct iphdr ip; >> + struct { >> +#if defined(__LITTLE_ENDIAN_BITFIELD) >> + __u8 ihl:4, >> + version:4; >> +#elif defined (__BIG_ENDIAN_BITFIELD) >> + __u8 version:4, >> + ihl:4; >> +#else >> +#error "Please fix <asm/byteorder.h>" >> +#endif >> + __u8 tos; >> + __be16 tot_len; >> + __be16 id; >> + __be16 frag_off; >> + __u8 ttl; >> + __u8 protocol; >> + __sum16 check; >> + __be32 saddr; >> + __be32 daddr; >> + } __packed ip; /* unaligned struct iphdr */ >> struct udphdr udp; >> __be16 iteration; >> char msg[64]; >> diff --git a/drivers/net/ethernet/sfc/selftest.c b/drivers/net/ethernet/sfc/selftest.c >> index 3c5227afd4977..440a57953779c 100644 >> --- a/drivers/net/ethernet/sfc/selftest.c >> +++ b/drivers/net/ethernet/sfc/selftest.c >> @@ -43,7 +43,26 @@ >> */ >> struct efx_loopback_payload { >> struct ethhdr header; >> - struct iphdr ip; >> + struct { >> +#if defined(__LITTLE_ENDIAN_BITFIELD) >> + __u8 ihl:4, >> + version:4; >> +#elif defined (__BIG_ENDIAN_BITFIELD) >> + __u8 version:4, >> + ihl:4; >> +#else >> +#error "Please fix <asm/byteorder.h>" >> +#endif >> + __u8 tos; >> + __be16 tot_len; >> + __be16 id; >> + __be16 frag_off; >> + __u8 ttl; >> + __u8 protocol; >> + __sum16 check; >> + __be32 saddr; >> + __be32 daddr; >> + } __packed ip; /* unaligned struct iphdr */ >> struct udphdr udp; >> __be16 iteration; >> char msg[64]; >> diff --git a/drivers/net/ethernet/sfc/siena/selftest.c b/drivers/net/ethernet/sfc/siena/selftest.c >> index 07715a3d6beab..b8a8b0495f661 100644 >> --- a/drivers/net/ethernet/sfc/siena/selftest.c >> +++ b/drivers/net/ethernet/sfc/siena/selftest.c >> @@ -43,7 +43,26 @@ >> */ >> struct efx_loopback_payload { >> struct ethhdr header; >> - struct iphdr ip; >> + struct { >> +#if defined(__LITTLE_ENDIAN_BITFIELD) >> + __u8 ihl:4, >> + version:4; >> +#elif defined (__BIG_ENDIAN_BITFIELD) >> + __u8 version:4, >> + ihl:4; >> +#else >> +#error "Please fix <asm/byteorder.h>" >> +#endif >> + __u8 tos; >> + __be16 tot_len; >> + __be16 id; >> + __be16 frag_off; >> + __u8 ttl; >> + __u8 protocol; >> + __sum16 check; >> + __be32 saddr; >> + __be32 daddr; >> + } __packed ip; /* unaligned struct iphdr */ >> struct udphdr udp; >> __be16 iteration; >> char msg[64]; >>
On Mon, Jun 19, 2023, at 12:25, Edward Cree wrote: > On 19/06/2023 10:12, Arnd Bergmann wrote: >> From: Arnd Bergmann <arnd@arndb.de> >> >> Three of the sfc drivers define a packed loopback_payload structure with an >> ethernet header followed by an IP header. However, the kernel definition >> of iphdr specifies that this is 4-byte aligned, causing a W=1 warning: >> >> net/ethernet/sfc/siena/selftest.c:46:15: error: field ip within 'struct efx_loopback_payload' is less aligned than 'struct iphdr' and is usually due to 'struct efx_loopback_payload' being packed, which can lead to unaligned accesses [-Werror,-Wunaligned-access] >> struct iphdr ip; >> >> As the iphdr packing is not easily changed without breaking other code, >> change the three structures to use a local definition instead. >> >> Signed-off-by: Arnd Bergmann <arnd@arndb.de> > > Duplicating the definition isn't the prettiest thing in the world; it'd > do for a quick fix if needed but I assume W=1 warnings aren't blocking > anyone, so maybe defer this one for now and I'll follow up soon with a > rewrite that fixes this more cleanly? My idea is to drop the __packed > from the containing struct, make efx_begin_loopback() copy the layers > separately, and efx_loopback_rx_packet() similarly do something less > direct than casting the packet data to the struct. > > But I don't insist on it; if you want this fix in immediately then I'm > okay with that too. It's not urgent, if you can come up with a nicer solution, that is probably better than applying my patch now. I have a patch [1] that addresses -Wunaligned-access for all x86 and arm randconfig builds, and this currently affects 23 drivers. Most of the changes don't have changelog texts yet, and some need a more detailed analysis to come up with a correct patch. I'd probably aim for linux-6.6 or later to get them all done, at which point we could move the warning from W=1 to the default set. Arnd [1] https://pastebin.com/g6D9NTS4
... > Duplicating the definition isn't the prettiest thing in the world; it'd > do for a quick fix if needed but I assume W=1 warnings aren't blocking > anyone, so maybe defer this one for now and I'll follow up soon with a > rewrite that fixes this more cleanly? My idea is to drop the __packed > from the containing struct, make efx_begin_loopback() copy the layers > separately, and efx_loopback_rx_packet() similarly do something less > direct than casting the packet data to the struct. Maybe you can get away with adding a 16bit pad before the ethernet header so that the IP header is actually aligned. (Then fight all the stuff that stops you doing a memcpy() that runs into a second field of a structure.) Failing that maybe a single shared copy of the misaligned IP header. I also suspect you could just add __packed to the two 32bit address fields. That would generate better code on systems that care. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
On 23/06/2023 11:52, David Laight wrote: > Maybe you can get away with adding a 16bit pad before the ethernet > header so that the IP header is actually aligned. That's what I ended up doing, because my original idea was overcomplicated and turned out super ugly. See https://lore.kernel.org/netdev/6f87fdf5-1844-4633-b4fe-6b247bc6ab49@app.fastmail.com/T/ > (Then fight all the stuff that stops you doing a memcpy() > that runs into a second field of a structure.) Yeah, I don't know how you're meant to annotate that stuff. I guess I'll have to wait until Kees shouts at me and tells me what to do :S -ed
diff --git a/drivers/net/ethernet/sfc/falcon/selftest.c b/drivers/net/ethernet/sfc/falcon/selftest.c index 6a454ac6f8763..fb7fcd27a33a5 100644 --- a/drivers/net/ethernet/sfc/falcon/selftest.c +++ b/drivers/net/ethernet/sfc/falcon/selftest.c @@ -40,7 +40,26 @@ */ struct ef4_loopback_payload { struct ethhdr header; - struct iphdr ip; + struct { +#if defined(__LITTLE_ENDIAN_BITFIELD) + __u8 ihl:4, + version:4; +#elif defined (__BIG_ENDIAN_BITFIELD) + __u8 version:4, + ihl:4; +#else +#error "Please fix <asm/byteorder.h>" +#endif + __u8 tos; + __be16 tot_len; + __be16 id; + __be16 frag_off; + __u8 ttl; + __u8 protocol; + __sum16 check; + __be32 saddr; + __be32 daddr; + } __packed ip; /* unaligned struct iphdr */ struct udphdr udp; __be16 iteration; char msg[64]; diff --git a/drivers/net/ethernet/sfc/selftest.c b/drivers/net/ethernet/sfc/selftest.c index 3c5227afd4977..440a57953779c 100644 --- a/drivers/net/ethernet/sfc/selftest.c +++ b/drivers/net/ethernet/sfc/selftest.c @@ -43,7 +43,26 @@ */ struct efx_loopback_payload { struct ethhdr header; - struct iphdr ip; + struct { +#if defined(__LITTLE_ENDIAN_BITFIELD) + __u8 ihl:4, + version:4; +#elif defined (__BIG_ENDIAN_BITFIELD) + __u8 version:4, + ihl:4; +#else +#error "Please fix <asm/byteorder.h>" +#endif + __u8 tos; + __be16 tot_len; + __be16 id; + __be16 frag_off; + __u8 ttl; + __u8 protocol; + __sum16 check; + __be32 saddr; + __be32 daddr; + } __packed ip; /* unaligned struct iphdr */ struct udphdr udp; __be16 iteration; char msg[64]; diff --git a/drivers/net/ethernet/sfc/siena/selftest.c b/drivers/net/ethernet/sfc/siena/selftest.c index 07715a3d6beab..b8a8b0495f661 100644 --- a/drivers/net/ethernet/sfc/siena/selftest.c +++ b/drivers/net/ethernet/sfc/siena/selftest.c @@ -43,7 +43,26 @@ */ struct efx_loopback_payload { struct ethhdr header; - struct iphdr ip; + struct { +#if defined(__LITTLE_ENDIAN_BITFIELD) + __u8 ihl:4, + version:4; +#elif defined (__BIG_ENDIAN_BITFIELD) + __u8 version:4, + ihl:4; +#else +#error "Please fix <asm/byteorder.h>" +#endif + __u8 tos; + __be16 tot_len; + __be16 id; + __be16 frag_off; + __u8 ttl; + __u8 protocol; + __sum16 check; + __be32 saddr; + __be32 daddr; + } __packed ip; /* unaligned struct iphdr */ struct udphdr udp; __be16 iteration; char msg[64];