DPDK 之 TX-Offload Checksum

DPDK 之 TX-Offload Checksum

计算 IP checksum

mb->l2_len = len(out_eth)
mb->l3_len = len(out_ip)
mb->ol_flags |= PKT_TX_IPV4 | PKT_TX_IP_CSUM

:
out_ip.checksum = 0
网卡支持 DEV_TX_OFFLOAD_IPV4_CKSUM 特性.

计算 IP & UDP checksum

mb->l2_len = len(out_eth)
mb->l3_len = len(out_ip)
mb->ol_flags |= PKT_TX_IPV4 | PKT_TX_IP_CSUM | PKT_TX_UDP_CKSUM

:
out_ip.checksum = 0
out_udp.checksum = rte_ipv4_phdr_cksum()
网卡支持 DEV_TX_OFFLOAD_IPV4_CKSUM and DEV_TX_OFFLOAD_UDP_CKSUM 特性.

计算内层封装 ip checksum.

mb->l2_len = len(out_eth + out_ip + out_udp + vxlan + in_eth)
mb->l3_len = len(in_ip)
mb->ol_flags |= PKT_TX_IPV4 | PKT_TX_IP_CSUM

:
in_ip.checksum = 0
网卡支持 DEV_TX_OFFLOAD_IPV4_CKSUM` 特性.
Note that it can only work if outer L4 checksum is 0.

计算内层封装 IP & TCP checksum

mb->l2_len = len(out_eth + out_ip + out_udp + vxlan + in_eth)
mb->l3_len = len(in_ip)
mb->ol_flags |= PKT_TX_IPV4 | PKT_TX_IP_CSUM | PKT_TX_TCP_CKSUM

:
in_ip.checksum = 0
in_tcp.checksum = rte_ipv4_phdr_cksum()
网卡支持 DEV_TX_OFFLOAD_IPV4_CKSUM and DEV_TX_OFFLOAD_TCP_CKSUM 特性.
Note that it can only work if outer L4 checksum is 0.

计算内层封装 ip checksum 并启用 tso.

mb->l2_len = len(out_eth + out_ip + out_udp + vxlan + in_eth)
mb->l3_len = len(in_ip)
mb->l4_len = len(in_tcp)
mb->ol_flags |= PKT_TX_IPV4 | PKT_TX_IP_CKSUM | PKT_TX_TCP_CKSUM |
  PKT_TX_TCP_SEG;

:
in_ip.checksum = 0
in_tcp.checksum = rte_ipv4_phdr_cksum()
网卡支持 DEV_TX_OFFLOAD_TCP_TSO 特性.
Note that it can only work if outer L4 checksum is 0.

计算内层 ip & 内存封装 ip & tcp checksum .


mb->outer_l2_len = len(out_eth)
mb->outer_l3_len = len(out_ip)
mb->l2_len = len(out_udp + vxlan + in_eth)
mb->l3_len = len(in_ip)
mb->ol_flags |= PKT_TX_OUTER_IPV4 | PKT_TX_OUTER_IP_CKSUM | \
PKT_TX_IP_CKSUM | PKT_TX_TCP_CKSUM;

:
out_ip.checksum = 0
in_ip.checksum = 0
in_tcp.checksum = rte_ipv4_phdr_cksum()

网卡支持 DEV_TX_OFFLOAD_IPV4_CKSUM, DEV_TX_OFFLOAD_UDP_CKSUM and DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM 特性.

以上所有参数使用详情可参考 testpmdcsumonly.c.

你可能感兴趣的:(DPDK)