https://chenghuiyu.gitbooks.io/neutron-vxlan-offload/content/doc/1-introduction/
https://decodezp.github.io/2019/07/16/test15-dpdk-vxlan-csum-offload/
IXGBE
以IXGBE驱动为例,看一下如何让把内层报文Checksum的计算Offload给网卡。
本质上来说,是在DPDK的mbuf
结构中,将L2 Header的长度配置为外层VxLAN报文+内层L2 Header的总长度,这样对网卡来说,该mbuf
对应的报文就是一个L2 Header长得令人发指的普通非隧道报文,但是这样就可以计算内层L3/L4 Header的Checksum了。
ixgbe_tx_offload
在DPDK的IXGBE驱动代码中有如下结构体:
1
|
/** Offload features */
|
这里面l2_len
是占了7个比特位,也就是说你外层报文头长度+内层L2 Header长度不要大于127Byte。
另外代码中还有一些ol_flag
的配置,也需要结合需求一起配置。
配置方法
以下内容节选自:https://doc.dpdk.org/guides/prog_guide/mbuf_lib.html
但是我感觉好像没什么人看到过的样子….
checksum of out_ip:
1
|
mb->l2_len = len(out_eth)
|
set out_ip checksum to 0 in the packet
This is supported on hardware advertising DEV_TX_OFFLOAD_IPV4_CKSUM.
checksum of out_ip and out_udp:
1
|
mb->l2_len = len(out_eth)
|
set out_ip checksum to 0 in the packet
set out_udp checksum to pseudo header using rte_ipv4_phdr_cksum()
This is supported on hardware advertising DEV_TX_OFFLOAD_IPV4_CKSUM and DEV_TX_OFFLOAD_UDP_CKSUM.
checksum of in_ip:
1
|
mb->l2_len = len(out_eth + out_ip + out_udp + vxlan + in_eth)
|
set in_ip checksum to 0 in the packet
This is similar to case 1), but l2_len is different. It is supported on hardware advertising DEV_TX_OFFLOAD_IPV4_CKSUM. Note that it can only work if outer L4 checksum is 0.
checksum of in_ip and in_tcp:
1
|
mb->l2_len = len(out_eth + out_ip + out_udp + vxlan + in_eth)
|
set in_ip checksum to 0 in the packet
set in_tcp checksum to pseudo header using rte_ipv4_phdr_cksum()
This is similar to case 2), but l2_len is different. It is supported on hardware advertising DEV_TX_OFFLOAD_IPV4_CKSUM and DEV_TX_OFFLOAD_TCP_CKSUM. Note that it can only work if outer L4 checksum is 0.
segment inner TCP:
1
|
mb->l2_len = len(out_eth + out_ip + out_udp + vxlan + in_eth)
|
set in_ip checksum to 0 in the packet
set in_tcp checksum to pseudo header without including the IP
payload length using rte_ipv4_phdr_cksum()
This is supported on hardware advertising DEV_TX_OFFLOAD_TCP_TSO. Note that it can only work if outer L4 checksum is 0.
checksum of out_ip, in_ip, in_tcp:
1
|
mb->outer_l2_len = len(out_eth)
|
set out_ip checksum to 0 in the packet
set in_ip checksum to 0 in the packet
set in_tcp checksum to pseudo header using rte_ipv4_phdr_cksum()
This is supported on hardware advertising DEV_TX_OFFLOAD_IPV4_CKSUM, DEV_TX_OFFLOAD_UDP_CKSUM and DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM.