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 03/21] net/nfp: pack various flags of flow action
Date: Wed, 19 Jun 2024 17:13:40 +0800 [thread overview]
Message-ID: <20240619091358.3479247-4-chaoyong.he@corigine.com> (raw)
In-Reply-To: <20240619091358.3479247-1-chaoyong.he@corigine.com>
Pack various flags of the flow action into single structure, also
refactor the related logic.
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 | 132 +++++++++++------------
1 file changed, 66 insertions(+), 66 deletions(-)
diff --git a/drivers/net/nfp/flower/nfp_flower_flow.c b/drivers/net/nfp/flower/nfp_flower_flow.c
index 4dacac1d28..9717af9c9c 100644
--- a/drivers/net/nfp/flower/nfp_flower_flow.c
+++ b/drivers/net/nfp/flower/nfp_flower_flow.c
@@ -974,17 +974,22 @@ nfp_flow_key_layers_calculate_items(const struct rte_flow_item items[],
return 0;
}
+struct nfp_action_flag {
+ bool drop_flag;
+ bool meter_flag;
+ bool tc_hl_flag;
+ bool ip_set_flag;
+ bool tp_set_flag;
+ bool mac_set_flag;
+ bool ttl_tos_flag;
+};
+
static int
nfp_flow_key_layers_calculate_actions(const struct rte_flow_action actions[],
struct nfp_fl_key_ls *key_ls)
{
int ret = 0;
- bool meter_flag = false;
- bool tc_hl_flag = false;
- bool ip_set_flag = false;
- bool tp_set_flag = false;
- bool mac_set_flag = false;
- bool ttl_tos_flag = false;
+ struct nfp_action_flag flag = {};
const struct rte_flow_action *action;
for (action = actions; action->type != RTE_FLOW_ACTION_TYPE_END; ++action) {
@@ -1018,16 +1023,16 @@ nfp_flow_key_layers_calculate_actions(const struct rte_flow_action actions[],
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) {
+ if (!flag.mac_set_flag) {
key_ls->act_size += sizeof(struct nfp_fl_act_set_eth);
- mac_set_flag = true;
+ flag.mac_set_flag = true;
}
break;
case RTE_FLOW_ACTION_TYPE_SET_MAC_DST:
PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_SET_MAC_DST detected");
- if (!mac_set_flag) {
+ if (!flag.mac_set_flag) {
key_ls->act_size += sizeof(struct nfp_fl_act_set_eth);
- mac_set_flag = true;
+ flag.mac_set_flag = true;
}
break;
case RTE_FLOW_ACTION_TYPE_OF_POP_VLAN:
@@ -1046,18 +1051,18 @@ nfp_flow_key_layers_calculate_actions(const struct rte_flow_action actions[],
break;
case RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC:
PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC detected");
- if (!ip_set_flag) {
+ if (!flag.ip_set_flag) {
key_ls->act_size +=
sizeof(struct nfp_fl_act_set_ip4_addrs);
- ip_set_flag = true;
+ flag.ip_set_flag = true;
}
break;
case RTE_FLOW_ACTION_TYPE_SET_IPV4_DST:
PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_SET_IPV4_DST detected");
- if (!ip_set_flag) {
+ if (!flag.ip_set_flag) {
key_ls->act_size +=
sizeof(struct nfp_fl_act_set_ip4_addrs);
- ip_set_flag = true;
+ flag.ip_set_flag = true;
}
break;
case RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC:
@@ -1070,48 +1075,48 @@ nfp_flow_key_layers_calculate_actions(const struct rte_flow_action actions[],
break;
case RTE_FLOW_ACTION_TYPE_SET_TP_SRC:
PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_SET_TP_SRC detected");
- if (!tp_set_flag) {
+ if (!flag.tp_set_flag) {
key_ls->act_size += sizeof(struct nfp_fl_act_set_tport);
- tp_set_flag = true;
+ flag.tp_set_flag = true;
}
break;
case RTE_FLOW_ACTION_TYPE_SET_TP_DST:
PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_SET_TP_DST detected");
- if (!tp_set_flag) {
+ if (!flag.tp_set_flag) {
key_ls->act_size += sizeof(struct nfp_fl_act_set_tport);
- tp_set_flag = true;
+ flag.tp_set_flag = true;
}
break;
case RTE_FLOW_ACTION_TYPE_SET_TTL:
PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_SET_TTL detected");
if ((key_ls->key_layer & NFP_FLOWER_LAYER_IPV4) != 0) {
- if (!ttl_tos_flag) {
+ if (!flag.ttl_tos_flag) {
key_ls->act_size +=
sizeof(struct nfp_fl_act_set_ip4_ttl_tos);
- ttl_tos_flag = true;
+ flag.ttl_tos_flag = true;
}
} else {
- if (!tc_hl_flag) {
+ if (!flag.tc_hl_flag) {
key_ls->act_size +=
sizeof(struct nfp_fl_act_set_ipv6_tc_hl_fl);
- tc_hl_flag = true;
+ flag.tc_hl_flag = true;
}
}
break;
case RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP:
PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP detected");
- if (!ttl_tos_flag) {
+ if (!flag.ttl_tos_flag) {
key_ls->act_size +=
sizeof(struct nfp_fl_act_set_ip4_ttl_tos);
- ttl_tos_flag = true;
+ flag.ttl_tos_flag = true;
}
break;
case RTE_FLOW_ACTION_TYPE_SET_IPV6_DSCP:
PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_SET_IPV6_DSCP detected");
- if (!tc_hl_flag) {
+ if (!flag.tc_hl_flag) {
key_ls->act_size +=
sizeof(struct nfp_fl_act_set_ipv6_tc_hl_fl);
- tc_hl_flag = true;
+ flag.tc_hl_flag = true;
}
break;
case RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP:
@@ -1132,9 +1137,9 @@ nfp_flow_key_layers_calculate_actions(const struct rte_flow_action actions[],
break;
case RTE_FLOW_ACTION_TYPE_METER:
PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_METER detected");
- if (!meter_flag) {
+ if (!flag.meter_flag) {
key_ls->act_size += sizeof(struct nfp_fl_act_meter);
- meter_flag = true;
+ flag.meter_flag = true;
} else {
PMD_DRV_LOG(ERR, "Only support one meter action.");
return -ENOTSUP;
@@ -3656,13 +3661,8 @@ nfp_flow_compile_action(struct nfp_flower_representor *representor,
uint32_t count;
char *position;
char *action_data;
- bool drop_flag = false;
- bool tc_hl_flag = false;
- bool ip_set_flag = false;
- bool tp_set_flag = false;
- bool mac_set_flag = false;
- bool ttl_tos_flag = false;
uint32_t total_actions = 0;
+ struct nfp_action_flag flag = {};
const struct rte_flow_action *action;
struct nfp_flower_meta_tci *meta_tci;
struct nfp_fl_rule_metadata *nfp_flow_meta;
@@ -3680,7 +3680,7 @@ nfp_flow_compile_action(struct nfp_flower_representor *representor,
break;
case RTE_FLOW_ACTION_TYPE_DROP:
PMD_DRV_LOG(DEBUG, "Process RTE_FLOW_ACTION_TYPE_DROP");
- drop_flag = true;
+ flag.drop_flag = true;
break;
case RTE_FLOW_ACTION_TYPE_COUNT:
PMD_DRV_LOG(DEBUG, "Process RTE_FLOW_ACTION_TYPE_COUNT");
@@ -3714,18 +3714,18 @@ nfp_flow_compile_action(struct nfp_flower_representor *representor,
break;
case RTE_FLOW_ACTION_TYPE_SET_MAC_SRC:
PMD_DRV_LOG(DEBUG, "Process RTE_FLOW_ACTION_TYPE_SET_MAC_SRC");
- nfp_flow_action_set_mac(position, action, true, mac_set_flag);
- if (!mac_set_flag) {
+ nfp_flow_action_set_mac(position, action, true, flag.mac_set_flag);
+ if (!flag.mac_set_flag) {
position += sizeof(struct nfp_fl_act_set_eth);
- mac_set_flag = true;
+ flag.mac_set_flag = true;
}
break;
case RTE_FLOW_ACTION_TYPE_SET_MAC_DST:
PMD_DRV_LOG(DEBUG, "Process RTE_FLOW_ACTION_TYPE_SET_MAC_DST");
- nfp_flow_action_set_mac(position, action, false, mac_set_flag);
- if (!mac_set_flag) {
+ nfp_flow_action_set_mac(position, action, false, flag.mac_set_flag);
+ if (!flag.mac_set_flag) {
position += sizeof(struct nfp_fl_act_set_eth);
- mac_set_flag = true;
+ flag.mac_set_flag = true;
}
break;
case RTE_FLOW_ACTION_TYPE_OF_POP_VLAN:
@@ -3752,18 +3752,18 @@ nfp_flow_compile_action(struct nfp_flower_representor *representor,
break;
case RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC:
PMD_DRV_LOG(DEBUG, "Process RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC");
- nfp_flow_action_set_ip(position, action, true, ip_set_flag);
- if (!ip_set_flag) {
+ nfp_flow_action_set_ip(position, action, true, flag.ip_set_flag);
+ if (!flag.ip_set_flag) {
position += sizeof(struct nfp_fl_act_set_ip4_addrs);
- ip_set_flag = true;
+ flag.ip_set_flag = true;
}
break;
case RTE_FLOW_ACTION_TYPE_SET_IPV4_DST:
PMD_DRV_LOG(DEBUG, "Process RTE_FLOW_ACTION_TYPE_SET_IPV4_DST");
- nfp_flow_action_set_ip(position, action, false, ip_set_flag);
- if (!ip_set_flag) {
+ nfp_flow_action_set_ip(position, action, false, flag.ip_set_flag);
+ if (!flag.ip_set_flag) {
position += sizeof(struct nfp_fl_act_set_ip4_addrs);
- ip_set_flag = true;
+ flag.ip_set_flag = true;
}
break;
case RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC:
@@ -3779,51 +3779,51 @@ nfp_flow_compile_action(struct nfp_flower_representor *representor,
case RTE_FLOW_ACTION_TYPE_SET_TP_SRC:
PMD_DRV_LOG(DEBUG, "Process RTE_FLOW_ACTION_TYPE_SET_TP_SRC");
nfp_flow_action_set_tp(position, action, true,
- tp_set_flag, nfp_flow->tcp_flag);
- if (!tp_set_flag) {
+ flag.tp_set_flag, nfp_flow->tcp_flag);
+ if (!flag.tp_set_flag) {
position += sizeof(struct nfp_fl_act_set_tport);
- tp_set_flag = true;
+ flag.tp_set_flag = true;
}
break;
case RTE_FLOW_ACTION_TYPE_SET_TP_DST:
PMD_DRV_LOG(DEBUG, "Process RTE_FLOW_ACTION_TYPE_SET_TP_DST");
nfp_flow_action_set_tp(position, action, false,
- tp_set_flag, nfp_flow->tcp_flag);
- if (!tp_set_flag) {
+ flag.tp_set_flag, nfp_flow->tcp_flag);
+ if (!flag.tp_set_flag) {
position += sizeof(struct nfp_fl_act_set_tport);
- tp_set_flag = true;
+ flag.tp_set_flag = true;
}
break;
case RTE_FLOW_ACTION_TYPE_SET_TTL:
PMD_DRV_LOG(DEBUG, "Process RTE_FLOW_ACTION_TYPE_SET_TTL");
if (meta_tci->nfp_flow_key_layer & NFP_FLOWER_LAYER_IPV4) {
- nfp_flow_action_set_ttl(position, action, ttl_tos_flag);
- if (!ttl_tos_flag) {
+ nfp_flow_action_set_ttl(position, action, flag.ttl_tos_flag);
+ if (!flag.ttl_tos_flag) {
position += sizeof(struct nfp_fl_act_set_ip4_ttl_tos);
- ttl_tos_flag = true;
+ flag.ttl_tos_flag = true;
}
} else {
- nfp_flow_action_set_hl(position, action, tc_hl_flag);
- if (!tc_hl_flag) {
+ nfp_flow_action_set_hl(position, action, flag.tc_hl_flag);
+ if (!flag.tc_hl_flag) {
position += sizeof(struct nfp_fl_act_set_ipv6_tc_hl_fl);
- tc_hl_flag = true;
+ flag.tc_hl_flag = true;
}
}
break;
case RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP:
PMD_DRV_LOG(DEBUG, "Process RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP");
- nfp_flow_action_set_tos(position, action, ttl_tos_flag);
- if (!ttl_tos_flag) {
+ nfp_flow_action_set_tos(position, action, flag.ttl_tos_flag);
+ if (!flag.ttl_tos_flag) {
position += sizeof(struct nfp_fl_act_set_ip4_ttl_tos);
- ttl_tos_flag = true;
+ flag.ttl_tos_flag = true;
}
break;
case RTE_FLOW_ACTION_TYPE_SET_IPV6_DSCP:
PMD_DRV_LOG(DEBUG, "Process RTE_FLOW_ACTION_TYPE_SET_IPV6_DSCP");
- nfp_flow_action_set_tc(position, action, tc_hl_flag);
- if (!tc_hl_flag) {
+ nfp_flow_action_set_tc(position, action, flag.tc_hl_flag);
+ if (!flag.tc_hl_flag) {
position += sizeof(struct nfp_fl_act_set_ipv6_tc_hl_fl);
- tc_hl_flag = true;
+ flag.tc_hl_flag = true;
}
break;
case RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP:
@@ -3898,7 +3898,7 @@ nfp_flow_compile_action(struct nfp_flower_representor *representor,
total_actions++;
}
- if (drop_flag)
+ if (flag.drop_flag)
nfp_flow_meta->shortcut = rte_cpu_to_be_32(NFP_FL_SC_ACT_DROP);
else if (total_actions > 1)
nfp_flow_meta->shortcut = rte_cpu_to_be_32(NFP_FL_SC_ACT_NULL);
--
2.39.1
next prev parent reply other threads:[~2024-06-19 9:15 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-19 9:13 [PATCH 00/21] support modify field " Chaoyong He
2024-06-19 9:13 ` [PATCH 01/21] net/nfp: fix IPv6 TTL and DSCP " Chaoyong He
2024-06-19 9:13 ` [PATCH 02/21] net/nfp: pack parameters of flow item function Chaoyong He
2024-06-19 9:13 ` Chaoyong He [this message]
2024-06-19 9:13 ` [PATCH 04/21] net/nfp: refactor flow action calculate function Chaoyong He
2024-06-19 9:13 ` [PATCH 05/21] net/nfp: refactor flow action compile function Chaoyong He
2024-06-19 9:13 ` [PATCH 06/21] net/nfp: pack various flags of flow item Chaoyong He
2024-06-19 9:13 ` [PATCH 07/21] net/nfp: refactor flow item calculate function Chaoyong He
2024-06-19 9:13 ` [PATCH 08/21] net/nfp: support modify IPv4 source address Chaoyong He
2024-06-19 9:13 ` [PATCH 09/21] net/nfp: support modify IPv4 dest address Chaoyong He
2024-06-19 9:13 ` [PATCH 10/21] net/nfp: support modify IPv6 source address Chaoyong He
2024-06-19 9:13 ` [PATCH 11/21] net/nfp: support modify IPv6 dest address Chaoyong He
2024-06-19 9:13 ` [PATCH 12/21] net/nfp: support modify TCP source port Chaoyong He
2024-06-19 9:13 ` [PATCH 13/21] net/nfp: support modify TCP dest port Chaoyong He
2024-06-19 9:13 ` [PATCH 14/21] net/nfp: support modify UDP source port Chaoyong He
2024-06-19 9:13 ` [PATCH 15/21] net/nfp: support modify UDP dest port Chaoyong He
2024-06-19 9:13 ` [PATCH 16/21] net/nfp: support modify IPv4 TTL Chaoyong He
2024-06-19 9:13 ` [PATCH 17/21] net/nfp: support modify IPv6 hop limit Chaoyong He
2024-06-19 9:13 ` [PATCH 18/21] net/nfp: support modify MAC source address Chaoyong He
2024-06-19 9:13 ` [PATCH 19/21] net/nfp: support modify MAC dest address Chaoyong He
2024-06-19 9:13 ` [PATCH 20/21] net/nfp: support modify IPv4 DSCP Chaoyong He
2024-06-19 9:13 ` [PATCH 21/21] net/nfp: support modify IPv6 DSCP Chaoyong He
2024-07-07 2:10 ` [PATCH 00/21] support modify field flow action 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=20240619091358.3479247-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).