* [PATCH 01/21] net/nfp: fix IPv6 TTL and DSCP flow action
2024-06-19 9:13 [PATCH 00/21] support modify field flow action Chaoyong He
@ 2024-06-19 9:13 ` Chaoyong He
2024-06-19 9:13 ` [PATCH 02/21] net/nfp: pack parameters of flow item function Chaoyong He
` (20 subsequent siblings)
21 siblings, 0 replies; 23+ messages in thread
From: Chaoyong He @ 2024-06-19 9:13 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, Chaoyong He, stable, Long Wu, Peng Zhang
The IPv6 TTL and DSCP flow action logic use 'ttl_tos_flag' wrongly,
actually it should use 'tc_hl_flag'.
Fixes: ac12e126c482 ("net/nfp: support TTL flow action")
Fixes: 3202b003bec1 ("net/nfp: support IPv6 DSCP flow action")
Cc: stable@dpdk.org
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 | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/nfp/flower/nfp_flower_flow.c b/drivers/net/nfp/flower/nfp_flower_flow.c
index bd77807db0..45a020b228 100644
--- a/drivers/net/nfp/flower/nfp_flower_flow.c
+++ b/drivers/net/nfp/flower/nfp_flower_flow.c
@@ -3833,7 +3833,7 @@ nfp_flow_compile_action(struct nfp_flower_representor *representor,
ttl_tos_flag = true;
}
} else {
- nfp_flow_action_set_hl(position, action, ttl_tos_flag);
+ nfp_flow_action_set_hl(position, action, tc_hl_flag);
if (!tc_hl_flag) {
position += sizeof(struct nfp_fl_act_set_ipv6_tc_hl_fl);
tc_hl_flag = true;
@@ -3850,7 +3850,7 @@ nfp_flow_compile_action(struct nfp_flower_representor *representor,
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, ttl_tos_flag);
+ nfp_flow_action_set_tc(position, action, tc_hl_flag);
if (!tc_hl_flag) {
position += sizeof(struct nfp_fl_act_set_ipv6_tc_hl_fl);
tc_hl_flag = true;
--
2.39.1
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 02/21] net/nfp: pack parameters of flow item function
2024-06-19 9:13 [PATCH 00/21] support modify field flow action Chaoyong He
2024-06-19 9:13 ` [PATCH 01/21] net/nfp: fix IPv6 TTL and DSCP " Chaoyong He
@ 2024-06-19 9:13 ` Chaoyong He
2024-06-19 9:13 ` [PATCH 03/21] net/nfp: pack various flags of flow action Chaoyong He
` (19 subsequent siblings)
21 siblings, 0 replies; 23+ messages in thread
From: Chaoyong He @ 2024-06-19 9:13 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang
Pack parameters of flow item process function into a single
structure, which makes the logic more clear.
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 | 322 ++++++++++-------------
1 file changed, 146 insertions(+), 176 deletions(-)
diff --git a/drivers/net/nfp/flower/nfp_flower_flow.c b/drivers/net/nfp/flower/nfp_flower_flow.c
index 45a020b228..4dacac1d28 100644
--- a/drivers/net/nfp/flower/nfp_flower_flow.c
+++ b/drivers/net/nfp/flower/nfp_flower_flow.c
@@ -115,6 +115,16 @@
sizeof(struct rte_flow_item_gre) + \
sizeof(rte_be32_t)) /* Gre key */
+struct nfp_flow_merge_param {
+ struct nfp_app_fw_flower *app_fw_flower;
+ struct rte_flow *nfp_flow;
+ char **mbuf_off;
+ const struct rte_flow_item *item;
+ const struct nfp_flow_item_proc *proc;
+ bool is_mask;
+ bool is_outer_layer;
+};
+
/* Process structure associated with a flow item */
struct nfp_flow_item_proc {
/** Bit-mask for fields supported by this PMD. */
@@ -124,13 +134,7 @@ struct nfp_flow_item_proc {
/** Size in bytes for @p mask_support and @p mask_default. */
const size_t mask_sz;
/** Merge a pattern item into a flow rule handle. */
- int (*merge)(struct nfp_app_fw_flower *app_fw_flower,
- struct rte_flow *nfp_flow,
- char **mbuf_off,
- const struct rte_flow_item *item,
- const struct nfp_flow_item_proc *proc,
- bool is_mask,
- bool is_outer_layer);
+ int (*merge)(struct nfp_flow_merge_param *param);
/** List of possible subsequent items. */
const enum rte_flow_item_type *const next_item;
};
@@ -1200,28 +1204,24 @@ nfp_flow_is_tunnel(struct rte_flow *nfp_flow)
}
static int
-nfp_flow_merge_eth(__rte_unused struct nfp_app_fw_flower *app_fw_flower,
- __rte_unused struct rte_flow *nfp_flow,
- char **mbuf_off,
- const struct rte_flow_item *item,
- const struct nfp_flow_item_proc *proc,
- bool is_mask,
- __rte_unused bool is_outer_layer)
+nfp_flow_merge_eth(struct nfp_flow_merge_param *param)
{
struct nfp_flower_mac_mpls *eth;
+ const struct rte_flow_item *item;
const struct rte_flow_item_eth *spec;
const struct rte_flow_item_eth *mask;
+ item = param->item;
spec = item->spec;
if (spec == NULL) {
PMD_DRV_LOG(DEBUG, "nfp flow merge eth: no item->spec!");
goto eth_end;
}
- mask = item->mask ? item->mask : proc->mask_default;
- eth = (void *)*mbuf_off;
+ mask = item->mask ? item->mask : param->proc->mask_default;
+ eth = (void *)(*param->mbuf_off);
- if (is_mask) {
+ if (param->is_mask) {
memcpy(eth->mac_src, mask->hdr.src_addr.addr_bytes, RTE_ETHER_ADDR_LEN);
memcpy(eth->mac_dst, mask->hdr.dst_addr.addr_bytes, RTE_ETHER_ADDR_LEN);
} else {
@@ -1230,37 +1230,33 @@ nfp_flow_merge_eth(__rte_unused struct nfp_app_fw_flower *app_fw_flower,
}
eth->mpls_lse = 0;
- *mbuf_off += sizeof(struct nfp_flower_mac_mpls);
+ *param->mbuf_off += sizeof(struct nfp_flower_mac_mpls);
eth_end:
return 0;
}
static int
-nfp_flow_merge_vlan(__rte_unused struct nfp_app_fw_flower *app_fw_flower,
- struct rte_flow *nfp_flow,
- __rte_unused char **mbuf_off,
- const struct rte_flow_item *item,
- const struct nfp_flow_item_proc *proc,
- bool is_mask,
- __rte_unused bool is_outer_layer)
+nfp_flow_merge_vlan(struct nfp_flow_merge_param *param)
{
+ const struct rte_flow_item *item;
struct nfp_flower_meta_tci *meta_tci;
const struct rte_flow_item_vlan *spec;
const struct rte_flow_item_vlan *mask;
+ item = param->item;
spec = item->spec;
if (spec == NULL) {
PMD_DRV_LOG(DEBUG, "nfp flow merge vlan: no item->spec!");
return 0;
}
- mask = item->mask ? item->mask : proc->mask_default;
- if (is_mask) {
- meta_tci = (struct nfp_flower_meta_tci *)nfp_flow->payload.mask_data;
+ mask = item->mask ? item->mask : param->proc->mask_default;
+ if (param->is_mask) {
+ meta_tci = (struct nfp_flower_meta_tci *)param->nfp_flow->payload.mask_data;
meta_tci->tci |= mask->hdr.vlan_tci;
} else {
- meta_tci = (struct nfp_flower_meta_tci *)nfp_flow->payload.unmasked_data;
+ meta_tci = (struct nfp_flower_meta_tci *)param->nfp_flow->payload.unmasked_data;
meta_tci->tci |= spec->hdr.vlan_tci;
}
@@ -1268,16 +1264,11 @@ nfp_flow_merge_vlan(__rte_unused struct nfp_app_fw_flower *app_fw_flower,
}
static int
-nfp_flow_merge_ipv4(__rte_unused struct nfp_app_fw_flower *app_fw_flower,
- struct rte_flow *nfp_flow,
- char **mbuf_off,
- const struct rte_flow_item *item,
- const struct nfp_flow_item_proc *proc,
- bool is_mask,
- bool is_outer_layer)
+nfp_flow_merge_ipv4(struct nfp_flow_merge_param *param)
{
struct nfp_flower_ipv4 *ipv4;
const struct rte_ipv4_hdr *hdr;
+ const struct rte_flow_item *item;
struct nfp_flower_meta_tci *meta_tci;
const struct rte_flow_item_ipv4 *spec;
const struct rte_flow_item_ipv4 *mask;
@@ -1285,30 +1276,31 @@ nfp_flow_merge_ipv4(__rte_unused struct nfp_app_fw_flower *app_fw_flower,
struct nfp_flower_ipv4_udp_tun *ipv4_udp_tun;
struct nfp_flower_ipv4_gre_tun *ipv4_gre_tun;
+ item = param->item;
spec = item->spec;
- mask = item->mask ? item->mask : proc->mask_default;
- meta_tci = (struct nfp_flower_meta_tci *)nfp_flow->payload.unmasked_data;
+ mask = item->mask ? item->mask : param->proc->mask_default;
+ meta_tci = (struct nfp_flower_meta_tci *)param->nfp_flow->payload.unmasked_data;
if ((meta_tci->nfp_flow_key_layer & NFP_FLOWER_LAYER_EXT_META) != 0)
ext_meta = (struct nfp_flower_ext_meta *)(meta_tci + 1);
- if (is_outer_layer && nfp_flow_is_tunnel(nfp_flow)) {
+ if (param->is_outer_layer && nfp_flow_is_tunnel(param->nfp_flow)) {
if (spec == NULL) {
PMD_DRV_LOG(DEBUG, "nfp flow merge ipv4: no item->spec!");
return 0;
}
- hdr = is_mask ? &mask->hdr : &spec->hdr;
+ hdr = param->is_mask ? &mask->hdr : &spec->hdr;
if (ext_meta != NULL && (rte_be_to_cpu_32(ext_meta->nfp_flow_key_layer2) &
NFP_FLOWER_LAYER2_GRE) != 0) {
- ipv4_gre_tun = (struct nfp_flower_ipv4_gre_tun *)*mbuf_off;
+ ipv4_gre_tun = (struct nfp_flower_ipv4_gre_tun *)(*param->mbuf_off);
ipv4_gre_tun->ip_ext.tos = hdr->type_of_service;
ipv4_gre_tun->ip_ext.ttl = hdr->time_to_live;
ipv4_gre_tun->ipv4.src = hdr->src_addr;
ipv4_gre_tun->ipv4.dst = hdr->dst_addr;
} else {
- ipv4_udp_tun = (struct nfp_flower_ipv4_udp_tun *)*mbuf_off;
+ ipv4_udp_tun = (struct nfp_flower_ipv4_udp_tun *)(*param->mbuf_off);
ipv4_udp_tun->ip_ext.tos = hdr->type_of_service;
ipv4_udp_tun->ip_ext.ttl = hdr->time_to_live;
@@ -1321,15 +1313,15 @@ nfp_flow_merge_ipv4(__rte_unused struct nfp_app_fw_flower *app_fw_flower,
* rte_flow has ipv4 before L4 but NFP flower fw requires L4 before ipv4.
*/
if ((meta_tci->nfp_flow_key_layer & NFP_FLOWER_LAYER_TP) != 0)
- *mbuf_off += sizeof(struct nfp_flower_tp_ports);
+ *param->mbuf_off += sizeof(struct nfp_flower_tp_ports);
if (spec == NULL) {
PMD_DRV_LOG(DEBUG, "nfp flow merge ipv4: no item->spec!");
goto ipv4_end;
}
- hdr = is_mask ? &mask->hdr : &spec->hdr;
- ipv4 = (struct nfp_flower_ipv4 *)*mbuf_off;
+ hdr = param->is_mask ? &mask->hdr : &spec->hdr;
+ ipv4 = (struct nfp_flower_ipv4 *)(*param->mbuf_off);
ipv4->ip_ext.tos = hdr->type_of_service;
ipv4->ip_ext.proto = hdr->next_proto_id;
@@ -1338,24 +1330,19 @@ nfp_flow_merge_ipv4(__rte_unused struct nfp_app_fw_flower *app_fw_flower,
ipv4->ipv4_dst = hdr->dst_addr;
ipv4_end:
- *mbuf_off += sizeof(struct nfp_flower_ipv4);
+ *param->mbuf_off += sizeof(struct nfp_flower_ipv4);
}
return 0;
}
static int
-nfp_flow_merge_ipv6(__rte_unused struct nfp_app_fw_flower *app_fw_flower,
- struct rte_flow *nfp_flow,
- char **mbuf_off,
- const struct rte_flow_item *item,
- const struct nfp_flow_item_proc *proc,
- bool is_mask,
- bool is_outer_layer)
+nfp_flow_merge_ipv6(struct nfp_flow_merge_param *param)
{
uint32_t vtc_flow;
struct nfp_flower_ipv6 *ipv6;
const struct rte_ipv6_hdr *hdr;
+ const struct rte_flow_item *item;
struct nfp_flower_meta_tci *meta_tci;
const struct rte_flow_item_ipv6 *spec;
const struct rte_flow_item_ipv6 *mask;
@@ -1363,24 +1350,25 @@ nfp_flow_merge_ipv6(__rte_unused struct nfp_app_fw_flower *app_fw_flower,
struct nfp_flower_ipv6_udp_tun *ipv6_udp_tun;
struct nfp_flower_ipv6_gre_tun *ipv6_gre_tun;
+ item = param->item;
spec = item->spec;
- mask = item->mask ? item->mask : proc->mask_default;
- meta_tci = (struct nfp_flower_meta_tci *)nfp_flow->payload.unmasked_data;
+ mask = item->mask ? item->mask : param->proc->mask_default;
+ meta_tci = (struct nfp_flower_meta_tci *)param->nfp_flow->payload.unmasked_data;
if ((meta_tci->nfp_flow_key_layer & NFP_FLOWER_LAYER_EXT_META) != 0)
ext_meta = (struct nfp_flower_ext_meta *)(meta_tci + 1);
- if (is_outer_layer && nfp_flow_is_tunnel(nfp_flow)) {
+ if (param->is_outer_layer && nfp_flow_is_tunnel(param->nfp_flow)) {
if (spec == NULL) {
PMD_DRV_LOG(DEBUG, "nfp flow merge ipv6: no item->spec!");
return 0;
}
- hdr = is_mask ? &mask->hdr : &spec->hdr;
+ hdr = param->is_mask ? &mask->hdr : &spec->hdr;
vtc_flow = rte_be_to_cpu_32(hdr->vtc_flow);
if (ext_meta != NULL && (rte_be_to_cpu_32(ext_meta->nfp_flow_key_layer2) &
NFP_FLOWER_LAYER2_GRE) != 0) {
- ipv6_gre_tun = (struct nfp_flower_ipv6_gre_tun *)*mbuf_off;
+ ipv6_gre_tun = (struct nfp_flower_ipv6_gre_tun *)(*param->mbuf_off);
ipv6_gre_tun->ip_ext.tos = vtc_flow >> RTE_IPV6_HDR_TC_SHIFT;
ipv6_gre_tun->ip_ext.ttl = hdr->hop_limits;
@@ -1389,7 +1377,7 @@ nfp_flow_merge_ipv6(__rte_unused struct nfp_app_fw_flower *app_fw_flower,
memcpy(ipv6_gre_tun->ipv6.ipv6_dst, hdr->dst_addr,
sizeof(ipv6_gre_tun->ipv6.ipv6_dst));
} else {
- ipv6_udp_tun = (struct nfp_flower_ipv6_udp_tun *)*mbuf_off;
+ ipv6_udp_tun = (struct nfp_flower_ipv6_udp_tun *)(*param->mbuf_off);
ipv6_udp_tun->ip_ext.tos = vtc_flow >> RTE_IPV6_HDR_TC_SHIFT;
ipv6_udp_tun->ip_ext.ttl = hdr->hop_limits;
@@ -1404,16 +1392,16 @@ nfp_flow_merge_ipv6(__rte_unused struct nfp_app_fw_flower *app_fw_flower,
* rte_flow has ipv6 before L4 but NFP flower fw requires L4 before ipv6.
*/
if ((meta_tci->nfp_flow_key_layer & NFP_FLOWER_LAYER_TP) != 0)
- *mbuf_off += sizeof(struct nfp_flower_tp_ports);
+ *param->mbuf_off += sizeof(struct nfp_flower_tp_ports);
if (spec == NULL) {
PMD_DRV_LOG(DEBUG, "nfp flow merge ipv6: no item->spec!");
goto ipv6_end;
}
- hdr = is_mask ? &mask->hdr : &spec->hdr;
+ hdr = param->is_mask ? &mask->hdr : &spec->hdr;
vtc_flow = rte_be_to_cpu_32(hdr->vtc_flow);
- ipv6 = (struct nfp_flower_ipv6 *)*mbuf_off;
+ ipv6 = (struct nfp_flower_ipv6 *)(*param->mbuf_off);
ipv6->ip_ext.tos = vtc_flow >> RTE_IPV6_HDR_TC_SHIFT;
ipv6->ip_ext.proto = hdr->proto;
@@ -1422,22 +1410,17 @@ nfp_flow_merge_ipv6(__rte_unused struct nfp_app_fw_flower *app_fw_flower,
memcpy(ipv6->ipv6_dst, hdr->dst_addr, sizeof(ipv6->ipv6_dst));
ipv6_end:
- *mbuf_off += sizeof(struct nfp_flower_ipv6);
+ *param->mbuf_off += sizeof(struct nfp_flower_ipv6);
}
return 0;
}
static int
-nfp_flow_merge_tcp(__rte_unused struct nfp_app_fw_flower *app_fw_flower,
- struct rte_flow *nfp_flow,
- char **mbuf_off,
- const struct rte_flow_item *item,
- const struct nfp_flow_item_proc *proc,
- bool is_mask,
- __rte_unused bool is_outer_layer)
+nfp_flow_merge_tcp(struct nfp_flow_merge_param *param)
{
uint8_t tcp_flags;
+ const struct rte_flow_item *item;
struct nfp_flower_tp_ports *ports;
struct nfp_flower_ipv4 *ipv4 = NULL;
struct nfp_flower_ipv6 *ipv6 = NULL;
@@ -1445,11 +1428,11 @@ nfp_flow_merge_tcp(__rte_unused struct nfp_app_fw_flower *app_fw_flower,
const struct rte_flow_item_tcp *mask;
struct nfp_flower_meta_tci *meta_tci;
- meta_tci = (struct nfp_flower_meta_tci *)nfp_flow->payload.unmasked_data;
+ meta_tci = (struct nfp_flower_meta_tci *)param->nfp_flow->payload.unmasked_data;
if ((meta_tci->nfp_flow_key_layer & NFP_FLOWER_LAYER_IPV4) != 0) {
ipv4 = (struct nfp_flower_ipv4 *)
- (*mbuf_off - sizeof(struct nfp_flower_ipv4));
- if (is_mask)
+ (*param->mbuf_off - sizeof(struct nfp_flower_ipv4));
+ if (param->is_mask)
ipv4->ip_ext.proto = 0xFF;
else
ipv4->ip_ext.proto = IPPROTO_TCP;
@@ -1457,8 +1440,8 @@ nfp_flow_merge_tcp(__rte_unused struct nfp_app_fw_flower *app_fw_flower,
((char *)ipv4 - sizeof(struct nfp_flower_tp_ports));
} else if ((meta_tci->nfp_flow_key_layer & NFP_FLOWER_LAYER_IPV6) != 0) {
ipv6 = (struct nfp_flower_ipv6 *)
- (*mbuf_off - sizeof(struct nfp_flower_ipv6));
- if (is_mask)
+ (*param->mbuf_off - sizeof(struct nfp_flower_ipv6));
+ if (param->is_mask)
ipv6->ip_ext.proto = 0xFF;
else
ipv6->ip_ext.proto = IPPROTO_TCP;
@@ -1469,14 +1452,15 @@ nfp_flow_merge_tcp(__rte_unused struct nfp_app_fw_flower *app_fw_flower,
return -EINVAL;
}
+ item = param->item;
spec = item->spec;
if (spec == NULL) {
PMD_DRV_LOG(DEBUG, "nfp flow merge tcp: no item->spec!");
return 0;
}
- mask = item->mask ? item->mask : proc->mask_default;
- if (is_mask) {
+ mask = item->mask ? item->mask : param->proc->mask_default;
+ if (param->is_mask) {
ports->port_src = mask->hdr.src_port;
ports->port_dst = mask->hdr.dst_port;
tcp_flags = mask->hdr.tcp_flags;
@@ -1514,14 +1498,9 @@ nfp_flow_merge_tcp(__rte_unused struct nfp_app_fw_flower *app_fw_flower,
}
static int
-nfp_flow_merge_udp(__rte_unused struct nfp_app_fw_flower *app_fw_flower,
- struct rte_flow *nfp_flow,
- char **mbuf_off,
- const struct rte_flow_item *item,
- const struct nfp_flow_item_proc *proc,
- bool is_mask,
- bool is_outer_layer)
+nfp_flow_merge_udp(struct nfp_flow_merge_param *param)
{
+ const struct rte_flow_item *item;
struct nfp_flower_tp_ports *ports;
struct nfp_flower_ipv4 *ipv4 = NULL;
struct nfp_flower_ipv6 *ipv6 = NULL;
@@ -1530,16 +1509,16 @@ nfp_flow_merge_udp(__rte_unused struct nfp_app_fw_flower *app_fw_flower,
struct nfp_flower_meta_tci *meta_tci;
/* Don't add L4 info if working on a inner layer pattern */
- if (!is_outer_layer) {
+ if (!param->is_outer_layer) {
PMD_DRV_LOG(INFO, "Detected inner layer UDP, skipping.");
return 0;
}
- meta_tci = (struct nfp_flower_meta_tci *)nfp_flow->payload.unmasked_data;
+ meta_tci = (struct nfp_flower_meta_tci *)param->nfp_flow->payload.unmasked_data;
if ((meta_tci->nfp_flow_key_layer & NFP_FLOWER_LAYER_IPV4) != 0) {
ipv4 = (struct nfp_flower_ipv4 *)
- (*mbuf_off - sizeof(struct nfp_flower_ipv4));
- if (is_mask)
+ (*param->mbuf_off - sizeof(struct nfp_flower_ipv4));
+ if (param->is_mask)
ipv4->ip_ext.proto = 0xFF;
else
ipv4->ip_ext.proto = IPPROTO_UDP;
@@ -1547,8 +1526,8 @@ nfp_flow_merge_udp(__rte_unused struct nfp_app_fw_flower *app_fw_flower,
((char *)ipv4 - sizeof(struct nfp_flower_tp_ports));
} else if ((meta_tci->nfp_flow_key_layer & NFP_FLOWER_LAYER_IPV6) != 0) {
ipv6 = (struct nfp_flower_ipv6 *)
- (*mbuf_off - sizeof(struct nfp_flower_ipv6));
- if (is_mask)
+ (*param->mbuf_off - sizeof(struct nfp_flower_ipv6));
+ if (param->is_mask)
ipv6->ip_ext.proto = 0xFF;
else
ipv6->ip_ext.proto = IPPROTO_UDP;
@@ -1559,14 +1538,15 @@ nfp_flow_merge_udp(__rte_unused struct nfp_app_fw_flower *app_fw_flower,
return -EINVAL;
}
+ item = param->item;
spec = item->spec;
if (spec == NULL) {
PMD_DRV_LOG(DEBUG, "nfp flow merge udp: no item->spec!");
return 0;
}
- mask = item->mask ? item->mask : proc->mask_default;
- if (is_mask) {
+ mask = item->mask ? item->mask : param->proc->mask_default;
+ if (param->is_mask) {
ports->port_src = mask->hdr.src_port;
ports->port_dst = mask->hdr.dst_port;
} else {
@@ -1578,14 +1558,9 @@ nfp_flow_merge_udp(__rte_unused struct nfp_app_fw_flower *app_fw_flower,
}
static int
-nfp_flow_merge_sctp(__rte_unused struct nfp_app_fw_flower *app_fw_flower,
- struct rte_flow *nfp_flow,
- char **mbuf_off,
- const struct rte_flow_item *item,
- const struct nfp_flow_item_proc *proc,
- bool is_mask,
- __rte_unused bool is_outer_layer)
+nfp_flow_merge_sctp(struct nfp_flow_merge_param *param)
{
+ const struct rte_flow_item *item;
struct nfp_flower_tp_ports *ports;
struct nfp_flower_ipv4 *ipv4 = NULL;
struct nfp_flower_ipv6 *ipv6 = NULL;
@@ -1593,11 +1568,11 @@ nfp_flow_merge_sctp(__rte_unused struct nfp_app_fw_flower *app_fw_flower,
const struct rte_flow_item_sctp *spec;
const struct rte_flow_item_sctp *mask;
- meta_tci = (struct nfp_flower_meta_tci *)nfp_flow->payload.unmasked_data;
+ meta_tci = (struct nfp_flower_meta_tci *)param->nfp_flow->payload.unmasked_data;
if ((meta_tci->nfp_flow_key_layer & NFP_FLOWER_LAYER_IPV4) != 0) {
ipv4 = (struct nfp_flower_ipv4 *)
- (*mbuf_off - sizeof(struct nfp_flower_ipv4));
- if (is_mask)
+ (*param->mbuf_off - sizeof(struct nfp_flower_ipv4));
+ if (param->is_mask)
ipv4->ip_ext.proto = 0xFF;
else
ipv4->ip_ext.proto = IPPROTO_SCTP;
@@ -1605,8 +1580,8 @@ nfp_flow_merge_sctp(__rte_unused struct nfp_app_fw_flower *app_fw_flower,
((char *)ipv4 - sizeof(struct nfp_flower_tp_ports));
} else if ((meta_tci->nfp_flow_key_layer & NFP_FLOWER_LAYER_IPV6) != 0) {
ipv6 = (struct nfp_flower_ipv6 *)
- (*mbuf_off - sizeof(struct nfp_flower_ipv6));
- if (is_mask)
+ (*param->mbuf_off - sizeof(struct nfp_flower_ipv6));
+ if (param->is_mask)
ipv6->ip_ext.proto = 0xFF;
else
ipv6->ip_ext.proto = IPPROTO_SCTP;
@@ -1617,14 +1592,15 @@ nfp_flow_merge_sctp(__rte_unused struct nfp_app_fw_flower *app_fw_flower,
return -EINVAL;
}
+ item = param->item;
spec = item->spec;
if (spec == NULL) {
PMD_DRV_LOG(DEBUG, "nfp flow merge sctp: no item->spec!");
return 0;
}
- mask = item->mask ? item->mask : proc->mask_default;
- if (is_mask) {
+ mask = item->mask ? item->mask : param->proc->mask_default;
+ if (param->is_mask) {
ports->port_src = mask->hdr.src_port;
ports->port_dst = mask->hdr.dst_port;
} else {
@@ -1636,16 +1612,11 @@ nfp_flow_merge_sctp(__rte_unused struct nfp_app_fw_flower *app_fw_flower,
}
static int
-nfp_flow_merge_vxlan(struct nfp_app_fw_flower *app_fw_flower,
- struct rte_flow *nfp_flow,
- char **mbuf_off,
- const struct rte_flow_item *item,
- const struct nfp_flow_item_proc *proc,
- bool is_mask,
- __rte_unused bool is_outer_layer)
+nfp_flow_merge_vxlan(struct nfp_flow_merge_param *param)
{
int ret = 0;
const struct rte_vxlan_hdr *hdr;
+ const struct rte_flow_item *item;
struct nfp_flower_ipv4_udp_tun *tun4;
struct nfp_flower_ipv6_udp_tun *tun6;
struct nfp_flower_meta_tci *meta_tci;
@@ -1653,52 +1624,48 @@ nfp_flow_merge_vxlan(struct nfp_app_fw_flower *app_fw_flower,
const struct rte_flow_item_vxlan *mask;
struct nfp_flower_ext_meta *ext_meta = NULL;
- meta_tci = (struct nfp_flower_meta_tci *)nfp_flow->payload.unmasked_data;
+ meta_tci = (struct nfp_flower_meta_tci *)param->nfp_flow->payload.unmasked_data;
if ((meta_tci->nfp_flow_key_layer & NFP_FLOWER_LAYER_EXT_META) != 0)
ext_meta = (struct nfp_flower_ext_meta *)(meta_tci + 1);
+ item = param->item;
spec = item->spec;
if (spec == NULL) {
PMD_DRV_LOG(DEBUG, "nfp flow merge vxlan: no item->spec!");
goto vxlan_end;
}
- mask = item->mask ? item->mask : proc->mask_default;
- hdr = is_mask ? &mask->hdr : &spec->hdr;
+ mask = item->mask ? item->mask : param->proc->mask_default;
+ hdr = param->is_mask ? &mask->hdr : &spec->hdr;
if (ext_meta != NULL && (rte_be_to_cpu_32(ext_meta->nfp_flow_key_layer2) &
NFP_FLOWER_LAYER2_TUN_IPV6) != 0) {
- tun6 = (struct nfp_flower_ipv6_udp_tun *)*mbuf_off;
+ tun6 = (struct nfp_flower_ipv6_udp_tun *)(*param->mbuf_off);
tun6->tun_id = hdr->vx_vni;
- if (!is_mask)
- ret = nfp_tun_add_ipv6_off(app_fw_flower, tun6->ipv6.ipv6_dst);
+ if (!param->is_mask)
+ ret = nfp_tun_add_ipv6_off(param->app_fw_flower, tun6->ipv6.ipv6_dst);
} else {
- tun4 = (struct nfp_flower_ipv4_udp_tun *)*mbuf_off;
+ tun4 = (struct nfp_flower_ipv4_udp_tun *)(*param->mbuf_off);
tun4->tun_id = hdr->vx_vni;
- if (!is_mask)
- ret = nfp_tun_add_ipv4_off(app_fw_flower, tun4->ipv4.dst);
+ if (!param->is_mask)
+ ret = nfp_tun_add_ipv4_off(param->app_fw_flower, tun4->ipv4.dst);
}
vxlan_end:
if (ext_meta != NULL && (rte_be_to_cpu_32(ext_meta->nfp_flow_key_layer2) &
NFP_FLOWER_LAYER2_TUN_IPV6) != 0)
- *mbuf_off += sizeof(struct nfp_flower_ipv6_udp_tun);
+ *param->mbuf_off += sizeof(struct nfp_flower_ipv6_udp_tun);
else
- *mbuf_off += sizeof(struct nfp_flower_ipv4_udp_tun);
+ *param->mbuf_off += sizeof(struct nfp_flower_ipv4_udp_tun);
return ret;
}
static int
-nfp_flow_merge_geneve(struct nfp_app_fw_flower *app_fw_flower,
- struct rte_flow *nfp_flow,
- char **mbuf_off,
- const struct rte_flow_item *item,
- const struct nfp_flow_item_proc *proc,
- bool is_mask,
- __rte_unused bool is_outer_layer)
+nfp_flow_merge_geneve(struct nfp_flow_merge_param *param)
{
int ret = 0;
+ const struct rte_flow_item *item;
struct nfp_flower_ipv4_udp_tun *tun4;
struct nfp_flower_ipv6_udp_tun *tun6;
struct nfp_flower_meta_tci *meta_tci;
@@ -1707,73 +1674,68 @@ nfp_flow_merge_geneve(struct nfp_app_fw_flower *app_fw_flower,
const struct rte_flow_item_geneve *geneve;
struct nfp_flower_ext_meta *ext_meta = NULL;
- meta_tci = (struct nfp_flower_meta_tci *)nfp_flow->payload.unmasked_data;
+ meta_tci = (struct nfp_flower_meta_tci *)param->nfp_flow->payload.unmasked_data;
if ((meta_tci->nfp_flow_key_layer & NFP_FLOWER_LAYER_EXT_META) != 0)
ext_meta = (struct nfp_flower_ext_meta *)(meta_tci + 1);
+ item = param->item;
spec = item->spec;
if (spec == NULL) {
PMD_DRV_LOG(DEBUG, "nfp flow merge geneve: no item->spec!");
goto geneve_end;
}
- mask = item->mask ? item->mask : proc->mask_default;
- geneve = is_mask ? mask : spec;
+ mask = item->mask ? item->mask : param->proc->mask_default;
+ geneve = param->is_mask ? mask : spec;
if (ext_meta != NULL && (rte_be_to_cpu_32(ext_meta->nfp_flow_key_layer2) &
NFP_FLOWER_LAYER2_TUN_IPV6) != 0) {
- tun6 = (struct nfp_flower_ipv6_udp_tun *)*mbuf_off;
+ tun6 = (struct nfp_flower_ipv6_udp_tun *)(*param->mbuf_off);
tun6->tun_id = rte_cpu_to_be_32((geneve->vni[0] << 16) |
(geneve->vni[1] << 8) | (geneve->vni[2]));
- if (!is_mask)
- ret = nfp_tun_add_ipv6_off(app_fw_flower, tun6->ipv6.ipv6_dst);
+ if (!param->is_mask)
+ ret = nfp_tun_add_ipv6_off(param->app_fw_flower, tun6->ipv6.ipv6_dst);
} else {
- tun4 = (struct nfp_flower_ipv4_udp_tun *)*mbuf_off;
+ tun4 = (struct nfp_flower_ipv4_udp_tun *)(*param->mbuf_off);
tun4->tun_id = rte_cpu_to_be_32((geneve->vni[0] << 16) |
(geneve->vni[1] << 8) | (geneve->vni[2]));
- if (!is_mask)
- ret = nfp_tun_add_ipv4_off(app_fw_flower, tun4->ipv4.dst);
+ if (!param->is_mask)
+ ret = nfp_tun_add_ipv4_off(param->app_fw_flower, tun4->ipv4.dst);
}
geneve_end:
if (ext_meta != NULL && (rte_be_to_cpu_32(ext_meta->nfp_flow_key_layer2) &
NFP_FLOWER_LAYER2_TUN_IPV6) != 0) {
- *mbuf_off += sizeof(struct nfp_flower_ipv6_udp_tun);
+ *param->mbuf_off += sizeof(struct nfp_flower_ipv6_udp_tun);
} else {
- *mbuf_off += sizeof(struct nfp_flower_ipv4_udp_tun);
+ *param->mbuf_off += sizeof(struct nfp_flower_ipv4_udp_tun);
}
return ret;
}
static int
-nfp_flow_merge_gre(__rte_unused struct nfp_app_fw_flower *app_fw_flower,
- struct rte_flow *nfp_flow,
- char **mbuf_off,
- __rte_unused const struct rte_flow_item *item,
- __rte_unused const struct nfp_flow_item_proc *proc,
- bool is_mask,
- __rte_unused bool is_outer_layer)
+nfp_flow_merge_gre(struct nfp_flow_merge_param *param)
{
struct nfp_flower_meta_tci *meta_tci;
struct nfp_flower_ext_meta *ext_meta;
struct nfp_flower_ipv4_gre_tun *tun4;
struct nfp_flower_ipv6_gre_tun *tun6;
- meta_tci = (struct nfp_flower_meta_tci *)nfp_flow->payload.unmasked_data;
+ meta_tci = (struct nfp_flower_meta_tci *)param->nfp_flow->payload.unmasked_data;
ext_meta = (struct nfp_flower_ext_meta *)(meta_tci + 1);
/* NVGRE is the only supported GRE tunnel type */
if ((rte_be_to_cpu_32(ext_meta->nfp_flow_key_layer2) &
NFP_FLOWER_LAYER2_TUN_IPV6) != 0) {
- tun6 = (struct nfp_flower_ipv6_gre_tun *)*mbuf_off;
- if (is_mask)
+ tun6 = (struct nfp_flower_ipv6_gre_tun *)(*param->mbuf_off);
+ if (param->is_mask)
tun6->ethertype = rte_cpu_to_be_16(~0);
else
tun6->ethertype = rte_cpu_to_be_16(0x6558);
} else {
- tun4 = (struct nfp_flower_ipv4_gre_tun *)*mbuf_off;
- if (is_mask)
+ tun4 = (struct nfp_flower_ipv4_gre_tun *)(*param->mbuf_off);
+ if (param->is_mask)
tun4->ethertype = rte_cpu_to_be_16(~0);
else
tun4->ethertype = rte_cpu_to_be_16(0x6558);
@@ -1783,56 +1745,52 @@ nfp_flow_merge_gre(__rte_unused struct nfp_app_fw_flower *app_fw_flower,
}
static int
-nfp_flow_merge_gre_key(struct nfp_app_fw_flower *app_fw_flower,
- struct rte_flow *nfp_flow,
- char **mbuf_off,
- const struct rte_flow_item *item,
- const struct nfp_flow_item_proc *proc,
- bool is_mask,
- __rte_unused bool is_outer_layer)
+nfp_flow_merge_gre_key(struct nfp_flow_merge_param *param)
{
int ret = 0;
rte_be32_t tun_key;
const rte_be32_t *spec;
const rte_be32_t *mask;
+ const struct rte_flow_item *item;
struct nfp_flower_meta_tci *meta_tci;
struct nfp_flower_ext_meta *ext_meta;
struct nfp_flower_ipv4_gre_tun *tun4;
struct nfp_flower_ipv6_gre_tun *tun6;
- meta_tci = (struct nfp_flower_meta_tci *)nfp_flow->payload.unmasked_data;
+ meta_tci = (struct nfp_flower_meta_tci *)param->nfp_flow->payload.unmasked_data;
ext_meta = (struct nfp_flower_ext_meta *)(meta_tci + 1);
+ item = param->item;
spec = item->spec;
if (spec == NULL) {
PMD_DRV_LOG(DEBUG, "nfp flow merge gre key: no item->spec!");
goto gre_key_end;
}
- mask = item->mask ? item->mask : proc->mask_default;
- tun_key = is_mask ? *mask : *spec;
+ mask = item->mask ? item->mask : param->proc->mask_default;
+ tun_key = param->is_mask ? *mask : *spec;
if ((rte_be_to_cpu_32(ext_meta->nfp_flow_key_layer2) &
NFP_FLOWER_LAYER2_TUN_IPV6) != 0) {
- tun6 = (struct nfp_flower_ipv6_gre_tun *)*mbuf_off;
+ tun6 = (struct nfp_flower_ipv6_gre_tun *)(*param->mbuf_off);
tun6->tun_key = tun_key;
tun6->tun_flags = rte_cpu_to_be_16(NFP_FL_GRE_FLAG_KEY);
- if (!is_mask)
- ret = nfp_tun_add_ipv6_off(app_fw_flower, tun6->ipv6.ipv6_dst);
+ if (!param->is_mask)
+ ret = nfp_tun_add_ipv6_off(param->app_fw_flower, tun6->ipv6.ipv6_dst);
} else {
- tun4 = (struct nfp_flower_ipv4_gre_tun *)*mbuf_off;
+ tun4 = (struct nfp_flower_ipv4_gre_tun *)(*param->mbuf_off);
tun4->tun_key = tun_key;
tun4->tun_flags = rte_cpu_to_be_16(NFP_FL_GRE_FLAG_KEY);
- if (!is_mask)
- ret = nfp_tun_add_ipv4_off(app_fw_flower, tun4->ipv4.dst);
+ if (!param->is_mask)
+ ret = nfp_tun_add_ipv4_off(param->app_fw_flower, tun4->ipv4.dst);
}
gre_key_end:
if ((rte_be_to_cpu_32(ext_meta->nfp_flow_key_layer2) &
NFP_FLOWER_LAYER2_TUN_IPV6) != 0)
- *mbuf_off += sizeof(struct nfp_flower_ipv6_gre_tun);
+ *param->mbuf_off += sizeof(struct nfp_flower_ipv6_gre_tun);
else
- *mbuf_off += sizeof(struct nfp_flower_ipv4_gre_tun);
+ *param->mbuf_off += sizeof(struct nfp_flower_ipv4_gre_tun);
return ret;
}
@@ -2133,15 +2091,27 @@ nfp_flow_compile_item_proc(struct nfp_flower_representor *repr,
break;
}
- ret = proc->merge(app_fw_flower, nfp_flow, mbuf_off_exact, item,
- proc, false, is_outer_layer);
+ struct nfp_flow_merge_param param = {
+ .app_fw_flower = app_fw_flower,
+ .nfp_flow = nfp_flow,
+ .item = item,
+ .proc = proc,
+ .is_outer_layer = is_outer_layer,
+ };
+
+ /* Proc the exact match section */
+ param.mbuf_off = mbuf_off_exact;
+ param.is_mask = false;
+ ret = proc->merge(¶m);
if (ret != 0) {
PMD_DRV_LOG(ERR, "nfp flow item %d exact merge failed", item->type);
break;
}
- ret = proc->merge(app_fw_flower, nfp_flow, mbuf_off_mask, item,
- proc, true, is_outer_layer);
+ /*Proc the mask section */
+ param.mbuf_off = mbuf_off_mask;
+ param.is_mask = true;
+ ret = proc->merge(¶m);
if (ret != 0) {
PMD_DRV_LOG(ERR, "nfp flow item %d mask merge failed", item->type);
break;
--
2.39.1
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 03/21] net/nfp: pack various flags of flow action
2024-06-19 9:13 [PATCH 00/21] support modify field flow action 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
2024-06-19 9:13 ` [PATCH 04/21] net/nfp: refactor flow action calculate function Chaoyong He
` (18 subsequent siblings)
21 siblings, 0 replies; 23+ messages in thread
From: Chaoyong He @ 2024-06-19 9:13 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang
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
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 04/21] net/nfp: refactor flow action calculate function
2024-06-19 9:13 [PATCH 00/21] support modify field flow action Chaoyong He
` (2 preceding siblings ...)
2024-06-19 9:13 ` [PATCH 03/21] net/nfp: pack various flags of flow action Chaoyong He
@ 2024-06-19 9:13 ` Chaoyong He
2024-06-19 9:13 ` [PATCH 05/21] net/nfp: refactor flow action compile function Chaoyong He
` (17 subsequent siblings)
21 siblings, 0 replies; 23+ messages in thread
From: Chaoyong He @ 2024-06-19 9:13 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang
Refactor the flow action calculate function, break the big function with
a long 'switch' control statement into a array of small functions, which
makes the logic more clear and easy to reuse.
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 | 361 +++++++++++++----------
1 file changed, 199 insertions(+), 162 deletions(-)
diff --git a/drivers/net/nfp/flower/nfp_flower_flow.c b/drivers/net/nfp/flower/nfp_flower_flow.c
index 9717af9c9c..9477e4a94f 100644
--- a/drivers/net/nfp/flower/nfp_flower_flow.c
+++ b/drivers/net/nfp/flower/nfp_flower_flow.c
@@ -984,184 +984,221 @@ struct nfp_action_flag {
bool ttl_tos_flag;
};
+struct nfp_action_calculate_param {
+ const struct rte_flow_action *action;
+ struct nfp_fl_key_ls *key_ls;
+ struct nfp_action_flag *flag;
+};
+
+typedef int (*nfp_flow_key_calculate_action_fn)(struct nfp_action_calculate_param *param);
+
+static int
+nfp_flow_action_calculate_stub(struct nfp_action_calculate_param *param __rte_unused)
+{
+ return 0;
+}
+
+static int
+nfp_flow_action_calculate_port(struct nfp_action_calculate_param *param)
+{
+ param->key_ls->act_size += sizeof(struct nfp_fl_act_output);
+
+ return 0;
+}
+
+static int
+nfp_flow_action_calculate_mac(struct nfp_action_calculate_param *param)
+{
+ if (!param->flag->mac_set_flag) {
+ param->key_ls->act_size += sizeof(struct nfp_fl_act_set_eth);
+ param->flag->mac_set_flag = true;
+ }
+
+ return 0;
+}
+
+static int
+nfp_flow_action_calculate_pop_vlan(struct nfp_action_calculate_param *param)
+{
+ param->key_ls->act_size += sizeof(struct nfp_fl_act_pop_vlan);
+
+ return 0;
+}
+
+static int
+nfp_flow_action_calculate_push_vlan(struct nfp_action_calculate_param *param)
+{
+ param->key_ls->act_size += sizeof(struct nfp_fl_act_push_vlan);
+
+ return 0;
+}
+
+static int
+nfp_flow_action_calculate_ipv4_addr(struct nfp_action_calculate_param *param)
+{
+ if (!param->flag->ip_set_flag) {
+ param->key_ls->act_size += sizeof(struct nfp_fl_act_set_ip4_addrs);
+ param->flag->ip_set_flag = true;
+ }
+
+ return 0;
+}
+
+static int
+nfp_flow_action_calculate_ipv6_addr(struct nfp_action_calculate_param *param)
+{
+ param->key_ls->act_size += sizeof(struct nfp_fl_act_set_ipv6_addr);
+
+ return 0;
+}
+
+static int
+nfp_flow_action_calculate_tp(struct nfp_action_calculate_param *param)
+{
+ if (!param->flag->tp_set_flag) {
+ param->key_ls->act_size += sizeof(struct nfp_fl_act_set_tport);
+ param->flag->tp_set_flag = true;
+ }
+
+ return 0;
+}
+
+static int
+nfp_flow_action_calculate_ttl(struct nfp_action_calculate_param *param)
+{
+ if ((param->key_ls->key_layer & NFP_FLOWER_LAYER_IPV4) != 0) {
+ if (!param->flag->ttl_tos_flag) {
+ param->key_ls->act_size += sizeof(struct nfp_fl_act_set_ip4_ttl_tos);
+ param->flag->ttl_tos_flag = true;
+ }
+ } else {
+ if (!param->flag->tc_hl_flag) {
+ param->key_ls->act_size += sizeof(struct nfp_fl_act_set_ipv6_tc_hl_fl);
+ param->flag->tc_hl_flag = true;
+ }
+ }
+
+ return 0;
+}
+
+static int
+nfp_flow_action_calculate_ipv4_dscp(struct nfp_action_calculate_param *param)
+{
+ if (!param->flag->ttl_tos_flag) {
+ param->key_ls->act_size += sizeof(struct nfp_fl_act_set_ip4_ttl_tos);
+ param->flag->ttl_tos_flag = true;
+ }
+
+ return 0;
+}
+
+static int
+nfp_flow_action_calculate_ipv6_dscp(struct nfp_action_calculate_param *param)
+{
+ if (!param->flag->tc_hl_flag) {
+ param->key_ls->act_size += sizeof(struct nfp_fl_act_set_ipv6_tc_hl_fl);
+ param->flag->tc_hl_flag = true;
+ }
+
+ return 0;
+}
+
+static int
+nfp_flow_action_calculate_encap(struct nfp_action_calculate_param *param)
+{
+ param->key_ls->act_size += sizeof(struct nfp_fl_act_pre_tun);
+ param->key_ls->act_size += sizeof(struct nfp_fl_act_set_tun);
+
+ return 0;
+}
+
+static int
+nfp_flow_action_calculate_meter(struct nfp_action_calculate_param *param)
+{
+ if (param->flag->meter_flag) {
+ PMD_DRV_LOG(ERR, "Only support one meter action.");
+ return -ENOTSUP;
+ }
+
+ param->key_ls->act_size += sizeof(struct nfp_fl_act_meter);
+ param->flag->meter_flag = true;
+
+ return 0;
+}
+
+static int
+nfp_flow_action_calculate_mark(struct nfp_action_calculate_param *param)
+{
+ param->key_ls->act_size += sizeof(struct nfp_fl_act_mark);
+
+ return 0;
+}
+
+static nfp_flow_key_calculate_action_fn action_fns[] = {
+ [RTE_FLOW_ACTION_TYPE_VOID] = nfp_flow_action_calculate_stub,
+ [RTE_FLOW_ACTION_TYPE_DROP] = nfp_flow_action_calculate_stub,
+ [RTE_FLOW_ACTION_TYPE_COUNT] = nfp_flow_action_calculate_stub,
+ [RTE_FLOW_ACTION_TYPE_JUMP] = nfp_flow_action_calculate_stub,
+ [RTE_FLOW_ACTION_TYPE_PORT_ID] = nfp_flow_action_calculate_port,
+ [RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT] = nfp_flow_action_calculate_port,
+ [RTE_FLOW_ACTION_TYPE_SET_MAC_SRC] = nfp_flow_action_calculate_mac,
+ [RTE_FLOW_ACTION_TYPE_SET_MAC_DST] = nfp_flow_action_calculate_mac,
+ [RTE_FLOW_ACTION_TYPE_OF_POP_VLAN] = nfp_flow_action_calculate_pop_vlan,
+ [RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN] = nfp_flow_action_calculate_push_vlan,
+ [RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID] = nfp_flow_action_calculate_stub,
+ [RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP] = nfp_flow_action_calculate_stub,
+ [RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC] = nfp_flow_action_calculate_ipv4_addr,
+ [RTE_FLOW_ACTION_TYPE_SET_IPV4_DST] = nfp_flow_action_calculate_ipv4_addr,
+ [RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC] = nfp_flow_action_calculate_ipv6_addr,
+ [RTE_FLOW_ACTION_TYPE_SET_IPV6_DST] = nfp_flow_action_calculate_ipv6_addr,
+ [RTE_FLOW_ACTION_TYPE_SET_TP_SRC] = nfp_flow_action_calculate_tp,
+ [RTE_FLOW_ACTION_TYPE_SET_TP_DST] = nfp_flow_action_calculate_tp,
+ [RTE_FLOW_ACTION_TYPE_SET_TTL] = nfp_flow_action_calculate_ttl,
+ [RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP] = nfp_flow_action_calculate_ipv4_dscp,
+ [RTE_FLOW_ACTION_TYPE_SET_IPV6_DSCP] = nfp_flow_action_calculate_ipv6_dscp,
+ [RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP] = nfp_flow_action_calculate_encap,
+ [RTE_FLOW_ACTION_TYPE_RAW_ENCAP] = nfp_flow_action_calculate_encap,
+ [RTE_FLOW_ACTION_TYPE_VXLAN_DECAP] = nfp_flow_action_calculate_stub,
+ [RTE_FLOW_ACTION_TYPE_RAW_DECAP] = nfp_flow_action_calculate_stub,
+ [RTE_FLOW_ACTION_TYPE_METER] = nfp_flow_action_calculate_meter,
+ [RTE_FLOW_ACTION_TYPE_CONNTRACK] = nfp_flow_action_calculate_stub,
+ [RTE_FLOW_ACTION_TYPE_MARK] = nfp_flow_action_calculate_mark,
+ [RTE_FLOW_ACTION_TYPE_RSS] = nfp_flow_action_calculate_stub,
+};
+
static int
nfp_flow_key_layers_calculate_actions(const struct rte_flow_action actions[],
struct nfp_fl_key_ls *key_ls)
{
- int ret = 0;
+ int ret;
struct nfp_action_flag flag = {};
const struct rte_flow_action *action;
+ struct nfp_action_calculate_param param = {
+ .key_ls = key_ls,
+ .flag = &flag,
+ };
for (action = actions; action->type != RTE_FLOW_ACTION_TYPE_END; ++action) {
/* Make sure actions length no longer than NFP_FL_MAX_A_SIZ */
if (key_ls->act_size > NFP_FL_MAX_A_SIZ) {
PMD_DRV_LOG(ERR, "The action list is too long.");
- ret = -ERANGE;
- break;
+ return -EINVAL;
}
- switch (action->type) {
- case RTE_FLOW_ACTION_TYPE_VOID:
- PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_VOID detected");
- break;
- case RTE_FLOW_ACTION_TYPE_DROP:
- PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_DROP detected");
- break;
- case RTE_FLOW_ACTION_TYPE_COUNT:
- PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_COUNT detected");
- break;
- case RTE_FLOW_ACTION_TYPE_JUMP:
- PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_JUMP detected");
- break;
- case RTE_FLOW_ACTION_TYPE_PORT_ID:
- 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 (!flag.mac_set_flag) {
- key_ls->act_size += sizeof(struct nfp_fl_act_set_eth);
- 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 (!flag.mac_set_flag) {
- key_ls->act_size += sizeof(struct nfp_fl_act_set_eth);
- flag.mac_set_flag = true;
- }
- break;
- case RTE_FLOW_ACTION_TYPE_OF_POP_VLAN:
- PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_OF_POP_VLAN detected");
- key_ls->act_size += sizeof(struct nfp_fl_act_pop_vlan);
- break;
- case RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN:
- PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN detected");
- key_ls->act_size += sizeof(struct nfp_fl_act_push_vlan);
- break;
- case RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID:
- PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID detected");
- break;
- case RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP:
- PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP detected");
- break;
- case RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC:
- PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC detected");
- if (!flag.ip_set_flag) {
- key_ls->act_size +=
- sizeof(struct nfp_fl_act_set_ip4_addrs);
- 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 (!flag.ip_set_flag) {
- key_ls->act_size +=
- sizeof(struct nfp_fl_act_set_ip4_addrs);
- flag.ip_set_flag = true;
- }
- break;
- case RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC:
- PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC detected");
- key_ls->act_size += sizeof(struct nfp_fl_act_set_ipv6_addr);
- break;
- case RTE_FLOW_ACTION_TYPE_SET_IPV6_DST:
- PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_SET_IPV6_DST detected");
- key_ls->act_size += sizeof(struct nfp_fl_act_set_ipv6_addr);
- break;
- case RTE_FLOW_ACTION_TYPE_SET_TP_SRC:
- PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_SET_TP_SRC detected");
- if (!flag.tp_set_flag) {
- key_ls->act_size += sizeof(struct nfp_fl_act_set_tport);
- 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 (!flag.tp_set_flag) {
- key_ls->act_size += sizeof(struct nfp_fl_act_set_tport);
- 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 (!flag.ttl_tos_flag) {
- key_ls->act_size +=
- sizeof(struct nfp_fl_act_set_ip4_ttl_tos);
- flag.ttl_tos_flag = true;
- }
- } else {
- if (!flag.tc_hl_flag) {
- key_ls->act_size +=
- sizeof(struct nfp_fl_act_set_ipv6_tc_hl_fl);
- 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 (!flag.ttl_tos_flag) {
- key_ls->act_size +=
- sizeof(struct nfp_fl_act_set_ip4_ttl_tos);
- 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 (!flag.tc_hl_flag) {
- key_ls->act_size +=
- sizeof(struct nfp_fl_act_set_ipv6_tc_hl_fl);
- flag.tc_hl_flag = true;
- }
- break;
- case RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP:
- PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP detected");
- key_ls->act_size += sizeof(struct nfp_fl_act_pre_tun);
- key_ls->act_size += sizeof(struct nfp_fl_act_set_tun);
- break;
- case RTE_FLOW_ACTION_TYPE_RAW_ENCAP:
- PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_RAW_ENCAP detected");
- key_ls->act_size += sizeof(struct nfp_fl_act_pre_tun);
- key_ls->act_size += sizeof(struct nfp_fl_act_set_tun);
- break;
- case RTE_FLOW_ACTION_TYPE_VXLAN_DECAP:
- PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_VXLAN_DECAP detected");
- break;
- case RTE_FLOW_ACTION_TYPE_RAW_DECAP:
- PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_RAW_DECAP detected");
- break;
- case RTE_FLOW_ACTION_TYPE_METER:
- PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_METER detected");
- if (!flag.meter_flag) {
- key_ls->act_size += sizeof(struct nfp_fl_act_meter);
- flag.meter_flag = true;
- } else {
- PMD_DRV_LOG(ERR, "Only support one meter action.");
- return -ENOTSUP;
- }
- break;
- case RTE_FLOW_ACTION_TYPE_CONNTRACK:
- PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_CONNTRACK detected");
- break;
- case RTE_FLOW_ACTION_TYPE_MARK:
- key_ls->act_size += sizeof(struct nfp_fl_act_mark);
- PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_MARK detected");
- break;
- case RTE_FLOW_ACTION_TYPE_RSS:
- PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_RSS detected");
- break;
- default:
- PMD_DRV_LOG(ERR, "Action type %d not supported.", action->type);
- return -ENOTSUP;
+ if (action->type >= RTE_DIM(action_fns) || action_fns[action->type] == NULL) {
+ PMD_DRV_LOG(ERR, "Flow action %d unsupported", action->type);
+ return -ERANGE;
+ }
+
+ param.action = action;
+ ret = action_fns[action->type](¶m);
+ if (ret != 0) {
+ PMD_DRV_LOG(ERR, "Flow action %d calculate fail", action->type);
+ return ret;
}
}
- return ret;
+ return 0;
}
static int
--
2.39.1
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 05/21] net/nfp: refactor flow action compile function
2024-06-19 9:13 [PATCH 00/21] support modify field flow action Chaoyong He
` (3 preceding siblings ...)
2024-06-19 9:13 ` [PATCH 04/21] net/nfp: refactor flow action calculate function Chaoyong He
@ 2024-06-19 9:13 ` Chaoyong He
2024-06-19 9:13 ` [PATCH 06/21] net/nfp: pack various flags of flow item Chaoyong He
` (16 subsequent siblings)
21 siblings, 0 replies; 23+ messages in thread
From: Chaoyong He @ 2024-06-19 9:13 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang
Refactor the flow action compile function, break the big function with
a long 'switch' control statement into a array of small functions, which
makes the logic more clear and easy to reuse.
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 | 627 ++++++++++++++---------
1 file changed, 399 insertions(+), 228 deletions(-)
diff --git a/drivers/net/nfp/flower/nfp_flower_flow.c b/drivers/net/nfp/flower/nfp_flower_flow.c
index 9477e4a94f..bfd4645afb 100644
--- a/drivers/net/nfp/flower/nfp_flower_flow.c
+++ b/drivers/net/nfp/flower/nfp_flower_flow.c
@@ -3689,252 +3689,423 @@ nfp_flow_count_output(const struct rte_flow_action actions[])
return count;
}
+struct nfp_action_compile_param {
+ const struct rte_flow_action *action;
+ char *action_data;
+ char *position;
+ uint32_t *output_cnt;
+ struct rte_flow *nfp_flow;
+ struct nfp_action_flag *flag;
+ struct nfp_flower_representor *repr;
+ struct nfp_fl_rule_metadata *nfp_flow_meta;
+};
+
+typedef int (*nfp_flow_action_compile_fn)(struct nfp_action_compile_param *param);
+
+static int
+nfp_flow_action_compile_stub(struct nfp_action_compile_param *param __rte_unused)
+{
+ return 0;
+}
+
+static int
+nfp_flow_action_compile_drop(struct nfp_action_compile_param *param)
+{
+ param->flag->drop_flag = true;
+
+ return 0;
+}
+
+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)
+{
+ int ret;
+ uint32_t output_cnt;
+
+ output_cnt = *param->output_cnt - 1;
+ *param->output_cnt = output_cnt;
+
+ 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");
+ return ret;
+ }
+
+ param->position += sizeof(struct nfp_fl_act_output);
+
+ return 0;
+}
+
+static int
+nfp_flow_action_compile_mac_src(struct nfp_action_compile_param *param)
+{
+ nfp_flow_action_set_mac(param->position, param->action, true,
+ param->flag->mac_set_flag);
+ if (!param->flag->mac_set_flag) {
+ param->position += sizeof(struct nfp_fl_act_set_eth);
+ param->flag->mac_set_flag = true;
+ }
+
+ return 0;
+}
+
+static int
+nfp_flow_action_compile_mac_dst(struct nfp_action_compile_param *param)
+{
+ nfp_flow_action_set_mac(param->position, param->action, false,
+ param->flag->mac_set_flag);
+ if (!param->flag->mac_set_flag) {
+ param->position += sizeof(struct nfp_fl_act_set_eth);
+ param->flag->mac_set_flag = true;
+ }
+
+ return 0;
+}
+
+static int
+nfp_flow_action_compile_pop_vlan(struct nfp_action_compile_param *param)
+{
+ nfp_flow_action_pop_vlan(param->position, param->nfp_flow_meta);
+ param->position += sizeof(struct nfp_fl_act_pop_vlan);
+
+ return 0;
+}
+
+static int
+nfp_flow_action_compile_push_vlan(struct nfp_action_compile_param *param)
+{
+ int ret;
+
+ ret = nfp_flow_action_push_vlan(param->position, param->action);
+ if (ret != 0) {
+ PMD_DRV_LOG(ERR, "Failed process RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN");
+ return ret;
+ }
+
+ param->position += sizeof(struct nfp_fl_act_push_vlan);
+
+ return 0;
+}
+
+static int
+nfp_flow_action_compile_ipv4_src(struct nfp_action_compile_param *param)
+{
+ nfp_flow_action_set_ip(param->position, param->action, true,
+ param->flag->ip_set_flag);
+ if (!param->flag->ip_set_flag) {
+ param->position += sizeof(struct nfp_fl_act_set_ip4_addrs);
+ param->flag->ip_set_flag = true;
+ }
+
+ return 0;
+}
+
+static int
+nfp_flow_action_compile_ipv4_dst(struct nfp_action_compile_param *param)
+{
+ nfp_flow_action_set_ip(param->position, param->action, false,
+ param->flag->ip_set_flag);
+ if (!param->flag->ip_set_flag) {
+ param->position += sizeof(struct nfp_fl_act_set_ip4_addrs);
+ param->flag->ip_set_flag = true;
+ }
+
+ return 0;
+}
+
+static int
+nfp_flow_action_compile_ipv6_src(struct nfp_action_compile_param *param)
+{
+ nfp_flow_action_set_ipv6(param->position, param->action, true);
+ param->position += sizeof(struct nfp_fl_act_set_ipv6_addr);
+
+ return 0;
+}
+
+static int
+nfp_flow_action_compile_ipv6_dst(struct nfp_action_compile_param *param)
+{
+ nfp_flow_action_set_ipv6(param->position, param->action, false);
+ param->position += sizeof(struct nfp_fl_act_set_ipv6_addr);
+
+ return 0;
+}
+
+static int
+nfp_flow_action_compile_tp_src(struct nfp_action_compile_param *param)
+{
+ nfp_flow_action_set_tp(param->position, param->action, true,
+ param->flag->tp_set_flag, param->nfp_flow->tcp_flag);
+ if (!param->flag->tp_set_flag) {
+ param->position += sizeof(struct nfp_fl_act_set_tport);
+ param->flag->tp_set_flag = true;
+ }
+
+ return 0;
+}
+
+static int
+nfp_flow_action_compile_tp_dst(struct nfp_action_compile_param *param)
+{
+ nfp_flow_action_set_tp(param->position, param->action, false,
+ param->flag->tp_set_flag, param->nfp_flow->tcp_flag);
+ if (!param->flag->tp_set_flag) {
+ param->position += sizeof(struct nfp_fl_act_set_tport);
+ param->flag->tp_set_flag = true;
+ }
+
+ return 0;
+}
+
+static int
+nfp_flow_action_compile_ttl(struct nfp_action_compile_param *param)
+{
+ struct nfp_flower_meta_tci *meta_tci;
+
+ meta_tci = (struct nfp_flower_meta_tci *)param->nfp_flow->payload.unmasked_data;
+ if (meta_tci->nfp_flow_key_layer & NFP_FLOWER_LAYER_IPV4) {
+ nfp_flow_action_set_ttl(param->position, param->action,
+ param->flag->ttl_tos_flag);
+ if (!param->flag->ttl_tos_flag) {
+ param->position += sizeof(struct nfp_fl_act_set_ip4_ttl_tos);
+ param->flag->ttl_tos_flag = true;
+ }
+ } else {
+ nfp_flow_action_set_hl(param->position, param->action,
+ param->flag->ttl_tos_flag);
+ if (!param->flag->tc_hl_flag) {
+ param->position += sizeof(struct nfp_fl_act_set_ipv6_tc_hl_fl);
+ param->flag->tc_hl_flag = true;
+ }
+ }
+
+ return 0;
+}
+
+static int
+nfp_flow_action_compile_ipv4_dscp(struct nfp_action_compile_param *param)
+{
+ nfp_flow_action_set_tos(param->position, param->action,
+ param->flag->ttl_tos_flag);
+ if (!param->flag->ttl_tos_flag) {
+ param->position += sizeof(struct nfp_fl_act_set_ip4_ttl_tos);
+ param->flag->ttl_tos_flag = true;
+ }
+
+ return 0;
+}
+
+static int
+nfp_flow_action_compile_ipv6_dscp(struct nfp_action_compile_param *param)
+{
+ nfp_flow_action_set_tc(param->position, param->action,
+ param->flag->ttl_tos_flag);
+ if (!param->flag->tc_hl_flag) {
+ param->position += sizeof(struct nfp_fl_act_set_ipv6_tc_hl_fl);
+ param->flag->tc_hl_flag = true;
+ }
+
+ return 0;
+}
+
+static int
+nfp_flow_action_compile_vxlan_encap(struct nfp_action_compile_param *param)
+{
+ int ret;
+
+ ret = nfp_flow_action_vxlan_encap(param->repr->app_fw_flower,
+ param->position, param->action_data, param->action,
+ param->nfp_flow_meta, ¶m->nfp_flow->tun);
+ if (ret != 0) {
+ PMD_DRV_LOG(ERR, "Failed process RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP");
+ return ret;
+ }
+
+ param->position += sizeof(struct nfp_fl_act_pre_tun);
+ param->position += sizeof(struct nfp_fl_act_set_tun);
+ param->nfp_flow->type = NFP_FLOW_ENCAP;
+
+ return 0;
+}
+
+static int
+nfp_flow_action_compile_raw_encap(struct nfp_action_compile_param *param)
+{
+ int ret;
+
+ ret = nfp_flow_action_raw_encap(param->repr->app_fw_flower,
+ param->position, param->action_data, param->action,
+ param->nfp_flow_meta, ¶m->nfp_flow->tun);
+ if (ret != 0) {
+ PMD_DRV_LOG(ERR, "Failed process RTE_FLOW_ACTION_TYPE_RAW_ENCAP");
+ return ret;
+ }
+
+ param->position += sizeof(struct nfp_fl_act_pre_tun);
+ param->position += sizeof(struct nfp_fl_act_set_tun);
+ param->nfp_flow->type = NFP_FLOW_ENCAP;
+
+ return 0;
+}
+
+static int
+nfp_flow_action_compile_tnl_decap(struct nfp_action_compile_param *param)
+{
+ int ret;
+
+ ret = nfp_flow_action_tunnel_decap(param->repr, param->action,
+ param->nfp_flow_meta, param->nfp_flow);
+ if (ret != 0) {
+ PMD_DRV_LOG(ERR, "Failed process tunnel decap");
+ return ret;
+ }
+
+ param->nfp_flow->type = NFP_FLOW_DECAP;
+ param->nfp_flow->install_flag = false;
+ if (param->action->conf != NULL)
+ param->nfp_flow->tun.payload.v6_flag = 1;
+
+ return 0;
+}
+
+static int
+nfp_flow_action_compile_meter(struct nfp_action_compile_param *param)
+{
+ int ret;
+
+ ret = nfp_flow_action_meter(param->repr, param->action,
+ param->position, ¶m->nfp_flow->mtr_id);
+ if (ret != 0) {
+ PMD_DRV_LOG(ERR, "Failed process RTE_FLOW_ACTION_TYPE_METER");
+ return -EINVAL;
+ }
+
+ param->position += sizeof(struct nfp_fl_act_meter);
+
+ return 0;
+}
+
+static int
+nfp_flow_action_compile_mark(struct nfp_action_compile_param *param)
+{
+ nfp_flow_action_mark(param->position, param->action);
+ param->position += sizeof(struct nfp_fl_act_mark);
+
+ return 0;
+}
+
+static int
+nfp_flow_action_compile_rss(struct nfp_action_compile_param *param)
+{
+ int ret;
+
+ ret = nfp_flow_action_rss_add(param->repr, param->action,
+ ¶m->nfp_flow->rss);
+ if (ret != 0) {
+ PMD_DRV_LOG(ERR, "Failed process RTE_FLOW_ACTION_TYPE_RSS");
+ return ret;
+ }
+
+ param->nfp_flow->type = NFP_FLOW_RSS;
+
+ return 0;
+}
+
+static nfp_flow_action_compile_fn action_compile_fns[] = {
+ [RTE_FLOW_ACTION_TYPE_VOID] = nfp_flow_action_compile_stub,
+ [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_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,
+ [RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN] = nfp_flow_action_compile_push_vlan,
+ [RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID] = nfp_flow_action_compile_stub,
+ [RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP] = nfp_flow_action_compile_stub,
+ [RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC] = nfp_flow_action_compile_ipv4_src,
+ [RTE_FLOW_ACTION_TYPE_SET_IPV4_DST] = nfp_flow_action_compile_ipv4_dst,
+ [RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC] = nfp_flow_action_compile_ipv6_src,
+ [RTE_FLOW_ACTION_TYPE_SET_IPV6_DST] = nfp_flow_action_compile_ipv6_dst,
+ [RTE_FLOW_ACTION_TYPE_SET_TP_SRC] = nfp_flow_action_compile_tp_src,
+ [RTE_FLOW_ACTION_TYPE_SET_TP_DST] = nfp_flow_action_compile_tp_dst,
+ [RTE_FLOW_ACTION_TYPE_SET_TTL] = nfp_flow_action_compile_ttl,
+ [RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP] = nfp_flow_action_compile_ipv4_dscp,
+ [RTE_FLOW_ACTION_TYPE_SET_IPV6_DSCP] = nfp_flow_action_compile_ipv6_dscp,
+ [RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP] = nfp_flow_action_compile_vxlan_encap,
+ [RTE_FLOW_ACTION_TYPE_RAW_ENCAP] = nfp_flow_action_compile_raw_encap,
+ [RTE_FLOW_ACTION_TYPE_VXLAN_DECAP] = nfp_flow_action_compile_tnl_decap,
+ [RTE_FLOW_ACTION_TYPE_RAW_DECAP] = nfp_flow_action_compile_tnl_decap,
+ [RTE_FLOW_ACTION_TYPE_METER] = nfp_flow_action_compile_meter,
+ [RTE_FLOW_ACTION_TYPE_CONNTRACK] = nfp_flow_action_compile_stub,
+ [RTE_FLOW_ACTION_TYPE_MARK] = nfp_flow_action_compile_mark,
+ [RTE_FLOW_ACTION_TYPE_RSS] = nfp_flow_action_compile_rss,
+};
+
static int
nfp_flow_compile_action(struct nfp_flower_representor *representor,
const struct rte_flow_action actions[],
struct rte_flow *nfp_flow)
{
int ret = 0;
- uint32_t count;
- char *position;
- char *action_data;
+ uint32_t output_cnt;
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;
+ struct nfp_action_compile_param param = {
+ .action_data = nfp_flow->payload.action_data,
+ .position = nfp_flow->payload.action_data,
+ .nfp_flow = nfp_flow,
+ .nfp_flow_meta = nfp_flow->payload.meta,
+ .repr = representor,
+ .flag = &flag,
+ };
- nfp_flow_meta = nfp_flow->payload.meta;
- action_data = nfp_flow->payload.action_data;
- position = action_data;
- meta_tci = (struct nfp_flower_meta_tci *)nfp_flow->payload.unmasked_data;
-
- count = nfp_flow_count_output(actions);
+ output_cnt = nfp_flow_count_output(actions);
+ param.output_cnt = &output_cnt;
for (action = actions; action->type != RTE_FLOW_ACTION_TYPE_END; ++action) {
- switch (action->type) {
- case RTE_FLOW_ACTION_TYPE_VOID:
- break;
- case RTE_FLOW_ACTION_TYPE_DROP:
- PMD_DRV_LOG(DEBUG, "Process RTE_FLOW_ACTION_TYPE_DROP");
- flag.drop_flag = true;
- break;
- case RTE_FLOW_ACTION_TYPE_COUNT:
- PMD_DRV_LOG(DEBUG, "Process RTE_FLOW_ACTION_TYPE_COUNT");
- break;
- 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--;
- ret = nfp_flow_action_output(position, action, nfp_flow_meta, count);
- if (ret != 0) {
- PMD_DRV_LOG(ERR, "Failed when process"
- " RTE_FLOW_ACTION_TYPE_PORT_ID");
- return ret;
- }
-
- position += sizeof(struct nfp_fl_act_output);
- 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, flag.mac_set_flag);
- if (!flag.mac_set_flag) {
- position += sizeof(struct nfp_fl_act_set_eth);
- 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, flag.mac_set_flag);
- if (!flag.mac_set_flag) {
- position += sizeof(struct nfp_fl_act_set_eth);
- flag.mac_set_flag = true;
- }
- break;
- case RTE_FLOW_ACTION_TYPE_OF_POP_VLAN:
- PMD_DRV_LOG(DEBUG, "Process RTE_FLOW_ACTION_TYPE_OF_POP_VLAN");
- nfp_flow_action_pop_vlan(position, nfp_flow_meta);
- position += sizeof(struct nfp_fl_act_pop_vlan);
- break;
- case RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN:
- PMD_DRV_LOG(DEBUG, "Process RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN");
- ret = nfp_flow_action_push_vlan(position, action);
- if (ret != 0) {
- PMD_DRV_LOG(ERR, "Failed when process"
- " RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN");
- return ret;
- }
+ if (action->type >= RTE_DIM(action_compile_fns) ||
+ action_compile_fns[action->type] == NULL) {
+ PMD_DRV_LOG(ERR, "Flow action %d unsupported", action->type);
+ return -ERANGE;
+ }
- /*
- * RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP and
- * RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID
- * have also been processed.
- */
- action += 2;
- position += sizeof(struct nfp_fl_act_push_vlan);
- 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, flag.ip_set_flag);
- if (!flag.ip_set_flag) {
- position += sizeof(struct nfp_fl_act_set_ip4_addrs);
- 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, flag.ip_set_flag);
- if (!flag.ip_set_flag) {
- position += sizeof(struct nfp_fl_act_set_ip4_addrs);
- flag.ip_set_flag = true;
- }
- break;
- case RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC:
- PMD_DRV_LOG(DEBUG, "Process RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC");
- nfp_flow_action_set_ipv6(position, action, true);
- position += sizeof(struct nfp_fl_act_set_ipv6_addr);
- break;
- case RTE_FLOW_ACTION_TYPE_SET_IPV6_DST:
- PMD_DRV_LOG(DEBUG, "Process RTE_FLOW_ACTION_TYPE_SET_IPV6_DST");
- nfp_flow_action_set_ipv6(position, action, false);
- position += sizeof(struct nfp_fl_act_set_ipv6_addr);
- break;
- 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,
- flag.tp_set_flag, nfp_flow->tcp_flag);
- if (!flag.tp_set_flag) {
- position += sizeof(struct nfp_fl_act_set_tport);
- 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,
- flag.tp_set_flag, nfp_flow->tcp_flag);
- if (!flag.tp_set_flag) {
- position += sizeof(struct nfp_fl_act_set_tport);
- 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, flag.ttl_tos_flag);
- if (!flag.ttl_tos_flag) {
- position += sizeof(struct nfp_fl_act_set_ip4_ttl_tos);
- flag.ttl_tos_flag = true;
- }
- } else {
- 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);
- 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, flag.ttl_tos_flag);
- if (!flag.ttl_tos_flag) {
- position += sizeof(struct nfp_fl_act_set_ip4_ttl_tos);
- 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, flag.tc_hl_flag);
- if (!flag.tc_hl_flag) {
- position += sizeof(struct nfp_fl_act_set_ipv6_tc_hl_fl);
- flag.tc_hl_flag = true;
- }
- break;
- case RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP:
- PMD_DRV_LOG(DEBUG, "Process RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP");
- ret = nfp_flow_action_vxlan_encap(representor->app_fw_flower,
- position, action_data, action, nfp_flow_meta,
- &nfp_flow->tun);
- if (ret != 0) {
- PMD_DRV_LOG(ERR, "Failed when process"
- " RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP");
- return ret;
- }
- position += sizeof(struct nfp_fl_act_pre_tun);
- position += sizeof(struct nfp_fl_act_set_tun);
- nfp_flow->type = NFP_FLOW_ENCAP;
- break;
- case RTE_FLOW_ACTION_TYPE_RAW_ENCAP:
- PMD_DRV_LOG(DEBUG, "Process RTE_FLOW_ACTION_TYPE_RAW_ENCAP");
- ret = nfp_flow_action_raw_encap(representor->app_fw_flower,
- position, action_data, action, nfp_flow_meta,
- &nfp_flow->tun);
- if (ret != 0) {
- PMD_DRV_LOG(ERR, "Failed when process"
- " RTE_FLOW_ACTION_TYPE_RAW_ENCAP");
- return ret;
- }
- position += sizeof(struct nfp_fl_act_pre_tun);
- position += sizeof(struct nfp_fl_act_set_tun);
- nfp_flow->type = NFP_FLOW_ENCAP;
- break;
- case RTE_FLOW_ACTION_TYPE_VXLAN_DECAP:
- case RTE_FLOW_ACTION_TYPE_RAW_DECAP:
- PMD_DRV_LOG(DEBUG, "process action tunnel decap");
- ret = nfp_flow_action_tunnel_decap(representor, action,
- nfp_flow_meta, nfp_flow);
- if (ret != 0) {
- PMD_DRV_LOG(ERR, "Failed when process tunnel decap");
- return ret;
- }
- nfp_flow->type = NFP_FLOW_DECAP;
- nfp_flow->install_flag = false;
- if (action->conf != NULL)
- nfp_flow->tun.payload.v6_flag = 1;
- break;
- case RTE_FLOW_ACTION_TYPE_METER:
- PMD_DRV_LOG(DEBUG, "Process RTE_FLOW_ACTION_TYPE_METER");
- ret = nfp_flow_action_meter(representor, action,
- position, &nfp_flow->mtr_id);
- if (ret != 0)
- return -EINVAL;
- position += sizeof(struct nfp_fl_act_meter);
- break;
- case RTE_FLOW_ACTION_TYPE_CONNTRACK:
- PMD_DRV_LOG(DEBUG, "Process RTE_FLOW_ACTION_TYPE_CONNTRACK");
- break;
- case RTE_FLOW_ACTION_TYPE_MARK:
- PMD_DRV_LOG(DEBUG, "Process RTE_FLOW_ACTION_TYPE_MARK");
- nfp_flow_action_mark(position, action);
- position += sizeof(struct nfp_fl_act_mark);
- break;
- case RTE_FLOW_ACTION_TYPE_RSS:
- PMD_DRV_LOG(DEBUG, "Process RTE_FLOW_ACTION_TYPE_RSS");
- ret = nfp_flow_action_rss_add(representor, action, &nfp_flow->rss);
- if (ret != 0)
- return ret;
- nfp_flow->type = NFP_FLOW_RSS;
- break;
- default:
- PMD_DRV_LOG(ERR, "Unsupported action type: %d", action->type);
- return -ENOTSUP;
+ param.action = action;
+ ret = action_compile_fns[action->type](¶m);
+ if (ret != 0) {
+ PMD_DRV_LOG(ERR, "Flow action %d compile fail", action->type);
+ return ret;
}
+
total_actions++;
}
+ nfp_flow_meta = nfp_flow->payload.meta;
if (flag.drop_flag)
nfp_flow_meta->shortcut = rte_cpu_to_be_32(NFP_FL_SC_ACT_DROP);
else if (total_actions > 1)
--
2.39.1
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 06/21] net/nfp: pack various flags of flow item
2024-06-19 9:13 [PATCH 00/21] support modify field flow action Chaoyong He
` (4 preceding siblings ...)
2024-06-19 9:13 ` [PATCH 05/21] net/nfp: refactor flow action compile function Chaoyong He
@ 2024-06-19 9:13 ` Chaoyong He
2024-06-19 9:13 ` [PATCH 07/21] net/nfp: refactor flow item calculate function Chaoyong He
` (15 subsequent siblings)
21 siblings, 0 replies; 23+ messages in thread
From: Chaoyong He @ 2024-06-19 9:13 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang
Pack various flags of the flow item 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 | 28 ++++++++++++++----------
1 file changed, 16 insertions(+), 12 deletions(-)
diff --git a/drivers/net/nfp/flower/nfp_flower_flow.c b/drivers/net/nfp/flower/nfp_flower_flow.c
index bfd4645afb..db4551d98b 100644
--- a/drivers/net/nfp/flower/nfp_flower_flow.c
+++ b/drivers/net/nfp/flower/nfp_flower_flow.c
@@ -809,13 +809,17 @@ nfp_flow_compile_metadata(struct nfp_flow_priv *priv,
mbuf_off_mask += sizeof(struct nfp_flower_in_port);
}
+struct nfp_item_flag {
+ bool outer_ip4_flag;
+ bool outer_ip6_flag;
+};
+
static int
nfp_flow_key_layers_calculate_items(const struct rte_flow_item items[],
struct nfp_fl_key_ls *key_ls)
{
struct rte_eth_dev *ethdev;
- bool outer_ip4_flag = false;
- bool outer_ip6_flag = false;
+ struct nfp_item_flag flag = {};
const struct rte_flow_item *item;
struct nfp_flower_representor *representor;
const struct rte_flow_item_port_id *port_id;
@@ -850,15 +854,15 @@ nfp_flow_key_layers_calculate_items(const struct rte_flow_item items[],
PMD_DRV_LOG(DEBUG, "RTE_FLOW_ITEM_TYPE_IPV4 detected");
key_ls->key_layer |= NFP_FLOWER_LAYER_IPV4;
key_ls->key_size += sizeof(struct nfp_flower_ipv4);
- if (!outer_ip4_flag)
- outer_ip4_flag = true;
+ if (!flag.outer_ip4_flag)
+ flag.outer_ip4_flag = true;
break;
case RTE_FLOW_ITEM_TYPE_IPV6:
PMD_DRV_LOG(DEBUG, "RTE_FLOW_ITEM_TYPE_IPV6 detected");
key_ls->key_layer |= NFP_FLOWER_LAYER_IPV6;
key_ls->key_size += sizeof(struct nfp_flower_ipv6);
- if (!outer_ip6_flag)
- outer_ip6_flag = true;
+ if (!flag.outer_ip6_flag)
+ flag.outer_ip6_flag = true;
break;
case RTE_FLOW_ITEM_TYPE_TCP:
PMD_DRV_LOG(DEBUG, "RTE_FLOW_ITEM_TYPE_TCP detected");
@@ -882,14 +886,14 @@ nfp_flow_key_layers_calculate_items(const struct rte_flow_item items[],
key_ls->key_layer &= ~NFP_FLOWER_LAYER_IPV6;
key_ls->tun_type = NFP_FL_TUN_VXLAN;
key_ls->key_layer |= NFP_FLOWER_LAYER_VXLAN;
- if (outer_ip4_flag) {
+ if (flag.outer_ip4_flag) {
key_ls->key_size += sizeof(struct nfp_flower_ipv4_udp_tun);
/*
* The outer l3 layer information is
* in `struct nfp_flower_ipv4_udp_tun`.
*/
key_ls->key_size -= sizeof(struct nfp_flower_ipv4);
- } else if (outer_ip6_flag) {
+ } else if (flag.outer_ip6_flag) {
key_ls->key_layer |= NFP_FLOWER_LAYER_EXT_META;
key_ls->key_layer_two |= NFP_FLOWER_LAYER2_TUN_IPV6;
key_ls->key_size += sizeof(struct nfp_flower_ext_meta);
@@ -913,14 +917,14 @@ nfp_flow_key_layers_calculate_items(const struct rte_flow_item items[],
key_ls->key_layer |= NFP_FLOWER_LAYER_EXT_META;
key_ls->key_layer_two |= NFP_FLOWER_LAYER2_GENEVE;
key_ls->key_size += sizeof(struct nfp_flower_ext_meta);
- if (outer_ip4_flag) {
+ if (flag.outer_ip4_flag) {
key_ls->key_size += sizeof(struct nfp_flower_ipv4_udp_tun);
/*
* The outer l3 layer information is
* in `struct nfp_flower_ipv4_udp_tun`.
*/
key_ls->key_size -= sizeof(struct nfp_flower_ipv4);
- } else if (outer_ip6_flag) {
+ } else if (flag.outer_ip6_flag) {
key_ls->key_layer_two |= NFP_FLOWER_LAYER2_TUN_IPV6;
key_ls->key_size += sizeof(struct nfp_flower_ipv6_udp_tun);
/*
@@ -942,14 +946,14 @@ nfp_flow_key_layers_calculate_items(const struct rte_flow_item items[],
key_ls->key_layer |= NFP_FLOWER_LAYER_EXT_META;
key_ls->key_layer_two |= NFP_FLOWER_LAYER2_GRE;
key_ls->key_size += sizeof(struct nfp_flower_ext_meta);
- if (outer_ip4_flag) {
+ if (flag.outer_ip4_flag) {
key_ls->key_size += sizeof(struct nfp_flower_ipv4_gre_tun);
/*
* The outer l3 layer information is
* in `struct nfp_flower_ipv4_gre_tun`.
*/
key_ls->key_size -= sizeof(struct nfp_flower_ipv4);
- } else if (outer_ip6_flag) {
+ } else if (flag.outer_ip6_flag) {
key_ls->key_layer_two |= NFP_FLOWER_LAYER2_TUN_IPV6;
key_ls->key_size += sizeof(struct nfp_flower_ipv6_gre_tun);
/*
--
2.39.1
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 07/21] net/nfp: refactor flow item calculate function
2024-06-19 9:13 [PATCH 00/21] support modify field flow action Chaoyong He
` (5 preceding siblings ...)
2024-06-19 9:13 ` [PATCH 06/21] net/nfp: pack various flags of flow item Chaoyong He
@ 2024-06-19 9:13 ` Chaoyong He
2024-06-19 9:13 ` [PATCH 08/21] net/nfp: support modify IPv4 source address Chaoyong He
` (14 subsequent siblings)
21 siblings, 0 replies; 23+ messages in thread
From: Chaoyong He @ 2024-06-19 9:13 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang
Refactor the flow item calculate function, break the big function with
a long 'switch' control statement into a array of small functions, which
makes the logic more clear and easy to reuse.
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 | 367 ++++++++++++++---------
1 file changed, 217 insertions(+), 150 deletions(-)
diff --git a/drivers/net/nfp/flower/nfp_flower_flow.c b/drivers/net/nfp/flower/nfp_flower_flow.c
index db4551d98b..95f9e8c2d6 100644
--- a/drivers/net/nfp/flower/nfp_flower_flow.c
+++ b/drivers/net/nfp/flower/nfp_flower_flow.c
@@ -814,164 +814,231 @@ struct nfp_item_flag {
bool outer_ip6_flag;
};
+struct nfp_item_calculate_param {
+ const struct rte_flow_item *item;
+ struct nfp_fl_key_ls *key_ls;
+ struct nfp_item_flag *flag;
+};
+
+typedef int (*nfp_flow_key_calculate_item_fn)(struct nfp_item_calculate_param *param);
+
+static int
+nfp_flow_item_calculate_stub(struct nfp_item_calculate_param *param __rte_unused)
+{
+ return 0;
+}
+
+static int
+nfp_flow_item_calculate_eth(struct nfp_item_calculate_param *param)
+{
+ if (param->item->spec != NULL) {
+ param->key_ls->key_layer |= NFP_FLOWER_LAYER_MAC;
+ param->key_ls->key_size += sizeof(struct nfp_flower_mac_mpls);
+ }
+
+ return 0;
+}
+
+static int
+nfp_flow_item_calculate_port(struct nfp_item_calculate_param *param)
+{
+ struct rte_eth_dev *ethdev;
+ struct nfp_flower_representor *repr;
+ const struct rte_flow_item_port_id *port_id;
+
+ port_id = param->item->spec;
+ if (port_id == NULL || port_id->id >= RTE_MAX_ETHPORTS)
+ return -ERANGE;
+
+ ethdev = &rte_eth_devices[port_id->id];
+ repr = ethdev->data->dev_private;
+ param->key_ls->port = repr->port_id;
+
+ return 0;
+}
+
+static int
+nfp_flow_item_calculate_vlan(struct nfp_item_calculate_param *param)
+{
+ param->key_ls->vlan = NFP_FLOWER_MASK_VLAN_CFI;
+
+ return 0;
+}
+
+static int
+nfp_flow_item_calculate_ipv4(struct nfp_item_calculate_param *param)
+{
+ param->key_ls->key_layer |= NFP_FLOWER_LAYER_IPV4;
+ param->key_ls->key_size += sizeof(struct nfp_flower_ipv4);
+ if (!param->flag->outer_ip4_flag)
+ param->flag->outer_ip4_flag = true;
+
+ return 0;
+}
+
+static int
+nfp_flow_item_calculate_ipv6(struct nfp_item_calculate_param *param)
+{
+ param->key_ls->key_layer |= NFP_FLOWER_LAYER_IPV6;
+ param->key_ls->key_size += sizeof(struct nfp_flower_ipv6);
+ if (!param->flag->outer_ip6_flag)
+ param->flag->outer_ip6_flag = true;
+
+ return 0;
+}
+
+static int
+nfp_flow_item_calculate_l4(struct nfp_item_calculate_param *param)
+{
+ param->key_ls->key_layer |= NFP_FLOWER_LAYER_TP;
+ param->key_ls->key_size += sizeof(struct nfp_flower_tp_ports);
+
+ return 0;
+}
+
+static int
+nfp_flow_item_calculate_vxlan(struct nfp_item_calculate_param *param)
+{
+ struct nfp_fl_key_ls *key_ls = param->key_ls;
+
+ /* Clear IPv4 and IPv6 bits */
+ key_ls->key_layer &= ~NFP_FLOWER_LAYER_IPV4;
+ key_ls->key_layer &= ~NFP_FLOWER_LAYER_IPV6;
+ key_ls->tun_type = NFP_FL_TUN_VXLAN;
+ key_ls->key_layer |= NFP_FLOWER_LAYER_VXLAN;
+ if (param->flag->outer_ip4_flag) {
+ key_ls->key_size += sizeof(struct nfp_flower_ipv4_udp_tun);
+ /*
+ * The outer l3 layer information is
+ * in `struct nfp_flower_ipv4_udp_tun`.
+ */
+ key_ls->key_size -= sizeof(struct nfp_flower_ipv4);
+ } else if (param->flag->outer_ip6_flag) {
+ key_ls->key_layer |= NFP_FLOWER_LAYER_EXT_META;
+ key_ls->key_layer_two |= NFP_FLOWER_LAYER2_TUN_IPV6;
+ key_ls->key_size += sizeof(struct nfp_flower_ext_meta);
+ key_ls->key_size += sizeof(struct nfp_flower_ipv6_udp_tun);
+ /*
+ * The outer l3 layer information is
+ * in `struct nfp_flower_ipv6_udp_tun`.
+ */
+ key_ls->key_size -= sizeof(struct nfp_flower_ipv6);
+ } else {
+ PMD_DRV_LOG(ERR, "No outer IP layer for VXLAN tunnel.");
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+static int
+nfp_flow_item_calculate_geneve(struct nfp_item_calculate_param *param)
+{
+ struct nfp_fl_key_ls *key_ls = param->key_ls;
+
+ /* Clear IPv4 and IPv6 bits */
+ key_ls->key_layer &= ~NFP_FLOWER_LAYER_IPV4;
+ key_ls->key_layer &= ~NFP_FLOWER_LAYER_IPV6;
+ key_ls->tun_type = NFP_FL_TUN_GENEVE;
+ key_ls->key_layer |= NFP_FLOWER_LAYER_EXT_META;
+ key_ls->key_layer_two |= NFP_FLOWER_LAYER2_GENEVE;
+ key_ls->key_size += sizeof(struct nfp_flower_ext_meta);
+ if (param->flag->outer_ip4_flag) {
+ key_ls->key_size += sizeof(struct nfp_flower_ipv4_udp_tun);
+ /*
+ * The outer l3 layer information is
+ * in `struct nfp_flower_ipv4_udp_tun`.
+ */
+ key_ls->key_size -= sizeof(struct nfp_flower_ipv4);
+ } else if (param->flag->outer_ip6_flag) {
+ key_ls->key_layer_two |= NFP_FLOWER_LAYER2_TUN_IPV6;
+ key_ls->key_size += sizeof(struct nfp_flower_ipv6_udp_tun);
+ /*
+ * The outer l3 layer information is
+ * in `struct nfp_flower_ipv6_udp_tun`.
+ */
+ key_ls->key_size -= sizeof(struct nfp_flower_ipv6);
+ } else {
+ PMD_DRV_LOG(ERR, "No outer IP layer for GENEVE tunnel.");
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+static int
+nfp_flow_item_calculate_gre(struct nfp_item_calculate_param *param)
+{
+ struct nfp_fl_key_ls *key_ls = param->key_ls;
+
+ /* Clear IPv4 and IPv6 bits */
+ key_ls->key_layer &= ~NFP_FLOWER_LAYER_IPV4;
+ key_ls->key_layer &= ~NFP_FLOWER_LAYER_IPV6;
+ key_ls->tun_type = NFP_FL_TUN_GRE;
+ key_ls->key_layer |= NFP_FLOWER_LAYER_EXT_META;
+ key_ls->key_layer_two |= NFP_FLOWER_LAYER2_GRE;
+ key_ls->key_size += sizeof(struct nfp_flower_ext_meta);
+ if (param->flag->outer_ip4_flag) {
+ key_ls->key_size += sizeof(struct nfp_flower_ipv4_gre_tun);
+ /*
+ * The outer l3 layer information is
+ * in `struct nfp_flower_ipv4_gre_tun`.
+ */
+ key_ls->key_size -= sizeof(struct nfp_flower_ipv4);
+ } else if (param->flag->outer_ip6_flag) {
+ key_ls->key_layer_two |= NFP_FLOWER_LAYER2_TUN_IPV6;
+ key_ls->key_size += sizeof(struct nfp_flower_ipv6_gre_tun);
+ /*
+ * The outer l3 layer information is
+ * in `struct nfp_flower_ipv6_gre_tun`.
+ */
+ key_ls->key_size -= sizeof(struct nfp_flower_ipv6);
+ } else {
+ PMD_DRV_LOG(ERR, "No outer IP layer for GRE tunnel.");
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+static nfp_flow_key_calculate_item_fn item_fns[] = {
+ [RTE_FLOW_ITEM_TYPE_ETH] = nfp_flow_item_calculate_eth,
+ [RTE_FLOW_ITEM_TYPE_PORT_ID] = nfp_flow_item_calculate_port,
+ [RTE_FLOW_ITEM_TYPE_VLAN] = nfp_flow_item_calculate_vlan,
+ [RTE_FLOW_ITEM_TYPE_IPV4] = nfp_flow_item_calculate_ipv4,
+ [RTE_FLOW_ITEM_TYPE_IPV6] = nfp_flow_item_calculate_ipv6,
+ [RTE_FLOW_ITEM_TYPE_TCP] = nfp_flow_item_calculate_l4,
+ [RTE_FLOW_ITEM_TYPE_UDP] = nfp_flow_item_calculate_l4,
+ [RTE_FLOW_ITEM_TYPE_SCTP] = nfp_flow_item_calculate_l4,
+ [RTE_FLOW_ITEM_TYPE_VXLAN] = nfp_flow_item_calculate_vxlan,
+ [RTE_FLOW_ITEM_TYPE_GENEVE] = nfp_flow_item_calculate_geneve,
+ [RTE_FLOW_ITEM_TYPE_GRE] = nfp_flow_item_calculate_gre,
+ [RTE_FLOW_ITEM_TYPE_GRE_KEY] = nfp_flow_item_calculate_stub,
+};
+
static int
nfp_flow_key_layers_calculate_items(const struct rte_flow_item items[],
struct nfp_fl_key_ls *key_ls)
{
- struct rte_eth_dev *ethdev;
+ int ret;
struct nfp_item_flag flag = {};
const struct rte_flow_item *item;
- struct nfp_flower_representor *representor;
- const struct rte_flow_item_port_id *port_id;
+ struct nfp_item_calculate_param param = {
+ .key_ls = key_ls,
+ .flag = &flag,
+ };
for (item = items; item->type != RTE_FLOW_ITEM_TYPE_END; ++item) {
- switch (item->type) {
- case RTE_FLOW_ITEM_TYPE_ETH:
- PMD_DRV_LOG(DEBUG, "RTE_FLOW_ITEM_TYPE_ETH detected");
- /*
- * Eth is set with no specific params.
- * NFP does not need this.
- */
- if (item->spec == NULL)
- continue;
- key_ls->key_layer |= NFP_FLOWER_LAYER_MAC;
- key_ls->key_size += sizeof(struct nfp_flower_mac_mpls);
- break;
- case RTE_FLOW_ITEM_TYPE_PORT_ID:
- PMD_DRV_LOG(DEBUG, "RTE_FLOW_ITEM_TYPE_PORT_ID detected");
- port_id = item->spec;
- if (port_id->id >= RTE_MAX_ETHPORTS)
- return -ERANGE;
- ethdev = &rte_eth_devices[port_id->id];
- representor = ethdev->data->dev_private;
- key_ls->port = representor->port_id;
- break;
- case RTE_FLOW_ITEM_TYPE_VLAN:
- PMD_DRV_LOG(DEBUG, "RTE_FLOW_ITEM_TYPE_VLAN detected");
- key_ls->vlan = NFP_FLOWER_MASK_VLAN_CFI;
- break;
- case RTE_FLOW_ITEM_TYPE_IPV4:
- PMD_DRV_LOG(DEBUG, "RTE_FLOW_ITEM_TYPE_IPV4 detected");
- key_ls->key_layer |= NFP_FLOWER_LAYER_IPV4;
- key_ls->key_size += sizeof(struct nfp_flower_ipv4);
- if (!flag.outer_ip4_flag)
- flag.outer_ip4_flag = true;
- break;
- case RTE_FLOW_ITEM_TYPE_IPV6:
- PMD_DRV_LOG(DEBUG, "RTE_FLOW_ITEM_TYPE_IPV6 detected");
- key_ls->key_layer |= NFP_FLOWER_LAYER_IPV6;
- key_ls->key_size += sizeof(struct nfp_flower_ipv6);
- if (!flag.outer_ip6_flag)
- flag.outer_ip6_flag = true;
- break;
- case RTE_FLOW_ITEM_TYPE_TCP:
- PMD_DRV_LOG(DEBUG, "RTE_FLOW_ITEM_TYPE_TCP detected");
- key_ls->key_layer |= NFP_FLOWER_LAYER_TP;
- key_ls->key_size += sizeof(struct nfp_flower_tp_ports);
- break;
- case RTE_FLOW_ITEM_TYPE_UDP:
- PMD_DRV_LOG(DEBUG, "RTE_FLOW_ITEM_TYPE_UDP detected");
- key_ls->key_layer |= NFP_FLOWER_LAYER_TP;
- key_ls->key_size += sizeof(struct nfp_flower_tp_ports);
- break;
- case RTE_FLOW_ITEM_TYPE_SCTP:
- PMD_DRV_LOG(DEBUG, "RTE_FLOW_ITEM_TYPE_SCTP detected");
- key_ls->key_layer |= NFP_FLOWER_LAYER_TP;
- key_ls->key_size += sizeof(struct nfp_flower_tp_ports);
- break;
- case RTE_FLOW_ITEM_TYPE_VXLAN:
- PMD_DRV_LOG(DEBUG, "RTE_FLOW_ITEM_TYPE_VXLAN detected");
- /* Clear IPv4 and IPv6 bits */
- key_ls->key_layer &= ~NFP_FLOWER_LAYER_IPV4;
- key_ls->key_layer &= ~NFP_FLOWER_LAYER_IPV6;
- key_ls->tun_type = NFP_FL_TUN_VXLAN;
- key_ls->key_layer |= NFP_FLOWER_LAYER_VXLAN;
- if (flag.outer_ip4_flag) {
- key_ls->key_size += sizeof(struct nfp_flower_ipv4_udp_tun);
- /*
- * The outer l3 layer information is
- * in `struct nfp_flower_ipv4_udp_tun`.
- */
- key_ls->key_size -= sizeof(struct nfp_flower_ipv4);
- } else if (flag.outer_ip6_flag) {
- key_ls->key_layer |= NFP_FLOWER_LAYER_EXT_META;
- key_ls->key_layer_two |= NFP_FLOWER_LAYER2_TUN_IPV6;
- key_ls->key_size += sizeof(struct nfp_flower_ext_meta);
- key_ls->key_size += sizeof(struct nfp_flower_ipv6_udp_tun);
- /*
- * The outer l3 layer information is
- * in `struct nfp_flower_ipv6_udp_tun`.
- */
- key_ls->key_size -= sizeof(struct nfp_flower_ipv6);
- } else {
- PMD_DRV_LOG(ERR, "No outer IP layer for VXLAN tunnel.");
- return -EINVAL;
- }
- break;
- case RTE_FLOW_ITEM_TYPE_GENEVE:
- PMD_DRV_LOG(DEBUG, "RTE_FLOW_ITEM_TYPE_GENEVE detected");
- /* Clear IPv4 and IPv6 bits */
- key_ls->key_layer &= ~NFP_FLOWER_LAYER_IPV4;
- key_ls->key_layer &= ~NFP_FLOWER_LAYER_IPV6;
- key_ls->tun_type = NFP_FL_TUN_GENEVE;
- key_ls->key_layer |= NFP_FLOWER_LAYER_EXT_META;
- key_ls->key_layer_two |= NFP_FLOWER_LAYER2_GENEVE;
- key_ls->key_size += sizeof(struct nfp_flower_ext_meta);
- if (flag.outer_ip4_flag) {
- key_ls->key_size += sizeof(struct nfp_flower_ipv4_udp_tun);
- /*
- * The outer l3 layer information is
- * in `struct nfp_flower_ipv4_udp_tun`.
- */
- key_ls->key_size -= sizeof(struct nfp_flower_ipv4);
- } else if (flag.outer_ip6_flag) {
- key_ls->key_layer_two |= NFP_FLOWER_LAYER2_TUN_IPV6;
- key_ls->key_size += sizeof(struct nfp_flower_ipv6_udp_tun);
- /*
- * The outer l3 layer information is
- * in `struct nfp_flower_ipv6_udp_tun`.
- */
- key_ls->key_size -= sizeof(struct nfp_flower_ipv6);
- } else {
- PMD_DRV_LOG(ERR, "No outer IP layer for GENEVE tunnel.");
- return -EINVAL;
- }
- break;
- case RTE_FLOW_ITEM_TYPE_GRE:
- PMD_DRV_LOG(DEBUG, "RTE_FLOW_ITEM_TYPE_GRE detected");
- /* Clear IPv4 and IPv6 bits */
- key_ls->key_layer &= ~NFP_FLOWER_LAYER_IPV4;
- key_ls->key_layer &= ~NFP_FLOWER_LAYER_IPV6;
- key_ls->tun_type = NFP_FL_TUN_GRE;
- key_ls->key_layer |= NFP_FLOWER_LAYER_EXT_META;
- key_ls->key_layer_two |= NFP_FLOWER_LAYER2_GRE;
- key_ls->key_size += sizeof(struct nfp_flower_ext_meta);
- if (flag.outer_ip4_flag) {
- key_ls->key_size += sizeof(struct nfp_flower_ipv4_gre_tun);
- /*
- * The outer l3 layer information is
- * in `struct nfp_flower_ipv4_gre_tun`.
- */
- key_ls->key_size -= sizeof(struct nfp_flower_ipv4);
- } else if (flag.outer_ip6_flag) {
- key_ls->key_layer_two |= NFP_FLOWER_LAYER2_TUN_IPV6;
- key_ls->key_size += sizeof(struct nfp_flower_ipv6_gre_tun);
- /*
- * The outer l3 layer information is
- * in `struct nfp_flower_ipv6_gre_tun`.
- */
- key_ls->key_size -= sizeof(struct nfp_flower_ipv6);
- } else {
- PMD_DRV_LOG(ERR, "No outer IP layer for GRE tunnel.");
- return -1;
- }
- break;
- case RTE_FLOW_ITEM_TYPE_GRE_KEY:
- PMD_DRV_LOG(DEBUG, "RTE_FLOW_ITEM_TYPE_GRE_KEY detected");
- break;
- default:
- PMD_DRV_LOG(ERR, "Item type %d not supported.", item->type);
- return -ENOTSUP;
+ if (item->type >= RTE_DIM(item_fns) || item_fns[item->type] == NULL) {
+ PMD_DRV_LOG(ERR, "Flow item %d unsupported", item->type);
+ return -ERANGE;
+ }
+
+ param.item = item;
+ ret = item_fns[item->type](¶m);
+ if (ret != 0) {
+ PMD_DRV_LOG(ERR, "Flow item %d calculate fail", item->type);
+ return ret;
}
}
--
2.39.1
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 08/21] net/nfp: support modify IPv4 source address
2024-06-19 9:13 [PATCH 00/21] support modify field flow action Chaoyong He
` (6 preceding siblings ...)
2024-06-19 9:13 ` [PATCH 07/21] net/nfp: refactor flow item calculate function Chaoyong He
@ 2024-06-19 9:13 ` Chaoyong He
2024-06-19 9:13 ` [PATCH 09/21] net/nfp: support modify IPv4 dest address Chaoyong He
` (13 subsequent siblings)
21 siblings, 0 replies; 23+ messages in thread
From: Chaoyong He @ 2024-06-19 9:13 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang
Add the framework of modify field flow action and the logic of modify
IPv4 source address 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>
---
doc/guides/nics/features/nfp.ini | 1 +
drivers/net/nfp/flower/nfp_flower_flow.c | 172 +++++++++++++++++++++++
2 files changed, 173 insertions(+)
diff --git a/doc/guides/nics/features/nfp.ini b/doc/guides/nics/features/nfp.ini
index b20049b4f5..5b507cfe94 100644
--- a/doc/guides/nics/features/nfp.ini
+++ b/doc/guides/nics/features/nfp.ini
@@ -51,6 +51,7 @@ drop = Y
jump = Y
mark = Y
meter = Y
+modify_field = Y
of_pop_vlan = Y
of_push_vlan = Y
of_set_vlan_pcp = Y
diff --git a/drivers/net/nfp/flower/nfp_flower_flow.c b/drivers/net/nfp/flower/nfp_flower_flow.c
index 95f9e8c2d6..8997d67627 100644
--- a/drivers/net/nfp/flower/nfp_flower_flow.c
+++ b/drivers/net/nfp/flower/nfp_flower_flow.c
@@ -1205,6 +1205,129 @@ nfp_flow_action_calculate_mark(struct nfp_action_calculate_param *param)
return 0;
}
+static bool
+nfp_flow_field_id_dst_support(enum rte_flow_field_id field)
+{
+ switch (field) {
+ case RTE_FLOW_FIELD_IPV4_SRC:
+ return true;
+ default:
+ break;
+ }
+
+ return false;
+}
+
+static bool
+nfp_flow_field_id_src_support(enum rte_flow_field_id field)
+{
+ return field == RTE_FLOW_FIELD_POINTER ||
+ field == RTE_FLOW_FIELD_VALUE;
+}
+
+static uint32_t
+nfp_flow_field_width(enum rte_flow_field_id field,
+ uint32_t inherit)
+{
+ switch (field) {
+ case RTE_FLOW_FIELD_IPV4_SRC:
+ return 32;
+ case RTE_FLOW_FIELD_POINTER:
+ /* FALLTHROUGH */
+ case RTE_FLOW_FIELD_VALUE:
+ return inherit;
+ default:
+ break;
+ }
+
+ return 0;
+}
+
+static bool
+nfp_flow_is_validate_field_data(const struct rte_flow_field_data *data,
+ uint32_t conf_width,
+ uint32_t data_width)
+{
+ if (data->level != 0) {
+ PMD_DRV_LOG(ERR, "The 'level' is not support");
+ return false;
+ }
+
+ if (data->tag_index != 0) {
+ PMD_DRV_LOG(ERR, "The 'tag_index' is not support");
+ return false;
+ }
+
+ if (data->class_id != 0) {
+ PMD_DRV_LOG(ERR, "The 'class_id' is not support");
+ return false;
+ }
+
+ if (data->offset + conf_width > data_width) {
+ PMD_DRV_LOG(ERR, "The 'offset' value is too big");
+ return false;
+ }
+
+ return true;
+}
+
+static int
+nfp_flow_action_calculate_modify_dispatch(struct nfp_action_calculate_param *param,
+ enum rte_flow_field_id field)
+{
+ switch (field) {
+ case RTE_FLOW_FIELD_IPV4_SRC:
+ return nfp_flow_action_calculate_ipv4_addr(param);
+ default:
+ break; /* NOTREACHED */
+ }
+
+ return -ENOTSUP;
+}
+
+static int
+nfp_flow_action_calculate_modify(struct nfp_action_calculate_param *param)
+{
+ uint32_t width;
+ uint32_t dst_width;
+ uint32_t src_width;
+ const struct rte_flow_field_data *dst_data;
+ const struct rte_flow_field_data *src_data;
+ const struct rte_flow_action_modify_field *conf;
+
+ conf = param->action->conf;
+ if (conf == NULL)
+ return -EINVAL;
+
+ dst_data = &conf->dst;
+ src_data = &conf->src;
+ if (!nfp_flow_field_id_dst_support(dst_data->field) ||
+ !nfp_flow_field_id_src_support(src_data->field)) {
+ PMD_DRV_LOG(ERR, "Not supported field id");
+ return -EINVAL;
+ }
+
+ width = conf->width;
+ if (width == 0) {
+ PMD_DRV_LOG(ERR, "No bits are required to modify");
+ return -EINVAL;
+ }
+
+ dst_width = nfp_flow_field_width(dst_data->field, 0);
+ src_width = nfp_flow_field_width(src_data->field, dst_width);
+ if (width > dst_width || width > src_width) {
+ PMD_DRV_LOG(ERR, "Cannot modify more bits than the width of a field");
+ return -EINVAL;
+ }
+
+ if (!nfp_flow_is_validate_field_data(dst_data, width, dst_width)) {
+ PMD_DRV_LOG(ERR, "The dest field data has problem");
+ return -EINVAL;
+ }
+
+ return nfp_flow_action_calculate_modify_dispatch(param, dst_data->field);
+}
+
static nfp_flow_key_calculate_action_fn action_fns[] = {
[RTE_FLOW_ACTION_TYPE_VOID] = nfp_flow_action_calculate_stub,
[RTE_FLOW_ACTION_TYPE_DROP] = nfp_flow_action_calculate_stub,
@@ -1235,6 +1358,7 @@ static nfp_flow_key_calculate_action_fn action_fns[] = {
[RTE_FLOW_ACTION_TYPE_CONNTRACK] = nfp_flow_action_calculate_stub,
[RTE_FLOW_ACTION_TYPE_MARK] = nfp_flow_action_calculate_mark,
[RTE_FLOW_ACTION_TYPE_RSS] = nfp_flow_action_calculate_stub,
+ [RTE_FLOW_ACTION_TYPE_MODIFY_FIELD] = nfp_flow_action_calculate_modify,
};
static int
@@ -4104,6 +4228,53 @@ nfp_flow_action_compile_rss(struct nfp_action_compile_param *param)
return 0;
}
+static int
+nfp_flow_action_compile_modify_dispatch(struct nfp_action_compile_param *param,
+ enum rte_flow_field_id field)
+{
+ switch (field) {
+ case RTE_FLOW_FIELD_IPV4_SRC:
+ return nfp_flow_action_compile_ipv4_src(param);
+ default:
+ break; /* NOTREACHED */
+ }
+
+ return -ENOTSUP;
+}
+
+static int
+nfp_flow_action_compile_modify(struct nfp_action_compile_param *param)
+{
+ int ret;
+ struct rte_flow_action action = {};
+ const struct rte_flow_action *action_old;
+ const struct rte_flow_action_modify_field *conf;
+
+ conf = param->action->conf;
+
+ if (conf->src.field == RTE_FLOW_FIELD_POINTER) {
+ action.conf = conf->src.pvalue;
+ } else if (conf->src.field == RTE_FLOW_FIELD_VALUE) {
+ action.conf = (void *)(uintptr_t)&conf->src.value;
+ } else {
+ PMD_DRV_LOG(ERR, "The SRC field of flow modify is not right");
+ return -EINVAL;
+ }
+
+ /* Store the old action pointer */
+ action_old = param->action;
+
+ param->action = &action;
+ ret = nfp_flow_action_compile_modify_dispatch(param, conf->dst.field);
+ if (ret != 0)
+ PMD_DRV_LOG(ERR, "Something wrong when modify dispatch");
+
+ /* Reload the old action pointer */
+ param->action = action_old;
+
+ return ret;
+}
+
static nfp_flow_action_compile_fn action_compile_fns[] = {
[RTE_FLOW_ACTION_TYPE_VOID] = nfp_flow_action_compile_stub,
[RTE_FLOW_ACTION_TYPE_DROP] = nfp_flow_action_compile_drop,
@@ -4134,6 +4305,7 @@ static nfp_flow_action_compile_fn action_compile_fns[] = {
[RTE_FLOW_ACTION_TYPE_CONNTRACK] = nfp_flow_action_compile_stub,
[RTE_FLOW_ACTION_TYPE_MARK] = nfp_flow_action_compile_mark,
[RTE_FLOW_ACTION_TYPE_RSS] = nfp_flow_action_compile_rss,
+ [RTE_FLOW_ACTION_TYPE_MODIFY_FIELD] = nfp_flow_action_compile_modify,
};
static int
--
2.39.1
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 09/21] net/nfp: support modify IPv4 dest address
2024-06-19 9:13 [PATCH 00/21] support modify field flow action Chaoyong He
` (7 preceding siblings ...)
2024-06-19 9:13 ` [PATCH 08/21] net/nfp: support modify IPv4 source address Chaoyong He
@ 2024-06-19 9:13 ` Chaoyong He
2024-06-19 9:13 ` [PATCH 10/21] net/nfp: support modify IPv6 source address Chaoyong He
` (12 subsequent siblings)
21 siblings, 0 replies; 23+ messages in thread
From: Chaoyong He @ 2024-06-19 9:13 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang
Add the logic of modify IPv4 dest address.
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 | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/net/nfp/flower/nfp_flower_flow.c b/drivers/net/nfp/flower/nfp_flower_flow.c
index 8997d67627..c568e4ebaf 100644
--- a/drivers/net/nfp/flower/nfp_flower_flow.c
+++ b/drivers/net/nfp/flower/nfp_flower_flow.c
@@ -1210,6 +1210,8 @@ nfp_flow_field_id_dst_support(enum rte_flow_field_id field)
{
switch (field) {
case RTE_FLOW_FIELD_IPV4_SRC:
+ /* FALLTHROUGH */
+ case RTE_FLOW_FIELD_IPV4_DST:
return true;
default:
break;
@@ -1231,6 +1233,8 @@ nfp_flow_field_width(enum rte_flow_field_id field,
{
switch (field) {
case RTE_FLOW_FIELD_IPV4_SRC:
+ /* FALLTHROUGH */
+ case RTE_FLOW_FIELD_IPV4_DST:
return 32;
case RTE_FLOW_FIELD_POINTER:
/* FALLTHROUGH */
@@ -1277,6 +1281,8 @@ nfp_flow_action_calculate_modify_dispatch(struct nfp_action_calculate_param *par
{
switch (field) {
case RTE_FLOW_FIELD_IPV4_SRC:
+ /* FALLTHROUGH */
+ case RTE_FLOW_FIELD_IPV4_DST:
return nfp_flow_action_calculate_ipv4_addr(param);
default:
break; /* NOTREACHED */
@@ -4235,6 +4241,8 @@ nfp_flow_action_compile_modify_dispatch(struct nfp_action_compile_param *param,
switch (field) {
case RTE_FLOW_FIELD_IPV4_SRC:
return nfp_flow_action_compile_ipv4_src(param);
+ case RTE_FLOW_FIELD_IPV4_DST:
+ return nfp_flow_action_compile_ipv4_dst(param);
default:
break; /* NOTREACHED */
}
--
2.39.1
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 10/21] net/nfp: support modify IPv6 source address
2024-06-19 9:13 [PATCH 00/21] support modify field flow action Chaoyong He
` (8 preceding siblings ...)
2024-06-19 9:13 ` [PATCH 09/21] net/nfp: support modify IPv4 dest address Chaoyong He
@ 2024-06-19 9:13 ` Chaoyong He
2024-06-19 9:13 ` [PATCH 11/21] net/nfp: support modify IPv6 dest address Chaoyong He
` (11 subsequent siblings)
21 siblings, 0 replies; 23+ messages in thread
From: Chaoyong He @ 2024-06-19 9:13 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang
Add the logic of modify IPv6 source address.
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 | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/net/nfp/flower/nfp_flower_flow.c b/drivers/net/nfp/flower/nfp_flower_flow.c
index c568e4ebaf..74f138a301 100644
--- a/drivers/net/nfp/flower/nfp_flower_flow.c
+++ b/drivers/net/nfp/flower/nfp_flower_flow.c
@@ -1212,6 +1212,8 @@ nfp_flow_field_id_dst_support(enum rte_flow_field_id field)
case RTE_FLOW_FIELD_IPV4_SRC:
/* FALLTHROUGH */
case RTE_FLOW_FIELD_IPV4_DST:
+ /* FALLTHROUGH */
+ case RTE_FLOW_FIELD_IPV6_SRC:
return true;
default:
break;
@@ -1236,6 +1238,8 @@ nfp_flow_field_width(enum rte_flow_field_id field,
/* FALLTHROUGH */
case RTE_FLOW_FIELD_IPV4_DST:
return 32;
+ case RTE_FLOW_FIELD_IPV6_SRC:
+ return 128;
case RTE_FLOW_FIELD_POINTER:
/* FALLTHROUGH */
case RTE_FLOW_FIELD_VALUE:
@@ -1284,6 +1288,8 @@ nfp_flow_action_calculate_modify_dispatch(struct nfp_action_calculate_param *par
/* FALLTHROUGH */
case RTE_FLOW_FIELD_IPV4_DST:
return nfp_flow_action_calculate_ipv4_addr(param);
+ case RTE_FLOW_FIELD_IPV6_SRC:
+ return nfp_flow_action_calculate_ipv6_addr(param);
default:
break; /* NOTREACHED */
}
@@ -4243,6 +4249,8 @@ nfp_flow_action_compile_modify_dispatch(struct nfp_action_compile_param *param,
return nfp_flow_action_compile_ipv4_src(param);
case RTE_FLOW_FIELD_IPV4_DST:
return nfp_flow_action_compile_ipv4_dst(param);
+ case RTE_FLOW_FIELD_IPV6_SRC:
+ return nfp_flow_action_compile_ipv6_src(param);
default:
break; /* NOTREACHED */
}
--
2.39.1
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 11/21] net/nfp: support modify IPv6 dest address
2024-06-19 9:13 [PATCH 00/21] support modify field flow action Chaoyong He
` (9 preceding siblings ...)
2024-06-19 9:13 ` [PATCH 10/21] net/nfp: support modify IPv6 source address Chaoyong He
@ 2024-06-19 9:13 ` Chaoyong He
2024-06-19 9:13 ` [PATCH 12/21] net/nfp: support modify TCP source port Chaoyong He
` (10 subsequent siblings)
21 siblings, 0 replies; 23+ messages in thread
From: Chaoyong He @ 2024-06-19 9:13 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang
Add the logic of modify IPv6 dest address.
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 | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/net/nfp/flower/nfp_flower_flow.c b/drivers/net/nfp/flower/nfp_flower_flow.c
index 74f138a301..afc2992e1f 100644
--- a/drivers/net/nfp/flower/nfp_flower_flow.c
+++ b/drivers/net/nfp/flower/nfp_flower_flow.c
@@ -1214,6 +1214,8 @@ nfp_flow_field_id_dst_support(enum rte_flow_field_id field)
case RTE_FLOW_FIELD_IPV4_DST:
/* FALLTHROUGH */
case RTE_FLOW_FIELD_IPV6_SRC:
+ /* FALLTHROUGH */
+ case RTE_FLOW_FIELD_IPV6_DST:
return true;
default:
break;
@@ -1239,6 +1241,8 @@ nfp_flow_field_width(enum rte_flow_field_id field,
case RTE_FLOW_FIELD_IPV4_DST:
return 32;
case RTE_FLOW_FIELD_IPV6_SRC:
+ /* FALLTHROUGH */
+ case RTE_FLOW_FIELD_IPV6_DST:
return 128;
case RTE_FLOW_FIELD_POINTER:
/* FALLTHROUGH */
@@ -1289,6 +1293,8 @@ nfp_flow_action_calculate_modify_dispatch(struct nfp_action_calculate_param *par
case RTE_FLOW_FIELD_IPV4_DST:
return nfp_flow_action_calculate_ipv4_addr(param);
case RTE_FLOW_FIELD_IPV6_SRC:
+ /* FALLTHROUGH */
+ case RTE_FLOW_FIELD_IPV6_DST:
return nfp_flow_action_calculate_ipv6_addr(param);
default:
break; /* NOTREACHED */
@@ -4251,6 +4257,8 @@ nfp_flow_action_compile_modify_dispatch(struct nfp_action_compile_param *param,
return nfp_flow_action_compile_ipv4_dst(param);
case RTE_FLOW_FIELD_IPV6_SRC:
return nfp_flow_action_compile_ipv6_src(param);
+ case RTE_FLOW_FIELD_IPV6_DST:
+ return nfp_flow_action_compile_ipv6_dst(param);
default:
break; /* NOTREACHED */
}
--
2.39.1
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 12/21] net/nfp: support modify TCP source port
2024-06-19 9:13 [PATCH 00/21] support modify field flow action Chaoyong He
` (10 preceding siblings ...)
2024-06-19 9:13 ` [PATCH 11/21] net/nfp: support modify IPv6 dest address Chaoyong He
@ 2024-06-19 9:13 ` Chaoyong He
2024-06-19 9:13 ` [PATCH 13/21] net/nfp: support modify TCP dest port Chaoyong He
` (9 subsequent siblings)
21 siblings, 0 replies; 23+ messages in thread
From: Chaoyong He @ 2024-06-19 9:13 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang
Add the logic of modify TCP source port.
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 | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/net/nfp/flower/nfp_flower_flow.c b/drivers/net/nfp/flower/nfp_flower_flow.c
index afc2992e1f..904d60ab04 100644
--- a/drivers/net/nfp/flower/nfp_flower_flow.c
+++ b/drivers/net/nfp/flower/nfp_flower_flow.c
@@ -1216,6 +1216,8 @@ nfp_flow_field_id_dst_support(enum rte_flow_field_id field)
case RTE_FLOW_FIELD_IPV6_SRC:
/* FALLTHROUGH */
case RTE_FLOW_FIELD_IPV6_DST:
+ /* FALLTHROUGH */
+ case RTE_FLOW_FIELD_TCP_PORT_SRC:
return true;
default:
break;
@@ -1244,6 +1246,8 @@ nfp_flow_field_width(enum rte_flow_field_id field,
/* FALLTHROUGH */
case RTE_FLOW_FIELD_IPV6_DST:
return 128;
+ case RTE_FLOW_FIELD_TCP_PORT_SRC:
+ return 16;
case RTE_FLOW_FIELD_POINTER:
/* FALLTHROUGH */
case RTE_FLOW_FIELD_VALUE:
@@ -1296,6 +1300,8 @@ nfp_flow_action_calculate_modify_dispatch(struct nfp_action_calculate_param *par
/* FALLTHROUGH */
case RTE_FLOW_FIELD_IPV6_DST:
return nfp_flow_action_calculate_ipv6_addr(param);
+ case RTE_FLOW_FIELD_TCP_PORT_SRC:
+ return nfp_flow_action_calculate_tp(param);
default:
break; /* NOTREACHED */
}
@@ -4259,6 +4265,8 @@ nfp_flow_action_compile_modify_dispatch(struct nfp_action_compile_param *param,
return nfp_flow_action_compile_ipv6_src(param);
case RTE_FLOW_FIELD_IPV6_DST:
return nfp_flow_action_compile_ipv6_dst(param);
+ case RTE_FLOW_FIELD_TCP_PORT_SRC:
+ return nfp_flow_action_compile_tp_src(param);
default:
break; /* NOTREACHED */
}
--
2.39.1
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 13/21] net/nfp: support modify TCP dest port
2024-06-19 9:13 [PATCH 00/21] support modify field flow action Chaoyong He
` (11 preceding siblings ...)
2024-06-19 9:13 ` [PATCH 12/21] net/nfp: support modify TCP source port Chaoyong He
@ 2024-06-19 9:13 ` Chaoyong He
2024-06-19 9:13 ` [PATCH 14/21] net/nfp: support modify UDP source port Chaoyong He
` (8 subsequent siblings)
21 siblings, 0 replies; 23+ messages in thread
From: Chaoyong He @ 2024-06-19 9:13 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang
Add the logic of modify TCP dest port.
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 | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/net/nfp/flower/nfp_flower_flow.c b/drivers/net/nfp/flower/nfp_flower_flow.c
index 904d60ab04..9b8db1e025 100644
--- a/drivers/net/nfp/flower/nfp_flower_flow.c
+++ b/drivers/net/nfp/flower/nfp_flower_flow.c
@@ -1218,6 +1218,8 @@ nfp_flow_field_id_dst_support(enum rte_flow_field_id field)
case RTE_FLOW_FIELD_IPV6_DST:
/* FALLTHROUGH */
case RTE_FLOW_FIELD_TCP_PORT_SRC:
+ /* FALLTHROUGH */
+ case RTE_FLOW_FIELD_TCP_PORT_DST:
return true;
default:
break;
@@ -1247,6 +1249,8 @@ nfp_flow_field_width(enum rte_flow_field_id field,
case RTE_FLOW_FIELD_IPV6_DST:
return 128;
case RTE_FLOW_FIELD_TCP_PORT_SRC:
+ /* FALLTHROUGH */
+ case RTE_FLOW_FIELD_TCP_PORT_DST:
return 16;
case RTE_FLOW_FIELD_POINTER:
/* FALLTHROUGH */
@@ -1301,6 +1305,8 @@ nfp_flow_action_calculate_modify_dispatch(struct nfp_action_calculate_param *par
case RTE_FLOW_FIELD_IPV6_DST:
return nfp_flow_action_calculate_ipv6_addr(param);
case RTE_FLOW_FIELD_TCP_PORT_SRC:
+ /* FALLTHROUGH */
+ case RTE_FLOW_FIELD_TCP_PORT_DST:
return nfp_flow_action_calculate_tp(param);
default:
break; /* NOTREACHED */
@@ -4267,6 +4273,8 @@ nfp_flow_action_compile_modify_dispatch(struct nfp_action_compile_param *param,
return nfp_flow_action_compile_ipv6_dst(param);
case RTE_FLOW_FIELD_TCP_PORT_SRC:
return nfp_flow_action_compile_tp_src(param);
+ case RTE_FLOW_FIELD_TCP_PORT_DST:
+ return nfp_flow_action_compile_tp_dst(param);
default:
break; /* NOTREACHED */
}
--
2.39.1
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 14/21] net/nfp: support modify UDP source port
2024-06-19 9:13 [PATCH 00/21] support modify field flow action Chaoyong He
` (12 preceding siblings ...)
2024-06-19 9:13 ` [PATCH 13/21] net/nfp: support modify TCP dest port Chaoyong He
@ 2024-06-19 9:13 ` Chaoyong He
2024-06-19 9:13 ` [PATCH 15/21] net/nfp: support modify UDP dest port Chaoyong He
` (7 subsequent siblings)
21 siblings, 0 replies; 23+ messages in thread
From: Chaoyong He @ 2024-06-19 9:13 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang
Add the logic of modify UDP source port.
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 | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/net/nfp/flower/nfp_flower_flow.c b/drivers/net/nfp/flower/nfp_flower_flow.c
index 9b8db1e025..a9fee4353f 100644
--- a/drivers/net/nfp/flower/nfp_flower_flow.c
+++ b/drivers/net/nfp/flower/nfp_flower_flow.c
@@ -1220,6 +1220,8 @@ nfp_flow_field_id_dst_support(enum rte_flow_field_id field)
case RTE_FLOW_FIELD_TCP_PORT_SRC:
/* FALLTHROUGH */
case RTE_FLOW_FIELD_TCP_PORT_DST:
+ /* FALLTHROUGH */
+ case RTE_FLOW_FIELD_UDP_PORT_SRC:
return true;
default:
break;
@@ -1251,6 +1253,8 @@ nfp_flow_field_width(enum rte_flow_field_id field,
case RTE_FLOW_FIELD_TCP_PORT_SRC:
/* FALLTHROUGH */
case RTE_FLOW_FIELD_TCP_PORT_DST:
+ /* FALLTHROUGH */
+ case RTE_FLOW_FIELD_UDP_PORT_SRC:
return 16;
case RTE_FLOW_FIELD_POINTER:
/* FALLTHROUGH */
@@ -1307,6 +1311,8 @@ nfp_flow_action_calculate_modify_dispatch(struct nfp_action_calculate_param *par
case RTE_FLOW_FIELD_TCP_PORT_SRC:
/* FALLTHROUGH */
case RTE_FLOW_FIELD_TCP_PORT_DST:
+ /* FALLTHROUGH */
+ case RTE_FLOW_FIELD_UDP_PORT_SRC:
return nfp_flow_action_calculate_tp(param);
default:
break; /* NOTREACHED */
@@ -4272,6 +4278,8 @@ nfp_flow_action_compile_modify_dispatch(struct nfp_action_compile_param *param,
case RTE_FLOW_FIELD_IPV6_DST:
return nfp_flow_action_compile_ipv6_dst(param);
case RTE_FLOW_FIELD_TCP_PORT_SRC:
+ /* FALLTHROUGH */
+ case RTE_FLOW_FIELD_UDP_PORT_SRC:
return nfp_flow_action_compile_tp_src(param);
case RTE_FLOW_FIELD_TCP_PORT_DST:
return nfp_flow_action_compile_tp_dst(param);
--
2.39.1
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 15/21] net/nfp: support modify UDP dest port
2024-06-19 9:13 [PATCH 00/21] support modify field flow action Chaoyong He
` (13 preceding siblings ...)
2024-06-19 9:13 ` [PATCH 14/21] net/nfp: support modify UDP source port Chaoyong He
@ 2024-06-19 9:13 ` Chaoyong He
2024-06-19 9:13 ` [PATCH 16/21] net/nfp: support modify IPv4 TTL Chaoyong He
` (6 subsequent siblings)
21 siblings, 0 replies; 23+ messages in thread
From: Chaoyong He @ 2024-06-19 9:13 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang
Add the logic of modify UDP dest port.
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 | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/net/nfp/flower/nfp_flower_flow.c b/drivers/net/nfp/flower/nfp_flower_flow.c
index a9fee4353f..a25151cca1 100644
--- a/drivers/net/nfp/flower/nfp_flower_flow.c
+++ b/drivers/net/nfp/flower/nfp_flower_flow.c
@@ -1222,6 +1222,8 @@ nfp_flow_field_id_dst_support(enum rte_flow_field_id field)
case RTE_FLOW_FIELD_TCP_PORT_DST:
/* FALLTHROUGH */
case RTE_FLOW_FIELD_UDP_PORT_SRC:
+ /* FALLTHROUGH */
+ case RTE_FLOW_FIELD_UDP_PORT_DST:
return true;
default:
break;
@@ -1255,6 +1257,8 @@ nfp_flow_field_width(enum rte_flow_field_id field,
case RTE_FLOW_FIELD_TCP_PORT_DST:
/* FALLTHROUGH */
case RTE_FLOW_FIELD_UDP_PORT_SRC:
+ /* FALLTHROUGH */
+ case RTE_FLOW_FIELD_UDP_PORT_DST:
return 16;
case RTE_FLOW_FIELD_POINTER:
/* FALLTHROUGH */
@@ -1313,6 +1317,8 @@ nfp_flow_action_calculate_modify_dispatch(struct nfp_action_calculate_param *par
case RTE_FLOW_FIELD_TCP_PORT_DST:
/* FALLTHROUGH */
case RTE_FLOW_FIELD_UDP_PORT_SRC:
+ /* FALLTHROUGH */
+ case RTE_FLOW_FIELD_UDP_PORT_DST:
return nfp_flow_action_calculate_tp(param);
default:
break; /* NOTREACHED */
@@ -4282,6 +4288,8 @@ nfp_flow_action_compile_modify_dispatch(struct nfp_action_compile_param *param,
case RTE_FLOW_FIELD_UDP_PORT_SRC:
return nfp_flow_action_compile_tp_src(param);
case RTE_FLOW_FIELD_TCP_PORT_DST:
+ /* FALLTHROUGH */
+ case RTE_FLOW_FIELD_UDP_PORT_DST:
return nfp_flow_action_compile_tp_dst(param);
default:
break; /* NOTREACHED */
--
2.39.1
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 16/21] net/nfp: support modify IPv4 TTL
2024-06-19 9:13 [PATCH 00/21] support modify field flow action Chaoyong He
` (14 preceding siblings ...)
2024-06-19 9:13 ` [PATCH 15/21] net/nfp: support modify UDP dest port Chaoyong He
@ 2024-06-19 9:13 ` Chaoyong He
2024-06-19 9:13 ` [PATCH 17/21] net/nfp: support modify IPv6 hop limit Chaoyong He
` (5 subsequent siblings)
21 siblings, 0 replies; 23+ messages in thread
From: Chaoyong He @ 2024-06-19 9:13 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang
Add the logic of modify IPv4 TTL value.
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 | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/net/nfp/flower/nfp_flower_flow.c b/drivers/net/nfp/flower/nfp_flower_flow.c
index a25151cca1..9950d158c3 100644
--- a/drivers/net/nfp/flower/nfp_flower_flow.c
+++ b/drivers/net/nfp/flower/nfp_flower_flow.c
@@ -1224,6 +1224,8 @@ nfp_flow_field_id_dst_support(enum rte_flow_field_id field)
case RTE_FLOW_FIELD_UDP_PORT_SRC:
/* FALLTHROUGH */
case RTE_FLOW_FIELD_UDP_PORT_DST:
+ /* FALLTHROUGH */
+ case RTE_FLOW_FIELD_IPV4_TTL:
return true;
default:
break;
@@ -1260,6 +1262,8 @@ nfp_flow_field_width(enum rte_flow_field_id field,
/* FALLTHROUGH */
case RTE_FLOW_FIELD_UDP_PORT_DST:
return 16;
+ case RTE_FLOW_FIELD_IPV4_TTL:
+ return 8;
case RTE_FLOW_FIELD_POINTER:
/* FALLTHROUGH */
case RTE_FLOW_FIELD_VALUE:
@@ -1320,6 +1324,8 @@ nfp_flow_action_calculate_modify_dispatch(struct nfp_action_calculate_param *par
/* FALLTHROUGH */
case RTE_FLOW_FIELD_UDP_PORT_DST:
return nfp_flow_action_calculate_tp(param);
+ case RTE_FLOW_FIELD_IPV4_TTL:
+ return nfp_flow_action_calculate_ttl(param);
default:
break; /* NOTREACHED */
}
@@ -4291,6 +4297,8 @@ nfp_flow_action_compile_modify_dispatch(struct nfp_action_compile_param *param,
/* FALLTHROUGH */
case RTE_FLOW_FIELD_UDP_PORT_DST:
return nfp_flow_action_compile_tp_dst(param);
+ case RTE_FLOW_FIELD_IPV4_TTL:
+ return nfp_flow_action_compile_ttl(param);
default:
break; /* NOTREACHED */
}
--
2.39.1
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 17/21] net/nfp: support modify IPv6 hop limit
2024-06-19 9:13 [PATCH 00/21] support modify field flow action Chaoyong He
` (15 preceding siblings ...)
2024-06-19 9:13 ` [PATCH 16/21] net/nfp: support modify IPv4 TTL Chaoyong He
@ 2024-06-19 9:13 ` Chaoyong He
2024-06-19 9:13 ` [PATCH 18/21] net/nfp: support modify MAC source address Chaoyong He
` (4 subsequent siblings)
21 siblings, 0 replies; 23+ messages in thread
From: Chaoyong He @ 2024-06-19 9:13 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang
Add the logic of modify IPv6 hop limit value.
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 | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/net/nfp/flower/nfp_flower_flow.c b/drivers/net/nfp/flower/nfp_flower_flow.c
index 9950d158c3..5c3c3777de 100644
--- a/drivers/net/nfp/flower/nfp_flower_flow.c
+++ b/drivers/net/nfp/flower/nfp_flower_flow.c
@@ -1226,6 +1226,8 @@ nfp_flow_field_id_dst_support(enum rte_flow_field_id field)
case RTE_FLOW_FIELD_UDP_PORT_DST:
/* FALLTHROUGH */
case RTE_FLOW_FIELD_IPV4_TTL:
+ /* FALLTHROUGH */
+ case RTE_FLOW_FIELD_IPV6_HOPLIMIT:
return true;
default:
break;
@@ -1263,6 +1265,8 @@ nfp_flow_field_width(enum rte_flow_field_id field,
case RTE_FLOW_FIELD_UDP_PORT_DST:
return 16;
case RTE_FLOW_FIELD_IPV4_TTL:
+ /* FALLTHROUGH */
+ case RTE_FLOW_FIELD_IPV6_HOPLIMIT:
return 8;
case RTE_FLOW_FIELD_POINTER:
/* FALLTHROUGH */
@@ -1325,6 +1329,8 @@ nfp_flow_action_calculate_modify_dispatch(struct nfp_action_calculate_param *par
case RTE_FLOW_FIELD_UDP_PORT_DST:
return nfp_flow_action_calculate_tp(param);
case RTE_FLOW_FIELD_IPV4_TTL:
+ /* FALLTHROUGH */
+ case RTE_FLOW_FIELD_IPV6_HOPLIMIT:
return nfp_flow_action_calculate_ttl(param);
default:
break; /* NOTREACHED */
@@ -4298,6 +4304,8 @@ nfp_flow_action_compile_modify_dispatch(struct nfp_action_compile_param *param,
case RTE_FLOW_FIELD_UDP_PORT_DST:
return nfp_flow_action_compile_tp_dst(param);
case RTE_FLOW_FIELD_IPV4_TTL:
+ /* FALLTHROUGH */
+ case RTE_FLOW_FIELD_IPV6_HOPLIMIT:
return nfp_flow_action_compile_ttl(param);
default:
break; /* NOTREACHED */
--
2.39.1
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 18/21] net/nfp: support modify MAC source address
2024-06-19 9:13 [PATCH 00/21] support modify field flow action Chaoyong He
` (16 preceding siblings ...)
2024-06-19 9:13 ` [PATCH 17/21] net/nfp: support modify IPv6 hop limit Chaoyong He
@ 2024-06-19 9:13 ` Chaoyong He
2024-06-19 9:13 ` [PATCH 19/21] net/nfp: support modify MAC dest address Chaoyong He
` (3 subsequent siblings)
21 siblings, 0 replies; 23+ messages in thread
From: Chaoyong He @ 2024-06-19 9:13 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang
Add the logic of modify MAC source address.
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 | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/net/nfp/flower/nfp_flower_flow.c b/drivers/net/nfp/flower/nfp_flower_flow.c
index 5c3c3777de..9ccdf499e7 100644
--- a/drivers/net/nfp/flower/nfp_flower_flow.c
+++ b/drivers/net/nfp/flower/nfp_flower_flow.c
@@ -1228,6 +1228,8 @@ nfp_flow_field_id_dst_support(enum rte_flow_field_id field)
case RTE_FLOW_FIELD_IPV4_TTL:
/* FALLTHROUGH */
case RTE_FLOW_FIELD_IPV6_HOPLIMIT:
+ /* FALLTHROUGH */
+ case RTE_FLOW_FIELD_MAC_SRC:
return true;
default:
break;
@@ -1268,6 +1270,8 @@ nfp_flow_field_width(enum rte_flow_field_id field,
/* FALLTHROUGH */
case RTE_FLOW_FIELD_IPV6_HOPLIMIT:
return 8;
+ case RTE_FLOW_FIELD_MAC_SRC:
+ return 48;
case RTE_FLOW_FIELD_POINTER:
/* FALLTHROUGH */
case RTE_FLOW_FIELD_VALUE:
@@ -1332,6 +1336,8 @@ nfp_flow_action_calculate_modify_dispatch(struct nfp_action_calculate_param *par
/* FALLTHROUGH */
case RTE_FLOW_FIELD_IPV6_HOPLIMIT:
return nfp_flow_action_calculate_ttl(param);
+ case RTE_FLOW_FIELD_MAC_SRC:
+ return nfp_flow_action_calculate_mac(param);
default:
break; /* NOTREACHED */
}
@@ -4307,6 +4313,8 @@ nfp_flow_action_compile_modify_dispatch(struct nfp_action_compile_param *param,
/* FALLTHROUGH */
case RTE_FLOW_FIELD_IPV6_HOPLIMIT:
return nfp_flow_action_compile_ttl(param);
+ case RTE_FLOW_FIELD_MAC_SRC:
+ return nfp_flow_action_compile_mac_src(param);
default:
break; /* NOTREACHED */
}
--
2.39.1
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 19/21] net/nfp: support modify MAC dest address
2024-06-19 9:13 [PATCH 00/21] support modify field flow action Chaoyong He
` (17 preceding siblings ...)
2024-06-19 9:13 ` [PATCH 18/21] net/nfp: support modify MAC source address Chaoyong He
@ 2024-06-19 9:13 ` Chaoyong He
2024-06-19 9:13 ` [PATCH 20/21] net/nfp: support modify IPv4 DSCP Chaoyong He
` (2 subsequent siblings)
21 siblings, 0 replies; 23+ messages in thread
From: Chaoyong He @ 2024-06-19 9:13 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang
Add the logic of modify MAC dest address.
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 | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/net/nfp/flower/nfp_flower_flow.c b/drivers/net/nfp/flower/nfp_flower_flow.c
index 9ccdf499e7..0d5d26f22b 100644
--- a/drivers/net/nfp/flower/nfp_flower_flow.c
+++ b/drivers/net/nfp/flower/nfp_flower_flow.c
@@ -1230,6 +1230,8 @@ nfp_flow_field_id_dst_support(enum rte_flow_field_id field)
case RTE_FLOW_FIELD_IPV6_HOPLIMIT:
/* FALLTHROUGH */
case RTE_FLOW_FIELD_MAC_SRC:
+ /* FALLTHROUGH */
+ case RTE_FLOW_FIELD_MAC_DST:
return true;
default:
break;
@@ -1271,6 +1273,8 @@ nfp_flow_field_width(enum rte_flow_field_id field,
case RTE_FLOW_FIELD_IPV6_HOPLIMIT:
return 8;
case RTE_FLOW_FIELD_MAC_SRC:
+ /* FALLTHROUGH */
+ case RTE_FLOW_FIELD_MAC_DST:
return 48;
case RTE_FLOW_FIELD_POINTER:
/* FALLTHROUGH */
@@ -1337,6 +1341,8 @@ nfp_flow_action_calculate_modify_dispatch(struct nfp_action_calculate_param *par
case RTE_FLOW_FIELD_IPV6_HOPLIMIT:
return nfp_flow_action_calculate_ttl(param);
case RTE_FLOW_FIELD_MAC_SRC:
+ /* FALLTHROUGH */
+ case RTE_FLOW_FIELD_MAC_DST:
return nfp_flow_action_calculate_mac(param);
default:
break; /* NOTREACHED */
@@ -4315,6 +4321,8 @@ nfp_flow_action_compile_modify_dispatch(struct nfp_action_compile_param *param,
return nfp_flow_action_compile_ttl(param);
case RTE_FLOW_FIELD_MAC_SRC:
return nfp_flow_action_compile_mac_src(param);
+ case RTE_FLOW_FIELD_MAC_DST:
+ return nfp_flow_action_compile_mac_dst(param);
default:
break; /* NOTREACHED */
}
--
2.39.1
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 20/21] net/nfp: support modify IPv4 DSCP
2024-06-19 9:13 [PATCH 00/21] support modify field flow action Chaoyong He
` (18 preceding siblings ...)
2024-06-19 9:13 ` [PATCH 19/21] net/nfp: support modify MAC dest address Chaoyong He
@ 2024-06-19 9:13 ` 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
21 siblings, 0 replies; 23+ messages in thread
From: Chaoyong He @ 2024-06-19 9:13 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang
Add the logic of modify IPv4 DSCP.
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 | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/net/nfp/flower/nfp_flower_flow.c b/drivers/net/nfp/flower/nfp_flower_flow.c
index 0d5d26f22b..43ee310213 100644
--- a/drivers/net/nfp/flower/nfp_flower_flow.c
+++ b/drivers/net/nfp/flower/nfp_flower_flow.c
@@ -1232,6 +1232,8 @@ nfp_flow_field_id_dst_support(enum rte_flow_field_id field)
case RTE_FLOW_FIELD_MAC_SRC:
/* FALLTHROUGH */
case RTE_FLOW_FIELD_MAC_DST:
+ /* FALLTHROUGH */
+ case RTE_FLOW_FIELD_IPV4_DSCP:
return true;
default:
break;
@@ -1276,6 +1278,8 @@ nfp_flow_field_width(enum rte_flow_field_id field,
/* FALLTHROUGH */
case RTE_FLOW_FIELD_MAC_DST:
return 48;
+ case RTE_FLOW_FIELD_IPV4_DSCP:
+ return 6;
case RTE_FLOW_FIELD_POINTER:
/* FALLTHROUGH */
case RTE_FLOW_FIELD_VALUE:
@@ -1344,6 +1348,8 @@ nfp_flow_action_calculate_modify_dispatch(struct nfp_action_calculate_param *par
/* FALLTHROUGH */
case RTE_FLOW_FIELD_MAC_DST:
return nfp_flow_action_calculate_mac(param);
+ case RTE_FLOW_FIELD_IPV4_DSCP:
+ return nfp_flow_action_calculate_ipv4_dscp(param);
default:
break; /* NOTREACHED */
}
@@ -4323,6 +4329,8 @@ nfp_flow_action_compile_modify_dispatch(struct nfp_action_compile_param *param,
return nfp_flow_action_compile_mac_src(param);
case RTE_FLOW_FIELD_MAC_DST:
return nfp_flow_action_compile_mac_dst(param);
+ case RTE_FLOW_FIELD_IPV4_DSCP:
+ return nfp_flow_action_compile_ipv4_dscp(param);
default:
break; /* NOTREACHED */
}
--
2.39.1
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 21/21] net/nfp: support modify IPv6 DSCP
2024-06-19 9:13 [PATCH 00/21] support modify field flow action Chaoyong He
` (19 preceding siblings ...)
2024-06-19 9:13 ` [PATCH 20/21] net/nfp: support modify IPv4 DSCP Chaoyong He
@ 2024-06-19 9:13 ` Chaoyong He
2024-07-07 2:10 ` [PATCH 00/21] support modify field flow action Ferruh Yigit
21 siblings, 0 replies; 23+ messages in thread
From: Chaoyong He @ 2024-06-19 9:13 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang
Add the logic of modify IPv6 DSCP.
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 | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/net/nfp/flower/nfp_flower_flow.c b/drivers/net/nfp/flower/nfp_flower_flow.c
index 43ee310213..f05e35580c 100644
--- a/drivers/net/nfp/flower/nfp_flower_flow.c
+++ b/drivers/net/nfp/flower/nfp_flower_flow.c
@@ -1234,6 +1234,8 @@ nfp_flow_field_id_dst_support(enum rte_flow_field_id field)
case RTE_FLOW_FIELD_MAC_DST:
/* FALLTHROUGH */
case RTE_FLOW_FIELD_IPV4_DSCP:
+ /* FALLTHROUGH */
+ case RTE_FLOW_FIELD_IPV6_DSCP:
return true;
default:
break;
@@ -1279,6 +1281,8 @@ nfp_flow_field_width(enum rte_flow_field_id field,
case RTE_FLOW_FIELD_MAC_DST:
return 48;
case RTE_FLOW_FIELD_IPV4_DSCP:
+ /* FALLTHROUGH */
+ case RTE_FLOW_FIELD_IPV6_DSCP:
return 6;
case RTE_FLOW_FIELD_POINTER:
/* FALLTHROUGH */
@@ -1350,6 +1354,8 @@ nfp_flow_action_calculate_modify_dispatch(struct nfp_action_calculate_param *par
return nfp_flow_action_calculate_mac(param);
case RTE_FLOW_FIELD_IPV4_DSCP:
return nfp_flow_action_calculate_ipv4_dscp(param);
+ case RTE_FLOW_FIELD_IPV6_DSCP:
+ return nfp_flow_action_calculate_ipv6_dscp(param);
default:
break; /* NOTREACHED */
}
@@ -4331,6 +4337,8 @@ nfp_flow_action_compile_modify_dispatch(struct nfp_action_compile_param *param,
return nfp_flow_action_compile_mac_dst(param);
case RTE_FLOW_FIELD_IPV4_DSCP:
return nfp_flow_action_compile_ipv4_dscp(param);
+ case RTE_FLOW_FIELD_IPV6_DSCP:
+ return nfp_flow_action_compile_ipv6_dscp(param);
default:
break; /* NOTREACHED */
}
--
2.39.1
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 00/21] support modify field flow action
2024-06-19 9:13 [PATCH 00/21] support modify field flow action Chaoyong He
` (20 preceding siblings ...)
2024-06-19 9:13 ` [PATCH 21/21] net/nfp: support modify IPv6 DSCP Chaoyong He
@ 2024-07-07 2:10 ` Ferruh Yigit
21 siblings, 0 replies; 23+ messages in thread
From: Ferruh Yigit @ 2024-07-07 2:10 UTC (permalink / raw)
To: Chaoyong He, dev; +Cc: oss-drivers
On 6/19/2024 10:13 AM, Chaoyong He wrote:
> This patch series try to support the modify field flow action
> as much as possible.
>
> Chaoyong He (21):
> net/nfp: fix IPv6 TTL and DSCP flow action
> net/nfp: pack parameters of flow item function
> net/nfp: pack various flags of flow action
> net/nfp: refactor flow action calculate function
> net/nfp: refactor flow action compile function
> net/nfp: pack various flags of flow item
> net/nfp: refactor flow item calculate function
> net/nfp: support modify IPv4 source address
> net/nfp: support modify IPv4 dest address
> net/nfp: support modify IPv6 source address
> net/nfp: support modify IPv6 dest address
> net/nfp: support modify TCP source port
> net/nfp: support modify TCP dest port
> net/nfp: support modify UDP source port
> net/nfp: support modify UDP dest port
> net/nfp: support modify IPv4 TTL
> net/nfp: support modify IPv6 hop limit
> net/nfp: support modify MAC source address
> net/nfp: support modify MAC dest address
> net/nfp: support modify IPv4 DSCP
> net/nfp: support modify IPv6 DSCP
>
Series applied to dpdk-next-net/main, thanks.
^ permalink raw reply [flat|nested] 23+ messages in thread