DPDK patches and discussions
 help / color / mirror / Atom feed
From: Chaoyong He <chaoyong.he@corigine.com>
To: dev@dpdk.org
Cc: oss-drivers@corigine.com, Chaoyong He <chaoyong.he@corigine.com>
Subject: [PATCH 1/4] net/nfp: prepare for the flow merge
Date: Sat, 30 Sep 2023 18:00:50 +0800	[thread overview]
Message-ID: <20230930100053.1227215-2-chaoyong.he@corigine.com> (raw)
In-Reply-To: <20230930100053.1227215-1-chaoyong.he@corigine.com>

Move data structure and macro from source file to header file.
Export the needed function to header file.

We add two more parameter for 'nfp_flow_process()' to prepare for the
flow merge.
The 'cookie' moved as parameter is because the flow merge logic need
this cookie.
The 'install' parameter is needed because in flow merge, some flow are
not need install to the hardware.

Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
---
 drivers/net/nfp/nfp_flow.c | 42 +++++++++++++++++---------------------
 drivers/net/nfp/nfp_flow.h | 31 ++++++++++++++++++++++++++++
 2 files changed, 50 insertions(+), 23 deletions(-)

diff --git a/drivers/net/nfp/nfp_flow.c b/drivers/net/nfp/nfp_flow.c
index aa286535f7..1bb93bcfb5 100644
--- a/drivers/net/nfp/nfp_flow.c
+++ b/drivers/net/nfp/nfp_flow.c
@@ -89,17 +89,6 @@
 /* Tunnel ports */
 #define NFP_FL_PORT_TYPE_TUN            0x50000000
 
