From: Ben Hutchings <bhutchings@solarflare.com>
To: Jim Baxter <jim_baxter@mentor.com>
Cc: Eric Dumazet <eric.dumazet@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
Frank Li <Frank.Li@freescale.com>,
Fugang Duan <B38611@freescale.com>, <netdev@vger.kernel.org>,
Fabio Estevam <festevam@gmail.com>,
Francois Romieu <romieu@fr.zoreil.com>
Subject: Re: [PATCH net-next v3 1/1] net: fec: Enable imx6 enet checksum acceleration.
Date: Thu, 18 Apr 2013 23:03:00 +0100 [thread overview]
Message-ID: <1366322580.2735.48.camel@bwh-desktop.uk.solarflarecom.com> (raw)
In-Reply-To: <5170653A.2000601@mentor.com>
On Thu, 2013-04-18 at 22:27 +0100, Jim Baxter wrote:
> On 18/04/13 18:21, Jim Baxter wrote:
> > On 18/04/13 18:12, Ben Hutchings wrote:
> >> On Thu, 2013-04-18 at 18:08 +0100, Jim Baxter wrote:
> >>> On 18/04/13 17:16, Ben Hutchings wrote:
> >>>> On Thu, 2013-04-18 at 13:49 +0100, Jim Baxter wrote:
> >>>>> On 17/04/13 22:37, Eric Dumazet wrote:
> >>>>>> On Wed, 2013-04-17 at 21:07 +0100, Jim Baxter wrote:
> >>>>>>
> >>>>>>> + skb_set_transport_header(skb,
> >>>>>>> + ETH_HLEN + ip_hdrlen(skb));
> >>>>>>> + udp_hdr(skb)->check = 0;
> >>>>>>> + break;
> >>>>>>> + case IPPROTO_TCP:
> >>>>>>> + hdr_len = (ETH_HLEN +
> >>>>>>> + (ip_hdr(skb)->ihl << 2) +
> >>>>>>> + sizeof(struct tcphdr));
> >>>>>>> + if (skb->len < hdr_len)
> >>>>>>> + return;
> >>>>>>> + skb_cow_head(skb, hdr_len);
> >>>>>>
> >>>>>> same here
> >>>>> Do I need to call skb_cow_head here, I am not changing the size of the
> >>>>> header?
> >>>> [...]
> >>>>
> >>>> The length passed to skb_cow_head() may be significant when the skb has
> >>>> paged fragments. Since you aren't (yet) implementing scatter-gather,
> >>>> that won't happen. And the headers shouldn't be in paged fragments
> >>>> anyway. I think you can safely use skb_cow_head(skb, 0).
> >>>>
> >>>> But you don't actually need to check protocol numbers at all, as the
> >>>> kernel already specifies where the checksum should be.
> >>>>
> >>>> So I think this function should look like:
> >>>> {
> >>>> if (skb->ip_summed != CHECKSUM_PARTIAL)
> >>>> return 0;
> >>>>
> >>>> if (unlikely(skb_cow_head(skb, 0)))
> >>>> return -1;
> >>>>
> >>>> *(__sum16 *)(skb->head + skb->csum_start + skb->csum_offset) = 0;
> >>>> return 0;
> >>>> }
> >>>>
> >>>> The caller needs to check for the failure, and free the skb
> >>>> (kfree_skb()) rather than transmitting it.
> >>>>
> >>>> Ben.
> >>>>
> >>>
> >>> Which checksum does skb->csum (skb->csum_start + skb->csum_offset)
> >>> relate to?
> >>
> >> TCP or UDP.
> >>
> >>> The network card can generate IP header and protocol (UDP/TCP/ICMP)
> >>> checksums as long as the checksums are zeroed?
> >>
> >> You don't need to offload the IPv4 header checksum. TX checksum offload
> >> will not be requested for ICMP.
> >
> > So the kernel only offloads TCP and UDP checksum's. All other transport
> > protocols (ICMP, ICMPIPV6 etc.) will be done by the kernel.
> >
> >>
> >> Ben.
> >>
> >
> > Thanks, though I saw you replied to my question before I could send it.
> >
> > It sounds like there is no reason wasting CPU cycles clearing the IP
> > header checksum, so I can keep the code efficient.
> >
> > Jim
> >
>
> Does anybody know if the kernel uses checksum offloading for IPV6, if I
> enable the feature NETIF_F_HW_CSUM, I only receive CHECKSUM_NONE when
> the protocol is 0x86DD?
NETIF_F_HW_CSUM means you can generate TCP-style checksums from an
arbitrary starting offset. You would then use skb->csum_start and
skb->csum_offset to construct the TX descriptor(s).
If the hardware generates checksums for specific protocols based on
parsing the packet contents, you should set NETIF_F_IP_CSUM (TCP and UDP
on IPv4) and/or NETIF_F_IPV6_CSUM (TCP and UDP on IPv6). It appears
from your original patch that the hardware behaves like this.
Ben.
> I realise there is no IP header checksum, but I thought the protocols
> still use a checksum.
>
> I am using iperf with the -V option in UDP mode, which offloads for IPV4.
--
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
next prev parent reply other threads:[~2013-04-18 22:03 UTC|newest]
Thread overview: 73+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <Jim Baxter <jim_baxter@mentor.com>
2013-04-17 20:07 ` [PATCH net-next v3 1/1] net: fec: Enable imx6 enet checksum acceleration Jim Baxter
2013-04-17 21:37 ` Eric Dumazet
2013-04-18 12:49 ` Jim Baxter
2013-04-18 16:16 ` Ben Hutchings
2013-04-18 17:07 ` Ben Hutchings
2013-04-18 17:08 ` Jim Baxter
2013-04-18 17:12 ` Ben Hutchings
2013-04-18 17:21 ` Jim Baxter
2013-04-18 21:27 ` Jim Baxter
2013-04-18 22:03 ` Ben Hutchings [this message]
2013-04-17 22:45 ` Francois Romieu
2013-04-18 10:18 ` Jim Baxter
2013-04-18 11:31 ` Fabio Estevam
2013-04-18 21:54 ` Francois Romieu
2013-04-19 8:45 ` Jim Baxter
2013-04-19 15:10 ` [PATCH net-next v4 " Jim Baxter
2013-04-19 15:29 ` Eric Dumazet
2013-04-19 15:55 ` Jim Baxter
2013-04-19 15:56 ` Ben Hutchings
2013-04-19 15:59 ` Eric Dumazet
2013-04-19 15:34 ` Ben Hutchings
2013-04-19 16:16 ` Jim Baxter
2013-04-19 16:20 ` Ben Hutchings
2013-04-19 18:10 ` [PATCH net-next v5 " Jim Baxter
2013-04-19 18:50 ` Ben Hutchings
2013-04-25 7:59 ` David Miller
2013-06-25 23:55 ` [PATCH net-next v1 1/1] net: fec: Add VLAN receive HW support Jim Baxter
2013-06-26 2:22 ` Duan Fugang-B38611
2013-06-26 2:31 ` Duan Fugang-B38611
2013-06-26 2:56 ` Shawn Guo
2013-06-26 3:13 ` Duan Fugang-B38611
2013-06-26 5:49 ` David Miller
2013-06-26 10:09 ` Jim Baxter
2013-06-26 11:18 ` Duan Fugang-B38611
2013-06-26 11:45 ` Jim Baxter
2013-06-27 1:41 ` Duan Fugang-B38611
2013-06-27 9:35 ` Jim Baxter
2013-06-27 9:44 ` Lucas Stach
2013-06-27 14:03 ` Jim Baxter
2013-06-27 18:25 ` [PATCH net v1 1/1] net: fec: Fix Transmitted bytes counter Jim Baxter
2013-06-28 2:11 ` Duan Fugang-B38611
2013-07-01 20:40 ` David Miller
2013-07-02 8:32 ` Jim Baxter
2013-07-02 8:46 ` David Miller
2013-06-28 9:51 ` [PATCH net v2 " Jim Baxter
2013-06-28 10:10 ` Duan Fugang-B38611
2013-06-28 14:08 ` [PATCH net-next v2 1/1] net: fec: Add VLAN receive HW support Jim Baxter
2013-06-29 5:34 ` Duan Fugang-B38611
2013-07-02 0:09 ` David Miller
2013-07-02 9:39 ` Jim Baxter
2013-06-28 15:07 ` [PATCH RFC net-next v1 1/1] net: fec: Fix RMON registers on imx6 Jim Baxter
2013-06-29 5:58 ` Duan Fugang-B38611
[not found] ` <CAFXsbZpgAqvkEy+S83iJNMH9-N7h68MDRuvARE9pmT7HbcpAOQ@mail.gmail.com>
[not found] ` <CAFXsbZoBQ3ODUnFg-VumP+YAfCJ2-d=nL_=Gk2LKXm7PadHUuQ@mail.gmail.com>
2013-07-01 10:16 ` Jim Baxter
2013-07-01 10:31 ` [PATCH " Jim Baxter
[not found] ` <CAFXsbZoDWn4KgAVEpUtajo+PwfnrJoO0eTw9g6+MdQ8b666=EQ@mail.gmail.com>
2013-07-01 13:52 ` Jim Baxter
2013-07-02 19:41 ` David Miller
2013-07-01 13:57 ` [PATCH net-next v3 " Jim Baxter
2013-07-02 21:52 ` [PATCH net-next v3 1/1] net: fec: Add VLAN receive HW support Jim Baxter
2013-07-03 23:45 ` David Miller
2014-05-29 17:12 ` [PATCH v1 0/3] usb: gadget: NCM: Fixes and Multi-frame for TX Jim Baxter
2014-05-29 17:12 ` [PATCH v1 1/3] usb: gadget: NCM: RX function support multiple NDPs Jim Baxter
2014-05-29 18:55 ` Bjørn Mork
2014-05-30 11:45 ` Jim Baxter
2014-05-29 17:12 ` [PATCH v1 2/3] usb: gadget: NCM: Add transmit multi-frame Jim Baxter
2014-05-29 17:12 ` [PATCH v1 3/3] usb: gadget: NCM: Stop RX TCP Bursts getting dropped Jim Baxter
2014-05-29 19:04 ` Eric Dumazet
2014-05-30 11:25 ` Jim Baxter
2014-06-12 9:38 ` Jim Baxter
2014-06-12 9:42 ` David Laight
2014-07-07 17:33 ` [PATCH v2 0/3] usb: gadget: NCM: Fixes and Multi-frame for TX Jim Baxter
2014-07-07 17:33 ` [PATCH v2 1/3] usb: gadget: NCM: RX function support multiple NDPs Jim Baxter
2014-07-07 17:33 ` [PATCH v2 2/3] usb: gadget: NCM: Add transmit multi-frame Jim Baxter
2014-07-07 17:33 ` [PATCH v2 3/3] usb: gadget: NCM: Stop RX TCP Bursts getting dropped Jim Baxter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1366322580.2735.48.camel@bwh-desktop.uk.solarflarecom.com \
--to=bhutchings@solarflare.com \
--cc=B38611@freescale.com \
--cc=Frank.Li@freescale.com \
--cc=davem@davemloft.net \
--cc=eric.dumazet@gmail.com \
--cc=festevam@gmail.com \
--cc=jim_baxter@mentor.com \
--cc=netdev@vger.kernel.org \
--cc=romieu@fr.zoreil.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).