All of lore.kernel.org
 help / color / mirror / Atom feed
* UDP Checksum
@ 2014-11-06 16:05 Alex Markuze
       [not found] ` <CAKfHP0WWCrftSR=z=jvUsHCLtTZdBwch0ZvadiLa9nMfcbpW-Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Alex Markuze @ 2014-11-06 16:05 UTC (permalink / raw)
  To: dev-VfR2kkLFssw

Hi,
I'm seeing "UDP: bad checksum." messages(dmesg) for packets sent by my dpdk
app to a socket on a remote machine.
Looking at the packets the scum value is set, its just not what wireshark
expects.

When sending I'm setting these fields in the egress packets.

        pkt->pkt.vlan_macip.f.l2_len = sizeof(struct ether_hdr);

        pkt->pkt.vlan_macip.f.l3_len = sizeof(struct ipv4_hdr);

        pkt->ol_flags |= (PKT_TX_IP_CKSUM | PKT_TX_L4_MASK);
//PKT_TX_OFFLOAD_MASK;


I'm working with a 82599 VF.


Any thoughts? I'm not sure what else to check.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: UDP Checksum
       [not found] ` <CAKfHP0WWCrftSR=z=jvUsHCLtTZdBwch0ZvadiLa9nMfcbpW-Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2014-11-06 16:15   ` Olivier MATZ
  2014-11-06 16:15   ` Ananyev, Konstantin
  1 sibling, 0 replies; 5+ messages in thread
From: Olivier MATZ @ 2014-11-06 16:15 UTC (permalink / raw)
  To: Alex Markuze, dev-VfR2kkLFssw

Hello,

On 11/06/2014 05:05 PM, Alex Markuze wrote:
> I'm seeing "UDP: bad checksum." messages(dmesg) for packets sent by my dpdk
> app to a socket on a remote machine.
> Looking at the packets the scum value is set, its just not what wireshark
> expects.
> 
> When sending I'm setting these fields in the egress packets.
> 
>         pkt->pkt.vlan_macip.f.l2_len = sizeof(struct ether_hdr);
> 
>         pkt->pkt.vlan_macip.f.l3_len = sizeof(struct ipv4_hdr);
> 
>         pkt->ol_flags |= (PKT_TX_IP_CKSUM | PKT_TX_L4_MASK);
> //PKT_TX_OFFLOAD_MASK;

I think you need to do:

 pkt->pkt.vlan_macip.f.l2_len = sizeof(struct ether_hdr);
 pkt->pkt.vlan_macip.f.l3_len = sizeof(struct ipv4_hdr);
 pkt->ol_flags |= (PKT_TX_IP_CKSUM | PKT_TX_UDP_CKSUM);
 ipv4_hdr->hdr_checksum = 0;
 udp_hdr->dgram_cksum = 0;
 udp_hdr->dgram_cksum = get_ipv4_psd_sum(ipv4_hdr); /* see csumonly.c */


Regards,
Olivier

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: UDP Checksum
       [not found] ` <CAKfHP0WWCrftSR=z=jvUsHCLtTZdBwch0ZvadiLa9nMfcbpW-Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  2014-11-06 16:15   ` Olivier MATZ
@ 2014-11-06 16:15   ` Ananyev, Konstantin
       [not found]     ` <2601191342CEEE43887BDE71AB977258213A2E79-kPTMFJFq+rEu0RiL9chJVbfspsVTdybXVpNB7YpNyf8@public.gmane.org>
  1 sibling, 1 reply; 5+ messages in thread
From: Ananyev, Konstantin @ 2014-11-06 16:15 UTC (permalink / raw)
  To: Alex Markuze, dev-VfR2kkLFssw



> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Alex Markuze
> Sent: Thursday, November 06, 2014 4:05 PM
> To: dev@dpdk.org
> Subject: [dpdk-dev] UDP Checksum
> 
> Hi,
> I'm seeing "UDP: bad checksum." messages(dmesg) for packets sent by my dpdk
> app to a socket on a remote machine.
> Looking at the packets the scum value is set, its just not what wireshark
> expects.
> 
> When sending I'm setting these fields in the egress packets.
> 
>         pkt->pkt.vlan_macip.f.l2_len = sizeof(struct ether_hdr);
> 
>         pkt->pkt.vlan_macip.f.l3_len = sizeof(struct ipv4_hdr);
> 
>         pkt->ol_flags |= (PKT_TX_IP_CKSUM | PKT_TX_L4_MASK);
> //PKT_TX_OFFLOAD_MASK;
> 
> 
> I'm working with a 82599 VF.
> 
> 
> Any thoughts? I'm not sure what else to check.

