0

I try to compute checksum for IP and TCP via DPDK checksum offload. The code does the following:

ipv4_hdr->hdr_checksum = 0;
mb->l2_len = eth_hdr_len;
mb->l3_len = ipv4_hdr_len;
mb->ol_flags = PKT_TX_IPV4 | PKT_TX_IP_CKSUM | PKT_TX_TCP_CKSUM;
tcp_hdr->cksum = rte_ipv4_phdr_cksum(ipv4_hdr, mb->ol_flags);

rte_eth_conf has been set:

port_conf.txmode.offloads = DEV_TX_OFFLOAD_IPV4_CKSUM | DEV_TX_OFFLOAD_TCP_CKSUM;

the IP checksum is right, TCP checksum has fixed offset from the correct checksum (under my environment, it is 4)

Any ideas?

HypoGump
  • 51
  • 1
  • 10

1 Answers1

0

Please refer to the answer DPDK HW and SW checksum. For enabling HW checksum one has to set the current checksum value to 0.

/* HW check sum */ 
ip_hdr->hdr_checksum = 0; 
tcp_hdr = (struct tcp_hdr *)((char *)ip_hdr + info->l3_len);
tcp_hdr->cksum = 0;
Vipin Varghese
  • 4,540
  • 2
  • 9
  • 25