From: Chaoyong He <chaoyong.he@corigine.com>
To: dev@dpdk.org
Cc: oss-drivers@corigine.com, Chaoyong He <chaoyong.he@corigine.com>,
Long Wu <long.wu@corigine.com>,
Peng Zhang <peng.zhang@corigine.com>
Subject: [PATCH 3/7] net/nfp: remove the duplicate logic of output action
Date: Wed, 19 Jun 2024 17:19:37 +0800 [thread overview]
Message-ID: <20240619091941.3479371-4-chaoyong.he@corigine.com> (raw)
In-Reply-To: <20240619091941.3479371-1-chaoyong.he@corigine.com>
Remove the duplicate logic of output flow 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/flower/nfp_flower_flow.c | 81 ++++++------------------
1 file changed, 19 insertions(+), 62 deletions(-)
diff --git a/drivers/net/nfp/flower/nfp_flower_flow.c b/drivers/net/nfp/flower/nfp_flower_flow.c
index f1388620d6..b533f4e3f2 100644
--- a/drivers/net/nfp/flower/nfp_flower_flow.c
+++ b/drivers/net/nfp/flower/nfp_flower_flow.c
@@ -2508,55 +2508,33 @@ nfp_flow_action_output(char *act_data,
struct nfp_fl_rule_metadata *nfp_flow_meta,
uint32_t output_cnt)
{
- size_t act_size;
+ uint32_t port_id;
struct rte_eth_dev *ethdev;
struct nfp_fl_act_output *output;
struct nfp_flower_representor *representor;
- const struct rte_flow_action_port_id *port_id;
-
- port_id = action->conf;
- if (port_id == NULL || port_id->id >= RTE_MAX_ETHPORTS)
- return -ERANGE;
-
- ethdev = &rte_eth_devices[port_id->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);
+ const struct rte_flow_action_ethdev *action_ethdev;
+ const struct rte_flow_action_port_id *action_port_id;
- return 0;
-}
+ if (action->conf == NULL)
+ return -EINVAL;
-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;
+ if (action->type == RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT) {
+ action_ethdev = action->conf;
+ port_id = action_ethdev->port_id;
+ } else {
+ action_port_id = action->conf;
+ port_id = action_port_id->id;
+ }
- action_ethdev = action->conf;
- if (action_ethdev == NULL || action_ethdev->port_id >= RTE_MAX_ETHPORTS)
+ if (port_id >= RTE_MAX_ETHPORTS)
return -ERANGE;
- ethdev = &rte_eth_devices[action_ethdev->port_id];
+ ethdev = &rte_eth_devices[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->head.len_lw = sizeof(struct nfp_fl_act_output) >> 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);
@@ -3999,28 +3977,7 @@ nfp_flow_action_compile_drop(struct nfp_action_compile_param *param)
}
static int
-nfp_flow_action_compile_repr_port(struct nfp_action_compile_param *param)
-{
- int ret;
- uint32_t output_cnt;
-
- output_cnt = *param->output_cnt - 1;
- *param->output_cnt = output_cnt;
-
- ret = nfp_flow_action_output_stage(param->position, param->action,
- param->nfp_flow_meta, output_cnt);
- if (ret != 0) {
- PMD_DRV_LOG(ERR, "Failed process RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT");
- return ret;
- }
-
- param->position += sizeof(struct nfp_fl_act_output);
-
- return 0;
-}
-
-static int
-nfp_flow_action_compile_port_id(struct nfp_action_compile_param *param)
+nfp_flow_action_compile_output(struct nfp_action_compile_param *param)
{
int ret;
uint32_t output_cnt;
@@ -4031,7 +3988,7 @@ nfp_flow_action_compile_port_id(struct nfp_action_compile_param *param)
ret = nfp_flow_action_output(param->position, param->action,
param->nfp_flow_meta, output_cnt);
if (ret != 0) {
- PMD_DRV_LOG(ERR, "Failed process RTE_FLOW_ACTION_TYPE_PORT_ID");
+ PMD_DRV_LOG(ERR, "Failed process output action");
return ret;
}
@@ -4393,8 +4350,8 @@ static nfp_flow_action_compile_fn action_compile_fns[] = {
[RTE_FLOW_ACTION_TYPE_DROP] = nfp_flow_action_compile_drop,
[RTE_FLOW_ACTION_TYPE_COUNT] = nfp_flow_action_compile_stub,
[RTE_FLOW_ACTION_TYPE_JUMP] = nfp_flow_action_compile_stub,
- [RTE_FLOW_ACTION_TYPE_PORT_ID] = nfp_flow_action_compile_port_id,
- [RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT] = nfp_flow_action_compile_repr_port,
+ [RTE_FLOW_ACTION_TYPE_PORT_ID] = nfp_flow_action_compile_output,
+ [RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT] = nfp_flow_action_compile_output,
[RTE_FLOW_ACTION_TYPE_SET_MAC_SRC] = nfp_flow_action_compile_mac_src,
[RTE_FLOW_ACTION_TYPE_SET_MAC_DST] = nfp_flow_action_compile_mac_dst,
[RTE_FLOW_ACTION_TYPE_OF_POP_VLAN] = nfp_flow_action_compile_pop_vlan,
--
2.39.1
next prev parent reply other threads:[~2024-06-19 9:20 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-19 9:19 [PATCH 0/7] refactor flow validate and create interface Chaoyong He
2024-06-19 9:19 ` [PATCH 1/7] net/nfp: remove the unused parameter Chaoyong He
2024-06-19 9:19 ` [PATCH 2/7] net/nfp: exit as soon as possible Chaoyong He
2024-06-19 9:19 ` Chaoyong He [this message]
2024-06-19 9:19 ` [PATCH 4/7] net/nfp: split out the flow item check logic Chaoyong He
2024-06-19 9:19 ` [PATCH 5/7] net/nfp: simplify the flow item calculate logic Chaoyong He
2024-06-19 9:19 ` [PATCH 6/7] net/nfp: split out the flow action check logic Chaoyong He
2024-06-19 9:19 ` [PATCH 7/7] net/nfp: simplify the flow action calculate logic Chaoyong He
2024-07-07 2:11 ` [PATCH 0/7] refactor flow validate and create interface 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=20240619091941.3479371-4-chaoyong.he@corigine.com \
--to=chaoyong.he@corigine.com \
--cc=dev@dpdk.org \
--cc=long.wu@corigine.com \
--cc=oss-drivers@corigine.com \
--cc=peng.zhang@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).