As I remember, you have to setup  IPV4 header checksum to 0 and
calculate and setup pseudo-header checksum for UDP.
From app/test-pmd/csumonly.c:
...
if (pkt_ol_flags & (PKT_RX_IPV4_HDR | PKT_RX_TUNNEL_IPV4_HDR)) {

                        /* Do not support ipv4 option field */
                        l3_len = sizeof(struct ipv4_hdr) ;

                        ...

                        /* Do not delete, this is required by HW*/
                        ipv4_hdr->hdr_checksum = 0;

                       ...
   
                      if (l4_proto == IPPROTO_UDP) {
                                udp_hdr = (struct udp_hdr*) (rte_pktmbuf_mtod(mb,
                                                unsigned char *) + l2_len + l3_len);
                                if (tx_ol_flags & 0x2) {
                                        /* HW Offload */
                                        ol_flags |= PKT_TX_UDP_CKSUM;
                                        if (ipv4_tunnel)
                                                udp_hdr->dgram_cksum = 0;
                                        else
                                                /* Pseudo header sum need be set properly */
                                                udp_hdr->dgram_cksum =
                                                        get_ipv4_psd_sum(ipv4_hdr);




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: UDP Checksum
       [not found]     ` <2601191342CEEE43887BDE71AB977258213A2E79-kPTMFJFq+rEu0RiL9chJVbfspsVTdybXVpNB7YpNyf8@public.gmane.org>
@ 2014-11-06 16:26       ` Alex Markuze
       [not found]         ` <2601191342CEEE43887BDE71AB977258213A2EC5@IRSMSX105.ger.corp.intel.com>
  0 siblings, 1 reply; 5+ messages in thread
From: Alex Markuze @ 2014-11-06 16:26 UTC (permalink / raw)
  To: Ananyev, Konstantin; +Cc: dev-VfR2kkLFssw

I was setting both ip and udp scum fields to 0. PKT_TX_UDP_CKSUM ==
PKT_TX_L4_MASK = 0x6000.

I was not aware of the get_ipv4_psd_sum(ipv4_hdr);
And I'm quite frankly surprised the HW doesn't already do this. Farther
more I don't remember kernel drivers messing with
L3 Headers(bnx2x/mlx4). Is this true for all PMDs that do scum offloads?

I will give it a try now.


On Thu, Nov 6, 2014 at 6:15 PM, Ananyev, Konstantin <
konstantin.ananyev-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> wrote:

>
>
> > -----Original Message-----
> > From: dev [mailto:dev-bounces-VfR2kkLFssw@public.gmane.org] On Behalf Of Alex Markuze
> > Sent: Thursday, November 06, 2014 4:05 PM
> > To: dev-VfR2kkLFssw@public.gmane.org
> > Subject: [dpdk-dev] UDP Checksum
> >
> > Hi,
> > I'm seeing "UDP: bad checksum." messages(dmesg) for packets sent by my
> dpdk
> > app to a socket on a remote machine.
> > Looking at the packets the scum value is set, its just not what wireshark
> > expects.
> >
> > When sending I'm setting these fields in the egress packets.
> >
> >         pkt->pkt.vlan_macip.f.l2_len = sizeof(struct ether_hdr);
> >
> >         pkt->pkt.vlan_macip.f.l3_len = sizeof(struct ipv4_hdr);
> >
> >         pkt->ol_flags |= (PKT_TX_IP_CKSUM | PKT_TX_L4_MASK);
> > //PKT_TX_OFFLOAD_MASK;
> >
> >
> > I'm working with a 82599 VF.
> >
> >
> > Any thoughts? I'm not sure what else to check.
>
> As I remember, you have to setup  IPV4 header checksum to 0 and
> calculate and setup pseudo-header checksum for UDP.
> From app/test-pmd/csumonly.c:
> ...
> if (pkt_ol_flags & (PKT_RX_IPV4_HDR | PKT_RX_TUNNEL_IPV4_HDR)) {
>
>                         /* Do not support ipv4 option field */
>                         l3_len = sizeof(struct ipv4_hdr) ;
>
>                         ...
>
>                         /* Do not delete, this is required by HW*/
>                         ipv4_hdr->hdr_checksum = 0;
>
>                        ...
>
>                       if (l4_proto == IPPROTO_UDP) {
>                                 udp_hdr = (struct udp_hdr*)
> (rte_pktmbuf_mtod(mb,
>                                                 unsigned char *) + l2_len
> + l3_len);
>                                 if (tx_ol_flags & 0x2) {
>                                         /* HW Offload */
>                                         ol_flags |= PKT_TX_UDP_CKSUM;
>                                         if (ipv4_tunnel)
>                                                 udp_hdr->dgram_cksum = 0;
>                                         else
>                                                 /* Pseudo header sum need
> be set properly */
>                                                 udp_hdr->dgram_cksum =
>
> get_ipv4_psd_sum(ipv4_hdr);
>
>
>
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: UDP Checksum
       [not found]           ` <2601191342CEEE43887BDE71AB977258213A2EC5-kPTMFJFq+rEu0RiL9chJVbfspsVTdybXVpNB7YpNyf8@public.gmane.org>
@ 2014-11-06 17:07             ` Ananyev, Konstantin
  0 siblings, 0 replies; 5+ messages in thread
From: Ananyev, Konstantin @ 2014-11-06 17:07 UTC (permalink / raw)
  To: Alex Markuze (alex-I7wstvAgZDk@public.gmane.org); +Cc: dev-VfR2kkLFssw



> -----Original Message-----
> From: Ananyev, Konstantin
> Sent: Thursday, November 06, 2014 5:04 PM
> To: Ananyev, Konstantin
> Subject: FW: [dpdk-dev] UDP Checksum
> 
> 
> 
> From: Alex Markuze [mailto:alex@weka.io]
> Sent: Thursday, November 06, 2014 4:27 PM
> To: Ananyev, Konstantin
> Cc: dev@dpdk.org
> Subject: Re: [dpdk-dev] UDP Checksum
> 
> I was setting both ip and udp scum fields to 0. PKT_TX_UDP_CKSUM == PKT_TX_L4_MASK = 0x6000.
> 
> I was not aware of the get_ipv4_psd_sum(ipv4_hdr);
> And I'm quite frankly surprised the HW doesn't already do this. Farther more I don't remember kernel drivers messing with
> L3 Headers(bnx2x/mlx4). Is this true for all PMDs that do scum offloads?

I suppose it depends on HW implementation.
All Intel NICs I am aware about (e1000, ixgbe, i40e) expect that SW provides the pseudo IP header checksum in the L4 header.
Not sure what is the story with NICs from other manufactures.

> 
> I will give it a try now.
> 
> 
> On Thu, Nov 6, 2014 at 6:15 PM, Ananyev, Konstantin <konstantin.ananyev@intel.com> wrote:
> 
> 
> > -----Original Message-----
> > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Alex Markuze
> > Sent: Thursday, November 06, 2014 4:05 PM
> > To: dev@dpdk.org
> > Subject: [dpdk-dev] UDP Checksum
> >
> > Hi,
> > I'm seeing "UDP: bad checksum." messages(dmesg) for packets sent by my dpdk
> > app to a socket on a remote machine.
> > Looking at the packets the scum value is set, its just not what wireshark
> > expects.
> >
> > When sending I'm setting these fields in the egress packets.
> >
> >         pkt->pkt.vlan_macip.f.l2_len = sizeof(struct ether_hdr);
> >
> >         pkt->pkt.vlan_macip.f.l3_len = sizeof(struct ipv4_hdr);
> >
> >         pkt->ol_flags |= (PKT_TX_IP_CKSUM | PKT_TX_L4_MASK);
> > //PKT_TX_OFFLOAD_MASK;
> >
> >
> > I'm working with a 82599 VF.
> >
> >
> > Any thoughts? I'm not sure what else to check.
> As I remember, you have to setup  IPV4 header checksum to 0 and
> calculate and setup pseudo-header checksum for UDP.
> From app/test-pmd/csumonly.c:
> ...
> if (pkt_ol_flags & (PKT_RX_IPV4_HDR | PKT_RX_TUNNEL_IPV4_HDR)) {
> 
>                         /* Do not support ipv4 option field */
>                         l3_len = sizeof(struct ipv4_hdr) ;
> 
>                         ...
> 
>                         /* Do not delete, this is required by HW*/
>                         ipv4_hdr->hdr_checksum = 0;
> 
>                        ...
> 
>                       if (l4_proto == IPPROTO_UDP) {
>                                 udp_hdr = (struct udp_hdr*) (rte_pktmbuf_mtod(mb,
>                                                 unsigned char *) + l2_len + l3_len);
>                                 if (tx_ol_flags & 0x2) {
>                                         /* HW Offload */
>                                         ol_flags |= PKT_TX_UDP_CKSUM;
>                                         if (ipv4_tunnel)
>                                                 udp_hdr->dgram_cksum = 0;
>                                         else
>                                                 /* Pseudo header sum need be set properly */
>                                                 udp_hdr->dgram_cksum =
>                                                         get_ipv4_psd_sum(ipv4_hdr);
> 
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-11-06 17:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-06 16:05 UDP Checksum Alex Markuze
     [not found] ` <CAKfHP0WWCrftSR=z=jvUsHCLtTZdBwch0ZvadiLa9nMfcbpW-Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-11-06 16:15   ` Olivier MATZ
2014-11-06 16:15   ` Ananyev, Konstantin
     [not found]     ` <2601191342CEEE43887BDE71AB977258213A2E79-kPTMFJFq+rEu0RiL9chJVbfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2014-11-06 16:26       ` Alex Markuze
     [not found]         ` <2601191342CEEE43887BDE71AB977258213A2EC5@IRSMSX105.ger.corp.intel.com>
     [not found]           ` <2601191342CEEE43887BDE71AB977258213A2EC5-kPTMFJFq+rEu0RiL9chJVbfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2014-11-06 17:07             ` Ananyev, Konstantin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.