little things about dataplane
  • Introduction
  • 1.about Linux Bridge
  • 2.dpdk nic offload
  • 3.2.dpdk nic offload:2
  • 4.1Linux-kernel-softirq.1
  • 5.SystemTap instrument
  • 5.SystemTap instrument.1
  • 6.stap script
  • 6 stap script.1
Powered by GitBook
On this page

Was this helpful?

3.2.dpdk nic offload:2

  • vlan strip offloading

make sure the nic supports DEV_RX_OFFLOAD_VLAN_STRIP feature by checking device information .

there are two ways to configure vlan striping in DPDK,one is to set the .hw_vlan_strip bit of rte_eth_conf during device configuration phase,another way is to configure at runtime,rte_eth_dev_set_vlan_offload(port_id,rte_eth_dev_get_vlan_offload()|ETH_VLAN_STRIP_OFFLOAD) .

upon receiving a packet,we see if it's a vlan packet ,'PKT_RX_VLAN_PKT' will be set,and then we could also find PKT_RX_VLAN_STRIPPED bit is set ,and rte-mbuf.vlan_tci is the tci of real vlan header .

-vlan filter offloading

vlan filtering offloading allows nic to filter VLAN packets basing on the vlan white list,still ,we need to configure by doing so:rte_eth_dev_set_vlan_offload(port_id,rte_eth_dev_get_vlan_offload()|ETH_VLAN_FILTER_OFFLOAD) ,and then we could call rte_eth_dev_vlan_filter() to add a vlan to white list. there is no feature bit indicating the packet is allowed after vlan filtering in rte_mbuf.

-vlan insertion offloading

if NIC supports DEV_TX_OFFLOAD_VLAN_INSERT ,then we could use the following code to make NIC insert a vlan header during transmission:

mbufs[idx]->vlan_tci=0xef00;
mbufs[idx]->ol_flags|=PKT_TX_VLAN_PKT;

-tx checksum offloading

first check TX checksum features the NIC supports . for example ,the NIC supports IP checksum tx offloading ,then before transmission ,we set setup offloading flags as follows:

buffer=rte_pktmbuf_mtod(mbufs[idx],char*);
ip4=(struct ipv4_hdr*)(buffer+14);
ip4->hdr_checksum=0;
mbufs[idx]->l2_len=14;
mbufs[idx]->l3_len=20;
mbufs[idx]->ol_flags=PKT_TX_IP_CKSUM|PKT_TX_IPV4;

different checksum types require different pre-setups , please refer to rte_mbuf.h.

Previous2.dpdk nic offloadNext4.1Linux-kernel-softirq.1

Last updated 4 years ago

Was this helpful?