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] net/nfp: support represented port action
Date: Thu, 19 Oct 2023 14:54:03 +0800	[thread overview]
Message-ID: <20231019065403.2078523-1-chaoyong.he@corigine.com> (raw)

Add the corresponding logics to support the offload of
represented port action.

Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
---
 doc/guides/nics/features/nfp.ini |  1 +
 drivers/net/nfp/nfp_flow.c       | 51 +++++++++++++++++++++++++++++++-
 2 files changed, 51 insertions(+), 1 deletion(-)

diff --git a/doc/guides/nics/features/nfp.ini b/doc/guides/nics/features/nfp.ini
index b53af7b60a..73efd41e43 100644
--- a/doc/guides/nics/features/nfp.ini
+++ b/doc/guides/nics/features/nfp.ini
@@ -54,6 +54,7 @@ of_set_vlan_pcp      = Y
 of_set_vlan_vid      = Y
 raw_decap            = Y
 raw_encap            = Y
+represented_port     = Y
 port_id              = Y
 set_ipv4_dscp        = Y
 set_ipv4_dst         = Y
diff --git a/drivers/net/nfp/nfp_flow.c b/drivers/net/nfp/nfp_flow.c
index 1bf31146fc..f832b52d89 100644
--- a/drivers/net/nfp/nfp_flow.c
+++ b/drivers/net/nfp/nfp_flow.c
@@ -1007,6 +1007,10 @@ nfp_flow_key_layers_calculate_actions(const struct rte_flow_action actions[],
 			PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_PORT_ID detected");
 			key_ls->act_size += sizeof(struct nfp_fl_act_output);
 			break;
+		case RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT:
+			PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT detected");
+			key_ls->act_size += sizeof(struct nfp_fl_act_output);
+			break;
 		case RTE_FLOW_ACTION_TYPE_SET_MAC_SRC:
 			PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_SET_MAC_SRC detected");
 			if (!mac_set_flag) {
@@ -2188,6 +2192,38 @@ nfp_flow_action_output(char *act_data,
 	return 0;
 }
 
+static int
+nfp_flow_action_output_stage(char *act_data,
+		const struct rte_flow_action *action,
+		struct nfp_fl_rule_metadata *nfp_flow_meta,
+		uint32_t output_cnt)
+{
+	size_t act_size;
+	struct rte_eth_dev *ethdev;
+	struct nfp_fl_act_output *output;
+	struct nfp_flower_representor *representor;
+	const struct rte_flow_action_ethdev *action_ethdev;
+
+	action_ethdev = action->conf;
+	if (action_ethdev == NULL || action_ethdev->port_id >= RTE_MAX_ETHPORTS)
+		return -ERANGE;
+
+	ethdev = &rte_eth_devices[action_ethdev->port_id];
+	representor = ethdev->data->dev_private;
+	act_size = sizeof(struct nfp_fl_act_output);
+
+	output = (struct nfp_fl_act_output *)act_data;
+	output->head.jump_id = NFP_FL_ACTION_OPCODE_OUTPUT;
+	output->head.len_lw  = act_size >> NFP_FL_LW_SIZ;
+	output->port         = rte_cpu_to_be_32(representor->port_id);
+	if (output_cnt == 0)
+		output->flags = rte_cpu_to_be_16(NFP_FL_OUT_FLAGS_LAST);
+
+	nfp_flow_meta->shortcut = rte_cpu_to_be_32(representor->port_id);
+
+	return 0;
+}
+
 static void
 nfp_flow_action_set_mac(char *act_data,
 		const struct rte_flow_action *action,
@@ -3458,7 +3494,8 @@ nfp_flow_count_output(const struct rte_flow_action actions[])
 	const struct rte_flow_action *action;
 
 	for (action = actions; action->type != RTE_FLOW_ACTION_TYPE_END; ++action) {
-		if (action->type == RTE_FLOW_ACTION_TYPE_PORT_ID)
+		if (action->type == RTE_FLOW_ACTION_TYPE_PORT_ID ||
+				action->type == RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT)
 			count++;
 	}
 
@@ -3506,6 +3543,18 @@ nfp_flow_compile_action(struct nfp_flower_representor *representor,
 		case RTE_FLOW_ACTION_TYPE_JUMP:
 			PMD_DRV_LOG(DEBUG, "Process RTE_FLOW_ACTION_TYPE_JUMP");
 			break;
+		case RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT:
+			PMD_DRV_LOG(DEBUG, "Process RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT");
+			count--;
+			ret = nfp_flow_action_output_stage(position, action, nfp_flow_meta, count);
+			if (ret != 0) {
+				PMD_DRV_LOG(ERR, "Failed when process"
+						" RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT");
+				return ret;
+			}
+
+			position += sizeof(struct nfp_fl_act_output);
+			break;
 		case RTE_FLOW_ACTION_TYPE_PORT_ID:
 			PMD_DRV_LOG(DEBUG, "Process RTE_FLOW_ACTION_TYPE_PORT_ID");
 			count--;
-- 
2.39.1


             reply	other threads:[~2023-10-19  6:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-19  6:54 Chaoyong He [this message]
2023-10-27  1:17 ` 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=20231019065403.2078523-1-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).