* [PATCH 0/2] Support match flow rule Ethernet type field @ 2024-08-30 3:10 Chaoyong He 2024-08-30 3:10 ` [PATCH 1/2] net/nfp: refactor flow item calculate function arguments Chaoyong He 2024-08-30 3:10 ` [PATCH 2/2] net/nfp: flow rule supports match Ethernet type Chaoyong He 0 siblings, 2 replies; 4+ messages in thread From: Chaoyong He @ 2024-08-30 3:10 UTC (permalink / raw) To: dev; +Cc: oss-drivers, Chaoyong He This patch series add support of match flow rule Ethernet type field, also do some needed refactor. Long Wu (2): net/nfp: refactor flow item calculate function arguments net/nfp: flow rule supports match Ethernet type drivers/net/nfp/flower/nfp_flower_cmsg.h | 14 +++++ drivers/net/nfp/flower/nfp_flower_flow.c | 78 ++++++++++++++++++------ 2 files changed, 74 insertions(+), 18 deletions(-) -- 2.39.1 ^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] net/nfp: refactor flow item calculate function arguments 2024-08-30 3:10 [PATCH 0/2] Support match flow rule Ethernet type field Chaoyong He @ 2024-08-30 3:10 ` Chaoyong He 2024-08-30 3:10 ` [PATCH 2/2] net/nfp: flow rule supports match Ethernet type Chaoyong He 1 sibling, 0 replies; 4+ messages in thread From: Chaoyong He @ 2024-08-30 3:10 UTC (permalink / raw) To: dev; +Cc: oss-drivers, Long Wu, Chaoyong He From: Long Wu <long.wu@corigine.com> Refactor the flow item calculate function, unify the arguments of item check and calculate function, make the Ethernet item calculate function more readable. Signed-off-by: Long Wu <long.wu@corigine.com> Reviewed-by: Chaoyong He <chaoyong.he@corigine.com> --- drivers/net/nfp/flower/nfp_flower_flow.c | 46 ++++++++++++++---------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/drivers/net/nfp/flower/nfp_flower_flow.c b/drivers/net/nfp/flower/nfp_flower_flow.c index 0078455658..50b0742b18 100644 --- a/drivers/net/nfp/flower/nfp_flower_flow.c +++ b/drivers/net/nfp/flower/nfp_flower_flow.c @@ -1044,14 +1044,14 @@ static nfp_flow_key_check_item_fn check_item_fns[] = { }; static int -nfp_flow_key_layers_check_items(const struct rte_flow_item items[]) +nfp_flow_key_layers_check_items(const struct rte_flow_item items[], + struct nfp_item_calculate_param *param) { int ret; struct nfp_item_flag flag = {}; const struct rte_flow_item *item; - struct nfp_item_calculate_param param = { - .flag = &flag, - }; + + param->flag = &flag; for (item = items; item->type != RTE_FLOW_ITEM_TYPE_END; ++item) { if (item->type >= RTE_DIM(check_item_fns)) { @@ -1062,8 +1062,8 @@ nfp_flow_key_layers_check_items(const struct rte_flow_item items[]) if (check_item_fns[item->type] == NULL) continue; - param.item = item; - ret = check_item_fns[item->type](¶m); + param->item = item; + ret = check_item_fns[item->type](param); if (ret != 0) { PMD_DRV_LOG(ERR, "Flow item %d check fail", item->type); return ret; @@ -1081,10 +1081,17 @@ nfp_flow_item_calculate_stub(struct nfp_item_calculate_param *param __rte_unused static void 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); - } + struct nfp_fl_key_ls *key_ls; + const struct rte_flow_item_eth *spec; + + spec = param->item->spec; + if (spec == NULL) + return; + + key_ls = param->key_ls; + + key_ls->key_layer |= NFP_FLOWER_LAYER_MAC; + key_ls->key_size += sizeof(struct nfp_flower_mac_mpls); } static void @@ -1238,14 +1245,12 @@ static nfp_flow_key_calculate_item_fn item_fns[] = { static int nfp_flow_key_layers_calculate_items(const struct rte_flow_item items[], - struct nfp_fl_key_ls *key_ls) + struct nfp_item_calculate_param *param) { struct nfp_item_flag flag = {}; const struct rte_flow_item *item; - struct nfp_item_calculate_param param = { - .key_ls = key_ls, - .flag = &flag, - }; + + param->flag = &flag; for (item = items; item->type != RTE_FLOW_ITEM_TYPE_END; ++item) { if (item->type >= RTE_DIM(item_fns) || item_fns[item->type] == NULL) { @@ -1253,8 +1258,8 @@ nfp_flow_key_layers_calculate_items(const struct rte_flow_item items[], return -ERANGE; } - param.item = item; - item_fns[item->type](¶m); + param->item = item; + item_fns[item->type](param); } return 0; @@ -1799,6 +1804,7 @@ nfp_flow_key_layers_calculate(struct rte_eth_dev *dev, struct nfp_fl_key_ls *key_ls) { int ret; + struct nfp_item_calculate_param param = {}; key_ls->key_layer_two = 0; key_ls->key_layer = NFP_FLOWER_LAYER_PORT; @@ -1809,13 +1815,15 @@ nfp_flow_key_layers_calculate(struct rte_eth_dev *dev, key_ls->vlan = 0; key_ls->tun_type = NFP_FL_TUN_NONE; - ret = nfp_flow_key_layers_check_items(items); + param.key_ls = key_ls; + + ret = nfp_flow_key_layers_check_items(items, ¶m); if (ret != 0) { PMD_DRV_LOG(ERR, "flow items check failed"); return ret; } - ret = nfp_flow_key_layers_calculate_items(items, key_ls); + ret = nfp_flow_key_layers_calculate_items(items, ¶m); if (ret != 0) { PMD_DRV_LOG(ERR, "flow items calculate failed"); return ret; -- 2.39.1 ^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 2/2] net/nfp: flow rule supports match Ethernet type 2024-08-30 3:10 [PATCH 0/2] Support match flow rule Ethernet type field Chaoyong He 2024-08-30 3:10 ` [PATCH 1/2] net/nfp: refactor flow item calculate function arguments Chaoyong He @ 2024-08-30 3:10 ` Chaoyong He 1 sibling, 0 replies; 4+ messages in thread From: Chaoyong He @ 2024-08-30 3:10 UTC (permalink / raw) To: dev; +Cc: oss-drivers, Long Wu, Chaoyong He From: Long Wu <long.wu@corigine.com> Add the support of match ethernet type item when using flower firmware, with a limit that it can only be used alone. Signed-off-by: Long Wu <long.wu@corigine.com> Reviewed-by: Chaoyong He <chaoyong.he@corigine.com> --- drivers/net/nfp/flower/nfp_flower_cmsg.h | 14 ++++++++++ drivers/net/nfp/flower/nfp_flower_flow.c | 34 ++++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/drivers/net/nfp/flower/nfp_flower_cmsg.h b/drivers/net/nfp/flower/nfp_flower_cmsg.h index 5d23227c24..5fc4210d8b 100644 --- a/drivers/net/nfp/flower/nfp_flower_cmsg.h +++ b/drivers/net/nfp/flower/nfp_flower_cmsg.h @@ -708,6 +708,20 @@ struct nfp_flower_ipv6_gre_tun { rte_be32_t reserved2; }; +/* + * L3 other (1W/4B) + * 3 2 1 + * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | reserved | ethertype | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * Note: This is only used when no specific L3 header available. + */ +struct nfp_flower_l3_other { + rte_be16_t reserved; + rte_be16_t ethertype; +}; + struct nfp_fl_act_head { uint8_t jump_id; uint8_t len_lw; diff --git a/drivers/net/nfp/flower/nfp_flower_flow.c b/drivers/net/nfp/flower/nfp_flower_flow.c index 50b0742b18..21a53eab68 100644 --- a/drivers/net/nfp/flower/nfp_flower_flow.c +++ b/drivers/net/nfp/flower/nfp_flower_flow.c @@ -26,6 +26,7 @@ #define NFP_FLOWER_LAYER_VXLAN RTE_BIT32(7) #define NFP_FLOWER_LAYER2_GRE RTE_BIT32(0) +#define NFP_FLOWER_LAYER2_L3_OTHER RTE_BIT32(3) #define NFP_FLOWER_LAYER2_QINQ RTE_BIT32(4) #define NFP_FLOWER_LAYER2_GENEVE RTE_BIT32(5) #define NFP_FLOWER_LAYER2_GENEVE_OP RTE_BIT32(6) @@ -962,10 +963,15 @@ struct nfp_item_flag { bool outer_ip6_flag; }; +struct nfp_item_shared_flag { + bool l3_other_flag; +}; + struct nfp_item_calculate_param { const struct rte_flow_item *item; struct nfp_fl_key_ls *key_ls; struct nfp_item_flag *flag; + struct nfp_item_shared_flag shared_flag; }; typedef int (*nfp_flow_key_check_item_fn)(struct nfp_item_calculate_param *param); @@ -1068,6 +1074,9 @@ nfp_flow_key_layers_check_items(const struct rte_flow_item items[], PMD_DRV_LOG(ERR, "Flow item %d check fail", item->type); return ret; } + + if (item->type != RTE_FLOW_ITEM_TYPE_ETH) + param->shared_flag.l3_other_flag = true; } return 0; @@ -1092,6 +1101,13 @@ nfp_flow_item_calculate_eth(struct nfp_item_calculate_param *param) key_ls->key_layer |= NFP_FLOWER_LAYER_MAC; key_ls->key_size += sizeof(struct nfp_flower_mac_mpls); + + if (!param->shared_flag.l3_other_flag && spec->type != 0) { + key_ls->key_layer |= NFP_FLOWER_LAYER_EXT_META; + key_ls->key_size += sizeof(struct nfp_flower_ext_meta); + key_ls->key_layer_two |= NFP_FLOWER_LAYER2_L3_OTHER; + key_ls->key_size += sizeof(struct nfp_flower_l3_other); + } } static void @@ -1873,6 +1889,9 @@ nfp_flow_merge_eth(struct nfp_flow_merge_param *param) const struct rte_flow_item *item; const struct rte_flow_item_eth *spec; const struct rte_flow_item_eth *mask; + struct nfp_flower_l3_other *l3_other; + struct nfp_flower_meta_tci *meta_tci; + struct nfp_flower_ext_meta *ext_meta = NULL; item = param->item; spec = item->spec; @@ -1895,6 +1914,21 @@ nfp_flow_merge_eth(struct nfp_flow_merge_param *param) eth->mpls_lse = 0; *param->mbuf_off += sizeof(struct nfp_flower_mac_mpls); + 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 (ext_meta != NULL && + (ext_meta->nfp_flow_key_layer2 & NFP_FLOWER_LAYER2_L3_OTHER) != 0) { + l3_other = (void *)(*param->mbuf_off); + if (param->is_mask) + l3_other->ethertype = mask->type; + else + l3_other->ethertype = spec->type; + + *param->mbuf_off += sizeof(struct nfp_flower_l3_other); + } + eth_end: return 0; } -- 2.39.1 ^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 0/2] Support match flow rule Ethernet type field @ 2024-08-30 7:13 Chaoyong He 2024-08-30 7:13 ` [PATCH 1/2] net/nfp: refactor flow item calculate function arguments Chaoyong He 0 siblings, 1 reply; 4+ messages in thread From: Chaoyong He @ 2024-08-30 7:13 UTC (permalink / raw) To: dev; +Cc: oss-drivers, Chaoyong He This patch series add support of match flow rule Ethernet type field, also do some needed refactor. --- v2: * Fix compile problem of 'dangling-pointer'. --- Long Wu (2): net/nfp: refactor flow item calculate function arguments net/nfp: flow rule supports match Ethernet type drivers/net/nfp/flower/nfp_flower_cmsg.h | 14 +++++ drivers/net/nfp/flower/nfp_flower_flow.c | 79 ++++++++++++++++++------ 2 files changed, 73 insertions(+), 20 deletions(-) -- 2.39.1 ^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] net/nfp: refactor flow item calculate function arguments 2024-08-30 7:13 [PATCH 0/2] Support match flow rule Ethernet type field Chaoyong He @ 2024-08-30 7:13 ` Chaoyong He 0 siblings, 0 replies; 4+ messages in thread From: Chaoyong He @ 2024-08-30 7:13 UTC (permalink / raw) To: dev; +Cc: oss-drivers, Long Wu, Chaoyong He From: Long Wu <long.wu@corigine.com> Refactor the flow item calculate function, unify the arguments of item check and calculate function, make the Ethernet item calculate function more readable. Signed-off-by: Long Wu <long.wu@corigine.com> Reviewed-by: Chaoyong He <chaoyong.he@corigine.com> --- drivers/net/nfp/flower/nfp_flower_flow.c | 47 +++++++++++++----------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/drivers/net/nfp/flower/nfp_flower_flow.c b/drivers/net/nfp/flower/nfp_flower_flow.c index 0078455658..f24e9cee9c 100644 --- a/drivers/net/nfp/flower/nfp_flower_flow.c +++ b/drivers/net/nfp/flower/nfp_flower_flow.c @@ -1044,14 +1044,11 @@ static nfp_flow_key_check_item_fn check_item_fns[] = { }; static int -nfp_flow_key_layers_check_items(const struct rte_flow_item items[]) +nfp_flow_key_layers_check_items(const struct rte_flow_item items[], + struct nfp_item_calculate_param *param) { int ret; - struct nfp_item_flag flag = {}; const struct rte_flow_item *item; - struct nfp_item_calculate_param param = { - .flag = &flag, - }; for (item = items; item->type != RTE_FLOW_ITEM_TYPE_END; ++item) { if (item->type >= RTE_DIM(check_item_fns)) { @@ -1062,8 +1059,8 @@ nfp_flow_key_layers_check_items(const struct rte_flow_item items[]) if (check_item_fns[item->type] == NULL) continue; - param.item = item; - ret = check_item_fns[item->type](¶m); + param->item = item; + ret = check_item_fns[item->type](param); if (ret != 0) { PMD_DRV_LOG(ERR, "Flow item %d check fail", item->type); return ret; @@ -1081,10 +1078,17 @@ nfp_flow_item_calculate_stub(struct nfp_item_calculate_param *param __rte_unused static void 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); - } + struct nfp_fl_key_ls *key_ls; + const struct rte_flow_item_eth *spec; + + spec = param->item->spec; + if (spec == NULL) + return; + + key_ls = param->key_ls; + + key_ls->key_layer |= NFP_FLOWER_LAYER_MAC; + key_ls->key_size += sizeof(struct nfp_flower_mac_mpls); } static void @@ -1238,14 +1242,9 @@ static nfp_flow_key_calculate_item_fn item_fns[] = { static int nfp_flow_key_layers_calculate_items(const struct rte_flow_item items[], - struct nfp_fl_key_ls *key_ls) + struct nfp_item_calculate_param *param) { - struct nfp_item_flag flag = {}; const struct rte_flow_item *item; - struct nfp_item_calculate_param param = { - .key_ls = key_ls, - .flag = &flag, - }; for (item = items; item->type != RTE_FLOW_ITEM_TYPE_END; ++item) { if (item->type >= RTE_DIM(item_fns) || item_fns[item->type] == NULL) { @@ -1253,8 +1252,8 @@ nfp_flow_key_layers_calculate_items(const struct rte_flow_item items[], return -ERANGE; } - param.item = item; - item_fns[item->type](¶m); + param->item = item; + item_fns[item->type](param); } return 0; @@ -1799,6 +1798,8 @@ nfp_flow_key_layers_calculate(struct rte_eth_dev *dev, struct nfp_fl_key_ls *key_ls) { int ret; + struct nfp_item_flag flag = {}; + struct nfp_item_calculate_param param = {}; key_ls->key_layer_two = 0; key_ls->key_layer = NFP_FLOWER_LAYER_PORT; @@ -1809,13 +1810,17 @@ nfp_flow_key_layers_calculate(struct rte_eth_dev *dev, key_ls->vlan = 0; key_ls->tun_type = NFP_FL_TUN_NONE; - ret = nfp_flow_key_layers_check_items(items); + param.key_ls = key_ls; + param.flag = &flag; + + ret = nfp_flow_key_layers_check_items(items, ¶m); if (ret != 0) { PMD_DRV_LOG(ERR, "flow items check failed"); return ret; } - ret = nfp_flow_key_layers_calculate_items(items, key_ls); + memset(param.flag, 0, sizeof(struct nfp_item_flag)); + ret = nfp_flow_key_layers_calculate_items(items, ¶m); if (ret != 0) { PMD_DRV_LOG(ERR, "flow items calculate failed"); return ret; -- 2.39.1 ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-08-30 7:13 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2024-08-30 3:10 [PATCH 0/2] Support match flow rule Ethernet type field Chaoyong He 2024-08-30 3:10 ` [PATCH 1/2] net/nfp: refactor flow item calculate function arguments Chaoyong He 2024-08-30 3:10 ` [PATCH 2/2] net/nfp: flow rule supports match Ethernet type Chaoyong He 2024-08-30 7:13 [PATCH 0/2] Support match flow rule Ethernet type field Chaoyong He 2024-08-30 7:13 ` [PATCH 1/2] net/nfp: refactor flow item calculate function arguments Chaoyong He
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).