From: Chaoyong He <chaoyong.he@corigine.com>
To: dev@dpdk.org
Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com,
Chaoyong He <chaoyong.he@corigine.com>
Subject: [PATCH v3 05/26] net/nfp: prepare for IPv6 tunnel encap flow action
Date: Tue, 25 Oct 2022 15:58:57 +0800 [thread overview]
Message-ID: <20221025075918.7778-6-chaoyong.he@corigine.com> (raw)
In-Reply-To: <20221025075918.7778-1-chaoyong.he@corigine.com>
Add the related data structure and functions, prepare for
the encap action of IPv6 tunnel.
Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
---
drivers/net/nfp/flower/nfp_flower_cmsg.c | 29 +++++++
drivers/net/nfp/flower/nfp_flower_cmsg.h | 40 +++++++++
drivers/net/nfp/nfp_flow.c | 105 ++++++++++++++++++++++-
3 files changed, 173 insertions(+), 1 deletion(-)
diff --git a/drivers/net/nfp/flower/nfp_flower_cmsg.c b/drivers/net/nfp/flower/nfp_flower_cmsg.c
index 7021d1fd43..8983178378 100644
--- a/drivers/net/nfp/flower/nfp_flower_cmsg.c
+++ b/drivers/net/nfp/flower/nfp_flower_cmsg.c
@@ -275,3 +275,32 @@ nfp_flower_cmsg_tun_neigh_v4_rule(struct nfp_app_fw_flower *app_fw_flower,
return 0;
}
+
+int
+nfp_flower_cmsg_tun_neigh_v6_rule(struct nfp_app_fw_flower *app_fw_flower,
+ struct nfp_flower_cmsg_tun_neigh_v6 *payload)
+{
+ uint16_t cnt;
+ size_t msg_len;
+ struct rte_mbuf *mbuf;
+ struct nfp_flower_cmsg_tun_neigh_v6 *msg;
+
+ mbuf = rte_pktmbuf_alloc(app_fw_flower->ctrl_pktmbuf_pool);
+ if (mbuf == NULL) {
+ PMD_DRV_LOG(DEBUG, "Failed to alloc mbuf for v6 tun neigh");
+ return -ENOMEM;
+ }
+
+ msg_len = sizeof(struct nfp_flower_cmsg_tun_neigh_v6);
+ msg = nfp_flower_cmsg_init(mbuf, NFP_FLOWER_CMSG_TYPE_TUN_NEIGH_V6, msg_len);
+ memcpy(msg, payload, msg_len);
+
+ cnt = nfp_flower_ctrl_vnic_xmit(app_fw_flower, mbuf);
+ if (cnt == 0) {
+ PMD_DRV_LOG(ERR, "Send cmsg through ctrl vnic failed.");
+ rte_pktmbuf_free(mbuf);
+ return -EIO;
+ }
+
+ return 0;
+}
diff --git a/drivers/net/nfp/flower/nfp_flower_cmsg.h b/drivers/net/nfp/flower/nfp_flower_cmsg.h
index e44e311176..d1e0562cf9 100644
--- a/drivers/net/nfp/flower/nfp_flower_cmsg.h
+++ b/drivers/net/nfp/flower/nfp_flower_cmsg.h
@@ -159,6 +159,42 @@ struct nfp_flower_cmsg_tun_neigh_v4 {
struct nfp_flower_tun_neigh common;
};
+/*
+ * NFP_FLOWER_CMSG_TYPE_TUN_NEIGH_V6
+ * Bit 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0
+ * -----\ 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
+ * +---------------------------------------------------------------+
+ * 0 | DST_IPV6 [0] |
+ * +---------------------------------------------------------------+
+ * 1 | DST_IPV6 [1] |
+ * +---------------------------------------------------------------+
+ * 2 | DST_IPV6 [2] |
+ * +---------------------------------------------------------------+
+ * 3 | DST_IPV6 [3] |
+ * +---------------------------------------------------------------+
+ * 4 | SRC_IPV6 [0] |
+ * +---------------------------------------------------------------+
+ * 5 | SRC_IPV6 [1] |
+ * +---------------------------------------------------------------+
+ * 6 | SRC_IPV6 [2] |
+ * +---------------------------------------------------------------+
+ * 7 | SRC_IPV6 [3] |
+ * +---------------------------------------------------------------+
+ * 8 | DST_MAC_B5_B4_B3_B2 |
+ * +-------------------------------+-------------------------------+
+ * 9 | DST_MAC_B1_B0 | SRC_MAC_B5_B4 |
+ * +-------------------------------+-------------------------------+
+ * 10 | SRC_MAC_B3_B2_B1_B0 |
+ * +---------------+---------------+---------------+---------------+
+ * 11 | Egress Port (NFP internal) |
+ * +---------------------------------------------------------------+
+ */
+struct nfp_flower_cmsg_tun_neigh_v6 {
+ uint8_t dst_ipv6[16];
+ uint8_t src_ipv6[16];
+ struct nfp_flower_tun_neigh common;
+};
+
/*
* NFP_FLOWER_CMSG_TYPE_FLOW_STATS
* Bit 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0
@@ -629,6 +665,8 @@ struct nfp_fl_act_pre_tun {
};
};
+#define NFP_FL_PRE_TUN_IPV6 (1 << 0)
+
/*
* Set tunnel
* 3 2 1
@@ -676,5 +714,7 @@ int nfp_flower_cmsg_flow_add(struct nfp_app_fw_flower *app_fw_flower,
struct rte_flow *flow);
int nfp_flower_cmsg_tun_neigh_v4_rule(struct nfp_app_fw_flower *app_fw_flower,
struct nfp_flower_cmsg_tun_neigh_v4 *payload);
+int nfp_flower_cmsg_tun_neigh_v6_rule(struct nfp_app_fw_flower *app_fw_flower,
+ struct nfp_flower_cmsg_tun_neigh_v6 *payload);
#endif /* _NFP_CMSG_H_ */
diff --git a/drivers/net/nfp/nfp_flow.c b/drivers/net/nfp/nfp_flow.c
index f71f8b1d5b..e1b892f303 100644
--- a/drivers/net/nfp/nfp_flow.c
+++ b/drivers/net/nfp/nfp_flow.c
@@ -1781,6 +1781,16 @@ nfp_flow_pre_tun_v4_process(struct nfp_fl_act_pre_tun *pre_tun,
pre_tun->ipv4_dst = ipv4_dst;
}
+__rte_unused static void
+nfp_flow_pre_tun_v6_process(struct nfp_fl_act_pre_tun *pre_tun,
+ const uint8_t ipv6_dst[])
+{
+ pre_tun->head.jump_id = NFP_FL_ACTION_OPCODE_PRE_TUNNEL;
+ pre_tun->head.len_lw = sizeof(struct nfp_fl_act_pre_tun) >> NFP_FL_LW_SIZ;
+ pre_tun->flags = rte_cpu_to_be_16(NFP_FL_PRE_TUN_IPV6);
+ memcpy(pre_tun->ipv6_dst, ipv6_dst, sizeof(pre_tun->ipv6_dst));
+}
+
__rte_unused static void
nfp_flow_set_tun_process(struct nfp_fl_act_set_tun *set_tun,
enum nfp_flower_tun_type tun_type,
@@ -1845,7 +1855,7 @@ nfp_flower_add_tun_neigh_v4_encap(struct nfp_app_fw_flower *app_fw_flower,
return nfp_flower_cmsg_tun_neigh_v4_rule(app_fw_flower, &payload);
}
-__rte_unused static int
+static int
nfp_flower_del_tun_neigh_v4(struct nfp_app_fw_flower *app_fw_flower,
rte_be32_t ipv4)
{
@@ -1857,6 +1867,99 @@ nfp_flower_del_tun_neigh_v4(struct nfp_app_fw_flower *app_fw_flower,
return nfp_flower_cmsg_tun_neigh_v4_rule(app_fw_flower, &payload);
}
+__rte_unused static int
+nfp_flower_add_tun_neigh_v6_encap(struct nfp_app_fw_flower *app_fw_flower,
+ struct nfp_fl_rule_metadata *nfp_flow_meta,
+ struct nfp_fl_tun *tun,
+ const struct rte_ether_hdr *eth,
+ const struct rte_flow_item_ipv6 *ipv6)
+{
+ struct nfp_fl_tun *tmp;
+ struct nfp_flow_priv *priv;
+ struct nfp_flower_in_port *port;
+ struct nfp_flower_cmsg_tun_neigh_v6 payload;
+
+ tun->payload.v6_flag = 1;
+ memcpy(tun->payload.dst.dst_ipv6, ipv6->hdr.dst_addr, sizeof(tun->payload.dst.dst_ipv6));
+ memcpy(tun->payload.src.src_ipv6, ipv6->hdr.src_addr, sizeof(tun->payload.src.src_ipv6));
+ memcpy(tun->payload.dst_addr, eth->dst_addr.addr_bytes, RTE_ETHER_ADDR_LEN);
+ memcpy(tun->payload.src_addr, eth->src_addr.addr_bytes, RTE_ETHER_ADDR_LEN);
+
+ tun->ref_cnt = 1;
+ priv = app_fw_flower->flow_priv;
+ LIST_FOREACH(tmp, &priv->nn_list, next) {
+ if (memcmp(&tmp->payload, &tun->payload, sizeof(struct nfp_fl_tun_entry)) == 0) {
+ tmp->ref_cnt++;
+ return 0;
+ }
+ }
+
+ LIST_INSERT_HEAD(&priv->nn_list, tun, next);
+
+ port = (struct nfp_flower_in_port *)((char *)nfp_flow_meta +
+ sizeof(struct nfp_fl_rule_metadata) +
+ sizeof(struct nfp_flower_meta_tci));
+
+ memset(&payload, 0, sizeof(struct nfp_flower_cmsg_tun_neigh_v6));
+ memcpy(payload.dst_ipv6, ipv6->hdr.dst_addr, sizeof(payload.dst_ipv6));
+ memcpy(payload.src_ipv6, ipv6->hdr.src_addr, sizeof(payload.src_ipv6));
+ memcpy(payload.common.dst_mac, eth->dst_addr.addr_bytes, RTE_ETHER_ADDR_LEN);
+ memcpy(payload.common.src_mac, eth->src_addr.addr_bytes, RTE_ETHER_ADDR_LEN);
+ payload.common.port_id = port->in_port;
+
+ return nfp_flower_cmsg_tun_neigh_v6_rule(app_fw_flower, &payload);
+}
+
+static int
+nfp_flower_del_tun_neigh_v6(struct nfp_app_fw_flower *app_fw_flower,
+ uint8_t *ipv6)
+{
+ struct nfp_flower_cmsg_tun_neigh_v6 payload;
+
+ memset(&payload, 0, sizeof(struct nfp_flower_cmsg_tun_neigh_v6));
+ memcpy(payload.dst_ipv6, ipv6, sizeof(payload.dst_ipv6));
+
+ return nfp_flower_cmsg_tun_neigh_v6_rule(app_fw_flower, &payload);
+}
+
+__rte_unused static int
+nfp_flower_del_tun_neigh(struct nfp_app_fw_flower *app_fw_flower,
+ struct rte_flow *nfp_flow)
+{
+ int ret;
+ bool flag = false;
+ struct nfp_fl_tun *tmp;
+ struct nfp_fl_tun *tun;
+
+ tun = &nfp_flow->tun;
+ LIST_FOREACH(tmp, &app_fw_flower->flow_priv->nn_list, next) {
+ ret = memcmp(&tmp->payload, &tun->payload, sizeof(struct nfp_fl_tun_entry));
+ if (ret == 0) {
+ tmp->ref_cnt--;
+ flag = true;
+ break;
+ }
+ }
+
+ if (!flag) {
+ PMD_DRV_LOG(DEBUG, "Can't find nn entry in the nn list");
+ return -EINVAL;
+ }
+
+ if (tmp->ref_cnt == 0) {
+ LIST_REMOVE(tmp, next);
+ if (tmp->payload.v6_flag != 0) {
+ return nfp_flower_del_tun_neigh_v6(app_fw_flower,
+ tmp->payload.dst.dst_ipv6);
+ } else {
+ return nfp_flower_del_tun_neigh_v4(app_fw_flower,
+ tmp->payload.dst.dst_ipv4);
+ }
+ }
+
+ return 0;
+}
+
static int
nfp_flow_compile_action(__rte_unused struct nfp_flower_representor *representor,
const struct rte_flow_action actions[],
--
2.29.3
next prev parent reply other threads:[~2022-10-25 8:00 UTC|newest]
Thread overview: 88+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-18 3:22 [PATCH 00/25] add the extend rte_flow offload support of nfp PMD Chaoyong He
2022-10-18 3:22 ` [PATCH 01/25] net/nfp: add the offload support of IPv4 VXLAN item Chaoyong He
2022-10-18 3:22 ` [PATCH 02/25] net/nfp: add the offload support of IPv6 " Chaoyong He
2022-10-18 3:22 ` [PATCH 03/25] net/nfp: prepare for the encap action of IPv4 tunnel Chaoyong He
2022-10-18 3:22 ` [PATCH 04/25] net/nfp: prepare for the encap action of IPv6 tunnel Chaoyong He
2022-10-18 3:22 ` [PATCH 05/25] net/nfp: add the offload support of IPv4 VXLAN encap action Chaoyong He
2022-10-18 3:22 ` [PATCH 06/25] net/nfp: add the offload support of IPv6 " Chaoyong He
2022-10-18 3:22 ` [PATCH 07/25] net/nfp: prepare for the decap action of IPv4 UDP tunnel Chaoyong He
2022-10-18 3:22 ` [PATCH 08/25] net/nfp: prepare for the decap action of IPv6 " Chaoyong He
2022-10-18 3:22 ` [PATCH 09/25] net/nfp: add the offload support of IPv4 VXLAN decap action Chaoyong He
2022-10-18 3:22 ` [PATCH 10/25] net/nfp: add the offload support of IPv6 " Chaoyong He
2022-10-18 3:22 ` [PATCH 11/25] net/nfp: add the offload support of IPv4 GENEVE encap action Chaoyong He
2022-10-18 3:22 ` [PATCH 12/25] net/nfp: add the offload support of IPv6 " Chaoyong He
2022-10-18 3:22 ` [PATCH 13/25] net/nfp: add the offload support of IPv4 GENEVE item Chaoyong He
2022-10-18 3:22 ` [PATCH 14/25] net/nfp: add the offload support of IPv6 " Chaoyong He
2022-10-18 3:22 ` [PATCH 15/25] net/nfp: add the offload support of IPv4 GENEVE decap action Chaoyong He
2022-10-18 3:22 ` [PATCH 16/25] net/nfp: add the offload support of IPv6 " Chaoyong He
2022-10-18 3:22 ` [PATCH 17/25] net/nfp: add the offload support of IPv4 NVGRE encap action Chaoyong He
2022-10-18 3:22 ` [PATCH 18/25] net/nfp: add the offload support of IPv6 " Chaoyong He
2022-10-18 3:22 ` [PATCH 19/25] net/nfp: prepare for the decap action of IPv4 GRE tunnel Chaoyong He
2022-10-18 3:22 ` [PATCH 20/25] net/nfp: prepare for the decap action of IPv6 " Chaoyong He
2022-10-18 3:22 ` [PATCH 21/25] net/nfp: add the offload support of IPv4 NVGRE item Chaoyong He
2022-10-18 3:22 ` [PATCH 22/25] net/nfp: add the offload support of IPv6 " Chaoyong He
2022-10-18 3:22 ` [PATCH 23/25] net/nfp: add the offload support of IPv4 NVGRE decap action Chaoyong He
2022-10-18 3:22 ` [PATCH 24/25] net/nfp: add the offload support of IPv6 " Chaoyong He
2022-10-18 3:22 ` [PATCH 25/25] net/nfp: add the support of new tunnel solution Chaoyong He
2022-10-21 13:37 ` [PATCH 00/25] add the extend rte_flow offload support of nfp PMD Ferruh Yigit
2022-10-21 13:39 ` Ferruh Yigit
2022-10-22 8:24 ` [PATCH v2 " Chaoyong He
2022-10-22 8:24 ` [PATCH v2 01/25] net/nfp: support IPv4 VXLAN flow item Chaoyong He
2022-10-22 8:24 ` [PATCH v2 02/25] net/nfp: support IPv6 " Chaoyong He
2022-10-22 8:24 ` [PATCH v2 03/25] net/nfp: prepare for IPv4 tunnel encap flow action Chaoyong He
2022-10-22 8:24 ` [PATCH v2 04/25] net/nfp: prepare for IPv6 " Chaoyong He
2022-10-22 8:24 ` [PATCH v2 05/25] net/nfp: support IPv4 VXLAN " Chaoyong He
2022-10-22 8:24 ` [PATCH v2 06/25] net/nfp: support IPv6 " Chaoyong He
2022-10-22 8:24 ` [PATCH v2 07/25] net/nfp: prepare for IPv4 UDP tunnel decap " Chaoyong He
2022-10-22 8:24 ` [PATCH v2 08/25] net/nfp: prepare for IPv6 " Chaoyong He
2022-10-22 8:24 ` [PATCH v2 09/25] net/nfp: support IPv4 VXLAN " Chaoyong He
2022-10-22 8:24 ` [PATCH v2 10/25] net/nfp: support IPv6 " Chaoyong He
2022-10-22 8:24 ` [PATCH v2 11/25] net/nfp: support IPv4 GENEVE encap " Chaoyong He
2022-10-22 8:24 ` [PATCH v2 12/25] net/nfp: support IPv6 " Chaoyong He
2022-10-22 8:24 ` [PATCH v2 13/25] net/nfp: support IPv4 GENEVE flow item Chaoyong He
2022-10-22 8:24 ` [PATCH v2 14/25] net/nfp: support IPv6 " Chaoyong He
2022-10-22 8:24 ` [PATCH v2 15/25] net/nfp: support IPv4 GENEVE decap flow action Chaoyong He
2022-10-22 8:24 ` [PATCH v2 16/25] net/nfp: support IPv6 " Chaoyong He
2022-10-22 8:24 ` [PATCH v2 17/25] net/nfp: support IPv4 NVGRE encap " Chaoyong He
2022-10-22 8:24 ` [PATCH v2 18/25] net/nfp: support IPv6 " Chaoyong He
2022-10-22 8:24 ` [PATCH v2 19/25] net/nfp: prepare for IPv4 GRE tunnel decap " Chaoyong He
2022-10-22 8:24 ` [PATCH v2 20/25] net/nfp: prepare for IPv6 " Chaoyong He
2022-10-22 8:24 ` [PATCH v2 21/25] net/nfp: support IPv4 NVGRE flow item Chaoyong He
2022-10-22 8:24 ` [PATCH v2 22/25] net/nfp: support IPv6 " Chaoyong He
2022-10-22 8:24 ` [PATCH v2 23/25] net/nfp: support IPv4 NVGRE decap flow action Chaoyong He
2022-10-22 8:24 ` [PATCH v2 24/25] net/nfp: support IPv6 " Chaoyong He
2022-10-22 8:24 ` [PATCH v2 25/25] net/nfp: support new tunnel solution Chaoyong He
2022-10-24 15:09 ` Ferruh Yigit
2022-10-25 1:44 ` Chaoyong He
2022-10-25 8:18 ` Ferruh Yigit
2022-10-24 15:07 ` [PATCH v2 00/25] add the extend rte_flow offload support of nfp PMD Ferruh Yigit
2022-10-25 3:17 ` Chaoyong He
2022-10-25 3:29 ` Chaoyong He
2022-10-25 7:58 ` [PATCH v3 00/26] " Chaoyong He
2022-10-25 7:58 ` [PATCH v3 01/26] net/nfp: fix the app stuck by CPP bridge service Chaoyong He
2022-10-25 7:58 ` [PATCH v3 02/26] net/nfp: support IPv4 VXLAN flow item Chaoyong He
2022-10-25 7:58 ` [PATCH v3 03/26] net/nfp: support IPv6 " Chaoyong He
2022-10-25 7:58 ` [PATCH v3 04/26] net/nfp: prepare for IPv4 tunnel encap flow action Chaoyong He
2022-10-25 7:58 ` Chaoyong He [this message]
2022-10-25 7:58 ` [PATCH v3 06/26] net/nfp: support IPv4 VXLAN " Chaoyong He
2022-10-25 7:58 ` [PATCH v3 07/26] net/nfp: support IPv6 " Chaoyong He
2022-10-25 7:59 ` [PATCH v3 08/26] net/nfp: prepare for IPv4 UDP tunnel decap " Chaoyong He
2022-10-25 7:59 ` [PATCH v3 09/26] net/nfp: prepare for IPv6 " Chaoyong He
2022-10-25 7:59 ` [PATCH v3 10/26] net/nfp: support IPv4 VXLAN " Chaoyong He
2022-10-25 7:59 ` [PATCH v3 11/26] net/nfp: support IPv6 " Chaoyong He
2022-10-25 7:59 ` [PATCH v3 12/26] net/nfp: support IPv4 GENEVE encap " Chaoyong He
2022-10-25 7:59 ` [PATCH v3 13/26] net/nfp: support IPv6 " Chaoyong He
2022-10-25 7:59 ` [PATCH v3 14/26] net/nfp: support IPv4 GENEVE flow item Chaoyong He
2022-10-25 7:59 ` [PATCH v3 15/26] net/nfp: support IPv6 " Chaoyong He
2022-10-25 7:59 ` [PATCH v3 16/26] net/nfp: support IPv4 GENEVE decap flow action Chaoyong He
2022-10-25 7:59 ` [PATCH v3 17/26] net/nfp: support IPv6 " Chaoyong He
2022-10-25 7:59 ` [PATCH v3 18/26] net/nfp: support IPv4 NVGRE encap " Chaoyong He
2022-10-25 7:59 ` [PATCH v3 19/26] net/nfp: support IPv6 " Chaoyong He
2022-10-25 7:59 ` [PATCH v3 20/26] net/nfp: prepare for IPv4 GRE tunnel decap " Chaoyong He
2022-10-25 7:59 ` [PATCH v3 21/26] net/nfp: prepare for IPv6 " Chaoyong He
2022-10-25 7:59 ` [PATCH v3 22/26] net/nfp: support IPv4 NVGRE flow item Chaoyong He
2022-10-25 7:59 ` [PATCH v3 23/26] net/nfp: support IPv6 " Chaoyong He
2022-10-25 7:59 ` [PATCH v3 24/26] net/nfp: support IPv4 NVGRE decap flow action Chaoyong He
2022-10-25 7:59 ` [PATCH v3 25/26] net/nfp: support IPv6 " Chaoyong He
2022-10-25 7:59 ` [PATCH v3 26/26] net/nfp: support new solution for tunnel decap action Chaoyong He
2022-10-25 11:42 ` [PATCH v3 00/26] add the extend rte_flow offload support of nfp PMD Ferruh Yigit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221025075918.7778-6-chaoyong.he@corigine.com \
--to=chaoyong.he@corigine.com \
--cc=dev@dpdk.org \
--cc=niklas.soderlund@corigine.com \
--cc=oss-drivers@corigine.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).