I want to define a set of General tunneling APIs, which are used to accelarate tunneling packet processing in DPDK, In this RFC patch set, I wll explain my idea using some codes.
1. Using flow director offload to define a tunnel flow in a pair of queues. flow rule: src IP + dst IP + src port + dst port + tunnel ID (for VXLAN) For example: struct rte_eth_tunnel_conf{ .tunnel_type = VXLAN, .rx_queue = 1, .tx_queue = 1, .filter_type = 'src ip + dst ip + src port + dst port + tunnel id' .flow_tnl { .tunnel_type = VXLAN, .tunnel_id = 100, .remote_mac = 11.22.33.44.55.66, .ip_type = ipv4, .outer_ipv4.src_ip = 192.168.10.1 .outer_ipv4.dst_ip = 10.239.129.11 .src_port = 1000, .dst_port =2000 }; 2. Configure tunnel flow for a device and for a pair of queues. rte_eth_dev_tunnel_configure(0, &rte_eth_tunnel_conf); In this API, it will call RX decapsulation and TX encapsulation callback function if HW doesn't support encap/decap, and a space will be allocated for tunnel configuration and store a pointer to this new allocated space as dev->post_rx/tx_burst_cbs[].param. rte_eth_add_rx_callback(port_id, tunnel_conf.rx_queue, rte_eth_tunnel_decap, (void *)tunnel_conf); rte_eth_add_tx_callback(port_id, tunnel_conf.tx_queue, rte_eth_tunnel_encap, (void *)tunnel_conf) 3. Using rte_vxlan_decap_burst() to do decapsulation of tunneling packet. 4. Using rte_vxlan_encap_burst() to do encapsulation of tunneling packet. The 'src ip, dst ip, src port, dst port and tunnel ID" can be got from tunnel configuration. And SIMD is used to accelarate the operation. How to use these APIs, there is a example below: 1)at config phase dev_config(port, ...); tunnel_config(port,...); ... dev_start(port); ... rx_burst(port, rxq,... ); tx_burst(port, txq,...); 2)at transmitting packet phase The only outer src/dst MAC address need to be set for TX tunnel configuration in dev->post_tx_burst_cbs[].param. In this patch set, I have not finished all of codes, the purpose of sending patch set is that I would like to collect more comments and sugestions on this idea. Jijiang Liu (6): extend rte_eth_tunnel_flow define tunnel flow structure and APIs implement tunnel flow APIs define rte_vxlan_decap/encap implement rte_vxlan_decap/encap i40e tunnel configure drivers/net/i40e/i40e_ethdev.c | 41 +++++ lib/librte_ether/libtunnel/rte_vxlan_opt.c | 251 ++++++++++++++++++++++++++++ lib/librte_ether/libtunnel/rte_vxlan_opt.h | 49 ++++++ lib/librte_ether/rte_eth_ctrl.h | 14 ++- lib/librte_ether/rte_ethdev.h | 28 +++ lib/librte_ether/rte_ethdev.c | 60 ++ 5 files changed, 440 insertions(+), 3 deletions(-) create mode 100644 lib/librte_ether/libtunnel/rte_vxlan_opt.c create mode 100644 lib/librte_ether/libtunnel/rte_vxlan_opt.h -- 1.7.7.6