[v2,06/11] net/nfp: support drop flow action

Message ID 20231205025457.1067372-7-chaoyong.he@corigine.com (mailing list archive)
State Accepted
Delegated to: Ferruh Yigit
Headers
Series Add basic flow support for corenic firmware |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Chaoyong He Dec. 5, 2023, 2:54 a.m. UTC
  Add the corresponding logics to support the offload of drop action.

Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
---
 drivers/net/nfp/nfp_net_flow.c | 39 +++++++++++++++++++++++++++++++++-
 1 file changed, 38 insertions(+), 1 deletion(-)
  

Patch

diff --git a/drivers/net/nfp/nfp_net_flow.c b/drivers/net/nfp/nfp_net_flow.c
index 5b6c8553d8..c8b6902bf1 100644
--- a/drivers/net/nfp/nfp_net_flow.c
+++ b/drivers/net/nfp/nfp_net_flow.c
@@ -335,6 +335,37 @@  nfp_net_flow_compile_items(const struct rte_flow_item items[],
 	return ret;
 }
 
+static void
+nfp_net_flow_action_drop(struct rte_flow *nfp_flow)
+{
+	struct nfp_net_cmsg_action *action_data;
+
+	action_data = (struct nfp_net_cmsg_action *)nfp_flow->payload.action_data;
+
+	action_data->action = NFP_NET_CMSG_ACTION_DROP;
+}
+
+static int
+nfp_net_flow_compile_actions(const struct rte_flow_action actions[],
+		struct rte_flow *nfp_flow)
+{
+	const struct rte_flow_action *action;
+
+	for (action = actions; action->type != RTE_FLOW_ACTION_TYPE_END; ++action) {
+		switch (action->type) {
+		case RTE_FLOW_ACTION_TYPE_DROP:
+			PMD_DRV_LOG(DEBUG, "Process RTE_FLOW_ACTION_TYPE_DROP");
+			nfp_net_flow_action_drop(nfp_flow);
+			return 0;
+		default:
+			PMD_DRV_LOG(ERR, "Unsupported action type: %d", action->type);
+			return -ENOTSUP;
+		}
+	}
+
+	return 0;
+}
+
 static void
 nfp_net_flow_process_priority(__rte_unused struct rte_flow *nfp_flow,
 		uint32_t match_len)
@@ -349,7 +380,7 @@  static struct rte_flow *
 nfp_net_flow_setup(struct rte_eth_dev *dev,
 		const struct rte_flow_attr *attr,
 		const struct rte_flow_item items[],
-		__rte_unused const struct rte_flow_action actions[])
+		const struct rte_flow_action actions[])
 {
 	int ret;
 	char *hash_data;
@@ -387,6 +418,12 @@  nfp_net_flow_setup(struct rte_eth_dev *dev,
 		goto free_flow;
 	}
 
+	ret = nfp_net_flow_compile_actions(actions, nfp_flow);
+	if (ret != 0) {
+		PMD_DRV_LOG(ERR, "NFP flow action process failed.");
+		goto free_flow;
+	}
+
 	/* Calculate and store the hash_key for later use */
 	hash_data = nfp_flow->payload.match_data;
 	nfp_flow->hash_key = rte_jhash(hash_data, match_len + action_len,