Add the offload support of encap action for IPv6 GENEVE tunnel.
Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
---
doc/guides/rel_notes/release_22_11.rst | 1 +
drivers/net/nfp/nfp_flow.c | 49 ++++++++++++++++++++++++++++++++++
2 files changed, 50 insertions(+)
@@ -185,6 +185,7 @@ New Features
* Set the TTL
* Set the DSCP of IPv4 and IPv6
* Encap and decap of VXLAN tunnel
+ * Encap of GENEVE tunnel
* **Updated NXP dpaa2 driver.**
@@ -43,6 +43,10 @@ struct vxlan_data {
sizeof(struct rte_ipv4_hdr) + \
sizeof(struct rte_udp_hdr) + \
sizeof(struct rte_flow_item_geneve))
+#define GENEVE_V6_LEN (sizeof(struct rte_ether_hdr) + \
+ sizeof(struct rte_ipv6_hdr) + \
+ sizeof(struct rte_udp_hdr) + \
+ sizeof(struct rte_flow_item_geneve))
/* Process structure associated with a flow item */
struct nfp_flow_item_proc {
@@ -2691,6 +2695,47 @@ struct nfp_pre_tun_entry {
}
static int
+nfp_flow_action_geneve_encap_v6(struct nfp_app_fw_flower *app_fw_flower,
+ char *act_data,
+ char *actions,
+ const struct rte_flow_action_raw_encap *raw_encap,
+ struct nfp_fl_rule_metadata *nfp_flow_meta,
+ struct nfp_fl_tun *tun)
+{
+ uint8_t tos;
+ uint64_t tun_id;
+ const struct rte_ether_hdr *eth;
+ const struct rte_flow_item_udp *udp;
+ const struct rte_flow_item_ipv6 *ipv6;
+ const struct rte_flow_item_geneve *geneve;
+ struct nfp_fl_act_pre_tun *pre_tun;
+ struct nfp_fl_act_set_tun *set_tun;
+ size_t act_pre_size = sizeof(struct nfp_fl_act_pre_tun);
+ size_t act_set_size = sizeof(struct nfp_fl_act_set_tun);
+
+ eth = (const struct rte_ether_hdr *)raw_encap->data;
+ ipv6 = (const struct rte_flow_item_ipv6 *)(eth + 1);
+ udp = (const struct rte_flow_item_udp *)(ipv6 + 1);
+ geneve = (const struct rte_flow_item_geneve *)(udp + 1);
+
+ pre_tun = (struct nfp_fl_act_pre_tun *)actions;
+ memset(pre_tun, 0, act_pre_size);
+ nfp_flow_pre_tun_v6_process(pre_tun, ipv6->hdr.dst_addr);
+
+ set_tun = (struct nfp_fl_act_set_tun *)(act_data + act_pre_size);
+ memset(set_tun, 0, act_set_size);
+ tos = (ipv6->hdr.vtc_flow >> RTE_IPV6_HDR_TC_SHIFT) & 0xff;
+ tun_id = (geneve->vni[0] << 16) | (geneve->vni[1] << 8) | geneve->vni[2];
+ nfp_flow_set_tun_process(set_tun, NFP_FL_TUN_GENEVE, tun_id,
+ ipv6->hdr.hop_limits, tos);
+ set_tun->tun_proto = geneve->protocol;
+
+ /* Send the tunnel neighbor cmsg to fw */
+ return nfp_flower_add_tun_neigh_v6_encap(app_fw_flower, nfp_flow_meta,
+ tun, eth, ipv6);
+}
+
+static int
nfp_flow_action_raw_encap(struct nfp_app_fw_flower *app_fw_flower,
char *act_data,
char *actions,
@@ -2724,6 +2769,10 @@ struct nfp_pre_tun_entry {
ret = nfp_flow_action_geneve_encap_v4(app_fw_flower, act_data,
actions, raw_encap, nfp_flow_meta, tun);
break;
+ case GENEVE_V6_LEN:
+ ret = nfp_flow_action_geneve_encap_v6(app_fw_flower, act_data,
+ actions, raw_encap, nfp_flow_meta, tun);
+ break;
default:
PMD_DRV_LOG(ERR, "Not an valid raw encap action conf.");
ret = -EINVAL;