-/*
- * Maximum number of items in struct rte_flow_action_vxlan_encap.
- * ETH / IPv4(6) / UDP / VXLAN / END
- */
-#define ACTION_VXLAN_ENCAP_ITEMS_NUM 5
-
-struct vxlan_data {
-	struct rte_flow_action_vxlan_encap conf;
-	struct rte_flow_item items[ACTION_VXLAN_ENCAP_ITEMS_NUM];
-};
-
 /* Static initializer for a list of subsequent item types */
 #define NEXT_ITEM(...) \
 	((const enum rte_flow_item_type []){ \
@@ -359,7 +348,7 @@ nfp_check_mask_remove(struct nfp_flow_priv *priv,
 	return true;
 }
 
-static int
+int
 nfp_flow_table_add(struct nfp_flow_priv *priv,
 		struct rte_flow *nfp_flow)
 {
@@ -440,7 +429,7 @@ nfp_flow_alloc(struct nfp_fl_key_ls *key_layer, uint32_t port_id)
 	return NULL;
 }
 
-static void
+void
 nfp_flow_free(struct rte_flow *nfp_flow)
 {
 	rte_free(nfp_flow->payload.meta);
@@ -721,7 +710,8 @@ static void
 nfp_flow_compile_metadata(struct nfp_flow_priv *priv,
 		struct rte_flow *nfp_flow,
 		struct nfp_fl_key_ls *key_layer,
-		uint32_t stats_ctx)
+		uint32_t stats_ctx,
+		uint64_t cookie)
 {
 	struct nfp_fl_rule_metadata *nfp_flow_meta;
 	char *mbuf_off_exact;
@@ -737,7 +727,7 @@ nfp_flow_compile_metadata(struct nfp_flow_priv *priv,
 	nfp_flow_meta->act_len      = key_layer->act_size >> NFP_FL_LW_SIZ;
 	nfp_flow_meta->flags        = 0;
 	nfp_flow_meta->host_ctx_id  = rte_cpu_to_be_32(stats_ctx);
-	nfp_flow_meta->host_cookie  = rte_rand();
+	nfp_flow_meta->host_cookie  = rte_cpu_to_be_64(cookie);
 	nfp_flow_meta->flow_version = rte_cpu_to_be_64(priv->flower_version);
 
 	mbuf_off_exact = nfp_flow->payload.unmasked_data;
@@ -1958,7 +1948,7 @@ nfp_flow_is_tun_item(const struct rte_flow_item *item)
 	return false;
 }
 
-static bool
+bool
 nfp_flow_inner_item_get(const struct rte_flow_item items[],
 		const struct rte_flow_item **inner_item)
 {
@@ -3650,11 +3640,13 @@ nfp_flow_compile_action(struct nfp_flower_representor *representor,
 	return 0;
 }
 
-static struct rte_flow *
+struct rte_flow *
 nfp_flow_process(struct nfp_flower_representor *representor,
 		const struct rte_flow_item items[],
 		const struct rte_flow_action actions[],
-		bool validate_flag)
+		bool validate_flag,
+		uint64_t cookie,
+		bool install_flag)
 {
 	int ret;
 	char *hash_data;
@@ -3690,9 +3682,9 @@ nfp_flow_process(struct nfp_flower_representor *representor,
 		goto free_stats;
 	}
 
-	nfp_flow->install_flag = true;
+	nfp_flow->install_flag = install_flag;
 
-	nfp_flow_compile_metadata(priv, nfp_flow, &key_layer, stats_ctx);
+	nfp_flow_compile_metadata(priv, nfp_flow, &key_layer, stats_ctx, cookie);
 
 	ret = nfp_flow_compile_items(representor, items, nfp_flow);
 	if (ret != 0) {
@@ -3755,6 +3747,8 @@ nfp_flow_setup(struct nfp_flower_representor *representor,
 		__rte_unused struct rte_flow_error *error,
 		bool validate_flag)
 {
+	uint64_t cookie;
+
 	if (attr->group != 0)
 		PMD_DRV_LOG(INFO, "Pretend we support group attribute.");
 
@@ -3764,10 +3758,12 @@ nfp_flow_setup(struct nfp_flower_representor *representor,
 	if (attr->transfer != 0)
 		PMD_DRV_LOG(INFO, "Pretend we support transfer attribute.");
 
-	return nfp_flow_process(representor, items, actions, validate_flag);
+	cookie = rte_rand();
+
+	return nfp_flow_process(representor, items, actions, validate_flag, cookie, true);
 }
 
-static int
+int
 nfp_flow_teardown(struct nfp_flow_priv *priv,
 		struct rte_flow *nfp_flow,
 		bool validate_flag)
@@ -3895,7 +3891,7 @@ nfp_flow_create(struct rte_eth_dev *dev,
 	return NULL;
 }
 
-static int
+int
 nfp_flow_destroy(struct rte_eth_dev *dev,
 		struct rte_flow *nfp_flow,
 		struct rte_flow_error *error)
diff --git a/drivers/net/nfp/nfp_flow.h b/drivers/net/nfp/nfp_flow.h
index 7ce7f62453..817eaecba2 100644
--- a/drivers/net/nfp/nfp_flow.h
+++ b/drivers/net/nfp/nfp_flow.h
@@ -11,6 +11,17 @@
 /* The firmware expects lengths in units of long words */
 #define NFP_FL_LW_SIZ                   2
 
+/*
+ * Maximum number of items in struct rte_flow_action_vxlan_encap.
+ * ETH / IPv4(6) / UDP / VXLAN / END
+ */
+#define ACTION_VXLAN_ENCAP_ITEMS_NUM 5
+
+struct vxlan_data {
+	struct rte_flow_action_vxlan_encap conf;
+	struct rte_flow_item items[ACTION_VXLAN_ENCAP_ITEMS_NUM];
+};
+
 enum nfp_flower_tun_type {
 	NFP_FL_TUN_NONE   = 0,
 	NFP_FL_TUN_GRE    = 1,
@@ -153,8 +164,28 @@ struct rte_flow {
 	enum nfp_flow_type type;
 };
 
+/* Forward declaration */
+struct nfp_flower_representor;
+
 int nfp_flow_priv_init(struct nfp_pf_dev *pf_dev);
 void nfp_flow_priv_uninit(struct nfp_pf_dev *pf_dev);
 int nfp_net_flow_ops_get(struct rte_eth_dev *dev, const struct rte_flow_ops **ops);
+bool nfp_flow_inner_item_get(const struct rte_flow_item items[],
+		const struct rte_flow_item **inner_item);
+struct rte_flow *nfp_flow_process(struct nfp_flower_representor *representor,
+		const struct rte_flow_item items[],
+		const struct rte_flow_action actions[],
+		bool validate_flag,
+		uint64_t cookie,
+		bool install_flag);
+int nfp_flow_table_add(struct nfp_flow_priv *priv,
+		struct rte_flow *nfp_flow);
+int nfp_flow_teardown(struct nfp_flow_priv *priv,
+		struct rte_flow *nfp_flow,
+		bool validate_flag);
+void nfp_flow_free(struct rte_flow *nfp_flow);
+int nfp_flow_destroy(struct rte_eth_dev *dev,
+		struct rte_flow *nfp_flow,
+		struct rte_flow_error *error);
 
 #endif /* _NFP_FLOW_H_ */
-- 
2.39.1


  reply	other threads:[~2023-09-30 10:01 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-30 10:00 [PATCH 0/4] support offload of simple conntrack flow rules Chaoyong He
2023-09-30 10:00 ` Chaoyong He [this message]
2023-09-30 10:00 ` [PATCH 2/4] net/nfp: add infrastructure for ct flow merge Chaoyong He
2023-09-30 10:00 ` [PATCH 3/4] net/nfp: add call to add and delete the flows to firmware Chaoyong He
2023-09-30 10:00 ` [PATCH 4/4] net/nfp: add support for merged flows and conntrack stats Chaoyong He
2023-10-03 12:46 ` [PATCH 0/4] support offload of simple conntrack flow rules Ferruh Yigit
2023-10-04  9:35 ` [PATCH v2 " Chaoyong He
2023-10-04  9:35   ` [PATCH v2 1/4] net/nfp: prepare for the flow merge Chaoyong He
2023-10-04  9:36   ` [PATCH v2 2/4] net/nfp: add infrastructure for conntrack " Chaoyong He
2023-10-04  9:36   ` [PATCH v2 3/4] net/nfp: add call to add and delete the flows to firmware Chaoyong He
2023-10-04  9:36   ` [PATCH v2 4/4] net/nfp: add support for merged flows and conntrack stats Chaoyong He
2023-10-04 11:55   ` [PATCH v2 0/4] support offload of simple conntrack flow rules 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=20230930100053.1227215-2-chaoyong.he@corigine.com \
    --to=chaoyong.he@corigine.com \
    --cc=dev@dpdk.org \
    --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).