net/nfp: support represented port action

Message ID 20231019065403.2078523-1-chaoyong.he@corigine.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series net/nfp: support represented port action |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/github-robot: build success github build: passed
ci/intel-Functional success Functional PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-unit-amd64-testing success Testing PASS

Commit Message

Chaoyong He Oct. 19, 2023, 6:54 a.m. UTC
  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(-)
  

Comments

Ferruh Yigit Oct. 27, 2023, 1:17 a.m. UTC | #1
On 10/19/2023 7:54 AM, Chaoyong He wrote:
> Add the corresponding logics to support the offload of
> represented port action.
> 
> Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
> 

Applied to dpdk-next-net/main, thanks.
  

Patch

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--;