Add the corresponding logics to support the offload of represented port action.
Signed-off-by: Chaoyong He <chaoyong...@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