[dpdk-dev] [PATCH v4 08/13] testpmd: rework csum forward engine
Liu, Jijiang
jijiang.liu at intel.com
Fri Nov 28 09:54:09 CET 2014
Hi Olivier,
> -----Original Message-----
> From: Ananyev, Konstantin
> Sent: Thursday, November 27, 2014 7:02 PM
> To: Olivier MATZ; dev at dpdk.org
> Cc: Walukiewicz, Miroslaw; Liu, Jijiang; Liu, Yong; jigsaw at gmail.com; Richardson,
> Bruce
> Subject: RE: [PATCH v4 08/13] testpmd: rework csum forward engine
>
> Hi Oliver,
>
> > -----Original Message-----
> > From: Olivier MATZ [mailto:olivier.matz at 6wind.com]
> > Sent: Thursday, November 27, 2014 9:11 AM
> > To: Ananyev, Konstantin; dev at dpdk.org
> > Cc: Walukiewicz, Miroslaw; Liu, Jijiang; Liu, Yong; jigsaw at gmail.com;
> > Richardson, Bruce
> > Subject: Re: [PATCH v4 08/13] testpmd: rework csum forward engine
> >
> > Hi Konstantin,
> >
> > On 11/26/2014 09:02 PM, Ananyev, Konstantin wrote:
> > >> +/* if possible, calculate the checksum of a packet in hw or sw,
> > >> + * depending on the testpmd command line configuration */ static
> > >> +uint64_t process_inner_cksums(void *l3_hdr, uint16_t ethertype,
> > >> +uint16_t l3_len,
> > >> + uint8_t l4_proto, uint16_t testpmd_ol_flags) {
> > >> + struct ipv4_hdr *ipv4_hdr = l3_hdr;
> > >> + struct udp_hdr *udp_hdr;
> > >> + struct tcp_hdr *tcp_hdr;
> > >> + struct sctp_hdr *sctp_hdr;
> > >> + uint64_t ol_flags = 0;
> > >> +
> > >> + if (ethertype == _htons(ETHER_TYPE_IPv4)) {
> > >> + ipv4_hdr = l3_hdr;
> > >> + ipv4_hdr->hdr_checksum = 0;
> > >> +
> > >> + if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM)
> > >> + ol_flags |= PKT_TX_IP_CKSUM;
> > >> + else
> > >> + ipv4_hdr->hdr_checksum = get_ipv4_cksum(ipv4_hdr);
> > >> +
> > >> + ol_flags |= PKT_TX_IPV4;
> > >
> > > Flags PKT_TX_IP_CKSUM, PKT_TX_IPV4, PKT_TX_IPV6 are all mutually
> exclusive.
> > > So it should be, I think:
> > >
> > > if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) {
> > > ol_flags |= PKT_TX_IP_CKSUM;
> > > } else {
> > > ipv4_hdr->hdr_checksum = get_ipv4_cksum(ipv4_hdr);
> > > ol_flags |= PKT_TX_IPV4; }
> >
> > It seems normal that PKT_TX_IPV4 are PKT_TX_IPV6 exclusive, but do you
> > mean that PKT_TX_IP_CKSUM and PKT_TX_IPV4 are exclusive too? It looks
> > strange to me.
> >
> > My understanding of the meaning of the flags is:
> >
> > - PKT_TX_IP_CKSUM: tell the NIC to compute IP cksum
> My initial thought:
> It tells the NIC that it is an IPV4 packet for which it has to compute checksum.
>
> >
> > - PKT_TX_IPV4: tell the NIC it's an IPv4 packet. Required for L4
> > checksum offload or TSO.
>
> It tells the NIC that it is an IPV4 packet for which it shouldn't compute checksum.
>
> >
> > - PKT_TX_IPV6: tell the NIC it's an IPv6 packet. Required for L4
> > checksum offload or TSO.
>
> Yes.
>
> >
> > If it's a i40e driver requirement, don't you think it's better to
> > change the driver?
There should be two logics in csum engine, which is that either HW computes TX checksum (using PKT_TX_IP_CKSUM) or SW compute TX checksum(use PKT_TX_IPV4(or another flag) to tell driver no IP checksum offload requirement ),
I think we shouldn't use L3 flag to tell driver what HW need do for L4, L3 and L4 flag should be separated .
> Yes, it could be done in both ways:
> either all 3 flags are mutually exclusive or first two and third one are mutually
> exclusive.
>
> Current i40e PMD seems to work correctly with the second way too.
>
> Though the second way implies a specific order for PMD to check flags.
> Something like:
> if (ol_flags & PKT_TX_IP_CKSUM) {..} else if (ol_flags & PKT_TX_IPV4) {...} else ...
> would work correctly.
I40e driver use this way.
> But:
> if (ol_flags & PKT_TX_IPV4) {...} else if (ol_flags & PKT_TX_IP_CKSUM) {..} else
> wouldn't.
> >
> > >> +/* Calculate the checksum of outer header (only vxlan is
> > >> +supported,
> > >> + * meaning IP + UDP). The caller already checked that it's a vxlan
> > >> + * packet */
> > >> +static uint64_t
> > >> +process_outer_cksums(void *outer_l3_hdr, uint16_t outer_ethertype,
> > >> + uint16_t outer_l3_len, uint16_t testpmd_ol_flags) {
> > >> + struct ipv4_hdr *ipv4_hdr = outer_l3_hdr;
> > >> + struct ipv6_hdr *ipv6_hdr = outer_l3_hdr;
> > >> + struct udp_hdr *udp_hdr;
> > >> + uint64_t ol_flags = 0;
> > >> +
> > >> + if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM)
> > >> + ol_flags |= PKT_TX_VXLAN_CKSUM;
> > >> +
> > >> + if (outer_ethertype == _htons(ETHER_TYPE_IPv4)) {
> > >> + ipv4_hdr->hdr_checksum = 0;
> > >> +
> > >> + if ((testpmd_ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM)
> == 0)
> > >> + ipv4_hdr->hdr_checksum = get_ipv4_cksum(ipv4_hdr);
> > >> + }
> > >> +
> > >> + udp_hdr = (struct udp_hdr *)((char *)outer_l3_hdr + outer_l3_len);
> > >> + /* do not recalculate udp cksum if it was 0 */
> > >> + if (udp_hdr->dgram_cksum != 0) {
> > >> + udp_hdr->dgram_cksum = 0;
> > >> + if ((testpmd_ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM)
> == 0) {
> > >
> > > In fact, FVL is not able to do HW caclualtion for outer L4, only outer IPV4
> cksum is supported.
> > > So no need for:
> > > if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) { above.
> > > And yes, if user will select to calculate inner checksums by HW - outer UDP
> checksum might be invalid anyway.
> >
> > I may have misunderstood how vxlan works, so I agree this code is
> > probably wrong. However, I don't find the line you are quoting in the
> > function above.
>
> Function: process_outer_cksums(), line 273:
>
> if (udp_hdr->dgram_cksum != 0) {
> udp_hdr->dgram_cksum = 0;
> if ((testpmd_ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM) == 0)
> { /* <-- THAT ONE. */
> if (outer_ethertype == _htons(ETHER_TYPE_IPv4))
>
> I think it is no need for it there.
>
> >
> > I'll check how Jijiang fixed the issue.
> >
> > Regards,
> > Olivier
More information about the dev
mailing list