Skip to content

Commit

Permalink
net/nfp: support Ethernet type flow item
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
wulong2022 authored and ferruhy committed Sep 2, 2024
1 parent cd18f6c commit 523fd7b
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
14 changes: 14 additions & 0 deletions drivers/net/nfp/flower/nfp_flower_cmsg.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
34 changes: 34 additions & 0 deletions drivers/net/nfp/flower/nfp_flower_flow.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -1065,6 +1071,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;
Expand All @@ -1089,6 +1098,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
Expand Down Expand Up @@ -1870,6 +1886,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;
Expand All @@ -1892,6 +1911,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;
}
Expand Down

0 comments on commit 523fd7b

Please sign in to comment.