[dpdk-dev] [PATCH v2 4/4] common/cnxk: fix dual VLAN parsing issue
From: Satheesh Paul Flow parsing was not handling pattern matching on the fields of inner VLAN even though MKEX profile could be extracting inner VLAN fields. Code has been modified to handle matching fields on two VLAN tags. Fixes: c34ea71b878 ("common/cnxk: add NPC parsing API") Cc: sta...@dpdk.org Signed-off-by: Satheesh Paul Reviewed-by: Kiran Kumar K --- drivers/common/cnxk/roc_npc_parse.c | 240 +--- drivers/common/cnxk/roc_npc_priv.h | 16 +- drivers/common/cnxk/roc_npc_utils.c | 2 +- 3 files changed, 186 insertions(+), 72 deletions(-) diff --git a/drivers/common/cnxk/roc_npc_parse.c b/drivers/common/cnxk/roc_npc_parse.c index c1af5f3087..d8f9271fa8 100644 --- a/drivers/common/cnxk/roc_npc_parse.c +++ b/drivers/common/cnxk/roc_npc_parse.c @@ -239,10 +239,185 @@ npc_parse_la(struct npc_parse_state *pst) #define NPC_MAX_SUPPORTED_VLANS 3 +static int +npc_parse_vlan_count(const struct roc_npc_item_info *pattern, +const struct roc_npc_item_info **pattern_list, +const struct roc_npc_flow_item_vlan **vlan_items, int *vlan_count) +{ + *vlan_count = 0; + while (pattern->type == ROC_NPC_ITEM_TYPE_VLAN) { + if (*vlan_count > NPC_MAX_SUPPORTED_VLANS - 1) + return NPC_ERR_PATTERN_NOTSUP; + + /* Don't support ranges */ + if (pattern->last != NULL) + return NPC_ERR_INVALID_RANGE; + + /* If spec is NULL, both mask and last must be NULL, this +* makes it to match ANY value (eq to mask = 0). +* Setting either mask or last without spec is an error +*/ + if (pattern->spec == NULL) { + if (pattern->last != NULL && pattern->mask != NULL) + return NPC_ERR_INVALID_SPEC; + } + + pattern_list[*vlan_count] = pattern; + vlan_items[*vlan_count] = pattern->spec; + (*vlan_count)++; + + pattern++; + pattern = npc_parse_skip_void_and_any_items(pattern); + } + + return 0; +} + +static int +npc_parse_vlan_ltype_get(struct npc_parse_state *pst, +const struct roc_npc_flow_item_vlan **vlan_item, int vlan_count, +int *ltype, int *lflags) +{ + switch (vlan_count) { + case 1: + *ltype = NPC_LT_LB_CTAG; + if (vlan_item[0] && vlan_item[0]->has_more_vlan) + *ltype = NPC_LT_LB_STAG_QINQ; + break; + case 2: + if (vlan_item[1] && vlan_item[1]->has_more_vlan) { + if (!(pst->npc->keyx_supp_nmask[pst->nix_intf] & + 0x3ULL << NPC_LFLAG_LB_OFFSET)) + return NPC_ERR_PATTERN_NOTSUP; + + /* This lflag value will match either one of +* NPC_F_LB_L_WITH_STAG_STAG, +* NPC_F_LB_L_WITH_QINQ_CTAG, +* NPC_F_LB_L_WITH_QINQ_QINQ and +* NPC_F_LB_L_WITH_ITAG (0b0100 to 0b0111). For +* NPC_F_LB_L_WITH_ITAG, ltype is NPC_LT_LB_ETAG +* hence will not match. +*/ + + *lflags = NPC_F_LB_L_WITH_QINQ_CTAG & NPC_F_LB_L_WITH_QINQ_QINQ & + NPC_F_LB_L_WITH_STAG_STAG; + } + *ltype = NPC_LT_LB_STAG_QINQ; + break; + case 3: + if (vlan_item[2] && vlan_item[2]->has_more_vlan) + return NPC_ERR_PATTERN_NOTSUP; + if (!(pst->npc->keyx_supp_nmask[pst->nix_intf] & 0x3ULL << NPC_LFLAG_LB_OFFSET)) + return NPC_ERR_PATTERN_NOTSUP; + *ltype = NPC_LT_LB_STAG_QINQ; + *lflags = NPC_F_STAG_STAG_CTAG; + break; + default: + return NPC_ERR_PATTERN_NOTSUP; + } + + return 0; +} + +static int +npc_update_vlan_parse_state(struct npc_parse_state *pst, const struct roc_npc_item_info *pattern, + int lid, int lt, uint8_t lflags, int vlan_count) +{ + uint8_t vlan_spec[NPC_MAX_SUPPORTED_VLANS * sizeof(struct roc_vlan_hdr)]; + uint8_t vlan_mask[NPC_MAX_SUPPORTED_VLANS * sizeof(struct roc_vlan_hdr)]; + int rc = 0, i, offset = NPC_TPID_LENGTH; + struct npc_parse_item_info parse_info; + char hw_mask[NPC_MAX_EXTRACT_HW_LEN]; + + memset(vlan_spec, 0, sizeof(struct roc_vlan_hdr) * NPC_MAX_SUPPORTED_VLANS); + memset(vlan_mask, 0, sizeof(struct roc_vlan_hdr) * NPC_MAX_SUPPORTED_VLANS); + memset(&parse_info, 0, sizeof(parse_info)); + + if (vlan_count > 2) + vlan_count = 2; + + for (i = 0; i < vlan_count; i++) { + if (pattern[i].spec) +
[dpdk-dev] [PATCH] common/cnxk: fix issue with IPv6 ext matching
From: Kiran Kumar K While configuring ipv6 flow, ipv6 ext ltype should be matched along with ipv6. Adding changes to fix this issue. Fixes: 474e275b1bc6 ("common/cnxk: support extensions attributes in IPv6 item") Cc: sta...@dpdk.org Signed-off-by: Kiran Kumar K Reviewed-by: Satheesh Paul --- drivers/common/cnxk/roc_npc_mcam.c | 19 ++- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/drivers/common/cnxk/roc_npc_mcam.c b/drivers/common/cnxk/roc_npc_mcam.c index c419ce3a4c..0abd8872b1 100644 --- a/drivers/common/cnxk/roc_npc_mcam.c +++ b/drivers/common/cnxk/roc_npc_mcam.c @@ -727,15 +727,16 @@ npc_set_ipv6ext_ltype_mask(struct npc_parse_state *pst) * because for AH and ESP, LC LFLAG is zero and we don't want to match * zero in LFLAG. */ - lcflag_offset = - __builtin_popcount(pst->npc->keyx_supp_nmask[pst->nix_intf] & - ((1ULL << NPC_LFLAG_LC_OFFSET) - 1)); - lcflag_offset *= 4; - - mask = (0xfULL << lcflag_offset); - val = pst->flow->mcam_data[0] & mask; - if (val) - pst->flow->mcam_mask[0] |= mask; + if (pst->npc->keyx_supp_nmask[pst->nix_intf] & (1ULL << NPC_LFLAG_LC_OFFSET)) { + lcflag_offset = __builtin_popcount(pst->npc->keyx_supp_nmask[pst->nix_intf] & + ((1ULL << NPC_LFLAG_LC_OFFSET) - 1)); + lcflag_offset *= 4; + + mask = (0xfULL << lcflag_offset); + val = pst->flow->mcam_data[0] & mask; + if (val) + pst->flow->mcam_mask[0] |= mask; + } } int -- 2.35.3
[dpdk-dev] [PATCH] common/cnxk: fix second pass flow rule layer type
From: Satheesh Paul When installing flow rule for second pass packets, set the LA LTYPE to LA_CPT_HDR. Fixes: 4968b362b63 ("common/cnxk: support CPT second pass flow rules") Cc: sta...@dpdk.org Signed-off-by: Satheesh Paul Reviewed-by: Kiran Kumar K --- drivers/common/cnxk/roc_npc_mcam.c | 24 +--- drivers/common/cnxk/roc_npc_mcam_dump.c | 6 -- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/drivers/common/cnxk/roc_npc_mcam.c b/drivers/common/cnxk/roc_npc_mcam.c index 312424d1c2..06f3212e8d 100644 --- a/drivers/common/cnxk/roc_npc_mcam.c +++ b/drivers/common/cnxk/roc_npc_mcam.c @@ -668,22 +668,32 @@ npc_mcam_alloc_and_write(struct npc *npc, struct roc_npc_flow *flow, npc_mcam_set_channel(flow, req, npc->channel, (BIT_ULL(12) - 1), pst->is_second_pass_rule); } - /* Always match both 1st pass and 2nd pass ltypes for all rules */ - if (!pst->is_second_pass_rule && pst->has_eth_type) { + /* +* For second pass rule, set LA LTYPE to CPT_HDR. +* For all other rules, set LA LTYPE to match both 1st pass and 2nd pass ltypes. +*/ + if (pst->is_second_pass_rule || (!pst->is_second_pass_rule && pst->has_eth_type)) { la_offset = __builtin_popcount(npc->keyx_supp_nmask[flow->nix_intf] & ((1ULL << 9 /* LA offset */) - 1)); la_offset *= 4; mask = ~((0xfULL << la_offset)); - /* Mask ltype ETHER (0x2) and CPT_HDR (0xa) */ req->entry_data.kw[0] &= mask; req->entry_data.kw_mask[0] &= mask; - req->entry_data.kw[0] |= (0x2ULL << la_offset); - req->entry_data.kw_mask[0] |= (0x7ULL << la_offset); flow->mcam_data[0] &= mask; flow->mcam_mask[0] &= mask; - flow->mcam_data[0] |= (0x2ULL << la_offset); - flow->mcam_mask[0] |= (0x7ULL << la_offset); + if (pst->is_second_pass_rule) { + req->entry_data.kw[0] |= ((uint64_t)NPC_LT_LA_CPT_HDR) << la_offset; + req->entry_data.kw_mask[0] |= (0xFULL << la_offset); + flow->mcam_data[0] |= ((uint64_t)NPC_LT_LA_CPT_HDR) << la_offset; + flow->mcam_mask[0] |= (0xFULL << la_offset); + } else { + /* Mask ltype ETHER (0x2) and CPT_HDR (0xa) */ + req->entry_data.kw[0] |= (0x2ULL << la_offset); + req->entry_data.kw_mask[0] |= (0x7ULL << la_offset); + flow->mcam_data[0] |= (0x2ULL << la_offset); + flow->mcam_mask[0] |= (0x7ULL << la_offset); + } } } else { uint16_t pf_func = (flow->npc_action >> 4) & 0x; diff --git a/drivers/common/cnxk/roc_npc_mcam_dump.c b/drivers/common/cnxk/roc_npc_mcam_dump.c index 2aaa2ac671..40909b45e6 100644 --- a/drivers/common/cnxk/roc_npc_mcam_dump.c +++ b/drivers/common/cnxk/roc_npc_mcam_dump.c @@ -69,8 +69,10 @@ static const char *const ltype_str[NPC_MAX_LID][NPC_MAX_LT] = { [NPC_LID_LA][NPC_LT_LA_IH_NIX_ETHER] = "LA_IH_NIX_ETHER", [NPC_LID_LA][NPC_LT_LA_HIGIG2_ETHER] = "LA_HIGIG2_ETHER", [NPC_LID_LA][NPC_LT_LA_IH_NIX_HIGIG2_ETHER] = "LA_IH_NIX_HIGIG2_ETHER", - [NPC_LID_LA][NPC_LT_LA_CUSTOM_PRE_L2_ETHER] = - "NPC_LT_LA_CUSTOM_PRE_L2_ETHER", + [NPC_LID_LA][NPC_LT_LA_CUSTOM_L2_90B_ETHER] = "LA_CUSTOM_L2_90B_ETHER", + [NPC_LID_LA][NPC_LT_LA_CPT_HDR] = "LA_CPT_HDR", + [NPC_LID_LA][NPC_LT_LA_CUSTOM_L2_24B_ETHER] = "LA_CUSTOM_L2_24B_ETHER", + [NPC_LID_LA][NPC_LT_LA_CUSTOM_PRE_L2_ETHER] = "NPC_LT_LA_CUSTOM_PRE_L2_ETHER", [NPC_LID_LB][0] = "NONE", [NPC_LID_LB][NPC_LT_LB_CTAG] = "LB_CTAG", [NPC_LID_LB][NPC_LT_LB_STAG_QINQ] = "LB_STAG_QINQ", -- 2.35.3
[dpdk-dev] [PATCH 1/2] common/cnxk: limit RSS key config with RTE Flow operations
From: Kiran Kumar K Limit the configuring RSS key with RTE Flow operations for cnxk device. Key can be update only with dev operations using rte_eth_dev_rss_hash_update. Signed-off-by: Kiran Kumar K Reviewed-by: Jerin Jacob --- drivers/common/cnxk/roc_npc.c | 33 ++--- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/drivers/common/cnxk/roc_npc.c b/drivers/common/cnxk/roc_npc.c index c0c168db76..0611a83bba 100644 --- a/drivers/common/cnxk/roc_npc.c +++ b/drivers/common/cnxk/roc_npc.c @@ -943,9 +943,35 @@ npc_rss_action_configure(struct roc_npc *roc_npc, uint8_t key[ROC_NIX_RSS_KEY_LEN]; const uint8_t *key_ptr; uint8_t flowkey_algx; + uint32_t key_len; uint16_t *reta; int rc; + roc_nix_rss_key_get(roc_nix, key); + if (rss->key == NULL) { + key_ptr = key; + } else { + key_len = rss->key_len; + if (key_len > ROC_NIX_RSS_KEY_LEN) + key_len = ROC_NIX_RSS_KEY_LEN; + + for (i = 0; i < key_len; i++) { + if (key[i] != rss->key[i]) { + plt_err("RSS key config not supported"); + plt_err("New Key:"); + for (i = 0; i < key_len; i++) + plt_dump_no_nl("0x%.2x ", rss->key[i]); + plt_dump_no_nl("\n"); + plt_err("Configured Key:"); + for (i = 0; i < ROC_NIX_RSS_KEY_LEN; i++) + plt_dump_no_nl("0x%.2x ", key[i]); + plt_dump_no_nl("\n"); + return -ENOTSUP; + } + } + key_ptr = rss->key; + } + rc = npc_rss_free_grp_get(npc, &rss_grp_idx); /* RSS group :0 is not usable for flow rss action */ if (rc < 0 || rss_grp_idx == 0) @@ -960,13 +986,6 @@ npc_rss_action_configure(struct roc_npc *roc_npc, *rss_grp = rss_grp_idx; - if (rss->key == NULL) { - roc_nix_rss_key_default_fill(roc_nix, key); - key_ptr = key; - } else { - key_ptr = rss->key; - } - roc_nix_rss_key_set(roc_nix, key_ptr); /* If queue count passed in the rss action is less than -- 2.39.2
[dpdk-dev] [PATCH 2/2] drivers: add represented port flow item for cnxk
From: Kiran Kumar K Adding support for represented port flow item for cnxk device. Signed-off-by: Kiran Kumar K Reviewed-by: Satheesh Paul --- doc/guides/nics/features/cnxk.ini| 1 + doc/guides/nics/features/cnxk_vf.ini | 1 + drivers/common/cnxk/roc_npc.c| 59 --- drivers/common/cnxk/roc_npc.h| 13 +++- drivers/common/cnxk/roc_npc_mcam.c | 72 +- drivers/common/cnxk/roc_npc_parse.c | 11 +++ drivers/common/cnxk/roc_npc_priv.h | 1 + drivers/net/cnxk/cnxk_flow.c | 106 ++- 8 files changed, 166 insertions(+), 98 deletions(-) diff --git a/doc/guides/nics/features/cnxk.ini b/doc/guides/nics/features/cnxk.ini index ac7de9a0f0..1c7d804aab 100644 --- a/doc/guides/nics/features/cnxk.ini +++ b/doc/guides/nics/features/cnxk.ini @@ -72,6 +72,7 @@ mark = Y mpls = Y nvgre= Y raw = Y +represented_port = Y sctp = Y tcp = Y tx_queue = Y diff --git a/doc/guides/nics/features/cnxk_vf.ini b/doc/guides/nics/features/cnxk_vf.ini index b03e8b35c3..96bfd86ac8 100644 --- a/doc/guides/nics/features/cnxk_vf.ini +++ b/doc/guides/nics/features/cnxk_vf.ini @@ -63,6 +63,7 @@ mark = Y mpls = Y nvgre= Y raw = Y +represented_port = Y sctp = Y tcp = Y tx_queue = Y diff --git a/drivers/common/cnxk/roc_npc.c b/drivers/common/cnxk/roc_npc.c index 0611a83bba..0d7253bf1a 100644 --- a/drivers/common/cnxk/roc_npc.c +++ b/drivers/common/cnxk/roc_npc.c @@ -499,6 +499,8 @@ npc_parse_actions(struct roc_npc *roc_npc, const struct roc_npc_attr *attr, flow->ctr_id = NPC_COUNTER_NONE; flow->mtr_id = ROC_NIX_MTR_ID_INVALID; pf_func = npc->pf_func; + if (flow->has_rep) + pf_func = flow->rep_pf_func; for (; actions->type != ROC_NPC_ACTION_TYPE_END; actions++) { switch (actions->type) { @@ -794,10 +796,14 @@ npc_parse_pattern(struct npc *npc, const struct roc_npc_item_info pattern[], struct roc_npc_flow *flow, struct npc_parse_state *pst) { npc_parse_stage_func_t parse_stage_funcs[] = { - npc_parse_meta_items, npc_parse_mark_item, npc_parse_pre_l2, npc_parse_cpt_hdr, - npc_parse_higig2_hdr, npc_parse_tx_queue, npc_parse_la, npc_parse_lb, - npc_parse_lc, npc_parse_ld,npc_parse_le, npc_parse_lf, - npc_parse_lg, npc_parse_lh, + npc_parse_meta_items, npc_parse_port_representor_id, + npc_parse_mark_item, npc_parse_pre_l2, + npc_parse_cpt_hdr,npc_parse_higig2_hdr, + npc_parse_tx_queue, npc_parse_la, + npc_parse_lb, npc_parse_lc, + npc_parse_ld, npc_parse_le, + npc_parse_lf, npc_parse_lg, + npc_parse_lh, }; uint8_t layer = 0; int key_offset; @@ -1036,15 +1042,18 @@ npc_rss_action_program(struct roc_npc *roc_npc, struct roc_npc_flow *flow) { const struct roc_npc_action_rss *rss; + struct roc_npc *npc = roc_npc; uint32_t rss_grp; uint8_t alg_idx; int rc; + if (flow->has_rep) + npc = roc_npc->rep_npc; + for (; actions->type != ROC_NPC_ACTION_TYPE_END; actions++) { if (actions->type == ROC_NPC_ACTION_TYPE_RSS) { rss = (const struct roc_npc_action_rss *)actions->conf; - rc = npc_rss_action_configure(roc_npc, rss, &alg_idx, - &rss_grp, flow->mcam_id); + rc = npc_rss_action_configure(npc, rss, &alg_idx, &rss_grp, flow->mcam_id); if (rc) return rc; @@ -1067,7 +1076,7 @@ npc_vtag_cfg_delete(struct roc_npc *roc_npc, struct roc_npc_flow *flow) struct roc_nix *roc_nix = roc_npc->roc_nix; struct nix_vtag_config *vtag_cfg; struct nix_vtag_config_rsp *rsp; - struct mbox *mbox; + struct mbox *mbox, *ombox; struct nix *nix; int rc = 0; @@ -1077,7 +1086,10 @@ npc_vtag_cfg_delete(struct roc_npc *roc_npc, struct roc_npc_flow *flow) } tx_vtag_action; nix = roc_nix_to_nix_priv(roc_nix); - mbox = mbox_get((&nix->dev)->mbox); + ombox = (&nix->dev)->mbox; + if (flow->has_rep) + ombox = flow->rep_mbox; + mbox = mbox_get(ombox); tx_vtag_action.reg = flow->vtag_action; vtag_cfg = mbox_alloc_msg_nix_vtag_cfg(mbox); @@ -1328,6 +1340,8 @@ npc_vtag_action_program(struct roc_npc *roc_npc, nix = roc_nix_to_nix_priv(roc_nix); mbox = (&nix->dev)->mbox; + if (flow->has_rep) +
[dpdk-dev] [PATCH 1/2] common/cnxk: add support for rte flow item raw
From: Satheesh Paul Add roc API for rte_flow_item_raw to parse custom L2 and L3 protocols. Signed-off-by: Satheesh Paul Reviewed-by: Kiran Kumar Kokkilagadda --- drivers/common/cnxk/roc_mbox.h | 24 ++-- drivers/common/cnxk/roc_nix_ops.c | 14 + drivers/common/cnxk/roc_npc.h | 11 drivers/common/cnxk/roc_npc_parse.c | 86 +++-- drivers/common/cnxk/roc_npc_priv.h | 9 +-- drivers/common/cnxk/roc_npc_utils.c | 6 +- drivers/common/cnxk/roc_utils.c | 2 +- 7 files changed, 136 insertions(+), 16 deletions(-) diff --git a/drivers/common/cnxk/roc_mbox.h b/drivers/common/cnxk/roc_mbox.h index 9c529d754..b254f005a 100644 --- a/drivers/common/cnxk/roc_mbox.h +++ b/drivers/common/cnxk/roc_mbox.h @@ -278,14 +278,28 @@ struct ready_msg_rsp { uint16_t __io rclk_freq; /* RCLK frequency */ }; +enum npc_pkind_type { + NPC_RX_VLAN_EXDSA_PKIND = 56ULL, + NPC_RX_CHLEN24B_PKIND, + NPC_RX_CPT_HDR_PKIND, + NPC_RX_CHLEN90B_PKIND, + NPC_TX_HIGIG_PKIND, + NPC_RX_HIGIG_PKIND, + NPC_RX_EXDSA_PKIND, + NPC_RX_EDSA_PKIND, + NPC_TX_DEF_PKIND, +}; + /* Struct to set pkind */ struct npc_set_pkind { struct mbox_msghdr hdr; -#define ROC_PRIV_FLAGS_DEFAULT BIT_ULL(0) -#define ROC_PRIV_FLAGS_EDSABIT_ULL(1) -#define ROC_PRIV_FLAGS_HIGIG BIT_ULL(2) -#define ROC_PRIV_FLAGS_LEN_90B BIT_ULL(3) -#define ROC_PRIV_FLAGS_CUSTOM BIT_ULL(63) +#define ROC_PRIV_FLAGS_DEFAULT BIT_ULL(0) +#define ROC_PRIV_FLAGS_EDSA BIT_ULL(1) +#define ROC_PRIV_FLAGS_HIGIG BIT_ULL(2) +#define ROC_PRIV_FLAGS_LEN_90B BIT_ULL(3) +#define ROC_PRIV_FLAGS_EXDSA BIT_ULL(4) +#define ROC_PRIV_FLAGS_VLAN_EXDSA BIT_ULL(5) +#define ROC_PRIV_FLAGS_CUSTOMBIT_ULL(63) uint64_t __io mode; #define PKIND_TX BIT_ULL(0) #define PKIND_RX BIT_ULL(1) diff --git a/drivers/common/cnxk/roc_nix_ops.c b/drivers/common/cnxk/roc_nix_ops.c index eeb85a54f..0e28302e7 100644 --- a/drivers/common/cnxk/roc_nix_ops.c +++ b/drivers/common/cnxk/roc_nix_ops.c @@ -378,6 +378,8 @@ roc_nix_switch_hdr_set(struct roc_nix *roc_nix, uint64_t switch_header_type) switch_header_type != ROC_PRIV_FLAGS_EDSA && switch_header_type != ROC_PRIV_FLAGS_HIGIG && switch_header_type != ROC_PRIV_FLAGS_LEN_90B && + switch_header_type != ROC_PRIV_FLAGS_EXDSA && + switch_header_type != ROC_PRIV_FLAGS_VLAN_EXDSA && switch_header_type != ROC_PRIV_FLAGS_CUSTOM) { plt_err("switch header type is not supported"); return NIX_ERR_PARAM; @@ -399,6 +401,18 @@ roc_nix_switch_hdr_set(struct roc_nix *roc_nix, uint64_t switch_header_type) if (req == NULL) return rc; req->mode = switch_header_type; + + if (switch_header_type == ROC_PRIV_FLAGS_LEN_90B) { + req->mode = ROC_PRIV_FLAGS_CUSTOM; + req->pkind = NPC_RX_CHLEN90B_PKIND; + } else if (switch_header_type == ROC_PRIV_FLAGS_EXDSA) { + req->mode = ROC_PRIV_FLAGS_CUSTOM; + req->pkind = NPC_RX_EXDSA_PKIND; + } else if (switch_header_type == ROC_PRIV_FLAGS_VLAN_EXDSA) { + req->mode = ROC_PRIV_FLAGS_CUSTOM; + req->pkind = NPC_RX_VLAN_EXDSA_PKIND; + } + req->dir = PKIND_RX; rc = mbox_process_msg(mbox, (void *)&rsp); if (rc) diff --git a/drivers/common/cnxk/roc_npc.h b/drivers/common/cnxk/roc_npc.h index 2c0a536c9..bab25fd72 100644 --- a/drivers/common/cnxk/roc_npc.h +++ b/drivers/common/cnxk/roc_npc.h @@ -36,6 +36,7 @@ enum roc_npc_item_type { ROC_NPC_ITEM_TYPE_CPT_HDR, ROC_NPC_ITEM_TYPE_L3_CUSTOM, ROC_NPC_ITEM_TYPE_QINQ, + ROC_NPC_ITEM_TYPE_RAW, ROC_NPC_ITEM_TYPE_END, }; @@ -47,6 +48,16 @@ struct roc_npc_item_info { const void *last; /* For range */ }; +struct roc_npc_flow_item_raw { + uint32_t relative : 1; /**< Look for pattern after the previous item. */ + uint32_t search : 1; /**< Search pattern from offset. */ + uint32_t reserved : 30; /**< Reserved, must be set to zero. */ + int32_t offset; /**< Absolute or relative offset for pattern. */ + uint16_t limit; /**< Search area limit for start of pattern. */ + uint16_t length;/**< Pattern length. */ + const uint8_t *pattern; /**< Byte string to look for. */ +}; + #define ROC_NPC_MAX_ACTION_COUNT 12 enum roc_npc_action_type { diff --git a/drivers/common/cnxk/roc_npc_parse.c b/drivers/common/cnxk/roc_npc_parse.c index d07f91db3..8125035dd 100644 --- a/drivers/common/cnxk/roc_npc_parse.c +++ b/drivers/common/cnxk/roc_npc_parse.c @@ -136,14 +136,46 @@ npc_parse_la(struct npc_parse_state *pst) return npc_update_parse_state(pst, &info, lid, lt, 0); } +static int +npc_flow_raw_item_prepare(const struct roc_npc_flow_item_raw *raw_spec, + const struct roc_npc_flow_item_
[dpdk-dev] [PATCH 2/2] net/cnxk: add support for rte flow item raw
From: Satheesh Paul Add support for rte_flow_item_raw to parse custom L2 and L3 protocols. Signed-off-by: Satheesh Paul Reviewed-by: Kiran Kumar Kokkilagadda --- doc/guides/nics/cnxk.rst | 169 +++-- drivers/net/cnxk/cnxk_ethdev_devargs.c | 7 + drivers/net/cnxk/cnxk_rte_flow.c | 12 +- 3 files changed, 172 insertions(+), 16 deletions(-) diff --git a/doc/guides/nics/cnxk.rst b/doc/guides/nics/cnxk.rst index cb2a51e1d..a7b59a48e 100644 --- a/doc/guides/nics/cnxk.rst +++ b/doc/guides/nics/cnxk.rst @@ -104,7 +104,7 @@ Runtime Config Options - ``Rx&Tx scalar mode enable`` (default ``0``) - PMD supports both scalar and vector mode, it may be selected at runtime + Ethdev supports both scalar and vector mode, it may be selected at runtime using ``scalar_enable`` ``devargs`` parameter. - ``RSS reta size`` (default ``64``) @@ -151,7 +151,7 @@ Runtime Config Options -a 0002:02:00.0,max_sqb_count=64 - With the above configuration, each send queue's descriptor buffer count is + With the above configuration, each send queue's decscriptor buffer count is limited to a maximum of 64 buffers. - ``Switch header enable`` (default ``none``) @@ -165,7 +165,7 @@ Runtime Config Options With the above configuration, higig2 will be enabled on that port and the traffic on this port should be higig2 traffic only. Supported switch header - types are "higig2", "dsa", "chlen90b" and "chlen24b". + types are "chlen24b", "chlen90b", "dsa", "exdsa", "higig2" and "vlan_exdsa". - ``RSS tag as XOR`` (default ``0``) @@ -186,6 +186,7 @@ Runtime Config Options -a 0002:02:00.0,tag_as_xor=1 + .. note:: Above devarg parameters are configurable per device, user needs to pass the @@ -196,7 +197,7 @@ Limitations --- ``mempool_cnxk`` external mempool handler dependency - +~ The OCTEON CN9K/CN10K SoC family NIC has inbuilt HW assisted external mempool manager. ``net_cnxk`` pmd only works with ``mempool_cnxk`` mempool handler @@ -209,12 +210,6 @@ CRC stripping The OCTEON CN9K/CN10K SoC family NICs strip the CRC for every packet being received by the host interface irrespective of the offload configuration. -RTE flow GRE support - - -- ``RTE_FLOW_ITEM_TYPE_GRE_KEY`` works only when checksum and routing - bits in the GRE header are equal to 0. - Debugging Options - @@ -229,3 +224,157 @@ Debugging Options +---++---+ | 2 | NPC| --log-level='pmd\.net.cnxk\.flow,8' | +---++---+ + +RTE Flow Support + + +The OCTEON CN9K/CN10K SoC family NIC has support for the following patterns and +actions. + +Patterns: + +.. _table_cnxk_supported_flow_item_types: + +.. table:: Item types + + +++ + | # | Pattern Type | + +++ + | 1 | RTE_FLOW_ITEM_TYPE_ETH | + +++ + | 2 | RTE_FLOW_ITEM_TYPE_VLAN| + +++ + | 3 | RTE_FLOW_ITEM_TYPE_E_TAG | + +++ + | 4 | RTE_FLOW_ITEM_TYPE_IPV4| + +++ + | 5 | RTE_FLOW_ITEM_TYPE_IPV6| + +++ + | 6 | RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4| + +++ + | 7 | RTE_FLOW_ITEM_TYPE_MPLS| + +++ + | 8 | RTE_FLOW_ITEM_TYPE_ICMP| + +++ + | 9 | RTE_FLOW_ITEM_TYPE_UDP | + +++ + | 10 | RTE_FLOW_ITEM_TYPE_TCP | + +++ + | 11 | RTE_FLOW_ITEM_TYPE_SCTP| + +++ + | 12 | RTE_FLOW_ITEM_TYPE_ESP | + +++ + | 13 | RTE_FLOW_ITEM_TYPE_GRE | + +++ + | 14 | RTE_FLOW_ITEM_TYPE_NVGRE | + +++ + | 15 | RTE_FLOW_ITEM_TYPE_VXLAN | + +++ + | 16 | RTE_FLOW_ITEM_TYPE_GTPC| + +++ + | 17 | RTE_FLOW_ITEM_TYPE_GTPU| + +++ + | 18 | RTE_FLOW_ITEM_TYPE_GENEVE | + +++ + | 19 | RTE_FLOW_ITEM_TYPE_VXLAN_GPE | + +++ + | 20 | RTE_FLOW_ITEM_TYPE_IPV6_EXT| + +++ + | 21 | RTE_FLOW_ITEM_TYPE_VOID| + ++-
[dpdk-dev] [PATCH] net/cnxk: fix default MCAM allocation size
From: Satheesh Paul Preallocation of MCAM entries is not valid anymore since the AF side MCAM allocation scheme has changed. This patch disables preallocation by changing the default MCAM preallocation size from 8 to 1. Fixes: 168c59cfe42 ("net/octeontx2: add flow MCAM utility functions") Signed-off-by: Satheesh Paul --- drivers/net/cnxk/cnxk_ethdev_devargs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/cnxk/cnxk_ethdev_devargs.c b/drivers/net/cnxk/cnxk_ethdev_devargs.c index c76b6281c..7f20e9228 100644 --- a/drivers/net/cnxk/cnxk_ethdev_devargs.c +++ b/drivers/net/cnxk/cnxk_ethdev_devargs.c @@ -116,7 +116,7 @@ cnxk_ethdev_parse_devargs(struct rte_devargs *devargs, struct cnxk_eth_dev *dev) { uint16_t reta_sz = ROC_NIX_RSS_RETA_SZ_64; uint16_t sqb_count = CNXK_NIX_TX_MAX_SQB; - uint16_t flow_prealloc_size = 8; + uint16_t flow_prealloc_size = 1; uint16_t switch_header_type = 0; uint16_t flow_max_priority = 3; uint16_t rss_tag_as_xor = 0; -- 2.25.4
[dpdk-dev] [PATCH v2 1/2] common/cnxk: add support for rte flow item raw
From: Satheesh Paul Add roc API for rte_flow_item_raw to parse custom L2 and L3 protocols. Signed-off-by: Satheesh Paul Reviewed-by: Kiran Kumar Kokkilagadda --- drivers/common/cnxk/roc_mbox.h | 24 ++-- drivers/common/cnxk/roc_nix_ops.c | 14 + drivers/common/cnxk/roc_npc.h | 11 drivers/common/cnxk/roc_npc_parse.c | 86 +++-- drivers/common/cnxk/roc_npc_priv.h | 9 +-- drivers/common/cnxk/roc_npc_utils.c | 6 +- drivers/common/cnxk/roc_utils.c | 2 +- 7 files changed, 136 insertions(+), 16 deletions(-) diff --git a/drivers/common/cnxk/roc_mbox.h b/drivers/common/cnxk/roc_mbox.h index 9c529d754..b254f005a 100644 --- a/drivers/common/cnxk/roc_mbox.h +++ b/drivers/common/cnxk/roc_mbox.h @@ -278,14 +278,28 @@ struct ready_msg_rsp { uint16_t __io rclk_freq; /* RCLK frequency */ }; +enum npc_pkind_type { + NPC_RX_VLAN_EXDSA_PKIND = 56ULL, + NPC_RX_CHLEN24B_PKIND, + NPC_RX_CPT_HDR_PKIND, + NPC_RX_CHLEN90B_PKIND, + NPC_TX_HIGIG_PKIND, + NPC_RX_HIGIG_PKIND, + NPC_RX_EXDSA_PKIND, + NPC_RX_EDSA_PKIND, + NPC_TX_DEF_PKIND, +}; + /* Struct to set pkind */ struct npc_set_pkind { struct mbox_msghdr hdr; -#define ROC_PRIV_FLAGS_DEFAULT BIT_ULL(0) -#define ROC_PRIV_FLAGS_EDSABIT_ULL(1) -#define ROC_PRIV_FLAGS_HIGIG BIT_ULL(2) -#define ROC_PRIV_FLAGS_LEN_90B BIT_ULL(3) -#define ROC_PRIV_FLAGS_CUSTOM BIT_ULL(63) +#define ROC_PRIV_FLAGS_DEFAULT BIT_ULL(0) +#define ROC_PRIV_FLAGS_EDSA BIT_ULL(1) +#define ROC_PRIV_FLAGS_HIGIG BIT_ULL(2) +#define ROC_PRIV_FLAGS_LEN_90B BIT_ULL(3) +#define ROC_PRIV_FLAGS_EXDSA BIT_ULL(4) +#define ROC_PRIV_FLAGS_VLAN_EXDSA BIT_ULL(5) +#define ROC_PRIV_FLAGS_CUSTOMBIT_ULL(63) uint64_t __io mode; #define PKIND_TX BIT_ULL(0) #define PKIND_RX BIT_ULL(1) diff --git a/drivers/common/cnxk/roc_nix_ops.c b/drivers/common/cnxk/roc_nix_ops.c index eeb85a54f..0e28302e7 100644 --- a/drivers/common/cnxk/roc_nix_ops.c +++ b/drivers/common/cnxk/roc_nix_ops.c @@ -378,6 +378,8 @@ roc_nix_switch_hdr_set(struct roc_nix *roc_nix, uint64_t switch_header_type) switch_header_type != ROC_PRIV_FLAGS_EDSA && switch_header_type != ROC_PRIV_FLAGS_HIGIG && switch_header_type != ROC_PRIV_FLAGS_LEN_90B && + switch_header_type != ROC_PRIV_FLAGS_EXDSA && + switch_header_type != ROC_PRIV_FLAGS_VLAN_EXDSA && switch_header_type != ROC_PRIV_FLAGS_CUSTOM) { plt_err("switch header type is not supported"); return NIX_ERR_PARAM; @@ -399,6 +401,18 @@ roc_nix_switch_hdr_set(struct roc_nix *roc_nix, uint64_t switch_header_type) if (req == NULL) return rc; req->mode = switch_header_type; + + if (switch_header_type == ROC_PRIV_FLAGS_LEN_90B) { + req->mode = ROC_PRIV_FLAGS_CUSTOM; + req->pkind = NPC_RX_CHLEN90B_PKIND; + } else if (switch_header_type == ROC_PRIV_FLAGS_EXDSA) { + req->mode = ROC_PRIV_FLAGS_CUSTOM; + req->pkind = NPC_RX_EXDSA_PKIND; + } else if (switch_header_type == ROC_PRIV_FLAGS_VLAN_EXDSA) { + req->mode = ROC_PRIV_FLAGS_CUSTOM; + req->pkind = NPC_RX_VLAN_EXDSA_PKIND; + } + req->dir = PKIND_RX; rc = mbox_process_msg(mbox, (void *)&rsp); if (rc) diff --git a/drivers/common/cnxk/roc_npc.h b/drivers/common/cnxk/roc_npc.h index 2c0a536c9..bab25fd72 100644 --- a/drivers/common/cnxk/roc_npc.h +++ b/drivers/common/cnxk/roc_npc.h @@ -36,6 +36,7 @@ enum roc_npc_item_type { ROC_NPC_ITEM_TYPE_CPT_HDR, ROC_NPC_ITEM_TYPE_L3_CUSTOM, ROC_NPC_ITEM_TYPE_QINQ, + ROC_NPC_ITEM_TYPE_RAW, ROC_NPC_ITEM_TYPE_END, }; @@ -47,6 +48,16 @@ struct roc_npc_item_info { const void *last; /* For range */ }; +struct roc_npc_flow_item_raw { + uint32_t relative : 1; /**< Look for pattern after the previous item. */ + uint32_t search : 1; /**< Search pattern from offset. */ + uint32_t reserved : 30; /**< Reserved, must be set to zero. */ + int32_t offset; /**< Absolute or relative offset for pattern. */ + uint16_t limit; /**< Search area limit for start of pattern. */ + uint16_t length;/**< Pattern length. */ + const uint8_t *pattern; /**< Byte string to look for. */ +}; + #define ROC_NPC_MAX_ACTION_COUNT 12 enum roc_npc_action_type { diff --git a/drivers/common/cnxk/roc_npc_parse.c b/drivers/common/cnxk/roc_npc_parse.c index d07f91db3..8125035dd 100644 --- a/drivers/common/cnxk/roc_npc_parse.c +++ b/drivers/common/cnxk/roc_npc_parse.c @@ -136,14 +136,46 @@ npc_parse_la(struct npc_parse_state *pst) return npc_update_parse_state(pst, &info, lid, lt, 0); } +static int +npc_flow_raw_item_prepare(const struct roc_npc_flow_item_raw *raw_spec, + const struct roc_npc_flow_item_
[dpdk-dev] [PATCH v2 2/2] net/cnxk: add support for rte flow item raw
From: Satheesh Paul Add support for rte_flow_item_raw to parse custom L2 and L3 protocols. Signed-off-by: Satheesh Paul Reviewed-by: Kiran Kumar Kokkilagadda --- doc/guides/nics/cnxk.rst | 37 +- drivers/net/cnxk/cnxk_ethdev_devargs.c | 7 + drivers/net/cnxk/cnxk_rte_flow.c | 12 - 3 files changed, 49 insertions(+), 7 deletions(-) diff --git a/doc/guides/nics/cnxk.rst b/doc/guides/nics/cnxk.rst index cb2a51e1d..90d27dbaa 100644 --- a/doc/guides/nics/cnxk.rst +++ b/doc/guides/nics/cnxk.rst @@ -165,7 +165,7 @@ Runtime Config Options With the above configuration, higig2 will be enabled on that port and the traffic on this port should be higig2 traffic only. Supported switch header - types are "higig2", "dsa", "chlen90b" and "chlen24b". + types are "chlen24b", "chlen90b", "dsa", "exdsa", "higig2" and "vlan_exdsa". - ``RSS tag as XOR`` (default ``0``) @@ -215,6 +215,41 @@ RTE flow GRE support - ``RTE_FLOW_ITEM_TYPE_GRE_KEY`` works only when checksum and routing bits in the GRE header are equal to 0. +Custom protocols supported in RTE Flow +~~ + +The ``RTE_FLOW_ITEM_TYPE_RAW`` can be used to parse the below custom protocols. + +* ``vlan_exdsa`` and ``exdsa`` can be parsed at L2 level. +* ``NGIO`` can be parsed at L3 level. + +For ``vlan_exdsa`` and ``exdsa``, the port has to be configured with the +respective switch header. + +For example:: + + -a 0002:02:00.0,switch_header="vlan_exdsa" + +The below fields of ``struct rte_flow_item_raw`` shall be used to specify the +pattern. + +- ``relative`` Selects the layer at which parsing is done. + + - 0 for ``exdsa`` and ``vlan_exdsa``. + + - 1 for ``NGIO``. + +- ``offset`` The offset in the header where the pattern should be matched. +- ``length`` Length of the pattern. +- ``pattern`` Pattern as a byte string. + +Example usage in testpmd:: + + ./dpdk-testpmd -c 3 -w 0002:02:00.0,switch_header=exdsa -- -i \ + --rx-offloads=0x0008 --rxq 8 --txq 8 + testpmd> flow create 0 ingress pattern eth / raw relative is 0 pattern \ + spec ab pattern mask ab offset is 4 / end actions queue index 1 / end + Debugging Options - diff --git a/drivers/net/cnxk/cnxk_ethdev_devargs.c b/drivers/net/cnxk/cnxk_ethdev_devargs.c index c76b6281c..36b437a18 100644 --- a/drivers/net/cnxk/cnxk_ethdev_devargs.c +++ b/drivers/net/cnxk/cnxk_ethdev_devargs.c @@ -99,6 +99,13 @@ parse_switch_header_type(const char *key, const char *value, void *extra_args) if (strcmp(value, "chlen90b") == 0) *(uint16_t *)extra_args = ROC_PRIV_FLAGS_LEN_90B; + + if (strcmp(value, "exdsa") == 0) + *(uint16_t *)extra_args = ROC_PRIV_FLAGS_EXDSA; + + if (strcmp(value, "vlan_exdsa") == 0) + *(uint16_t *)extra_args = ROC_PRIV_FLAGS_VLAN_EXDSA; + return 0; } diff --git a/drivers/net/cnxk/cnxk_rte_flow.c b/drivers/net/cnxk/cnxk_rte_flow.c index 213125b56..32c1b5dee 100644 --- a/drivers/net/cnxk/cnxk_rte_flow.c +++ b/drivers/net/cnxk/cnxk_rte_flow.c @@ -15,8 +15,8 @@ const struct cnxk_rte_flow_term_info term[] = { [RTE_FLOW_ITEM_TYPE_IPV6] = {ROC_NPC_ITEM_TYPE_IPV6, sizeof(struct rte_flow_item_ipv6)}, [RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4] = { - ROC_NPC_ITEM_TYPE_ARP_ETH_IPV4, - sizeof(struct rte_flow_item_arp_eth_ipv4)}, + ROC_NPC_ITEM_TYPE_ARP_ETH_IPV4, + sizeof(struct rte_flow_item_arp_eth_ipv4)}, [RTE_FLOW_ITEM_TYPE_MPLS] = {ROC_NPC_ITEM_TYPE_MPLS, sizeof(struct rte_flow_item_mpls)}, [RTE_FLOW_ITEM_TYPE_ICMP] = {ROC_NPC_ITEM_TYPE_ICMP, @@ -50,10 +50,10 @@ const struct cnxk_rte_flow_term_info term[] = { [RTE_FLOW_ITEM_TYPE_ANY] = {ROC_NPC_ITEM_TYPE_ANY, 0}, [RTE_FLOW_ITEM_TYPE_GRE_KEY] = {ROC_NPC_ITEM_TYPE_GRE_KEY, sizeof(uint32_t)}, - [RTE_FLOW_ITEM_TYPE_HIGIG2] = { - ROC_NPC_ITEM_TYPE_HIGIG2, - sizeof(struct rte_flow_item_higig2_hdr)} -}; + [RTE_FLOW_ITEM_TYPE_HIGIG2] = {ROC_NPC_ITEM_TYPE_HIGIG2, + sizeof(struct rte_flow_item_higig2_hdr)}, + [RTE_FLOW_ITEM_TYPE_RAW] = {ROC_NPC_ITEM_TYPE_RAW, + sizeof(struct rte_flow_item_raw)}}; static int npc_rss_action_validate(struct rte_eth_dev *eth_dev, -- 2.25.4
[dpdk-dev] [PATCH v2 1/2] common/cnxk: add support for rte flow item raw
From: Satheesh Paul Add roc API for rte_flow_item_raw to parse custom L2 and L3 protocols. Signed-off-by: Satheesh Paul Reviewed-by: Kiran Kumar Kokkilagadda --- drivers/common/cnxk/roc_mbox.h | 24 ++-- drivers/common/cnxk/roc_nix_ops.c | 14 + drivers/common/cnxk/roc_npc.h | 11 drivers/common/cnxk/roc_npc_parse.c | 86 +++-- drivers/common/cnxk/roc_npc_priv.h | 9 +-- drivers/common/cnxk/roc_npc_utils.c | 6 +- drivers/common/cnxk/roc_utils.c | 2 +- 7 files changed, 136 insertions(+), 16 deletions(-) diff --git a/drivers/common/cnxk/roc_mbox.h b/drivers/common/cnxk/roc_mbox.h index 9c529d754..b254f005a 100644 --- a/drivers/common/cnxk/roc_mbox.h +++ b/drivers/common/cnxk/roc_mbox.h @@ -278,14 +278,28 @@ struct ready_msg_rsp { uint16_t __io rclk_freq; /* RCLK frequency */ }; +enum npc_pkind_type { + NPC_RX_VLAN_EXDSA_PKIND = 56ULL, + NPC_RX_CHLEN24B_PKIND, + NPC_RX_CPT_HDR_PKIND, + NPC_RX_CHLEN90B_PKIND, + NPC_TX_HIGIG_PKIND, + NPC_RX_HIGIG_PKIND, + NPC_RX_EXDSA_PKIND, + NPC_RX_EDSA_PKIND, + NPC_TX_DEF_PKIND, +}; + /* Struct to set pkind */ struct npc_set_pkind { struct mbox_msghdr hdr; -#define ROC_PRIV_FLAGS_DEFAULT BIT_ULL(0) -#define ROC_PRIV_FLAGS_EDSABIT_ULL(1) -#define ROC_PRIV_FLAGS_HIGIG BIT_ULL(2) -#define ROC_PRIV_FLAGS_LEN_90B BIT_ULL(3) -#define ROC_PRIV_FLAGS_CUSTOM BIT_ULL(63) +#define ROC_PRIV_FLAGS_DEFAULT BIT_ULL(0) +#define ROC_PRIV_FLAGS_EDSA BIT_ULL(1) +#define ROC_PRIV_FLAGS_HIGIG BIT_ULL(2) +#define ROC_PRIV_FLAGS_LEN_90B BIT_ULL(3) +#define ROC_PRIV_FLAGS_EXDSA BIT_ULL(4) +#define ROC_PRIV_FLAGS_VLAN_EXDSA BIT_ULL(5) +#define ROC_PRIV_FLAGS_CUSTOMBIT_ULL(63) uint64_t __io mode; #define PKIND_TX BIT_ULL(0) #define PKIND_RX BIT_ULL(1) diff --git a/drivers/common/cnxk/roc_nix_ops.c b/drivers/common/cnxk/roc_nix_ops.c index eeb85a54f..0e28302e7 100644 --- a/drivers/common/cnxk/roc_nix_ops.c +++ b/drivers/common/cnxk/roc_nix_ops.c @@ -378,6 +378,8 @@ roc_nix_switch_hdr_set(struct roc_nix *roc_nix, uint64_t switch_header_type) switch_header_type != ROC_PRIV_FLAGS_EDSA && switch_header_type != ROC_PRIV_FLAGS_HIGIG && switch_header_type != ROC_PRIV_FLAGS_LEN_90B && + switch_header_type != ROC_PRIV_FLAGS_EXDSA && + switch_header_type != ROC_PRIV_FLAGS_VLAN_EXDSA && switch_header_type != ROC_PRIV_FLAGS_CUSTOM) { plt_err("switch header type is not supported"); return NIX_ERR_PARAM; @@ -399,6 +401,18 @@ roc_nix_switch_hdr_set(struct roc_nix *roc_nix, uint64_t switch_header_type) if (req == NULL) return rc; req->mode = switch_header_type; + + if (switch_header_type == ROC_PRIV_FLAGS_LEN_90B) { + req->mode = ROC_PRIV_FLAGS_CUSTOM; + req->pkind = NPC_RX_CHLEN90B_PKIND; + } else if (switch_header_type == ROC_PRIV_FLAGS_EXDSA) { + req->mode = ROC_PRIV_FLAGS_CUSTOM; + req->pkind = NPC_RX_EXDSA_PKIND; + } else if (switch_header_type == ROC_PRIV_FLAGS_VLAN_EXDSA) { + req->mode = ROC_PRIV_FLAGS_CUSTOM; + req->pkind = NPC_RX_VLAN_EXDSA_PKIND; + } + req->dir = PKIND_RX; rc = mbox_process_msg(mbox, (void *)&rsp); if (rc) diff --git a/drivers/common/cnxk/roc_npc.h b/drivers/common/cnxk/roc_npc.h index 2c0a536c9..bab25fd72 100644 --- a/drivers/common/cnxk/roc_npc.h +++ b/drivers/common/cnxk/roc_npc.h @@ -36,6 +36,7 @@ enum roc_npc_item_type { ROC_NPC_ITEM_TYPE_CPT_HDR, ROC_NPC_ITEM_TYPE_L3_CUSTOM, ROC_NPC_ITEM_TYPE_QINQ, + ROC_NPC_ITEM_TYPE_RAW, ROC_NPC_ITEM_TYPE_END, }; @@ -47,6 +48,16 @@ struct roc_npc_item_info { const void *last; /* For range */ }; +struct roc_npc_flow_item_raw { + uint32_t relative : 1; /**< Look for pattern after the previous item. */ + uint32_t search : 1; /**< Search pattern from offset. */ + uint32_t reserved : 30; /**< Reserved, must be set to zero. */ + int32_t offset; /**< Absolute or relative offset for pattern. */ + uint16_t limit; /**< Search area limit for start of pattern. */ + uint16_t length;/**< Pattern length. */ + const uint8_t *pattern; /**< Byte string to look for. */ +}; + #define ROC_NPC_MAX_ACTION_COUNT 12 enum roc_npc_action_type { diff --git a/drivers/common/cnxk/roc_npc_parse.c b/drivers/common/cnxk/roc_npc_parse.c index d07f91db3..8125035dd 100644 --- a/drivers/common/cnxk/roc_npc_parse.c +++ b/drivers/common/cnxk/roc_npc_parse.c @@ -136,14 +136,46 @@ npc_parse_la(struct npc_parse_state *pst) return npc_update_parse_state(pst, &info, lid, lt, 0); } +static int +npc_flow_raw_item_prepare(const struct roc_npc_flow_item_raw *raw_spec, + const struct roc_npc_flow_item_
[dpdk-dev] [PATCH v2 2/2] net/cnxk: add support for rte flow item raw
From: Satheesh Paul Add support for rte_flow_item_raw to parse custom L2 and L3 protocols. Signed-off-by: Satheesh Paul Reviewed-by: Kiran Kumar Kokkilagadda --- doc/guides/nics/cnxk.rst | 37 +- drivers/net/cnxk/cnxk_ethdev_devargs.c | 7 + drivers/net/cnxk/cnxk_rte_flow.c | 12 - 3 files changed, 49 insertions(+), 7 deletions(-) diff --git a/doc/guides/nics/cnxk.rst b/doc/guides/nics/cnxk.rst index cb2a51e1d..90d27dbaa 100644 --- a/doc/guides/nics/cnxk.rst +++ b/doc/guides/nics/cnxk.rst @@ -165,7 +165,7 @@ Runtime Config Options With the above configuration, higig2 will be enabled on that port and the traffic on this port should be higig2 traffic only. Supported switch header - types are "higig2", "dsa", "chlen90b" and "chlen24b". + types are "chlen24b", "chlen90b", "dsa", "exdsa", "higig2" and "vlan_exdsa". - ``RSS tag as XOR`` (default ``0``) @@ -215,6 +215,41 @@ RTE flow GRE support - ``RTE_FLOW_ITEM_TYPE_GRE_KEY`` works only when checksum and routing bits in the GRE header are equal to 0. +Custom protocols supported in RTE Flow +~~ + +The ``RTE_FLOW_ITEM_TYPE_RAW`` can be used to parse the below custom protocols. + +* ``vlan_exdsa`` and ``exdsa`` can be parsed at L2 level. +* ``NGIO`` can be parsed at L3 level. + +For ``vlan_exdsa`` and ``exdsa``, the port has to be configured with the +respective switch header. + +For example:: + + -a 0002:02:00.0,switch_header="vlan_exdsa" + +The below fields of ``struct rte_flow_item_raw`` shall be used to specify the +pattern. + +- ``relative`` Selects the layer at which parsing is done. + + - 0 for ``exdsa`` and ``vlan_exdsa``. + + - 1 for ``NGIO``. + +- ``offset`` The offset in the header where the pattern should be matched. +- ``length`` Length of the pattern. +- ``pattern`` Pattern as a byte string. + +Example usage in testpmd:: + + ./dpdk-testpmd -c 3 -w 0002:02:00.0,switch_header=exdsa -- -i \ + --rx-offloads=0x0008 --rxq 8 --txq 8 + testpmd> flow create 0 ingress pattern eth / raw relative is 0 pattern \ + spec ab pattern mask ab offset is 4 / end actions queue index 1 / end + Debugging Options - diff --git a/drivers/net/cnxk/cnxk_ethdev_devargs.c b/drivers/net/cnxk/cnxk_ethdev_devargs.c index c76b6281c..36b437a18 100644 --- a/drivers/net/cnxk/cnxk_ethdev_devargs.c +++ b/drivers/net/cnxk/cnxk_ethdev_devargs.c @@ -99,6 +99,13 @@ parse_switch_header_type(const char *key, const char *value, void *extra_args) if (strcmp(value, "chlen90b") == 0) *(uint16_t *)extra_args = ROC_PRIV_FLAGS_LEN_90B; + + if (strcmp(value, "exdsa") == 0) + *(uint16_t *)extra_args = ROC_PRIV_FLAGS_EXDSA; + + if (strcmp(value, "vlan_exdsa") == 0) + *(uint16_t *)extra_args = ROC_PRIV_FLAGS_VLAN_EXDSA; + return 0; } diff --git a/drivers/net/cnxk/cnxk_rte_flow.c b/drivers/net/cnxk/cnxk_rte_flow.c index 213125b56..32c1b5dee 100644 --- a/drivers/net/cnxk/cnxk_rte_flow.c +++ b/drivers/net/cnxk/cnxk_rte_flow.c @@ -15,8 +15,8 @@ const struct cnxk_rte_flow_term_info term[] = { [RTE_FLOW_ITEM_TYPE_IPV6] = {ROC_NPC_ITEM_TYPE_IPV6, sizeof(struct rte_flow_item_ipv6)}, [RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4] = { - ROC_NPC_ITEM_TYPE_ARP_ETH_IPV4, - sizeof(struct rte_flow_item_arp_eth_ipv4)}, + ROC_NPC_ITEM_TYPE_ARP_ETH_IPV4, + sizeof(struct rte_flow_item_arp_eth_ipv4)}, [RTE_FLOW_ITEM_TYPE_MPLS] = {ROC_NPC_ITEM_TYPE_MPLS, sizeof(struct rte_flow_item_mpls)}, [RTE_FLOW_ITEM_TYPE_ICMP] = {ROC_NPC_ITEM_TYPE_ICMP, @@ -50,10 +50,10 @@ const struct cnxk_rte_flow_term_info term[] = { [RTE_FLOW_ITEM_TYPE_ANY] = {ROC_NPC_ITEM_TYPE_ANY, 0}, [RTE_FLOW_ITEM_TYPE_GRE_KEY] = {ROC_NPC_ITEM_TYPE_GRE_KEY, sizeof(uint32_t)}, - [RTE_FLOW_ITEM_TYPE_HIGIG2] = { - ROC_NPC_ITEM_TYPE_HIGIG2, - sizeof(struct rte_flow_item_higig2_hdr)} -}; + [RTE_FLOW_ITEM_TYPE_HIGIG2] = {ROC_NPC_ITEM_TYPE_HIGIG2, + sizeof(struct rte_flow_item_higig2_hdr)}, + [RTE_FLOW_ITEM_TYPE_RAW] = {ROC_NPC_ITEM_TYPE_RAW, + sizeof(struct rte_flow_item_raw)}}; static int npc_rss_action_validate(struct rte_eth_dev *eth_dev, -- 2.25.4
[dpdk-dev] [PATCH v2] common/cnxk: add ROC API to free MCAM entry
From: Satheesh Paul Add ROC API to free the given MCAM entry. If the MCAM entry has flow counter associated, this API will clear and free the flow counter. Signed-off-by: Satheesh Paul Reviewed-by: Jerin Jacob --- v2: * Removed unnecessary variable initialization drivers/common/cnxk/roc_npc.c | 63 +++-- drivers/common/cnxk/roc_npc.h | 7 drivers/common/cnxk/roc_npc_mcam.c | 39 ++ drivers/common/cnxk/roc_npc_priv.h | 2 + drivers/common/cnxk/roc_npc_utils.c | 15 +++ drivers/common/cnxk/version.map | 3 ++ 6 files changed, 100 insertions(+), 29 deletions(-) diff --git a/drivers/common/cnxk/roc_npc.c b/drivers/common/cnxk/roc_npc.c index da5b96242e..b38389b18a 100644 --- a/drivers/common/cnxk/roc_npc.c +++ b/drivers/common/cnxk/roc_npc.c @@ -55,6 +55,53 @@ roc_npc_mcam_free_entry(struct roc_npc *roc_npc, uint32_t entry) return npc_mcam_free_entry(npc, entry); } +int +roc_npc_mcam_free(struct roc_npc *roc_npc, struct roc_npc_flow *mcam) +{ + int rc = 0; + + if (mcam->use_ctr) { + rc = roc_npc_mcam_clear_counter(roc_npc, mcam->ctr_id); + if (rc) + return rc; + + rc = roc_npc_mcam_free_counter(roc_npc, mcam->ctr_id); + if (rc) + return rc; + } + + return roc_npc_mcam_free_entry(roc_npc, mcam->mcam_id); +} + +int +roc_npc_mcam_init(struct roc_npc *roc_npc, struct roc_npc_flow *flow, + int mcam_id) +{ + struct npc *npc = roc_npc_to_npc_priv(roc_npc); + int rc; + + rc = npc_mcam_init(npc, flow, mcam_id); + if (rc != 0) { + plt_err("npc: mcam initialisation write failed"); + return rc; + } + return 0; +} + +int +roc_npc_mcam_move(struct roc_npc *roc_npc, uint16_t old_ent, uint16_t new_ent) +{ + struct npc *npc = roc_npc_to_npc_priv(roc_npc); + struct mbox *mbox = npc->mbox; + int rc; + + rc = npc_mcam_move(mbox, old_ent, new_ent); + if (rc) + return rc; + + return 0; +} + int roc_npc_mcam_free_all_resources(struct roc_npc *roc_npc) { @@ -383,7 +430,7 @@ npc_parse_actions(struct roc_npc *roc_npc, const struct roc_npc_attr *attr, case ROC_NPC_ACTION_TYPE_COUNT: /* Indicates, need a counter */ - flow->ctr_id = 1; + flow->use_ctr = 1; req_act |= ROC_NPC_ACTION_TYPE_COUNT; break; @@ -1268,7 +1315,7 @@ roc_npc_flow_create(struct roc_npc *roc_npc, const struct roc_npc_attr *attr, return flow; set_rss_failed: - rc = npc_mcam_free_entry(npc, flow->mcam_id); + rc = roc_npc_mcam_free_entry(roc_npc, flow->mcam_id); if (rc != 0) { *errcode = rc; plt_free(flow); @@ -1314,17 +1361,7 @@ roc_npc_flow_destroy(struct roc_npc *roc_npc, struct roc_npc_flow *flow) return rc; } - if (flow->ctr_id != NPC_COUNTER_NONE) { - rc = roc_npc_mcam_clear_counter(roc_npc, flow->ctr_id); - if (rc != 0) - return rc; - - rc = npc_mcam_free_counter(npc, flow->ctr_id); - if (rc != 0) - return rc; - } - - rc = npc_mcam_free_entry(npc, flow->mcam_id); + rc = roc_npc_mcam_free(roc_npc, flow); if (rc != 0) return rc; diff --git a/drivers/common/cnxk/roc_npc.h b/drivers/common/cnxk/roc_npc.h index f92c2a633c..1b4e5521cb 100644 --- a/drivers/common/cnxk/roc_npc.h +++ b/drivers/common/cnxk/roc_npc.h @@ -246,6 +246,7 @@ struct roc_npc_flow { uint8_t nix_intf; uint8_t enable; uint32_t mcam_id; + uint8_t use_ctr; int32_t ctr_id; uint32_t priority; uint32_t mtr_id; @@ -329,6 +330,8 @@ roc_npc_flow_create(struct roc_npc *roc_npc, const struct roc_npc_attr *attr, const struct roc_npc_action actions[], int *errcode); int __roc_api roc_npc_flow_destroy(struct roc_npc *roc_npc, struct roc_npc_flow *flow); +int __roc_api roc_npc_mcam_free(struct roc_npc *roc_npc, + struct roc_npc_flow *mcam); int __roc_api roc_npc_mcam_free_entry(struct roc_npc *roc_npc, uint32_t entry); int __roc_api roc_npc_mcam_enable_all_entries(struct roc_npc *roc_npc, bool enable); @@ -367,4 +370,8 @@ int __roc_api roc_npc_mcam_merge_base_steering_rule(struct roc_npc *roc_npc, struct roc_npc_flow *flow); int __roc_api roc_npc_validate_portid_action(struct roc_npc *roc_npc_src, struct roc_npc *roc_npc_dst); +int __roc_api roc_npc_mcam_init(struct roc_npc *roc_npc, +
[dpdk-dev] [PATCH v4] examples/ipsec-secgw: support more flow patterns and actions
From: Satheesh Paul Added support to create flow rules with count, mark and security actions and mark pattern. Signed-off-by: Satheesh Paul --- v4: * Added more description in documenation for flow rule options. v3: * Fixed IPv4 and IPv6 dst addr setting in flow pattern spec v2: * Updated documentation in ipsec_secgw.rst doc/guides/sample_app_ug/ipsec_secgw.rst | 63 +- examples/ipsec-secgw/flow.c | 276 +++ examples/ipsec-secgw/flow.h | 1 + examples/ipsec-secgw/ipsec-secgw.c | 3 +- 4 files changed, 291 insertions(+), 52 deletions(-) diff --git a/doc/guides/sample_app_ug/ipsec_secgw.rst b/doc/guides/sample_app_ug/ipsec_secgw.rst index d93acf0667..bf9032d138 100644 --- a/doc/guides/sample_app_ug/ipsec_secgw.rst +++ b/doc/guides/sample_app_ug/ipsec_secgw.rst @@ -886,16 +886,35 @@ The flow rule syntax is shown as follows: .. code-block:: console -flow - +flow\ + where each options means: + + + * Set RTE_FLOW_ITEM_TYPE_MARK pattern item in the flow rule with the given + mark value. This option can be used to match an arbitrary integer value + which was set using the RTE_FLOW_ACTION_TYPE_MARK action (see ) + in a previously matched rule. + + * Optional: Yes, this pattern is not set by default. + + * Syntax: *mark X* + + + + * Set RTE_FLOW_ITEM_TYPE_ETH pattern item. This matches all ethernet packets. + + * Optional: Yes, this pattern is not set by default. + + * Syntax: *eth* + * IP protocol version - * Optional: No + * Optional: Yes, this pattern is not set by default. * Available options: @@ -940,6 +959,32 @@ where each options means: * Syntax: *queue X* + + + * Set RTE_FLOW_ACTION_TYPE_COUNT action. + + * Optional: yes, this action is not set by default. + + * Syntax: *count* + + + + * Set RTE_FLOW_ITEM_TYPE_ESP pattern and RTE_FLOW_ACTION_TYPE_SECURITY action. + + * Optional: yes, this pattern and action are not set by default. + + * Syntax: *security* + + + + * Set RTE_FLOW_ACTION_TYPE_MARK action in the flow rule with the given mark + value. This option can be used to set the given integer value(mark) to + packets and set RTE_MBUF_F_RX_FDIR and RTE_MBUF_F_RX_FDIR_ID mbuf flags. + + * Optional: yes, this action is not set by default. + + * Syntax: *set_mark X* + Example flow rules: .. code-block:: console @@ -948,6 +993,18 @@ Example flow rules: flow ipv6 dst :::::::/116 port 1 queue 0 +flow mark 123 ipv4 dst 192.168.0.0/16 port 0 queue 0 count + +flow eth ipv4 dst 192.168.0.0/16 port 0 queue 0 count + +flow ipv4 dst 192.168.0.0/16 port 0 queue 0 count + +flow ipv4 dst 192.168.0.0/16 port 0 queue 0 + +flow port 0 security set_mark 123 + +flow ipv4 dst 1.1.0.0/16 port 0 count set_mark 123 security + Neighbour rule syntax ^ diff --git a/examples/ipsec-secgw/flow.c b/examples/ipsec-secgw/flow.c index 1a1ec7861c..2088876999 100644 --- a/examples/ipsec-secgw/flow.c +++ b/examples/ipsec-secgw/flow.c @@ -15,7 +15,9 @@ #define FLOW_RULES_MAX 128 struct flow_rule_entry { + uint8_t is_eth; uint8_t is_ipv4; + uint8_t is_ipv6; RTE_STD_C11 union { struct { @@ -27,8 +29,15 @@ struct flow_rule_entry { struct rte_flow_item_ipv6 mask; } ipv6; }; + struct rte_flow_item_mark mark_val; uint16_t port; uint16_t queue; + bool is_queue_set; + bool enable_count; + bool enable_mark; + bool set_security_action; + bool set_mark_action; + uint32_t mark_action_val; struct rte_flow *flow; } flow_rule_tbl[FLOW_RULES_MAX]; @@ -64,8 +73,9 @@ ipv4_addr_cpy(rte_be32_t *spec, rte_be32_t *mask, char *token, memcpy(mask, &rte_flow_item_ipv4_mask.hdr.src_addr, sizeof(ip)); *spec = ip.s_addr; + if (depth < 32) - *mask = *mask << (32-depth); + *mask = htonl(*mask << (32 - depth)); return 0; } @@ -124,7 +134,7 @@ parse_flow_tokens(char **tokens, uint32_t n_tokens, struct parse_status *status) { struct flow_rule_entry *rule; - uint32_t ti; + uint32_t ti = 0; if (nb_flow_rule >= FLOW_RULES_MAX) { printf("Too many flow rules\n"); @@ -134,49 +144,73 @@ parse_flow_tokens(char **tokens, uint32_t n_tokens, rule = &flow_rule_tbl[nb_flow_rule]; memset(rule, 0, sizeof(*rule)); - if (strcmp(tokens[0], "ipv4") == 0) { - rule->is_ipv4 = 1; - } else if (strcmp(tokens[0], "ipv6") == 0) { - rule->is_ipv4 = 0; - } else { - APP_CHECK(0, status, "unrecognized input \"%s\"", tokens[0]); - return; - } - - for (ti = 1; ti < n_tokens; ti++) { - if (strcmp(tokens[ti], "src") == 0) { + for (ti
[dpdk-dev] [PATCH v5] examples/ipsec-secgw: support more flow patterns and actions
From: Satheesh Paul Added support to create flow rules with count, mark and security actions and mark pattern. Signed-off-by: Satheesh Paul --- v5: * Rebased the patch. v4: * Added more description in documenation for flow rule options. v3: * Fixed IPv4 and IPv6 dst addr setting in flow pattern spec. v2: * Updated documentation in ipsec_secgw.rst. doc/guides/sample_app_ug/ipsec_secgw.rst | 63 +- examples/ipsec-secgw/flow.c | 274 +++ examples/ipsec-secgw/flow.h | 1 + examples/ipsec-secgw/ipsec-secgw.c | 3 +- 4 files changed, 290 insertions(+), 51 deletions(-) diff --git a/doc/guides/sample_app_ug/ipsec_secgw.rst b/doc/guides/sample_app_ug/ipsec_secgw.rst index 94197a34f0..7032da8d0d 100644 --- a/doc/guides/sample_app_ug/ipsec_secgw.rst +++ b/doc/guides/sample_app_ug/ipsec_secgw.rst @@ -890,16 +890,35 @@ The flow rule syntax is shown as follows: .. code-block:: console -flow - +flow\ + where each options means: + + + * Set RTE_FLOW_ITEM_TYPE_MARK pattern item in the flow rule with the given + mark value. This option can be used to match an arbitrary integer value + which was set using the RTE_FLOW_ACTION_TYPE_MARK action (see ) + in a previously matched rule. + + * Optional: Yes, this pattern is not set by default. + + * Syntax: *mark X* + + + + * Set RTE_FLOW_ITEM_TYPE_ETH pattern item. This matches all ethernet packets. + + * Optional: Yes, this pattern is not set by default. + + * Syntax: *eth* + * IP protocol version - * Optional: No + * Optional: Yes, this pattern is not set by default. * Available options: @@ -944,6 +963,32 @@ where each options means: * Syntax: *queue X* + + + * Set RTE_FLOW_ACTION_TYPE_COUNT action. + + * Optional: yes, this action is not set by default. + + * Syntax: *count* + + + + * Set RTE_FLOW_ITEM_TYPE_ESP pattern and RTE_FLOW_ACTION_TYPE_SECURITY action. + + * Optional: yes, this pattern and action are not set by default. + + * Syntax: *security* + + + + * Set RTE_FLOW_ACTION_TYPE_MARK action in the flow rule with the given mark + value. This option can be used to set the given integer value(mark) to + packets and set RTE_MBUF_F_RX_FDIR and RTE_MBUF_F_RX_FDIR_ID mbuf flags. + + * Optional: yes, this action is not set by default. + + * Syntax: *set_mark X* + Example flow rules: .. code-block:: console @@ -952,6 +997,18 @@ Example flow rules: flow ipv6 dst :::::::/116 port 1 queue 0 +flow mark 123 ipv4 dst 192.168.0.0/16 port 0 queue 0 count + +flow eth ipv4 dst 192.168.0.0/16 port 0 queue 0 count + +flow ipv4 dst 192.168.0.0/16 port 0 queue 0 count + +flow ipv4 dst 192.168.0.0/16 port 0 queue 0 + +flow port 0 security set_mark 123 + +flow ipv4 dst 1.1.0.0/16 port 0 count set_mark 123 security + Neighbour rule syntax ^ diff --git a/examples/ipsec-secgw/flow.c b/examples/ipsec-secgw/flow.c index c217b9e475..aee97b2fc4 100644 --- a/examples/ipsec-secgw/flow.c +++ b/examples/ipsec-secgw/flow.c @@ -15,7 +15,9 @@ #define FLOW_RULES_MAX 128 struct flow_rule_entry { + uint8_t is_eth; uint8_t is_ipv4; + uint8_t is_ipv6; RTE_STD_C11 union { struct { @@ -27,8 +29,15 @@ struct flow_rule_entry { struct rte_flow_item_ipv6 mask; } ipv6; }; + struct rte_flow_item_mark mark_val; uint16_t port; uint16_t queue; + bool is_queue_set; + bool enable_count; + bool enable_mark; + bool set_security_action; + bool set_mark_action; + uint32_t mark_action_val; struct rte_flow *flow; } flow_rule_tbl[FLOW_RULES_MAX]; @@ -64,8 +73,9 @@ ipv4_addr_cpy(rte_be32_t *spec, rte_be32_t *mask, char *token, memcpy(mask, &rte_flow_item_ipv4_mask.hdr.src_addr, sizeof(ip)); *spec = ip.s_addr; + if (depth < 32) - *mask = *mask << (32-depth); + *mask = htonl(*mask << (32 - depth)); return 0; } @@ -124,7 +134,7 @@ parse_flow_tokens(char **tokens, uint32_t n_tokens, struct parse_status *status) { struct flow_rule_entry *rule; - uint32_t ti; + uint32_t ti = 0; if (nb_flow_rule >= FLOW_RULES_MAX) { printf("Too many flow rules\n"); @@ -134,49 +144,73 @@ parse_flow_tokens(char **tokens, uint32_t n_tokens, rule = &flow_rule_tbl[nb_flow_rule]; memset(rule, 0, sizeof(*rule)); - if (strcmp(tokens[0], "ipv4") == 0) { - rule->is_ipv4 = 1; - } else if (strcmp(tokens[0], "ipv6") == 0) { - rule->is_ipv4 = 0; - } else { - APP_CHECK(0, status, "unrecognized input \"%s\"", tokens[0]); - return; - } - - for (ti = 1; ti < n_tokens; ti++) { - if (strcmp(tokens[ti], "src
[dpdk-dev] [PATCH] common/cnxk: fix GRE tunnel parsing issue
From: Satheesh Paul After parsing GRE tunnel, parse subsequent protocols (for example, TCP or UDP) as tunneled versions. Fixes: c34ea71b878 ("common/cnxk: add NPC parsing API") Cc: sta...@dpdk.org Signed-off-by: Satheesh Paul Reviewed-by: Kiran Kumar K --- drivers/common/cnxk/roc_npc_parse.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/common/cnxk/roc_npc_parse.c b/drivers/common/cnxk/roc_npc_parse.c index 0748646779..ff00c746d6 100644 --- a/drivers/common/cnxk/roc_npc_parse.c +++ b/drivers/common/cnxk/roc_npc_parse.c @@ -699,11 +699,13 @@ npc_parse_ld(struct npc_parse_state *pst) case ROC_NPC_ITEM_TYPE_GRE: lt = NPC_LT_LD_GRE; info.len = pst->pattern->size; + pst->tunnel = 1; break; case ROC_NPC_ITEM_TYPE_GRE_KEY: lt = NPC_LT_LD_GRE; info.len = pst->pattern->size; info.hw_hdr_len = 4; + pst->tunnel = 1; break; case ROC_NPC_ITEM_TYPE_NVGRE: lt = NPC_LT_LD_NVGRE; -- 2.35.3
[dpdk-dev] [PATCH] common/cnxk: fix log level during MCAM allocation
From: Satheesh Paul Changed log level from info to debug for a log message printed during MCAM allocation. Fixes: 1f66919817ee ("common/cnxk: improve MCAM entries management") Cc: sta...@dpdk.org Signed-off-by: Satheesh Paul Reviewed-by: Kiran Kumar Kokkilagadda --- drivers/common/cnxk/roc_npc_utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/common/cnxk/roc_npc_utils.c b/drivers/common/cnxk/roc_npc_utils.c index cbc6200fec..8bdabc116d 100644 --- a/drivers/common/cnxk/roc_npc_utils.c +++ b/drivers/common/cnxk/roc_npc_utils.c @@ -635,7 +635,7 @@ npc_alloc_mcam_by_ref_entry(struct mbox *mbox, struct roc_npc_flow *flow, npc_find_mcam_ref_entry(flow, npc, &prio, &ref_entry, dir); rc = npc_allocate_mcam_entry(mbox, prio, rsp_local, ref_entry); if (rc && !retry_done) { - plt_info( + plt_npc_dbg( "npc: Failed to allocate lower priority entry. Retrying for higher priority"); dir = NPC_MCAM_HIGHER_PRIO; -- 2.35.3
[dpdk-dev v3] [PATCH 1/4] drivers: support for switch header type pre_L2
From: Kiran Kumar K Adding changes to configure switch header type pre_L2 for cnxk. pre_L2 headers are custom headers placed before the ethernet header. Along with switch header type, user needs to provide the offset within the custom header that holds the size of the custom header and mask for the size within the size offset. Signed-off-by: Kiran Kumar K Reviewed-by: Satheesh Paul --- v3: * Fixed commit message grammar, added description of pre_L2 * Fixed grammar issues in documentation for pre_L2 support v2: * Fixed checkpatch errors in commit messages doc/guides/nics/cnxk.rst | 29 +- drivers/common/cnxk/hw/npc.h | 11 --- drivers/common/cnxk/roc_mbox.h | 1 + drivers/common/cnxk/roc_nix.h | 5 +++- drivers/common/cnxk/roc_nix_ops.c | 12 +++- drivers/common/cnxk/roc_npc.h | 8 + drivers/net/cnxk/cnxk_ethdev.c | 7 +++-- drivers/net/cnxk/cnxk_ethdev_devargs.c | 41 ++ 8 files changed, 103 insertions(+), 11 deletions(-) diff --git a/doc/guides/nics/cnxk.rst b/doc/guides/nics/cnxk.rst index bab009baf0..6fab707c27 100644 --- a/doc/guides/nics/cnxk.rst +++ b/doc/guides/nics/cnxk.rst @@ -167,7 +167,34 @@ Runtime Config Options With the above configuration, higig2 will be enabled on that port and the traffic on this port should be higig2 traffic only. Supported switch header - types are "chlen24b", "chlen90b", "dsa", "exdsa", "higig2" and "vlan_exdsa". + types are "chlen24b", "chlen90b", "dsa", "exdsa", "higig2", "vlan_exdsa" and + "pre_l2". + +- ``Flow pre_l2 info`` (default ``0x0/0x0/0x0``) + + pre_L2 headers are custom headers placed before the ethernet header. For + parsing custom pre_l2 headers, an offset, mask within the offset and shift + direction has to be provided within the custom header that holds the size of + the custom header. This is valid only with switch header pre_l2. Maximum + supported offset range is 0 to 255 and mask range is 1 to 255 and + shift direction, 0: left shift, 1: right shift. + Info format will be "offset/mask/shift direction". All parameters has to be + in hexadecimal format and mask should be contiguous. Info can be configured + using ``flow_pre_l2_info`` ``devargs`` parameter. + + For example:: + + -a 0002:02:00.0,switch_header="pre_l2",flow_pre_l2_info=0x2/0x7e/0x1 + + With the above configuration, custom pre_l2 header will be enabled on that + port and size of the header is placed at byte offset 0x2 in the packet with + mask 0x7e and right shift will be used to get the size. That is, size will be + (pkt[0x2] & 0x7e) >> shift count. Shift count will be calculated based on + mask and shift direction. For example, if mask is 0x7c and shift direction is + 1 (i.e., right shift) then the shift count will be 2, that is, absolute + position of the rightmost set bit. If the mask is 0x7c and shift direction + is 0 (i.e., left shift) then the shift count will be 1, that is, (8 - n), + where n is the absolute position of leftmost set bit. - ``RSS tag as XOR`` (default ``0``) diff --git a/drivers/common/cnxk/hw/npc.h b/drivers/common/cnxk/hw/npc.h index 68c5037e1c..6f896de9f0 100644 --- a/drivers/common/cnxk/hw/npc.h +++ b/drivers/common/cnxk/hw/npc.h @@ -169,13 +169,12 @@ enum npc_kpu_la_ltype { NPC_LT_LA_8023 = 1, NPC_LT_LA_ETHER, NPC_LT_LA_IH_NIX_ETHER, - NPC_LT_LA_IH_8_ETHER, - NPC_LT_LA_IH_4_ETHER, - NPC_LT_LA_IH_2_ETHER, - NPC_LT_LA_HIGIG2_ETHER, + NPC_LT_LA_HIGIG2_ETHER = 7, NPC_LT_LA_IH_NIX_HIGIG2_ETHER, - NPC_LT_LA_CH_LEN_90B_ETHER, + NPC_LT_LA_CUSTOM_L2_90B_ETHER, NPC_LT_LA_CPT_HDR, + NPC_LT_LA_CUSTOM_L2_24B_ETHER, + NPC_LT_LA_CUSTOM_PRE_L2_ETHER, NPC_LT_LA_CUSTOM0 = 0xE, NPC_LT_LA_CUSTOM1 = 0xF, }; @@ -185,7 +184,7 @@ enum npc_kpu_lb_ltype { NPC_LT_LB_CTAG, NPC_LT_LB_STAG_QINQ, NPC_LT_LB_BTAG, - NPC_LT_LB_ITAG, + NPC_LT_LB_PPPOE, NPC_LT_LB_DSA, NPC_LT_LB_DSA_VLAN, NPC_LT_LB_EDSA, diff --git a/drivers/common/cnxk/roc_mbox.h b/drivers/common/cnxk/roc_mbox.h index e97d93e261..8967858914 100644 --- a/drivers/common/cnxk/roc_mbox.h +++ b/drivers/common/cnxk/roc_mbox.h @@ -323,6 +323,7 @@ struct npc_set_pkind { #define ROC_PRIV_FLAGS_LEN_90B BIT_ULL(3) #define ROC_PRIV_FLAGS_EXDSA BIT_ULL(4) #define ROC_PRIV_FLAGS_VLAN_EXDSA BIT_ULL(5) +#define ROC_PRIV_FLAGS_PRE_L2BIT_ULL(6) #define ROC_PRIV_FLAGS_CUSTOMBIT_ULL(63) uint64_t __io mode; #define PKIND_TX BIT_ULL(0) diff --git a/drivers/common/cnxk/roc_nix.h b/drivers/common/cnxk/roc_nix.h index d79abfef9f..755212c8f9 100644 --- a/drivers/common/cnxk/roc_nix.h +++ b/drivers/common/cnxk/roc_nix.h @@ -714,7 +714,10 @@ void __roc_api roc_nix_mac_link_info_get_cb_unregister(struct roc_nix *roc_nix); /* Ops */ int __roc_api roc_nix_switch_hdr_set
[dpdk-dev v3] [PATCH 2/4] common/cnxk: support custom pre L2 header parsing as raw
From: Kiran Kumar K Add roc API for parsing custom pre L2 headers as raw data. Only relative offset is supported and search and limit is not supported with this raw item type. Signed-off-by: Kiran Kumar K Reviewed-by: Satheesh Paul --- drivers/common/cnxk/roc_npc.c | 8 +- drivers/common/cnxk/roc_npc_mcam_dump.c | 2 + drivers/common/cnxk/roc_npc_parse.c | 103 +--- drivers/common/cnxk/roc_npc_priv.h | 1 + 4 files changed, 81 insertions(+), 33 deletions(-) diff --git a/drivers/common/cnxk/roc_npc.c b/drivers/common/cnxk/roc_npc.c index d18dfd4259..e3961bfbc6 100644 --- a/drivers/common/cnxk/roc_npc.c +++ b/drivers/common/cnxk/roc_npc.c @@ -566,10 +566,10 @@ npc_parse_pattern(struct npc *npc, const struct roc_npc_item_info pattern[], struct roc_npc_flow *flow, struct npc_parse_state *pst) { npc_parse_stage_func_t parse_stage_funcs[] = { - npc_parse_meta_items, npc_parse_cpt_hdr, npc_parse_higig2_hdr, - npc_parse_la, npc_parse_lb, npc_parse_lc, - npc_parse_ld, npc_parse_le, npc_parse_lf, - npc_parse_lg, npc_parse_lh, + npc_parse_meta_items, npc_parse_pre_l2, npc_parse_cpt_hdr, + npc_parse_higig2_hdr, npc_parse_la, npc_parse_lb, + npc_parse_lc, npc_parse_ld, npc_parse_le, + npc_parse_lf, npc_parse_lg, npc_parse_lh, }; uint8_t layer = 0; int key_offset; diff --git a/drivers/common/cnxk/roc_npc_mcam_dump.c b/drivers/common/cnxk/roc_npc_mcam_dump.c index 278056591e..679e3d7657 100644 --- a/drivers/common/cnxk/roc_npc_mcam_dump.c +++ b/drivers/common/cnxk/roc_npc_mcam_dump.c @@ -69,6 +69,8 @@ static const char *const ltype_str[NPC_MAX_LID][NPC_MAX_LT] = { [NPC_LID_LA][NPC_LT_LA_IH_NIX_ETHER] = "LA_IH_NIX_ETHER", [NPC_LID_LA][NPC_LT_LA_HIGIG2_ETHER] = "LA_HIGIG2_ETHER", [NPC_LID_LA][NPC_LT_LA_IH_NIX_HIGIG2_ETHER] = "LA_IH_NIX_HIGIG2_ETHER", + [NPC_LID_LA][NPC_LT_LA_CUSTOM_PRE_L2_ETHER] = + "NPC_LT_LA_CUSTOM_PRE_L2_ETHER", [NPC_LID_LB][0] = "NONE", [NPC_LID_LB][NPC_LT_LB_CTAG] = "LB_CTAG", [NPC_LID_LB][NPC_LT_LB_STAG_QINQ] = "LB_STAG_QINQ", diff --git a/drivers/common/cnxk/roc_npc_parse.c b/drivers/common/cnxk/roc_npc_parse.c index 8125035dd8..c9ab9aef28 100644 --- a/drivers/common/cnxk/roc_npc_parse.c +++ b/drivers/common/cnxk/roc_npc_parse.c @@ -21,6 +21,80 @@ npc_parse_meta_items(struct npc_parse_state *pst) return 0; } +static int +npc_flow_raw_item_prepare(const struct roc_npc_flow_item_raw *raw_spec, + const struct roc_npc_flow_item_raw *raw_mask, + struct npc_parse_item_info *info, uint8_t *spec_buf, + uint8_t *mask_buf) +{ + + memset(spec_buf, 0, NPC_MAX_RAW_ITEM_LEN); + memset(mask_buf, 0, NPC_MAX_RAW_ITEM_LEN); + + memcpy(spec_buf + raw_spec->offset, raw_spec->pattern, + raw_spec->length); + + if (raw_mask && raw_mask->pattern) { + memcpy(mask_buf + raw_spec->offset, raw_mask->pattern, + raw_spec->length); + } else { + memset(mask_buf + raw_spec->offset, 0xFF, raw_spec->length); + } + + info->len = NPC_MAX_RAW_ITEM_LEN; + info->spec = spec_buf; + info->mask = mask_buf; + return 0; +} + +int +npc_parse_pre_l2(struct npc_parse_state *pst) +{ + uint8_t raw_spec_buf[NPC_MAX_RAW_ITEM_LEN] = {0}; + uint8_t raw_mask_buf[NPC_MAX_RAW_ITEM_LEN] = {0}; + uint8_t hw_mask[NPC_MAX_EXTRACT_HW_LEN] = {0}; + const struct roc_npc_flow_item_raw *raw_spec; + struct npc_parse_item_info info; + int lid, lt, len; + int rc; + + if (pst->npc->switch_header_type != ROC_PRIV_FLAGS_PRE_L2) + return 0; + + /* Identify the pattern type into lid, lt */ + if (pst->pattern->type != ROC_NPC_ITEM_TYPE_RAW) + return 0; + + lid = NPC_LID_LA; + lt = NPC_LT_LA_CUSTOM_PRE_L2_ETHER; + info.hw_hdr_len = 0; + + raw_spec = pst->pattern->spec; + len = raw_spec->length + raw_spec->offset; + if (len > NPC_MAX_RAW_ITEM_LEN) + return -EINVAL; + + if (raw_spec->relative == 0 || raw_spec->search || raw_spec->limit || + raw_spec->offset < 0) + return -EINVAL; + + npc_flow_raw_item_prepare( + (const struct roc_npc_flow_item_raw *)pst->pattern->spec, + (const struct roc_npc_flow_item_raw *)pst->pattern->mask, &info, + raw_spec_buf, raw_mask_buf); + + info.hw_mask = &hw_mask; + npc_get_hw_supp_mask(pst, &info, lid, lt); + + /* Basic validation of item parameters */ + rc = npc_parse_item_basic(pst->pattern, &info); + if (rc) + return rc; + + /* Update pst
[dpdk-dev v3] [PATCH 3/4] common/cnxk: support matching VLAN existence in RTE Flow
From: Satheesh Paul Support matching existence of VLAN after RTE_FLOW_ITEM_TYPE_ETH and RTE_FLOW_ITEM_TYPE_VLAN items. Signed-off-by: Satheesh Paul Reviewed-by: Kiran Kumar Kokkilagadda --- drivers/common/cnxk/roc_npc.h | 56 - drivers/common/cnxk/roc_npc_mcam.c | 37 --- drivers/common/cnxk/roc_npc_parse.c | 56 + drivers/common/cnxk/roc_npc_priv.h | 7 drivers/common/cnxk/roc_platform.h | 5 +++ 5 files changed, 150 insertions(+), 11 deletions(-) diff --git a/drivers/common/cnxk/roc_npc.h b/drivers/common/cnxk/roc_npc.h index 8b57678863..6ab185e188 100644 --- a/drivers/common/cnxk/roc_npc.h +++ b/drivers/common/cnxk/roc_npc.h @@ -58,6 +58,60 @@ struct roc_npc_flow_item_raw { const uint8_t *pattern; /**< Byte string to look for. */ }; +struct roc_ether_addr { + uint8_t addr_bytes[PLT_ETHER_ADDR_LEN]; /**< Addr bytes in tx order */ +} plt_aligned(2); + +struct roc_ether_hdr { + struct roc_ether_addr d_addr; /**< Destination address. */ + PLT_STD_C11 + union { + struct roc_ether_addr s_addr; /**< Source address. */ + struct { + struct roc_ether_addr S_addr; + } S_un; /**< Do not use directly; use s_addr instead.*/ + }; + uint16_t ether_type; /**< Frame type. */ +} plt_aligned(2); + +PLT_STD_C11 +struct roc_npc_flow_item_eth { + union { + struct { + /* +* These fields are retained +* for compatibility. +* Please switch to the new header field below. +*/ + struct roc_ether_addr dst; /**< Destination MAC. */ + struct roc_ether_addr src; /**< Source MAC. */ + uint16_t type; /**< EtherType or TPID. */ + }; + struct roc_ether_hdr hdr; + }; + uint32_t has_vlan : 1; /**< Packet header contains at least one VLAN. */ + uint32_t reserved : 31; /**< Reserved, must be zero. */ +}; + +struct roc_vlan_hdr { + uint16_t vlan_tci; /**< Priority (3) + CFI (1) + Identifier Code (12) */ + uint16_t eth_proto; /**< Ethernet type of encapsulated frame. */ +} __plt_packed; + +PLT_STD_C11 +struct roc_npc_flow_item_vlan { + union { + struct { + uint16_t tci;/**< Tag control information. */ + uint16_t inner_type; /**< Inner EtherType or TPID. */ + }; + struct roc_vlan_hdr hdr; + }; + uint32_t has_more_vlan : 1; + /**< Packet header contains at least one more VLAN, after this VLAN. */ + uint32_t reserved : 31; /**< Reserved, must be zero. */ +}; + #define ROC_NPC_MAX_ACTION_COUNT 19 enum roc_npc_action_type { @@ -97,7 +151,7 @@ struct roc_npc_action_vf { }; struct roc_npc_action_port_id { - uint32_t original : 1; /**< Use original DPDK port ID if possible. */ + uint32_t original : 1; /**< Use original port ID if possible. */ uint32_t reserved : 31; /**< Reserved, must be zero. */ uint32_t id;/**< port ID. */ }; diff --git a/drivers/common/cnxk/roc_npc_mcam.c b/drivers/common/cnxk/roc_npc_mcam.c index 7ed1fd3d6b..29bfc072c9 100644 --- a/drivers/common/cnxk/roc_npc_mcam.c +++ b/drivers/common/cnxk/roc_npc_mcam.c @@ -613,6 +613,28 @@ npc_mcam_alloc_and_write(struct npc *npc, struct roc_npc_flow *flow, return 0; } +static void +npc_set_vlan_ltype(struct npc_parse_state *pst) +{ + uint64_t val, mask; + uint8_t lb_offset; + + lb_offset = + __builtin_popcount(pst->npc->keyx_supp_nmask[pst->nix_intf] & + ((1ULL << NPC_LTYPE_LB_OFFSET) - 1)); + lb_offset *= 4; + + mask = ~((0xfULL << lb_offset)); + pst->flow->mcam_data[0] &= mask; + pst->flow->mcam_mask[0] &= mask; + /* NPC_LT_LB_CTAG: 0b0010, NPC_LT_LB_STAG_QINQ: 0b0011 +* Set LB layertype/mask as 0b0010/0b1110 to match both. +*/ + val = ((uint64_t)(NPC_LT_LB_CTAG & NPC_LT_LB_STAG_QINQ)) << lb_offset; + pst->flow->mcam_data[0] |= val; + pst->flow->mcam_mask[0] |= (0xeULL << lb_offset); +} + int npc_program_mcam(struct npc *npc, struct npc_parse_state *pst, bool mcam_alloc) { @@ -651,12 +673,16 @@ npc_program_mcam(struct npc *npc, struct npc_parse_state *pst, bool mcam_alloc) if (layer_info) { for (idx = 0; idx <= 2; idx++) { if (layer_info & (1 << idx)) { - if (idx == 2) + if (idx == 2) { data = lt; - else if (idx == 1) + mask = 0xf;
[dpdk-dev v3] [PATCH 4/4] common/cnxk: support extensions attributes in IPv6 item
From: Satheesh Paul Support matching existence of specific extension headers after RTE_FLOW_ITEM_TYPE_IPV6 item. Signed-off-by: Satheesh Paul Reviewed-by: Kiran Kumar Kokkilagadda --- drivers/common/cnxk/hw/npc.h| 17 drivers/common/cnxk/roc_npc.h | 33 +++ drivers/common/cnxk/roc_npc_mcam.c | 43 +++ drivers/common/cnxk/roc_npc_parse.c | 65 +++-- drivers/common/cnxk/roc_npc_priv.h | 6 +++ 5 files changed, 160 insertions(+), 4 deletions(-) diff --git a/drivers/common/cnxk/hw/npc.h b/drivers/common/cnxk/hw/npc.h index 6f896de9f0..b8218e25af 100644 --- a/drivers/common/cnxk/hw/npc.h +++ b/drivers/common/cnxk/hw/npc.h @@ -320,6 +320,23 @@ enum npc_kpu_lc_uflag { NPC_F_LC_U_IP6_FRAG = 0x40, }; +enum npc_kpu_lc_lflag { + NPC_F_LC_L_IP_IN_IP = 1, + NPC_F_LC_L_6TO4, + NPC_F_LC_L_MPLS_IN_IP, + NPC_F_LC_L_IP6_TUN_IP6, + NPC_F_LC_L_IP6_MPLS_IN_IP, + NPC_F_LC_L_MPLS_4_LABELS, + NPC_F_LC_L_MPLS_3_LABELS, + NPC_F_LC_L_MPLS_2_LABELS, + NPC_F_LC_L_EXT_HOP, + NPC_F_LC_L_EXT_DEST, + NPC_F_LC_L_EXT_ROUT, + NPC_F_LC_L_EXT_MOBILITY, + NPC_F_LC_L_EXT_HOSTID, + NPC_F_LC_L_EXT_SHIM6, +}; + /* Structures definitions */ struct npc_kpu_profile_cam { uint8_t state; diff --git a/drivers/common/cnxk/roc_npc.h b/drivers/common/cnxk/roc_npc.h index 6ab185e188..b836e264c6 100644 --- a/drivers/common/cnxk/roc_npc.h +++ b/drivers/common/cnxk/roc_npc.h @@ -112,6 +112,39 @@ struct roc_npc_flow_item_vlan { uint32_t reserved : 31; /**< Reserved, must be zero. */ }; +struct roc_ipv6_hdr { + uint32_t vtc_flow;/**< IP version, traffic class & flow label. */ + uint16_t payload_len; /**< IP payload size, including ext. headers */ + uint8_t proto;/**< Protocol, next header. */ + uint8_t hop_limits; /**< Hop limits. */ + uint8_t src_addr[16]; /**< IP address of source host. */ + uint8_t dst_addr[16]; /**< IP address of destination host(s). */ +} __plt_packed; + +struct roc_npc_flow_item_ipv6 { + struct roc_ipv6_hdr hdr; /**< IPv6 header definition. */ + uint32_t has_hop_ext : 1; + /**< Header contains Hop-by-Hop Options extension header. */ + uint32_t has_route_ext : 1; + /**< Header contains Routing extension header. */ + uint32_t has_frag_ext : 1; + /**< Header contains Fragment extension header. */ + uint32_t has_auth_ext : 1; + /**< Header contains Authentication extension header. */ + uint32_t has_esp_ext : 1; + /**< Header contains Encapsulation Security Payload extension header. */ + uint32_t has_dest_ext : 1; + /**< Header contains Destination Options extension header. */ + uint32_t has_mobil_ext : 1; + /**< Header contains Mobility extension header. */ + uint32_t has_hip_ext : 1; + /**< Header contains Host Identity Protocol extension header. */ + uint32_t has_shim6_ext : 1; + /**< Header contains Shim6 Protocol extension header. */ + uint32_t reserved : 23; + /**< Reserved for future extension headers, must be zero. */ +}; + #define ROC_NPC_MAX_ACTION_COUNT 19 enum roc_npc_action_type { diff --git a/drivers/common/cnxk/roc_npc_mcam.c b/drivers/common/cnxk/roc_npc_mcam.c index 29bfc072c9..b251f643bc 100644 --- a/drivers/common/cnxk/roc_npc_mcam.c +++ b/drivers/common/cnxk/roc_npc_mcam.c @@ -635,6 +635,46 @@ npc_set_vlan_ltype(struct npc_parse_state *pst) pst->flow->mcam_mask[0] |= (0xeULL << lb_offset); } +static void +npc_set_ipv6ext_ltype_mask(struct npc_parse_state *pst) +{ + uint8_t lc_offset, lcflag_offset; + uint64_t val, mask; + + lc_offset = + __builtin_popcount(pst->npc->keyx_supp_nmask[pst->nix_intf] & + ((1ULL << NPC_LTYPE_LC_OFFSET) - 1)); + lc_offset *= 4; + + mask = ~((0xfULL << lc_offset)); + pst->flow->mcam_data[0] &= mask; + pst->flow->mcam_mask[0] &= mask; + /* NPC_LT_LC_IP6: 0b0100, NPC_LT_LC_IP6_EXT: 0b0101 +* Set LC layertype/mask as 0b0100/0b1110 to match both. +*/ + val = ((uint64_t)(NPC_LT_LC_IP6 & NPC_LT_LC_IP6_EXT)) << lc_offset; + pst->flow->mcam_data[0] |= val; + pst->flow->mcam_mask[0] |= (0xeULL << lc_offset); + + /* If LC LFLAG is non-zero, set the LC LFLAG mask to 0xF. In general +* case flag mask is set same as the value in data. For example, to +* match 3 VLANs, flags have to match a range of values. But, for IPv6 +* extended attributes matching, we need an exact match. Hence, set the +* mask as 0xF. This is done only if LC LFLAG value is non-zero, +* because for AH and ESP, LC LFLAG is zero and we don't want to match +* zero in LFLAG. +*/ + lcflag_offset = + __builtin_popcount(pst->npc->keyx_supp_nmask[pst->nix_i
[dpdk-dev] [PATCH] common/cnxk: fix missing null check in IPv6 flow parsing
From: Satheesh Paul Added null check in IPv6 flow pattern parsing. Fixes: a55dc02af5 ("common/cnxk: support extensions attributes in IPv6 item") Cc: sta...@dpdk.org Signed-off-by: Satheesh Paul Reviewed-by: Jerin Jacob Kollanukkaran --- drivers/common/cnxk/roc_npc_parse.c | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/common/cnxk/roc_npc_parse.c b/drivers/common/cnxk/roc_npc_parse.c index 1f21693369..302ab66efc 100644 --- a/drivers/common/cnxk/roc_npc_parse.c +++ b/drivers/common/cnxk/roc_npc_parse.c @@ -562,9 +562,11 @@ npc_parse_lc(struct npc_parse_state *pst) ipv6_spec = pst->pattern->spec; lid = NPC_LID_LC; lt = NPC_LT_LC_IP6; - rc = npc_handle_ipv6ext_attr(ipv6_spec, pst, &flags); - if (rc) - return rc; + if (ipv6_spec) { + rc = npc_handle_ipv6ext_attr(ipv6_spec, pst, &flags); + if (rc) + return rc; + } info.len = sizeof(ipv6_spec->hdr); break; case ROC_NPC_ITEM_TYPE_ARP_ETH_IPV4: -- 2.25.4
[dpdk-dev] [PATCH] common/cnxk: fix missing RTE Flow counter deletion
From: Satheesh Paul Added code to clear and delete counters upon flow deletion. Fixes: a07f7ced43 ("common/cnxk: add NPC init and fini") Cc: sta...@dpdk.org Signed-off-by: Satheesh Paul Reviewed-by: Jerin Jacob Kollanukkaran --- drivers/common/cnxk/roc_npc.c | 10 ++ 1 file changed, 10 insertions(+) diff --git a/drivers/common/cnxk/roc_npc.c b/drivers/common/cnxk/roc_npc.c index e3961bfbc6..df3016f538 100644 --- a/drivers/common/cnxk/roc_npc.c +++ b/drivers/common/cnxk/roc_npc.c @@ -1259,6 +1259,16 @@ roc_npc_flow_destroy(struct roc_npc *roc_npc, struct roc_npc_flow *flow) return rc; } + if (flow->ctr_id != NPC_COUNTER_NONE) { + rc = roc_npc_mcam_clear_counter(roc_npc, flow->ctr_id); + if (rc != 0) + return rc; + + rc = npc_mcam_free_counter(npc, flow->ctr_id); + if (rc != 0) + return rc; + } + rc = npc_mcam_free_entry(npc, flow->mcam_id); if (rc != 0) return rc; -- 2.25.4
[dpdk-dev] [PATCH] common/cnxk: fix log level during MCAM allocation
From: Satheesh Paul Changed log level from info to debug for a couple of log messages printed during MCAM allocation. Fixes: 1f66919817 ("common/cnxk: improve MCAM entries management") Signed-off-by: Satheesh Paul Reviewed-by: Kiran Kumar Kokkilagadda --- drivers/common/cnxk/roc_npc_utils.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/common/cnxk/roc_npc_utils.c b/drivers/common/cnxk/roc_npc_utils.c index ed0ef5c462..26e104c39f 100644 --- a/drivers/common/cnxk/roc_npc_utils.c +++ b/drivers/common/cnxk/roc_npc_utils.c @@ -664,14 +664,14 @@ npc_get_free_mcam_entry(struct mbox *mbox, struct roc_npc_flow *flow, new_entry->flow = flow; - plt_info("npc: kernel allocated MCAM entry %d", rsp_local.entry); + plt_npc_dbg("kernel allocated MCAM entry %d", rsp_local.entry); rc = npc_sort_mcams_by_user_prio_level(mbox, new_entry, npc, &rsp_local); if (rc) goto err; - plt_info("npc: allocated MCAM entry after sorting %d", rsp_local.entry); + plt_npc_dbg("allocated MCAM entry after sorting %d", rsp_local.entry); flow->mcam_id = rsp_local.entry; npc_insert_into_flow_list(npc, new_entry); -- 2.25.4
[dpdk-dev] [PATCH] common/cnxk: fix base rule merging only for ingress
From: Satheesh Paul When creating flow rule, merge base steering rule only for ingress rules. Fixes: f9af9080746 ("common/cnxk: add mcam utility API") Cc: sta...@dpdk.org Signed-off-by: Satheesh Paul Reviewed-by: Kiran Kumar Kokkilagadda --- drivers/common/cnxk/roc_npc_mcam.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/common/cnxk/roc_npc_mcam.c b/drivers/common/cnxk/roc_npc_mcam.c index b251f643bc..7a3a8944f5 100644 --- a/drivers/common/cnxk/roc_npc_mcam.c +++ b/drivers/common/cnxk/roc_npc_mcam.c @@ -752,7 +752,7 @@ npc_program_mcam(struct npc *npc, struct npc_parse_state *pst, bool mcam_alloc) if (pst->set_ipv6ext_ltype_mask) npc_set_ipv6ext_ltype_mask(pst); - if (pst->is_vf) { + if (pst->is_vf && pst->flow->nix_intf == NIX_INTF_RX) { (void)mbox_alloc_msg_npc_read_base_steer_rule(npc->mbox); rc = mbox_process_msg(npc->mbox, (void *)&base_rule_rsp); if (rc) { -- 2.25.4
[dpdk-dev] [PATCH] drivers: enable keep flow rule device capability for cnxk
From: Kiran Kumar K Adding changes to enable keep flow rule device capability. With this change, flow rules will be kept across device restart. Signed-off-by: Kiran Kumar K Reviewed-by: Satheesh Paul --- drivers/common/cnxk/roc_npc.c | 8 drivers/common/cnxk/roc_npc.h | 2 ++ drivers/common/cnxk/roc_npc_mcam.c | 20 drivers/common/cnxk/roc_npc_priv.h | 1 + drivers/common/cnxk/version.map| 1 + drivers/net/cnxk/cnxk_ethdev.c | 15 +-- drivers/net/cnxk/cnxk_ethdev_ops.c | 4 ++-- drivers/net/cnxk/cnxk_rte_flow.c | 7 +++ 8 files changed, 54 insertions(+), 4 deletions(-) diff --git a/drivers/common/cnxk/roc_npc.c b/drivers/common/cnxk/roc_npc.c index e3961bfbc6..d470f53788 100644 --- a/drivers/common/cnxk/roc_npc.c +++ b/drivers/common/cnxk/roc_npc.c @@ -74,6 +74,14 @@ roc_npc_mcam_alloc_entries(struct roc_npc *roc_npc, int ref_entry, priority, resp_count); } +int +roc_npc_mcam_enable_all_entries(struct roc_npc *roc_npc, bool enable) +{ + struct npc *npc = roc_npc_to_npc_priv(roc_npc); + + return npc_flow_enable_all_entries(npc, enable); +} + int roc_npc_mcam_alloc_entry(struct roc_npc *roc_npc, struct roc_npc_flow *mcam, struct roc_npc_flow *ref_mcam, int prio, diff --git a/drivers/common/cnxk/roc_npc.h b/drivers/common/cnxk/roc_npc.h index b836e264c6..f9e5028cab 100644 --- a/drivers/common/cnxk/roc_npc.h +++ b/drivers/common/cnxk/roc_npc.h @@ -309,6 +309,8 @@ roc_npc_flow_create(struct roc_npc *roc_npc, const struct roc_npc_attr *attr, int __roc_api roc_npc_flow_destroy(struct roc_npc *roc_npc, struct roc_npc_flow *flow); int __roc_api roc_npc_mcam_free_entry(struct roc_npc *roc_npc, uint32_t entry); +int __roc_api roc_npc_mcam_enable_all_entries(struct roc_npc *roc_npc, + bool enable); int __roc_api roc_npc_mcam_alloc_entry(struct roc_npc *roc_npc, struct roc_npc_flow *mcam, struct roc_npc_flow *ref_mcam, int prio, diff --git a/drivers/common/cnxk/roc_npc_mcam.c b/drivers/common/cnxk/roc_npc_mcam.c index b251f643bc..30eceeb883 100644 --- a/drivers/common/cnxk/roc_npc_mcam.c +++ b/drivers/common/cnxk/roc_npc_mcam.c @@ -780,6 +780,26 @@ npc_program_mcam(struct npc *npc, struct npc_parse_state *pst, bool mcam_alloc) return 0; } +int +npc_flow_enable_all_entries(struct npc *npc, bool enable) +{ + struct npc_flow_list *list; + struct roc_npc_flow *flow; + int rc = 0, idx; + + /* Free any MCAM counters and delete flow list */ + for (idx = 0; idx < npc->flow_max_priority; idx++) { + list = &npc->flow_list[idx]; + TAILQ_FOREACH(flow, list, next) { + flow->enable = enable; + rc = npc_mcam_write_entry(npc, flow); + if (rc) + return rc; + } + } + return rc; +} + int npc_flow_free_all_resources(struct npc *npc) { diff --git a/drivers/common/cnxk/roc_npc_priv.h b/drivers/common/cnxk/roc_npc_priv.h index afd11add9a..23e8675253 100644 --- a/drivers/common/cnxk/roc_npc_priv.h +++ b/drivers/common/cnxk/roc_npc_priv.h @@ -413,6 +413,7 @@ int npc_mcam_alloc_entries(struct npc *npc, int ref_mcam, int *alloc_entry, int npc_mcam_ena_dis_entry(struct npc *npc, struct roc_npc_flow *mcam, bool enable); int npc_mcam_write_entry(struct npc *npc, struct roc_npc_flow *mcam); +int npc_flow_enable_all_entries(struct npc *npc, bool enable); int npc_update_parse_state(struct npc_parse_state *pst, struct npc_parse_item_info *info, int lid, int lt, uint8_t flags); diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map index 82b9fc1aea..39496d1906 100644 --- a/drivers/common/cnxk/version.map +++ b/drivers/common/cnxk/version.map @@ -311,6 +311,7 @@ INTERNAL { roc_npc_mcam_alloc_entries; roc_npc_mcam_alloc_entry; roc_npc_mcam_clear_counter; + roc_npc_mcam_enable_all_entries; roc_npc_mcam_ena_dis_entry; roc_npc_mcam_free_all_resources; roc_npc_mcam_free_counter; diff --git a/drivers/net/cnxk/cnxk_ethdev.c b/drivers/net/cnxk/cnxk_ethdev.c index 53dfb5eae8..304272acab 100644 --- a/drivers/net/cnxk/cnxk_ethdev.c +++ b/drivers/net/cnxk/cnxk_ethdev.c @@ -1407,8 +1407,10 @@ cnxk_nix_dev_stop(struct rte_eth_dev *eth_dev) int count, i, j, rc; void *rxq; - /* Disable switch hdr pkind */ - roc_nix_switch_hdr_set(&dev->nix, 0, 0, 0, 0); + /* Disable all the NPC entries */ + rc = roc_npc_mcam_enable_all_entries(&dev->npc, 0); + if (rc) + return rc; /* Stop link change events */ if (!roc_nix_is_vf_or_
[dpdk-dev] [PATCH] net/cnxk: fix updating Rx/Tx functions in fastpath ops
From: Satheesh Paul When Rx/Tx functions are updated such as in an rte flow rule creation with VLAN stripping or marking action, update the fastpath ops table as well. Fixes: b951c2efcb1 ("net/cnxk: add Rx burst for CN9K") Fixes: f742a9a6681 ("net/cnxk: add Rx burst for CN10K") Signed-off-by: Satheesh Paul Reviewed-by: Jerin Jacob Kollanukkaran --- drivers/net/cnxk/cn10k_rx.c| 4 drivers/net/cnxk/cn10k_rx_select.c | 4 drivers/net/cnxk/cn10k_tx_select.c | 4 drivers/net/cnxk/cn9k_rx.c | 4 drivers/net/cnxk/cn9k_rx_select.c | 4 drivers/net/cnxk/cn9k_tx.c | 4 drivers/net/cnxk/cn9k_tx_select.c | 4 7 files changed, 28 insertions(+) diff --git a/drivers/net/cnxk/cn10k_rx.c b/drivers/net/cnxk/cn10k_rx.c index 5d603514c0..15f71b14bd 100644 --- a/drivers/net/cnxk/cn10k_rx.c +++ b/drivers/net/cnxk/cn10k_rx.c @@ -31,6 +31,10 @@ pick_rx_func(struct rte_eth_dev *eth_dev, [!!(dev->rx_offload_flags & NIX_RX_OFFLOAD_PTYPE_F)] [!!(dev->rx_offload_flags & NIX_RX_OFFLOAD_RSS_F)]; + if (eth_dev->data->dev_started) + rte_eth_fp_ops[eth_dev->data->port_id].rx_pkt_burst = + eth_dev->rx_pkt_burst; + rte_atomic_thread_fence(__ATOMIC_RELEASE); } diff --git a/drivers/net/cnxk/cn10k_rx_select.c b/drivers/net/cnxk/cn10k_rx_select.c index 5ca18feb1e..60a3688114 100644 --- a/drivers/net/cnxk/cn10k_rx_select.c +++ b/drivers/net/cnxk/cn10k_rx_select.c @@ -15,6 +15,10 @@ pick_rx_func(struct rte_eth_dev *eth_dev, eth_dev->rx_pkt_burst = rx_burst[dev->rx_offload_flags & (NIX_RX_OFFLOAD_MAX - 1)]; + if (eth_dev->data->dev_started) + rte_eth_fp_ops[eth_dev->data->port_id].rx_pkt_burst = + eth_dev->rx_pkt_burst; + rte_atomic_thread_fence(__ATOMIC_RELEASE); } diff --git a/drivers/net/cnxk/cn10k_tx_select.c b/drivers/net/cnxk/cn10k_tx_select.c index 0b8e3f35b9..037ab6f447 100644 --- a/drivers/net/cnxk/cn10k_tx_select.c +++ b/drivers/net/cnxk/cn10k_tx_select.c @@ -14,6 +14,10 @@ pick_tx_func(struct rte_eth_dev *eth_dev, /* [SEC] [TSP] [TSO] [NOFF] [VLAN] [OL3_OL4_CSUM] [IL3_IL4_CSUM] */ eth_dev->tx_pkt_burst = tx_burst[dev->tx_offload_flags & (NIX_TX_OFFLOAD_MAX - 1)]; + + if (eth_dev->data->dev_started) + rte_eth_fp_ops[eth_dev->data->port_id].tx_pkt_burst = + eth_dev->tx_pkt_burst; } void diff --git a/drivers/net/cnxk/cn9k_rx.c b/drivers/net/cnxk/cn9k_rx.c index 8d504c4a6d..185b643692 100644 --- a/drivers/net/cnxk/cn9k_rx.c +++ b/drivers/net/cnxk/cn9k_rx.c @@ -31,6 +31,10 @@ pick_rx_func(struct rte_eth_dev *eth_dev, [!!(dev->rx_offload_flags & NIX_RX_OFFLOAD_PTYPE_F)] [!!(dev->rx_offload_flags & NIX_RX_OFFLOAD_RSS_F)]; + if (eth_dev->data->dev_started) + rte_eth_fp_ops[eth_dev->data->port_id].rx_pkt_burst = + eth_dev->rx_pkt_burst; + rte_atomic_thread_fence(__ATOMIC_RELEASE); } diff --git a/drivers/net/cnxk/cn9k_rx_select.c b/drivers/net/cnxk/cn9k_rx_select.c index d07a5e890c..fb66d9df7c 100644 --- a/drivers/net/cnxk/cn9k_rx_select.c +++ b/drivers/net/cnxk/cn9k_rx_select.c @@ -15,6 +15,10 @@ pick_rx_func(struct rte_eth_dev *eth_dev, eth_dev->rx_pkt_burst = rx_burst[dev->rx_offload_flags & (NIX_RX_OFFLOAD_MAX - 1)]; + if (eth_dev->data->dev_started) + rte_eth_fp_ops[eth_dev->data->port_id].rx_pkt_burst = + eth_dev->rx_pkt_burst; + rte_atomic_thread_fence(__ATOMIC_RELEASE); } diff --git a/drivers/net/cnxk/cn9k_tx.c b/drivers/net/cnxk/cn9k_tx.c index f3f19fed97..f99e5d3e23 100644 --- a/drivers/net/cnxk/cn9k_tx.c +++ b/drivers/net/cnxk/cn9k_tx.c @@ -36,6 +36,10 @@ pick_tx_func(struct rte_eth_dev *eth_dev, [!!(dev->tx_offload_flags & NIX_TX_OFFLOAD_VLAN_QINQ_F)] [!!(dev->tx_offload_flags & NIX_TX_OFFLOAD_OL3_OL4_CSUM_F)] [!!(dev->tx_offload_flags & NIX_TX_OFFLOAD_L3_L4_CSUM_F)]; + + if (eth_dev->data->dev_started) + rte_eth_fp_ops[eth_dev->data->port_id].tx_pkt_burst = + eth_dev->tx_pkt_burst; } void diff --git a/drivers/net/cnxk/cn9k_tx_select.c b/drivers/net/cnxk/cn9k_tx_select.c index c1fb2f41d5..a84f74a918 100644 --- a/drivers/net/cnxk/cn9k_tx_select.c +++ b/drivers/net/cnxk/cn9k_tx_select.c @@ -14,6 +14,10 @@ pick_tx_func(struct rte_eth_dev *eth_dev, /* [TS] [TSO] [NOFF] [VLAN] [OL3_OL4_CSUM] [IL3_IL4_CSUM] */ eth_dev->tx_pkt_burst = tx_burst[dev->tx_offload_flags & (NIX_TX_OFFLOAD_MAX - 1)]; + + if (eth_dev->data->dev_started) + rte_eth_fp_ops[eth_dev->data->port_id].tx_pkt_burst = + eth_dev->tx_pkt_burst; } void -- 2.25.4
[dpdk-dev] [PATCH v2] drivers: enable keep flow rule device capability for cnxk
From: Kiran Kumar K Adding changes to enable keep flow rule device capability. With this change, flow rules will be kept across device restart. Signed-off-by: Kiran Kumar K Reviewed-by: Satheesh Paul --- v2: * Allow creating flow rule before device start. drivers/common/cnxk/roc_npc.c | 8 drivers/common/cnxk/roc_npc.h | 2 ++ drivers/common/cnxk/roc_npc_mcam.c | 20 drivers/common/cnxk/roc_npc_priv.h | 1 + drivers/common/cnxk/version.map| 1 + drivers/net/cnxk/cnxk_ethdev.c | 15 +-- drivers/net/cnxk/cnxk_ethdev_ops.c | 4 ++-- 7 files changed, 47 insertions(+), 4 deletions(-) diff --git a/drivers/common/cnxk/roc_npc.c b/drivers/common/cnxk/roc_npc.c index e3961bfbc6..d470f53788 100644 --- a/drivers/common/cnxk/roc_npc.c +++ b/drivers/common/cnxk/roc_npc.c @@ -74,6 +74,14 @@ roc_npc_mcam_alloc_entries(struct roc_npc *roc_npc, int ref_entry, priority, resp_count); } +int +roc_npc_mcam_enable_all_entries(struct roc_npc *roc_npc, bool enable) +{ + struct npc *npc = roc_npc_to_npc_priv(roc_npc); + + return npc_flow_enable_all_entries(npc, enable); +} + int roc_npc_mcam_alloc_entry(struct roc_npc *roc_npc, struct roc_npc_flow *mcam, struct roc_npc_flow *ref_mcam, int prio, diff --git a/drivers/common/cnxk/roc_npc.h b/drivers/common/cnxk/roc_npc.h index b836e264c6..f9e5028cab 100644 --- a/drivers/common/cnxk/roc_npc.h +++ b/drivers/common/cnxk/roc_npc.h @@ -309,6 +309,8 @@ roc_npc_flow_create(struct roc_npc *roc_npc, const struct roc_npc_attr *attr, int __roc_api roc_npc_flow_destroy(struct roc_npc *roc_npc, struct roc_npc_flow *flow); int __roc_api roc_npc_mcam_free_entry(struct roc_npc *roc_npc, uint32_t entry); +int __roc_api roc_npc_mcam_enable_all_entries(struct roc_npc *roc_npc, + bool enable); int __roc_api roc_npc_mcam_alloc_entry(struct roc_npc *roc_npc, struct roc_npc_flow *mcam, struct roc_npc_flow *ref_mcam, int prio, diff --git a/drivers/common/cnxk/roc_npc_mcam.c b/drivers/common/cnxk/roc_npc_mcam.c index b251f643bc..30eceeb883 100644 --- a/drivers/common/cnxk/roc_npc_mcam.c +++ b/drivers/common/cnxk/roc_npc_mcam.c @@ -780,6 +780,26 @@ npc_program_mcam(struct npc *npc, struct npc_parse_state *pst, bool mcam_alloc) return 0; } +int +npc_flow_enable_all_entries(struct npc *npc, bool enable) +{ + struct npc_flow_list *list; + struct roc_npc_flow *flow; + int rc = 0, idx; + + /* Free any MCAM counters and delete flow list */ + for (idx = 0; idx < npc->flow_max_priority; idx++) { + list = &npc->flow_list[idx]; + TAILQ_FOREACH(flow, list, next) { + flow->enable = enable; + rc = npc_mcam_write_entry(npc, flow); + if (rc) + return rc; + } + } + return rc; +} + int npc_flow_free_all_resources(struct npc *npc) { diff --git a/drivers/common/cnxk/roc_npc_priv.h b/drivers/common/cnxk/roc_npc_priv.h index afd11add9a..23e8675253 100644 --- a/drivers/common/cnxk/roc_npc_priv.h +++ b/drivers/common/cnxk/roc_npc_priv.h @@ -413,6 +413,7 @@ int npc_mcam_alloc_entries(struct npc *npc, int ref_mcam, int *alloc_entry, int npc_mcam_ena_dis_entry(struct npc *npc, struct roc_npc_flow *mcam, bool enable); int npc_mcam_write_entry(struct npc *npc, struct roc_npc_flow *mcam); +int npc_flow_enable_all_entries(struct npc *npc, bool enable); int npc_update_parse_state(struct npc_parse_state *pst, struct npc_parse_item_info *info, int lid, int lt, uint8_t flags); diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map index ad1b5e8476..75a260f11e 100644 --- a/drivers/common/cnxk/version.map +++ b/drivers/common/cnxk/version.map @@ -312,6 +312,7 @@ INTERNAL { roc_npc_mcam_alloc_entries; roc_npc_mcam_alloc_entry; roc_npc_mcam_clear_counter; + roc_npc_mcam_enable_all_entries; roc_npc_mcam_ena_dis_entry; roc_npc_mcam_free_all_resources; roc_npc_mcam_free_counter; diff --git a/drivers/net/cnxk/cnxk_ethdev.c b/drivers/net/cnxk/cnxk_ethdev.c index 53dfb5eae8..304272acab 100644 --- a/drivers/net/cnxk/cnxk_ethdev.c +++ b/drivers/net/cnxk/cnxk_ethdev.c @@ -1407,8 +1407,10 @@ cnxk_nix_dev_stop(struct rte_eth_dev *eth_dev) int count, i, j, rc; void *rxq; - /* Disable switch hdr pkind */ - roc_nix_switch_hdr_set(&dev->nix, 0, 0, 0, 0); + /* Disable all the NPC entries */ + rc = roc_npc_mcam_enable_all_entries(&dev->npc, 0); + if (rc) + return rc; /* Stop link change events */ if (!roc_nix_is_vf
[dpdk-dev] [PATCH v2] drivers: enable keep flow rule device capability for cnxk
From: Kiran Kumar K Adding changes to enable keep flow rule device capability. With this change, flow rules will be kept across device restart. Signed-off-by: Kiran Kumar K Reviewed-by: Satheesh Paul --- v2: * Allow creating flow rule before device start. drivers/common/cnxk/roc_npc.c | 8 drivers/common/cnxk/roc_npc.h | 2 ++ drivers/common/cnxk/roc_npc_mcam.c | 20 drivers/common/cnxk/roc_npc_priv.h | 1 + drivers/common/cnxk/version.map| 1 + drivers/net/cnxk/cnxk_ethdev.c | 15 +-- drivers/net/cnxk/cnxk_ethdev_ops.c | 4 ++-- 7 files changed, 47 insertions(+), 4 deletions(-) diff --git a/drivers/common/cnxk/roc_npc.c b/drivers/common/cnxk/roc_npc.c index e3961bfbc6..d470f53788 100644 --- a/drivers/common/cnxk/roc_npc.c +++ b/drivers/common/cnxk/roc_npc.c @@ -74,6 +74,14 @@ roc_npc_mcam_alloc_entries(struct roc_npc *roc_npc, int ref_entry, priority, resp_count); } +int +roc_npc_mcam_enable_all_entries(struct roc_npc *roc_npc, bool enable) +{ + struct npc *npc = roc_npc_to_npc_priv(roc_npc); + + return npc_flow_enable_all_entries(npc, enable); +} + int roc_npc_mcam_alloc_entry(struct roc_npc *roc_npc, struct roc_npc_flow *mcam, struct roc_npc_flow *ref_mcam, int prio, diff --git a/drivers/common/cnxk/roc_npc.h b/drivers/common/cnxk/roc_npc.h index b836e264c6..f9e5028cab 100644 --- a/drivers/common/cnxk/roc_npc.h +++ b/drivers/common/cnxk/roc_npc.h @@ -309,6 +309,8 @@ roc_npc_flow_create(struct roc_npc *roc_npc, const struct roc_npc_attr *attr, int __roc_api roc_npc_flow_destroy(struct roc_npc *roc_npc, struct roc_npc_flow *flow); int __roc_api roc_npc_mcam_free_entry(struct roc_npc *roc_npc, uint32_t entry); +int __roc_api roc_npc_mcam_enable_all_entries(struct roc_npc *roc_npc, + bool enable); int __roc_api roc_npc_mcam_alloc_entry(struct roc_npc *roc_npc, struct roc_npc_flow *mcam, struct roc_npc_flow *ref_mcam, int prio, diff --git a/drivers/common/cnxk/roc_npc_mcam.c b/drivers/common/cnxk/roc_npc_mcam.c index b251f643bc..30eceeb883 100644 --- a/drivers/common/cnxk/roc_npc_mcam.c +++ b/drivers/common/cnxk/roc_npc_mcam.c @@ -780,6 +780,26 @@ npc_program_mcam(struct npc *npc, struct npc_parse_state *pst, bool mcam_alloc) return 0; } +int +npc_flow_enable_all_entries(struct npc *npc, bool enable) +{ + struct npc_flow_list *list; + struct roc_npc_flow *flow; + int rc = 0, idx; + + /* Free any MCAM counters and delete flow list */ + for (idx = 0; idx < npc->flow_max_priority; idx++) { + list = &npc->flow_list[idx]; + TAILQ_FOREACH(flow, list, next) { + flow->enable = enable; + rc = npc_mcam_write_entry(npc, flow); + if (rc) + return rc; + } + } + return rc; +} + int npc_flow_free_all_resources(struct npc *npc) { diff --git a/drivers/common/cnxk/roc_npc_priv.h b/drivers/common/cnxk/roc_npc_priv.h index afd11add9a..23e8675253 100644 --- a/drivers/common/cnxk/roc_npc_priv.h +++ b/drivers/common/cnxk/roc_npc_priv.h @@ -413,6 +413,7 @@ int npc_mcam_alloc_entries(struct npc *npc, int ref_mcam, int *alloc_entry, int npc_mcam_ena_dis_entry(struct npc *npc, struct roc_npc_flow *mcam, bool enable); int npc_mcam_write_entry(struct npc *npc, struct roc_npc_flow *mcam); +int npc_flow_enable_all_entries(struct npc *npc, bool enable); int npc_update_parse_state(struct npc_parse_state *pst, struct npc_parse_item_info *info, int lid, int lt, uint8_t flags); diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map index ad1b5e8476..75a260f11e 100644 --- a/drivers/common/cnxk/version.map +++ b/drivers/common/cnxk/version.map @@ -312,6 +312,7 @@ INTERNAL { roc_npc_mcam_alloc_entries; roc_npc_mcam_alloc_entry; roc_npc_mcam_clear_counter; + roc_npc_mcam_enable_all_entries; roc_npc_mcam_ena_dis_entry; roc_npc_mcam_free_all_resources; roc_npc_mcam_free_counter; diff --git a/drivers/net/cnxk/cnxk_ethdev.c b/drivers/net/cnxk/cnxk_ethdev.c index 53dfb5eae8..304272acab 100644 --- a/drivers/net/cnxk/cnxk_ethdev.c +++ b/drivers/net/cnxk/cnxk_ethdev.c @@ -1407,8 +1407,10 @@ cnxk_nix_dev_stop(struct rte_eth_dev *eth_dev) int count, i, j, rc; void *rxq; - /* Disable switch hdr pkind */ - roc_nix_switch_hdr_set(&dev->nix, 0, 0, 0, 0); + /* Disable all the NPC entries */ + rc = roc_npc_mcam_enable_all_entries(&dev->npc, 0); + if (rc) + return rc; /* Stop link change events */ if (!roc_nix_is_vf
[dpdk-dev] [PATCH] common/cnxk: fix channel number setting in MCAM entries
From: Satheesh Paul Adding changes to accommodate the following requirements while masking the channel number. 1. For CN10K device, channel number should not be masked for first pass rules with RTE_FLOW_ACTION_TYPE_SECURITY action. And channel number should be masked for all other flow rules. 2. For CN9K device channel number should not be masked. Fixes: 29dcc20985 ("common/cnxk: support for CPT second pass flow rules") Cc: sta...@dpdk.org Signed-off-by: Satheesh Paul Reviewed-by: Kiran Kumar Kokkilagadda --- drivers/common/cnxk/roc_npc_mcam.c | 30 ++ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/drivers/common/cnxk/roc_npc_mcam.c b/drivers/common/cnxk/roc_npc_mcam.c index bccbaaa51f..0ae58da0ba 100644 --- a/drivers/common/cnxk/roc_npc_mcam.c +++ b/drivers/common/cnxk/roc_npc_mcam.c @@ -508,19 +508,25 @@ npc_mcam_set_channel(struct roc_npc_flow *flow, req->entry_data.kw_mask[0] &= ~(GENMASK(11, 0)); flow->mcam_data[0] &= ~(GENMASK(11, 0)); flow->mcam_mask[0] &= ~(GENMASK(11, 0)); + chan = channel; + mask = chan_mask; - if (is_second_pass) { - chan = (channel | NIX_CHAN_CPT_CH_START); - mask = (chan_mask | NIX_CHAN_CPT_CH_START); - } else { - /* -* Clear bits 10 & 11 corresponding to CPT -* channel. By default, rules should match -* both first pass packets and second pass -* packets from CPT. -*/ - chan = (channel & NIX_CHAN_CPT_X2P_MASK); - mask = (chan_mask & NIX_CHAN_CPT_X2P_MASK); + if (roc_model_runtime_is_cn10k()) { + if (is_second_pass) { + chan = (channel | NIX_CHAN_CPT_CH_START); + mask = (chan_mask | NIX_CHAN_CPT_CH_START); + } else { + if (!(flow->npc_action & NIX_RX_ACTIONOP_UCAST_IPSEC)) { + /* +* Clear bits 10 & 11 corresponding to CPT +* channel. By default, rules should match +* both first pass packets and second pass +* packets from CPT. +*/ + chan = (channel & NIX_CHAN_CPT_X2P_MASK); + mask = (chan_mask & NIX_CHAN_CPT_X2P_MASK); + } + } } req->entry_data.kw[0] |= (uint64_t)chan; -- 2.25.4
[dpdk-dev] [PATCH] common/cnxk: dump hardware flow MCAM entry data
From: Satheesh Paul When dumping flow data, read hardware MCAM entry corresponding to the flow and print that data also. Signed-off-by: Satheesh Paul Reviewed-by: Kiran Kumar Kokkilagadda --- drivers/common/cnxk/roc_npc_mcam_dump.c | 26 - 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/drivers/common/cnxk/roc_npc_mcam_dump.c b/drivers/common/cnxk/roc_npc_mcam_dump.c index 679e3d7657..2aaf3ccd0b 100644 --- a/drivers/common/cnxk/roc_npc_mcam_dump.c +++ b/drivers/common/cnxk/roc_npc_mcam_dump.c @@ -586,8 +586,10 @@ roc_npc_flow_mcam_dump(FILE *file, struct roc_npc *roc_npc, struct roc_npc_flow *flow) { struct npc *npc = roc_npc_to_npc_priv(roc_npc); + struct npc_mcam_read_entry_req *mcam_read_req; + struct npc_mcam_read_entry_rsp *mcam_read_rsp; bool is_rx = 0; - int i; + int i, rc = 0; fprintf(file, "MCAM Index:%d\n", flow->mcam_id); fprintf(file, "Interface :%s (%d)\n", intf_str[flow->nix_intf], @@ -609,5 +611,27 @@ roc_npc_flow_mcam_dump(FILE *file, struct roc_npc *roc_npc, fprintf(file, "\tDW%d_Mask:%016lX\n", i, flow->mcam_mask[i]); } + mcam_read_req = mbox_alloc_msg_npc_mcam_read_entry(npc->mbox); + if (mcam_read_req == NULL) { + plt_err("Failed to alloc msg"); + return; + } + + mcam_read_req->entry = flow->mcam_id; + rc = mbox_process_msg(npc->mbox, (void *)&mcam_read_rsp); + if (rc) { + plt_err("Failed to fetch MCAM entry"); + return; + } + + fprintf(file, "HW MCAM Data :\n"); + + for (i = 0; i < ROC_NPC_MAX_MCAM_WIDTH_DWORDS; i++) { + fprintf(file, "\tDW%d :%016lX\n", i, + mcam_read_rsp->entry_data.kw[i]); + fprintf(file, "\tDW%d_Mask:%016lX\n", i, + mcam_read_rsp->entry_data.kw_mask[i]); + } + fprintf(file, "\n"); } -- 2.25.4
[dpdk-dev] [PATCH v2] examples/ipsec-secgw: support more flow patterns and actions
From: Satheesh Paul Added support to create flow rules with count, mark and security actions and mark pattern. Signed-off-by: Satheesh Paul --- v2: * Updated documentation in ipsec_secgw.rst doc/guides/sample_app_ug/ipsec_secgw.rst | 58 - examples/ipsec-secgw/flow.c | 280 +++ examples/ipsec-secgw/flow.h | 1 + examples/ipsec-secgw/ipsec-secgw.c | 3 +- 4 files changed, 288 insertions(+), 54 deletions(-) diff --git a/doc/guides/sample_app_ug/ipsec_secgw.rst b/doc/guides/sample_app_ug/ipsec_secgw.rst index d93acf0667..711026d2ef 100644 --- a/doc/guides/sample_app_ug/ipsec_secgw.rst +++ b/doc/guides/sample_app_ug/ipsec_secgw.rst @@ -886,16 +886,32 @@ The flow rule syntax is shown as follows: .. code-block:: console -flow - +flow\ + where each options means: + + + * Set RTE_FLOW_ITEM_TYPE_MARK pattern item with the given mark value. + + * Optional: Yes, this pattern is not set by default. + + * Syntax: *mark X* + + + + * Set RTE_FLOW_ITEM_TYPE_ETH pattern item. This matches all ethernet packets. + + * Optional: Yes, this pattern is not set by default. + + * Syntax: *eth* + * IP protocol version - * Optional: No + * Optional: Yes, this pattern is not set by default. * Available options: @@ -940,6 +956,30 @@ where each options means: * Syntax: *queue X* + + + * Set RTE_FLOW_ACTION_TYPE_COUNT action. + + * Optional: yes, this action is not set by default. + + * Syntax: *count* + + + + * Set RTE_FLOW_ITEM_TYPE_ESP pattern and RTE_FLOW_ACTION_TYPE_SECURITY action. + + * Optional: yes, this pattern and action are not set by default. + + * Syntax: *security* + + + + * Set RTE_FLOW_ACTION_TYPE_MARK action with the given mark value. + + * Optional: yes, this action is not set by default. + + * Syntax: *set_mark X* + Example flow rules: .. code-block:: console @@ -948,6 +988,18 @@ Example flow rules: flow ipv6 dst :::::::/116 port 1 queue 0 +flow mark 123 ipv4 dst 192.168.0.0/16 port 0 queue 0 count + +flow eth ipv4 dst 192.168.0.0/16 port 0 queue 0 count + +flow ipv4 dst 192.168.0.0/16 port 0 queue 0 count + +flow ipv4 dst 192.168.0.0/16 port 0 queue 0 + +flow port 0 security set_mark 123 + +flow ipv4 dst 1.1.0.0/16 port 0 count set_mark 123 security + Neighbour rule syntax ^ diff --git a/examples/ipsec-secgw/flow.c b/examples/ipsec-secgw/flow.c index 1a1ec7861c..23962f35e7 100644 --- a/examples/ipsec-secgw/flow.c +++ b/examples/ipsec-secgw/flow.c @@ -15,7 +15,9 @@ #define FLOW_RULES_MAX 128 struct flow_rule_entry { + uint8_t is_eth; uint8_t is_ipv4; + uint8_t is_ipv6; RTE_STD_C11 union { struct { @@ -27,8 +29,15 @@ struct flow_rule_entry { struct rte_flow_item_ipv6 mask; } ipv6; }; + struct rte_flow_item_mark mark_val; uint16_t port; uint16_t queue; + bool is_queue_set; + bool enable_count; + bool enable_mark; + bool set_security_action; + bool set_mark_action; + uint32_t mark_action_val; struct rte_flow *flow; } flow_rule_tbl[FLOW_RULES_MAX]; @@ -64,8 +73,9 @@ ipv4_addr_cpy(rte_be32_t *spec, rte_be32_t *mask, char *token, memcpy(mask, &rte_flow_item_ipv4_mask.hdr.src_addr, sizeof(ip)); *spec = ip.s_addr; + if (depth < 32) - *mask = *mask << (32-depth); + *mask = htonl(*mask << (32 - depth)); return 0; } @@ -124,7 +134,7 @@ parse_flow_tokens(char **tokens, uint32_t n_tokens, struct parse_status *status) { struct flow_rule_entry *rule; - uint32_t ti; + uint32_t ti = 0; if (nb_flow_rule >= FLOW_RULES_MAX) { printf("Too many flow rules\n"); @@ -134,49 +144,73 @@ parse_flow_tokens(char **tokens, uint32_t n_tokens, rule = &flow_rule_tbl[nb_flow_rule]; memset(rule, 0, sizeof(*rule)); - if (strcmp(tokens[0], "ipv4") == 0) { - rule->is_ipv4 = 1; - } else if (strcmp(tokens[0], "ipv6") == 0) { - rule->is_ipv4 = 0; - } else { - APP_CHECK(0, status, "unrecognized input \"%s\"", tokens[0]); - return; - } - - for (ti = 1; ti < n_tokens; ti++) { - if (strcmp(tokens[ti], "src") == 0) { + for (ti = 0; ti < n_tokens; ti++) { + if (strcmp(tokens[ti], "mark") == 0) { INCREMENT_TOKEN_INDEX(ti, n_tokens, status); + if (status->status < 0) + return; + APP_CHECK_TOKEN_IS_NUM(tokens, ti, status); if (status->status < 0) return; - if (rule->is_ipv4) { + rule->mark_val.i
[dpdk-dev] [PATCH v3] examples/ipsec-secgw: support more flow patterns and actions
From: Satheesh Paul Added support to create flow rules with count, mark and security actions and mark pattern. Signed-off-by: Satheesh Paul --- v3: * Fixed IPv4 and IPv6 dst addr setting in flow pattern spec v2: * Updated documentation in ipsec_secgw.rst doc/guides/sample_app_ug/ipsec_secgw.rst | 58 - examples/ipsec-secgw/flow.c | 276 +++ examples/ipsec-secgw/flow.h | 1 + examples/ipsec-secgw/ipsec-secgw.c | 3 +- 4 files changed, 286 insertions(+), 52 deletions(-) diff --git a/doc/guides/sample_app_ug/ipsec_secgw.rst b/doc/guides/sample_app_ug/ipsec_secgw.rst index d93acf0667..711026d2ef 100644 --- a/doc/guides/sample_app_ug/ipsec_secgw.rst +++ b/doc/guides/sample_app_ug/ipsec_secgw.rst @@ -886,16 +886,32 @@ The flow rule syntax is shown as follows: .. code-block:: console -flow - +flow\ + where each options means: + + + * Set RTE_FLOW_ITEM_TYPE_MARK pattern item with the given mark value. + + * Optional: Yes, this pattern is not set by default. + + * Syntax: *mark X* + + + + * Set RTE_FLOW_ITEM_TYPE_ETH pattern item. This matches all ethernet packets. + + * Optional: Yes, this pattern is not set by default. + + * Syntax: *eth* + * IP protocol version - * Optional: No + * Optional: Yes, this pattern is not set by default. * Available options: @@ -940,6 +956,30 @@ where each options means: * Syntax: *queue X* + + + * Set RTE_FLOW_ACTION_TYPE_COUNT action. + + * Optional: yes, this action is not set by default. + + * Syntax: *count* + + + + * Set RTE_FLOW_ITEM_TYPE_ESP pattern and RTE_FLOW_ACTION_TYPE_SECURITY action. + + * Optional: yes, this pattern and action are not set by default. + + * Syntax: *security* + + + + * Set RTE_FLOW_ACTION_TYPE_MARK action with the given mark value. + + * Optional: yes, this action is not set by default. + + * Syntax: *set_mark X* + Example flow rules: .. code-block:: console @@ -948,6 +988,18 @@ Example flow rules: flow ipv6 dst :::::::/116 port 1 queue 0 +flow mark 123 ipv4 dst 192.168.0.0/16 port 0 queue 0 count + +flow eth ipv4 dst 192.168.0.0/16 port 0 queue 0 count + +flow ipv4 dst 192.168.0.0/16 port 0 queue 0 count + +flow ipv4 dst 192.168.0.0/16 port 0 queue 0 + +flow port 0 security set_mark 123 + +flow ipv4 dst 1.1.0.0/16 port 0 count set_mark 123 security + Neighbour rule syntax ^ diff --git a/examples/ipsec-secgw/flow.c b/examples/ipsec-secgw/flow.c index 1a1ec7861c..2088876999 100644 --- a/examples/ipsec-secgw/flow.c +++ b/examples/ipsec-secgw/flow.c @@ -15,7 +15,9 @@ #define FLOW_RULES_MAX 128 struct flow_rule_entry { + uint8_t is_eth; uint8_t is_ipv4; + uint8_t is_ipv6; RTE_STD_C11 union { struct { @@ -27,8 +29,15 @@ struct flow_rule_entry { struct rte_flow_item_ipv6 mask; } ipv6; }; + struct rte_flow_item_mark mark_val; uint16_t port; uint16_t queue; + bool is_queue_set; + bool enable_count; + bool enable_mark; + bool set_security_action; + bool set_mark_action; + uint32_t mark_action_val; struct rte_flow *flow; } flow_rule_tbl[FLOW_RULES_MAX]; @@ -64,8 +73,9 @@ ipv4_addr_cpy(rte_be32_t *spec, rte_be32_t *mask, char *token, memcpy(mask, &rte_flow_item_ipv4_mask.hdr.src_addr, sizeof(ip)); *spec = ip.s_addr; + if (depth < 32) - *mask = *mask << (32-depth); + *mask = htonl(*mask << (32 - depth)); return 0; } @@ -124,7 +134,7 @@ parse_flow_tokens(char **tokens, uint32_t n_tokens, struct parse_status *status) { struct flow_rule_entry *rule; - uint32_t ti; + uint32_t ti = 0; if (nb_flow_rule >= FLOW_RULES_MAX) { printf("Too many flow rules\n"); @@ -134,49 +144,73 @@ parse_flow_tokens(char **tokens, uint32_t n_tokens, rule = &flow_rule_tbl[nb_flow_rule]; memset(rule, 0, sizeof(*rule)); - if (strcmp(tokens[0], "ipv4") == 0) { - rule->is_ipv4 = 1; - } else if (strcmp(tokens[0], "ipv6") == 0) { - rule->is_ipv4 = 0; - } else { - APP_CHECK(0, status, "unrecognized input \"%s\"", tokens[0]); - return; - } - - for (ti = 1; ti < n_tokens; ti++) { - if (strcmp(tokens[ti], "src") == 0) { + for (ti = 0; ti < n_tokens; ti++) { + if (strcmp(tokens[ti], "mark") == 0) { INCREMENT_TOKEN_INDEX(ti, n_tokens, status); + if (status->status < 0) + return; + APP_CHECK_TOKEN_IS_NUM(tokens, ti, status); if (status->status < 0) return; -
[dpdk-dev] [PATCH] common/cnxk: add ROC API to free MCAM entry
From: Satheesh Paul Add ROC API to free the given MCAM entry. If the MCAM entry has flow counter associated, this API will clear and free the flow counter. Signed-off-by: Satheesh Paul Reviewed-by: Jerin Jacob Kollanukkaran --- drivers/common/cnxk/roc_npc.c | 63 +++-- drivers/common/cnxk/roc_npc.h | 7 drivers/common/cnxk/roc_npc_mcam.c | 39 ++ drivers/common/cnxk/roc_npc_priv.h | 2 + drivers/common/cnxk/roc_npc_utils.c | 15 +++ drivers/common/cnxk/version.map | 3 ++ 6 files changed, 100 insertions(+), 29 deletions(-) diff --git a/drivers/common/cnxk/roc_npc.c b/drivers/common/cnxk/roc_npc.c index da5b96242e..02624856e0 100644 --- a/drivers/common/cnxk/roc_npc.c +++ b/drivers/common/cnxk/roc_npc.c @@ -55,6 +55,53 @@ roc_npc_mcam_free_entry(struct roc_npc *roc_npc, uint32_t entry) return npc_mcam_free_entry(npc, entry); } +int +roc_npc_mcam_free(struct roc_npc *roc_npc, struct roc_npc_flow *mcam) +{ + int rc = 0; + + if (mcam->use_ctr) { + rc = roc_npc_mcam_clear_counter(roc_npc, mcam->ctr_id); + if (rc) + return rc; + + rc = roc_npc_mcam_free_counter(roc_npc, mcam->ctr_id); + if (rc) + return rc; + } + + return roc_npc_mcam_free_entry(roc_npc, mcam->mcam_id); +} + +int +roc_npc_mcam_init(struct roc_npc *roc_npc, struct roc_npc_flow *flow, + int mcam_id) +{ + struct npc *npc = roc_npc_to_npc_priv(roc_npc); + int rc = 0; + + rc = npc_mcam_init(npc, flow, mcam_id); + if (rc != 0) { + plt_err("npc: mcam initialisation write failed"); + return rc; + } + return 0; +} + +int +roc_npc_mcam_move(struct roc_npc *roc_npc, uint16_t old_ent, uint16_t new_ent) +{ + struct npc *npc = roc_npc_to_npc_priv(roc_npc); + struct mbox *mbox = npc->mbox; + int rc = -ENOSPC; + + rc = npc_mcam_move(mbox, old_ent, new_ent); + if (rc) + return rc; + + return 0; +} + int roc_npc_mcam_free_all_resources(struct roc_npc *roc_npc) { @@ -383,7 +430,7 @@ npc_parse_actions(struct roc_npc *roc_npc, const struct roc_npc_attr *attr, case ROC_NPC_ACTION_TYPE_COUNT: /* Indicates, need a counter */ - flow->ctr_id = 1; + flow->use_ctr = 1; req_act |= ROC_NPC_ACTION_TYPE_COUNT; break; @@ -1268,7 +1315,7 @@ roc_npc_flow_create(struct roc_npc *roc_npc, const struct roc_npc_attr *attr, return flow; set_rss_failed: - rc = npc_mcam_free_entry(npc, flow->mcam_id); + rc = roc_npc_mcam_free_entry(roc_npc, flow->mcam_id); if (rc != 0) { *errcode = rc; plt_free(flow); @@ -1314,17 +1361,7 @@ roc_npc_flow_destroy(struct roc_npc *roc_npc, struct roc_npc_flow *flow) return rc; } - if (flow->ctr_id != NPC_COUNTER_NONE) { - rc = roc_npc_mcam_clear_counter(roc_npc, flow->ctr_id); - if (rc != 0) - return rc; - - rc = npc_mcam_free_counter(npc, flow->ctr_id); - if (rc != 0) - return rc; - } - - rc = npc_mcam_free_entry(npc, flow->mcam_id); + rc = roc_npc_mcam_free(roc_npc, flow); if (rc != 0) return rc; diff --git a/drivers/common/cnxk/roc_npc.h b/drivers/common/cnxk/roc_npc.h index f92c2a633c..1b4e5521cb 100644 --- a/drivers/common/cnxk/roc_npc.h +++ b/drivers/common/cnxk/roc_npc.h @@ -246,6 +246,7 @@ struct roc_npc_flow { uint8_t nix_intf; uint8_t enable; uint32_t mcam_id; + uint8_t use_ctr; int32_t ctr_id; uint32_t priority; uint32_t mtr_id; @@ -329,6 +330,8 @@ roc_npc_flow_create(struct roc_npc *roc_npc, const struct roc_npc_attr *attr, const struct roc_npc_action actions[], int *errcode); int __roc_api roc_npc_flow_destroy(struct roc_npc *roc_npc, struct roc_npc_flow *flow); +int __roc_api roc_npc_mcam_free(struct roc_npc *roc_npc, + struct roc_npc_flow *mcam); int __roc_api roc_npc_mcam_free_entry(struct roc_npc *roc_npc, uint32_t entry); int __roc_api roc_npc_mcam_enable_all_entries(struct roc_npc *roc_npc, bool enable); @@ -367,4 +370,8 @@ int __roc_api roc_npc_mcam_merge_base_steering_rule(struct roc_npc *roc_npc, struct roc_npc_flow *flow); int __roc_api roc_npc_validate_portid_action(struct roc_npc *roc_npc_src, struct roc_npc *roc_npc_dst); +int __roc_api roc_npc_mcam_init(struct roc_npc *roc_npc, + struct roc_npc_flow *f
[dpdk-dev] [PATCH v2 1/2] common/cnxk: add support for rte flow port ID action type
From: Satheesh Paul This patch adds ROC API to support rte flow port ID action type. Signed-off-by: Satheesh Paul --- drivers/common/cnxk/roc_npc.c | 35 + drivers/common/cnxk/roc_npc.h | 9 + drivers/common/cnxk/version.map | 1 + 3 files changed, 45 insertions(+) diff --git a/drivers/common/cnxk/roc_npc.c b/drivers/common/cnxk/roc_npc.c index 3ab8daa7ed..0a7966b52e 100644 --- a/drivers/common/cnxk/roc_npc.c +++ b/drivers/common/cnxk/roc_npc.c @@ -261,11 +261,38 @@ roc_npc_fini(struct roc_npc *roc_npc) return 0; } +int +roc_npc_validate_portid_action(struct roc_npc *roc_npc_src, + struct roc_npc *roc_npc_dst) +{ + struct roc_nix *roc_nix_src = roc_npc_src->roc_nix; + struct nix *nix_src = roc_nix_to_nix_priv(roc_nix_src); + struct roc_nix *roc_nix_dst = roc_npc_dst->roc_nix; + struct nix *nix_dst = roc_nix_to_nix_priv(roc_nix_dst); + + if (roc_nix_is_pf(roc_npc_dst->roc_nix)) { + plt_err("Output port should be VF"); + return -EINVAL; + } + + if (nix_dst->dev.vf >= nix_src->dev.maxvf) { + plt_err("Invalid VF for output port"); + return -EINVAL; + } + + if (nix_src->dev.pf != nix_dst->dev.pf) { + plt_err("Output port should be VF of ingress PF"); + return -EINVAL; + } + return 0; +} + static int npc_parse_actions(struct roc_npc *roc_npc, const struct roc_npc_attr *attr, const struct roc_npc_action actions[], struct roc_npc_flow *flow) { + const struct roc_npc_action_port_id *act_portid; struct npc *npc = roc_npc_to_npc_priv(roc_npc); const struct roc_npc_action_mark *act_mark; const struct roc_npc_action_meter *act_mtr; @@ -328,6 +355,14 @@ npc_parse_actions(struct roc_npc *roc_npc, const struct roc_npc_attr *attr, pf_func = (pf_func | (vf_id + 1)); break; + case ROC_NPC_ACTION_TYPE_PORT_ID: + act_portid = (const struct roc_npc_action_port_id *) +actions->conf; + pf_func &= (0xfc00); + pf_func = (pf_func | (act_portid->id + 1)); + req_act |= ROC_NPC_ACTION_TYPE_VF; + break; + case ROC_NPC_ACTION_TYPE_QUEUE: act_q = (const struct roc_npc_action_queue *) actions->conf; diff --git a/drivers/common/cnxk/roc_npc.h b/drivers/common/cnxk/roc_npc.h index 10d1ac82a4..ef85073b17 100644 --- a/drivers/common/cnxk/roc_npc.h +++ b/drivers/common/cnxk/roc_npc.h @@ -77,6 +77,7 @@ enum roc_npc_action_type { ROC_NPC_ACTION_TYPE_VLAN_INSERT = (1 << 13), ROC_NPC_ACTION_TYPE_VLAN_ETHTYPE_INSERT = (1 << 14), ROC_NPC_ACTION_TYPE_VLAN_PCP_INSERT = (1 << 15), + ROC_NPC_ACTION_TYPE_PORT_ID = (1 << 16), ROC_NPC_ACTION_TYPE_METER = (1 << 17), }; @@ -95,6 +96,12 @@ struct roc_npc_action_vf { uint32_t id;/**< VF ID. */ }; +struct roc_npc_action_port_id { + uint32_t original : 1; /**< Use original DPDK port ID if possible. */ + uint32_t reserved : 31; /**< Reserved, must be zero. */ + uint32_t id;/**< port ID. */ +}; + struct roc_npc_action_queue { uint16_t index; /**< Queue index to use. */ }; @@ -240,4 +247,6 @@ int __roc_api roc_npc_vtag_actions_sub_return(struct roc_npc *roc_npc, uint32_t count); int __roc_api roc_npc_mcam_merge_base_steering_rule(struct roc_npc *roc_npc, struct roc_npc_flow *flow); +int __roc_api roc_npc_validate_portid_action(struct roc_npc *roc_npc_src, +struct roc_npc *roc_npc_dst); #endif /* _ROC_NPC_H_ */ diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map index f5de985224..8d4d42f476 100644 --- a/drivers/common/cnxk/version.map +++ b/drivers/common/cnxk/version.map @@ -302,6 +302,7 @@ INTERNAL { roc_npc_mcam_write_entry; roc_npc_mcam_read_counter; roc_npc_profile_name_get; + roc_npc_validate_portid_action; roc_plt_init; roc_plt_init_cb_register; roc_sso_dev_fini; -- 2.25.4
[dpdk-dev] [PATCH v2 2/2] net/cnxk: support rte flow action type port ID
From: Satheesh Paul This patch adds support for rte flow action type port_id to enable directing packets from an input port PF to an output port which is a VF of the input port PF. Signed-off-by: Satheesh Paul --- doc/guides/nics/cnxk.rst | 5 + doc/guides/nics/features/cnxk.ini | 1 + drivers/net/cnxk/cnxk_rte_flow.c | 36 +++ 3 files changed, 42 insertions(+) diff --git a/doc/guides/nics/cnxk.rst b/doc/guides/nics/cnxk.rst index d3d9682501..05c66d94b1 100644 --- a/doc/guides/nics/cnxk.rst +++ b/doc/guides/nics/cnxk.rst @@ -305,6 +305,11 @@ RTE flow GRE support - ``RTE_FLOW_ITEM_TYPE_GRE_KEY`` works only when checksum and routing bits in the GRE header are equal to 0. +RTE flow action port_id support +~~~ + +- ``RTE_FLOW_ACTION_TYPE_PORT_ID`` is only supported between PF and its VFs. + Custom protocols supported in RTE Flow ~~ diff --git a/doc/guides/nics/features/cnxk.ini b/doc/guides/nics/features/cnxk.ini index f0586457ca..03af0da302 100644 --- a/doc/guides/nics/features/cnxk.ini +++ b/doc/guides/nics/features/cnxk.ini @@ -85,6 +85,7 @@ of_push_vlan = Y of_set_vlan_pcp = Y of_set_vlan_vid = Y pf = Y +port_id = Y queue= Y rss = Y security = Y diff --git a/drivers/net/cnxk/cnxk_rte_flow.c b/drivers/net/cnxk/cnxk_rte_flow.c index ad89a2e105..dfc33ba865 100644 --- a/drivers/net/cnxk/cnxk_rte_flow.c +++ b/drivers/net/cnxk/cnxk_rte_flow.c @@ -110,7 +110,13 @@ cnxk_map_actions(struct rte_eth_dev *eth_dev, const struct rte_flow_attr *attr, struct roc_npc_action in_actions[], uint32_t *flowkey_cfg) { struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev); + const struct rte_flow_action_port_id *port_act; const struct rte_flow_action_queue *act_q; + struct roc_npc *roc_npc_src = &dev->npc; + struct rte_eth_dev *portid_eth_dev; + char if_name[RTE_ETH_NAME_MAX_LEN]; + struct cnxk_eth_dev *hw_dst; + struct roc_npc *roc_npc_dst; int i = 0, rc = 0; int rq; @@ -146,6 +152,36 @@ cnxk_map_actions(struct rte_eth_dev *eth_dev, const struct rte_flow_attr *attr, in_actions[i].conf = actions->conf; break; + case RTE_FLOW_ACTION_TYPE_PORT_ID: + in_actions[i].type = ROC_NPC_ACTION_TYPE_PORT_ID; + in_actions[i].conf = actions->conf; + port_act = (const struct rte_flow_action_port_id *) + actions->conf; + if (rte_eth_dev_get_name_by_port(port_act->id, +if_name)) { + plt_err("Name not found for output port id"); + goto err_exit; + } + portid_eth_dev = rte_eth_dev_allocated(if_name); + if (!portid_eth_dev) { + plt_err("eth_dev not found for output port id"); + goto err_exit; + } + if (strcmp(portid_eth_dev->device->driver->name, + eth_dev->device->driver->name) != 0) { + plt_err("Output port not under same driver"); + goto err_exit; + } + hw_dst = portid_eth_dev->data->dev_private; + roc_npc_dst = &hw_dst->npc; + + rc = roc_npc_validate_portid_action(roc_npc_src, + roc_npc_dst); + + if (rc) + goto err_exit; + break; + case RTE_FLOW_ACTION_TYPE_QUEUE: act_q = (const struct rte_flow_action_queue *) actions->conf; -- 2.25.4
[dpdk-dev] [PATCH] app/flow-perf: added option to support flow priority
From: Satheesh Paul Added support to specify maximum flow priority option. When this option is given, each flow will be created with the priority attribute and the priority will be random between 0 to max-flow-priority. This is useful to measure performance on NICs which may have to rearrange flows to honor flow priority. Removed the lower limit of 10 flows per batch. Signed-off-by: Satheesh Paul --- app/test-flow-perf/flow_gen.c | 7 -- app/test-flow-perf/flow_gen.h | 1 + app/test-flow-perf/main.c | 44 +- doc/guides/tools/flow-perf.rst | 5 4 files changed, 38 insertions(+), 19 deletions(-) diff --git a/app/test-flow-perf/flow_gen.c b/app/test-flow-perf/flow_gen.c index 51871dbfdc..414ec0bc5e 100644 --- a/app/test-flow-perf/flow_gen.c +++ b/app/test-flow-perf/flow_gen.c @@ -18,7 +18,7 @@ static void fill_attributes(struct rte_flow_attr *attr, - uint64_t *flow_attrs, uint16_t group) + uint64_t *flow_attrs, uint16_t group, uint8_t max_priority) { uint8_t i; for (i = 0; i < MAX_ATTRS_NUM; i++) { @@ -32,6 +32,8 @@ fill_attributes(struct rte_flow_attr *attr, attr->transfer = 1; } attr->group = group; + if (max_priority) + attr->priority = rte_rand_max(max_priority); } struct rte_flow * @@ -48,6 +50,7 @@ generate_flow(uint16_t port_id, uint8_t core_idx, uint8_t rx_queues_count, bool unique_data, + uint8_t max_priority, struct rte_flow_error *error) { struct rte_flow_attr attr; @@ -59,7 +62,7 @@ generate_flow(uint16_t port_id, memset(actions, 0, sizeof(actions)); memset(&attr, 0, sizeof(struct rte_flow_attr)); - fill_attributes(&attr, flow_attrs, group); + fill_attributes(&attr, flow_attrs, group, max_priority); fill_actions(actions, flow_actions, outer_ip_src, next_table, hairpinq, diff --git a/app/test-flow-perf/flow_gen.h b/app/test-flow-perf/flow_gen.h index 1118a9fc14..40eeceae6e 100644 --- a/app/test-flow-perf/flow_gen.h +++ b/app/test-flow-perf/flow_gen.h @@ -37,6 +37,7 @@ generate_flow(uint16_t port_id, uint8_t core_idx, uint8_t rx_queues_count, bool unique_data, + uint8_t max_priority, struct rte_flow_error *error); #endif /* FLOW_PERF_FLOW_GEN */ diff --git a/app/test-flow-perf/main.c b/app/test-flow-perf/main.c index 3ebc025fb2..1d91f308fd 100644 --- a/app/test-flow-perf/main.c +++ b/app/test-flow-perf/main.c @@ -77,6 +77,7 @@ static uint32_t rules_count; static uint32_t rules_batch; static uint32_t hairpin_queues_num; /* total hairpin q number - default: 0 */ static uint32_t nb_lcores; +static uint8_t max_priority; #define MAX_PKT_BURST32 #define LCORE_MODE_PKT1 @@ -140,6 +141,7 @@ usage(char *progname) printf(" --enable-fwd: To enable packets forwarding" " after insertion\n"); printf(" --portmask=N: hexadecimal bitmask of ports used\n"); + printf(" --max-priority=N: Maximum priority level for flows\n"); printf(" --unique-data: flag to set using unique data for all" " actions that support data, such as header modify and encap actions\n"); @@ -589,6 +591,7 @@ args_parse(int argc, char **argv) { "unique-data",0, 0, 0 }, { "portmask", 1, 0, 0 }, { "cores", 1, 0, 0 }, + { "max-priority", 1, 0, 0 }, { "meter-profile-alg", 1, 0, 0 }, { "rxq",1, 0, 0 }, { "txq",1, 0, 0 }, @@ -767,26 +770,21 @@ args_parse(int argc, char **argv) /* Control */ if (strcmp(lgopts[opt_idx].name, "rules-batch") == 0) { - n = atoi(optarg); - if (n >= DEFAULT_RULES_BATCH) - rules_batch = n; - else { - rte_exit(EXIT_FAILURE, - "rules_batch should be >= %d\n", - DEFAULT_RULES_BATCH); - } + rules_batch = atoi(optarg); } if (strcmp(lgopts[opt_idx].name, "rules-count") == 0) { - n = atoi(optarg); - if (n >= (int) rules_batch) - rules_count = n; - else { - rte_exit(EXIT_FAILURE, - "rules_count should be >= %d\n", -
[dpdk-dev] [PATCH v2] app/flow-perf: added option to support flow priority
From: Satheesh Paul Added support to create flows with priority attribute set randomly between 0 and a user supplied maximum value. This is useful to measure performance on NICs which may have to rearrange flows to honor flow priority. Removed the lower limit of 10 flows per batch. Signed-off-by: Satheesh Paul --- v2: * Changed "--max-priority" to "--random-priority". * Added support to take seed for pseudo-random number generator. * Updated documentation for the above. app/test-flow-perf/flow_gen.c | 6 ++-- app/test-flow-perf/flow_gen.h | 1 + app/test-flow-perf/main.c | 56 +++--- doc/guides/tools/flow-perf.rst | 4 +++ 4 files changed, 47 insertions(+), 20 deletions(-) diff --git a/app/test-flow-perf/flow_gen.c b/app/test-flow-perf/flow_gen.c index 51871dbfdc..4eea8fb7c5 100644 --- a/app/test-flow-perf/flow_gen.c +++ b/app/test-flow-perf/flow_gen.c @@ -18,7 +18,7 @@ static void fill_attributes(struct rte_flow_attr *attr, - uint64_t *flow_attrs, uint16_t group) + uint64_t *flow_attrs, uint16_t group, uint8_t max_priority) { uint8_t i; for (i = 0; i < MAX_ATTRS_NUM; i++) { @@ -32,6 +32,7 @@ fill_attributes(struct rte_flow_attr *attr, attr->transfer = 1; } attr->group = group; + attr->priority = rte_rand_max(max_priority); } struct rte_flow * @@ -48,6 +49,7 @@ generate_flow(uint16_t port_id, uint8_t core_idx, uint8_t rx_queues_count, bool unique_data, + uint8_t max_priority, struct rte_flow_error *error) { struct rte_flow_attr attr; @@ -59,7 +61,7 @@ generate_flow(uint16_t port_id, memset(actions, 0, sizeof(actions)); memset(&attr, 0, sizeof(struct rte_flow_attr)); - fill_attributes(&attr, flow_attrs, group); + fill_attributes(&attr, flow_attrs, group, max_priority); fill_actions(actions, flow_actions, outer_ip_src, next_table, hairpinq, diff --git a/app/test-flow-perf/flow_gen.h b/app/test-flow-perf/flow_gen.h index 1118a9fc14..40eeceae6e 100644 --- a/app/test-flow-perf/flow_gen.h +++ b/app/test-flow-perf/flow_gen.h @@ -37,6 +37,7 @@ generate_flow(uint16_t port_id, uint8_t core_idx, uint8_t rx_queues_count, bool unique_data, + uint8_t max_priority, struct rte_flow_error *error); #endif /* FLOW_PERF_FLOW_GEN */ diff --git a/app/test-flow-perf/main.c b/app/test-flow-perf/main.c index 3ebc025fb2..c49c5e44e6 100644 --- a/app/test-flow-perf/main.c +++ b/app/test-flow-perf/main.c @@ -77,6 +77,8 @@ static uint32_t rules_count; static uint32_t rules_batch; static uint32_t hairpin_queues_num; /* total hairpin q number - default: 0 */ static uint32_t nb_lcores; +static uint8_t max_priority; +static uint32_t rand_seed; #define MAX_PKT_BURST32 #define LCORE_MODE_PKT1 @@ -140,6 +142,8 @@ usage(char *progname) printf(" --enable-fwd: To enable packets forwarding" " after insertion\n"); printf(" --portmask=N: hexadecimal bitmask of ports used\n"); + printf( " --random-priority=N,S: Use random priority levels from 0 to" + "(N - 1) for flows and S as seed for pseudo-random number generator\n"); printf(" --unique-data: flag to set using unique data for all" " actions that support data, such as header modify and encap actions\n"); @@ -238,8 +242,9 @@ usage(char *progname) static void args_parse(int argc, char **argv) { - uint64_t pm; + uint64_t pm, seed; char **argvopt; + uint32_t prio; char *token; char *end; int n, opt; @@ -589,6 +594,7 @@ args_parse(int argc, char **argv) { "unique-data",0, 0, 0 }, { "portmask", 1, 0, 0 }, { "cores", 1, 0, 0 }, + { "random-priority",1, 0, 0 }, { "meter-profile-alg", 1, 0, 0 }, { "rxq",1, 0, 0 }, { "txq",1, 0, 0 }, @@ -767,25 +773,27 @@ args_parse(int argc, char **argv) /* Control */ if (strcmp(lgopts[opt_idx].name, "rules-batch") == 0) { - n = atoi(optarg); - if (n >= DEFAULT_RULES_BATCH) - rules_batch = n; - else { - rte_exit(EXIT_FAILURE, - "rules_batch should be >= %d\n", - DEFAULT_RULES_BATCH); - } + rules_batch = atoi(optarg); } if (strcmp(lgopts[opt_idx].name,
[dpdk-dev] [PATCH v3] app/flow-perf: added option to support flow priority
From: Satheesh Paul Added support to create flows with priority attribute set randomly between 0 and a user supplied maximum value. This is useful to measure performance on NICs which may have to rearrange flows to honor flow priority. Removed the lower limit of 10 flows per batch. Signed-off-by: Satheesh Paul --- v3: * Fixed checkpatch errors v2: * Changed "--max-priority" to "--random-priority". * Added support to take seed for pseudo-random number generator. * Updated documentation for the above. app/test-flow-perf/flow_gen.c | 6 ++-- app/test-flow-perf/flow_gen.h | 1 + app/test-flow-perf/main.c | 58 +++--- doc/guides/tools/flow-perf.rst | 4 +++ 4 files changed, 49 insertions(+), 20 deletions(-) diff --git a/app/test-flow-perf/flow_gen.c b/app/test-flow-perf/flow_gen.c index 51871dbfdc..4eea8fb7c5 100644 --- a/app/test-flow-perf/flow_gen.c +++ b/app/test-flow-perf/flow_gen.c @@ -18,7 +18,7 @@ static void fill_attributes(struct rte_flow_attr *attr, - uint64_t *flow_attrs, uint16_t group) + uint64_t *flow_attrs, uint16_t group, uint8_t max_priority) { uint8_t i; for (i = 0; i < MAX_ATTRS_NUM; i++) { @@ -32,6 +32,7 @@ fill_attributes(struct rte_flow_attr *attr, attr->transfer = 1; } attr->group = group; + attr->priority = rte_rand_max(max_priority); } struct rte_flow * @@ -48,6 +49,7 @@ generate_flow(uint16_t port_id, uint8_t core_idx, uint8_t rx_queues_count, bool unique_data, + uint8_t max_priority, struct rte_flow_error *error) { struct rte_flow_attr attr; @@ -59,7 +61,7 @@ generate_flow(uint16_t port_id, memset(actions, 0, sizeof(actions)); memset(&attr, 0, sizeof(struct rte_flow_attr)); - fill_attributes(&attr, flow_attrs, group); + fill_attributes(&attr, flow_attrs, group, max_priority); fill_actions(actions, flow_actions, outer_ip_src, next_table, hairpinq, diff --git a/app/test-flow-perf/flow_gen.h b/app/test-flow-perf/flow_gen.h index 1118a9fc14..40eeceae6e 100644 --- a/app/test-flow-perf/flow_gen.h +++ b/app/test-flow-perf/flow_gen.h @@ -37,6 +37,7 @@ generate_flow(uint16_t port_id, uint8_t core_idx, uint8_t rx_queues_count, bool unique_data, + uint8_t max_priority, struct rte_flow_error *error); #endif /* FLOW_PERF_FLOW_GEN */ diff --git a/app/test-flow-perf/main.c b/app/test-flow-perf/main.c index 3ebc025fb2..abb9908306 100644 --- a/app/test-flow-perf/main.c +++ b/app/test-flow-perf/main.c @@ -77,6 +77,8 @@ static uint32_t rules_count; static uint32_t rules_batch; static uint32_t hairpin_queues_num; /* total hairpin q number - default: 0 */ static uint32_t nb_lcores; +static uint8_t max_priority; +static uint32_t rand_seed; #define MAX_PKT_BURST32 #define LCORE_MODE_PKT1 @@ -140,6 +142,9 @@ usage(char *progname) printf(" --enable-fwd: To enable packets forwarding" " after insertion\n"); printf(" --portmask=N: hexadecimal bitmask of ports used\n"); + printf(" --random-priority=N,S: Use random priority levels from 0 to" + " (N - 1) for flows and S as seed for pseudo-random number" + " generator\n"); printf(" --unique-data: flag to set using unique data for all" " actions that support data, such as header modify and encap actions\n"); @@ -238,8 +243,9 @@ usage(char *progname) static void args_parse(int argc, char **argv) { - uint64_t pm; + uint64_t pm, seed; char **argvopt; + uint32_t prio; char *token; char *end; int n, opt; @@ -589,6 +595,7 @@ args_parse(int argc, char **argv) { "unique-data",0, 0, 0 }, { "portmask", 1, 0, 0 }, { "cores", 1, 0, 0 }, + { "random-priority",1, 0, 0 }, { "meter-profile-alg", 1, 0, 0 }, { "rxq",1, 0, 0 }, { "txq",1, 0, 0 }, @@ -767,25 +774,28 @@ args_parse(int argc, char **argv) /* Control */ if (strcmp(lgopts[opt_idx].name, "rules-batch") == 0) { - n = atoi(optarg); - if (n >= DEFAULT_RULES_BATCH) - rules_batch = n; - else { - rte_exit(EXIT_FAILURE, - "rules_batch should be >= %d\n", - DEFAULT_RULES_BATCH); - } + rules_batch = atoi(optarg); } if (strcmp
[dpdk-dev] [PATCH 22.02 1/2] common/cnxk: support to set channel mask for SDP interfaces
From: Satheesh Paul ROC changes to support setting channel mask for SDP interfaces. Signed-off-by: Satheesh Paul --- drivers/common/cnxk/roc_npc.c | 13 + drivers/common/cnxk/roc_npc.h | 3 +++ drivers/common/cnxk/roc_npc_mcam.c | 10 ++ drivers/common/cnxk/roc_npc_priv.h | 3 +++ 4 files changed, 29 insertions(+) diff --git a/drivers/common/cnxk/roc_npc.c b/drivers/common/cnxk/roc_npc.c index 503c74748f..d18dfd4259 100644 --- a/drivers/common/cnxk/roc_npc.c +++ b/drivers/common/cnxk/roc_npc.c @@ -1152,6 +1152,19 @@ roc_npc_flow_create(struct roc_npc *roc_npc, const struct roc_npc_attr *attr, int rc; npc->channel = roc_npc->channel; + npc->is_sdp_link = roc_nix_is_sdp(roc_npc->roc_nix); + if (npc->is_sdp_link) { + if (roc_npc->is_sdp_mask_set) { + npc->sdp_channel = roc_npc->sdp_channel; + npc->sdp_channel_mask = roc_npc->sdp_channel_mask; + } else { + /* By default set the channel and mask to cover +* the whole SDP channel range. +*/ + npc->sdp_channel = (uint16_t)NIX_CHAN_SDP_CH_START; + npc->sdp_channel_mask = (uint16_t)NIX_CHAN_SDP_CH_START; + } + } flow = plt_zmalloc(sizeof(*flow), 0); if (flow == NULL) { diff --git a/drivers/common/cnxk/roc_npc.h b/drivers/common/cnxk/roc_npc.h index e13d557136..8c24126ae8 100644 --- a/drivers/common/cnxk/roc_npc.h +++ b/drivers/common/cnxk/roc_npc.h @@ -195,6 +195,9 @@ struct roc_npc { uint64_t rx_parse_nibble; /* Parsed RSS Flowkey cfg for current flow being created */ uint32_t flowkey_cfg_state; + bool is_sdp_mask_set; + uint16_t sdp_channel; + uint16_t sdp_channel_mask; #define ROC_NPC_MEM_SZ (5 * 1024) uint8_t reserved[ROC_NPC_MEM_SZ]; diff --git a/drivers/common/cnxk/roc_npc_mcam.c b/drivers/common/cnxk/roc_npc_mcam.c index ba7f89b45b..80851d6f9f 100644 --- a/drivers/common/cnxk/roc_npc_mcam.c +++ b/drivers/common/cnxk/roc_npc_mcam.c @@ -575,6 +575,16 @@ npc_mcam_alloc_and_write(struct npc *npc, struct roc_npc_flow *flow, flow->npc_action |= (uint64_t)pf_func << 4; flow->mcam_data[0] |= (uint64_t)inl_dev->channel; flow->mcam_mask[0] |= (uint64_t)inl_dev->chan_mask; + } else if (npc->is_sdp_link) { + req->entry_data.kw[0] &= ~(GENMASK(11, 0)); + req->entry_data.kw_mask[0] &= ~(GENMASK(11, 0)); + req->entry_data.kw[0] |= (uint64_t)npc->sdp_channel; + req->entry_data.kw_mask[0] |= + (uint64_t)npc->sdp_channel_mask; + flow->mcam_data[0] &= ~(GENMASK(11, 0)); + flow->mcam_mask[0] &= ~(GENMASK(11, 0)); + flow->mcam_data[0] |= (uint64_t)npc->sdp_channel; + flow->mcam_mask[0] |= (uint64_t)npc->sdp_channel_mask; } else { req->entry_data.kw[0] |= (uint64_t)npc->channel; req->entry_data.kw_mask[0] |= (BIT_ULL(12) - 1); diff --git a/drivers/common/cnxk/roc_npc_priv.h b/drivers/common/cnxk/roc_npc_priv.h index 712302bc5c..86c10ea082 100644 --- a/drivers/common/cnxk/roc_npc_priv.h +++ b/drivers/common/cnxk/roc_npc_priv.h @@ -360,6 +360,9 @@ struct npc { uint32_t keyw[NPC_MAX_INTF];/* max key + data len bits */ uint32_t mcam_entries; /* mcam entries supported */ uint16_t channel; /* RX Channel number */ + bool is_sdp_link; + uint16_t sdp_channel; + uint16_t sdp_channel_mask; uint32_t rss_grps; /* rss groups supported */ uint16_t flow_prealloc_size;/* Pre allocated mcam size */ uint16_t flow_max_priority; /* Max priority for flow */ -- 2.25.4
[dpdk-dev] [PATCH 22.02 2/2] net/cnxk: add devargs for configuring SDP channel mask
From: Satheesh Paul This patch adds support to configure channel mask which will be used by rte flow when adding flow rules on SDP interfaces. Signed-off-by: Satheesh Paul --- doc/guides/nics/cnxk.rst | 21 ++ drivers/net/cnxk/cnxk_ethdev_devargs.c | 40 -- 2 files changed, 59 insertions(+), 2 deletions(-) diff --git a/doc/guides/nics/cnxk.rst b/doc/guides/nics/cnxk.rst index 837ffc02b4..470e01b811 100644 --- a/doc/guides/nics/cnxk.rst +++ b/doc/guides/nics/cnxk.rst @@ -276,6 +276,27 @@ Runtime Config Options set with this custom mask, inbound encrypted traffic from all ports with matching channel number pattern will be directed to the inline IPSec device. +- ``SDP device channel and mask`` (default ``none``) + Set channel and channel mask configuration for the SDP device. This + will be used when creating flow rules on the SDP device. + + By default, for rules created on the SDP device, the RTE Flow API sets the + channel number and mask to cover the entire SDP channel range in the channel + field of the MCAM entry. This behaviour can be modified using the + ``sdp_channel_mask`` ``devargs`` parameter. + + For example:: + + -a 0002:1d:00.0,sdp_channel_mask=0x700/0xf00 + + With the above configuration, RTE Flow rules API will set the channel + and channel mask as 0x700 and 0xF00 in the MCAM entries of the flow rules + created on the SDP device. This option needs to be used when more than one + SDP interface is in use and RTE Flow rules created need to distinguish + between traffic from each SDP interface. The channel and mask combination + specified should match all the channels(or rings) configured on the SDP + interface. + .. note:: Above devarg parameters are configurable per device, user needs to pass the diff --git a/drivers/net/cnxk/cnxk_ethdev_devargs.c b/drivers/net/cnxk/cnxk_ethdev_devargs.c index e068f55349..ad7babdf52 100644 --- a/drivers/net/cnxk/cnxk_ethdev_devargs.c +++ b/drivers/net/cnxk/cnxk_ethdev_devargs.c @@ -7,6 +7,12 @@ #include "cnxk_ethdev.h" +struct sdp_channel { + bool is_sdp_mask_set; + uint16_t channel; + uint16_t mask; +}; + static int parse_outb_nb_desc(const char *key, const char *value, void *extra_args) { @@ -164,6 +170,27 @@ parse_switch_header_type(const char *key, const char *value, void *extra_args) return 0; } +static int +parse_sdp_channel_mask(const char *key, const char *value, void *extra_args) +{ + RTE_SET_USED(key); + uint16_t chan = 0, mask = 0; + char *next = 0; + + /* next will point to the separator '/' */ + chan = strtol(value, &next, 16); + mask = strtol(++next, 0, 16); + + if (chan > GENMASK(11, 0) || mask > GENMASK(11, 0)) + return -EINVAL; + + ((struct sdp_channel *)extra_args)->channel = chan; + ((struct sdp_channel *)extra_args)->mask = mask; + ((struct sdp_channel *)extra_args)->is_sdp_mask_set = true; + + return 0; +} + #define CNXK_RSS_RETA_SIZE "reta_size" #define CNXK_SCL_ENABLE"scalar_enable" #define CNXK_MAX_SQB_COUNT "max_sqb_count" @@ -177,6 +204,7 @@ parse_switch_header_type(const char *key, const char *value, void *extra_args) #define CNXK_OUTB_NB_DESC "outb_nb_desc" #define CNXK_FORCE_INB_INL_DEV "force_inb_inl_dev" #define CNXK_OUTB_NB_CRYPTO_QS "outb_nb_crypto_qs" +#define CNXK_SDP_CHANNEL_MASK "sdp_channel_mask" int cnxk_ethdev_parse_devargs(struct rte_devargs *devargs, struct cnxk_eth_dev *dev) @@ -191,11 +219,14 @@ cnxk_ethdev_parse_devargs(struct rte_devargs *devargs, struct cnxk_eth_dev *dev) uint16_t force_inb_inl_dev = 0; uint16_t outb_nb_crypto_qs = 1; uint16_t outb_nb_desc = 8200; + struct sdp_channel sdp_chan; uint16_t rss_tag_as_xor = 0; uint16_t scalar_enable = 0; uint8_t lock_rx_ctx = 0; struct rte_kvargs *kvlist; + memset(&sdp_chan, 0, sizeof(sdp_chan)); + if (devargs == NULL) goto null_devargs; @@ -228,6 +259,8 @@ cnxk_ethdev_parse_devargs(struct rte_devargs *devargs, struct cnxk_eth_dev *dev) &parse_outb_nb_crypto_qs, &outb_nb_crypto_qs); rte_kvargs_process(kvlist, CNXK_FORCE_INB_INL_DEV, &parse_flag, &force_inb_inl_dev); + rte_kvargs_process(kvlist, CNXK_SDP_CHANNEL_MASK, + &parse_sdp_channel_mask, &sdp_chan); rte_kvargs_free(kvlist); null_devargs: @@ -246,8 +279,10 @@ cnxk_ethdev_parse_devargs(struct rte_devargs *devargs, struct cnxk_eth_dev *dev) dev->npc.flow_prealloc_size = flow_prealloc_size; dev->npc.flow_max_priority = flow_max_priority; dev->npc.switch_header_type = switch_header_type; + dev->npc.sdp_channel = sdp_chan.channel; + dev->npc.sdp_channel_mask = sdp_chan.mask; + dev->npc.is_sdp_mask_set = sdp_chan.is_
[dpdk-dev] [PATCH] common/cnxk: fix incorrect free of MCAM counter
From: Satheesh Paul Upon MCAM allocation failure, free counters only if counters were allocated earlier for the flow rule. Fixes: f9af9080746 ("common/cnxk: add mcam utility API") Signed-off-by: Satheesh Paul --- drivers/common/cnxk/roc_npc_mcam.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/common/cnxk/roc_npc_mcam.c b/drivers/common/cnxk/roc_npc_mcam.c index 8ccaaad0af..7d9b0ed3e3 100644 --- a/drivers/common/cnxk/roc_npc_mcam.c +++ b/drivers/common/cnxk/roc_npc_mcam.c @@ -519,7 +519,8 @@ npc_mcam_alloc_and_write(struct npc *npc, struct roc_npc_flow *flow, entry = npc_check_preallocated_entry_cache(mbox, flow, npc); if (entry < 0) { - npc_mcam_free_counter(npc, ctr); + if (use_ctr) + npc_mcam_free_counter(npc, ctr); return NPC_ERR_MCAM_ALLOC; } -- 2.25.4
[dpdk-dev] [PATCH 1/2] common/cnxk: add support for rte flow item raw
From: Satheesh Paul Add roc API for rte_flow_item_raw to parse custom L2 and L3 protocols. Signed-off-by: Satheesh Paul Reviewed-by: Kiran Kumar Kokkilagadda --- drivers/common/cnxk/roc_mbox.h | 24 ++-- drivers/common/cnxk/roc_nix_ops.c | 14 + drivers/common/cnxk/roc_npc.h | 11 drivers/common/cnxk/roc_npc_parse.c | 86 +++-- drivers/common/cnxk/roc_npc_priv.h | 9 +-- drivers/common/cnxk/roc_npc_utils.c | 6 +- drivers/common/cnxk/roc_utils.c | 2 +- 7 files changed, 136 insertions(+), 16 deletions(-) diff --git a/drivers/common/cnxk/roc_mbox.h b/drivers/common/cnxk/roc_mbox.h index 9c529d754..b254f005a 100644 --- a/drivers/common/cnxk/roc_mbox.h +++ b/drivers/common/cnxk/roc_mbox.h @@ -278,14 +278,28 @@ struct ready_msg_rsp { uint16_t __io rclk_freq; /* RCLK frequency */ }; +enum npc_pkind_type { + NPC_RX_VLAN_EXDSA_PKIND = 56ULL, + NPC_RX_CHLEN24B_PKIND, + NPC_RX_CPT_HDR_PKIND, + NPC_RX_CHLEN90B_PKIND, + NPC_TX_HIGIG_PKIND, + NPC_RX_HIGIG_PKIND, + NPC_RX_EXDSA_PKIND, + NPC_RX_EDSA_PKIND, + NPC_TX_DEF_PKIND, +}; + /* Struct to set pkind */ struct npc_set_pkind { struct mbox_msghdr hdr; -#define ROC_PRIV_FLAGS_DEFAULT BIT_ULL(0) -#define ROC_PRIV_FLAGS_EDSABIT_ULL(1) -#define ROC_PRIV_FLAGS_HIGIG BIT_ULL(2) -#define ROC_PRIV_FLAGS_LEN_90B BIT_ULL(3) -#define ROC_PRIV_FLAGS_CUSTOM BIT_ULL(63) +#define ROC_PRIV_FLAGS_DEFAULT BIT_ULL(0) +#define ROC_PRIV_FLAGS_EDSA BIT_ULL(1) +#define ROC_PRIV_FLAGS_HIGIG BIT_ULL(2) +#define ROC_PRIV_FLAGS_LEN_90B BIT_ULL(3) +#define ROC_PRIV_FLAGS_EXDSA BIT_ULL(4) +#define ROC_PRIV_FLAGS_VLAN_EXDSA BIT_ULL(5) +#define ROC_PRIV_FLAGS_CUSTOMBIT_ULL(63) uint64_t __io mode; #define PKIND_TX BIT_ULL(0) #define PKIND_RX BIT_ULL(1) diff --git a/drivers/common/cnxk/roc_nix_ops.c b/drivers/common/cnxk/roc_nix_ops.c index eeb85a54f..0e28302e7 100644 --- a/drivers/common/cnxk/roc_nix_ops.c +++ b/drivers/common/cnxk/roc_nix_ops.c @@ -378,6 +378,8 @@ roc_nix_switch_hdr_set(struct roc_nix *roc_nix, uint64_t switch_header_type) switch_header_type != ROC_PRIV_FLAGS_EDSA && switch_header_type != ROC_PRIV_FLAGS_HIGIG && switch_header_type != ROC_PRIV_FLAGS_LEN_90B && + switch_header_type != ROC_PRIV_FLAGS_EXDSA && + switch_header_type != ROC_PRIV_FLAGS_VLAN_EXDSA && switch_header_type != ROC_PRIV_FLAGS_CUSTOM) { plt_err("switch header type is not supported"); return NIX_ERR_PARAM; @@ -399,6 +401,18 @@ roc_nix_switch_hdr_set(struct roc_nix *roc_nix, uint64_t switch_header_type) if (req == NULL) return rc; req->mode = switch_header_type; + + if (switch_header_type == ROC_PRIV_FLAGS_LEN_90B) { + req->mode = ROC_PRIV_FLAGS_CUSTOM; + req->pkind = NPC_RX_CHLEN90B_PKIND; + } else if (switch_header_type == ROC_PRIV_FLAGS_EXDSA) { + req->mode = ROC_PRIV_FLAGS_CUSTOM; + req->pkind = NPC_RX_EXDSA_PKIND; + } else if (switch_header_type == ROC_PRIV_FLAGS_VLAN_EXDSA) { + req->mode = ROC_PRIV_FLAGS_CUSTOM; + req->pkind = NPC_RX_VLAN_EXDSA_PKIND; + } + req->dir = PKIND_RX; rc = mbox_process_msg(mbox, (void *)&rsp); if (rc) diff --git a/drivers/common/cnxk/roc_npc.h b/drivers/common/cnxk/roc_npc.h index 2c0a536c9..bab25fd72 100644 --- a/drivers/common/cnxk/roc_npc.h +++ b/drivers/common/cnxk/roc_npc.h @@ -36,6 +36,7 @@ enum roc_npc_item_type { ROC_NPC_ITEM_TYPE_CPT_HDR, ROC_NPC_ITEM_TYPE_L3_CUSTOM, ROC_NPC_ITEM_TYPE_QINQ, + ROC_NPC_ITEM_TYPE_RAW, ROC_NPC_ITEM_TYPE_END, }; @@ -47,6 +48,16 @@ struct roc_npc_item_info { const void *last; /* For range */ }; +struct roc_npc_flow_item_raw { + uint32_t relative : 1; /**< Look for pattern after the previous item. */ + uint32_t search : 1; /**< Search pattern from offset. */ + uint32_t reserved : 30; /**< Reserved, must be set to zero. */ + int32_t offset; /**< Absolute or relative offset for pattern. */ + uint16_t limit; /**< Search area limit for start of pattern. */ + uint16_t length;/**< Pattern length. */ + const uint8_t *pattern; /**< Byte string to look for. */ +}; + #define ROC_NPC_MAX_ACTION_COUNT 12 enum roc_npc_action_type { diff --git a/drivers/common/cnxk/roc_npc_parse.c b/drivers/common/cnxk/roc_npc_parse.c index d07f91db3..8125035dd 100644 --- a/drivers/common/cnxk/roc_npc_parse.c +++ b/drivers/common/cnxk/roc_npc_parse.c @@ -136,14 +136,46 @@ npc_parse_la(struct npc_parse_state *pst) return npc_update_parse_state(pst, &info, lid, lt, 0); } +static int +npc_flow_raw_item_prepare(const struct roc_npc_flow_item_raw *raw_spec, + const struct roc_npc_flow_item_
[dpdk-dev] [PATCH 2/2] net/cnxk: add support for rte flow item raw
From: Satheesh Paul Add support for rte_flow_item_raw to parse custom L2 and L3 protocols. Signed-off-by: Satheesh Paul --- doc/guides/nics/cnxk.rst | 37 +- doc/guides/nics/features/cnxk.ini | 1 + doc/guides/nics/features/cnxk_vec.ini | 1 + doc/guides/nics/features/cnxk_vf.ini | 1 + drivers/net/cnxk/cnxk_ethdev_devargs.c | 7 + drivers/net/cnxk/cnxk_rte_flow.c | 12 - 6 files changed, 52 insertions(+), 7 deletions(-) diff --git a/doc/guides/nics/cnxk.rst b/doc/guides/nics/cnxk.rst index cb2a51e1d..90d27dbaa 100644 --- a/doc/guides/nics/cnxk.rst +++ b/doc/guides/nics/cnxk.rst @@ -165,7 +165,7 @@ Runtime Config Options With the above configuration, higig2 will be enabled on that port and the traffic on this port should be higig2 traffic only. Supported switch header - types are "higig2", "dsa", "chlen90b" and "chlen24b". + types are "chlen24b", "chlen90b", "dsa", "exdsa", "higig2" and "vlan_exdsa". - ``RSS tag as XOR`` (default ``0``) @@ -215,6 +215,41 @@ RTE flow GRE support - ``RTE_FLOW_ITEM_TYPE_GRE_KEY`` works only when checksum and routing bits in the GRE header are equal to 0. +Custom protocols supported in RTE Flow +~~ + +The ``RTE_FLOW_ITEM_TYPE_RAW`` can be used to parse the below custom protocols. + +* ``vlan_exdsa`` and ``exdsa`` can be parsed at L2 level. +* ``NGIO`` can be parsed at L3 level. + +For ``vlan_exdsa`` and ``exdsa``, the port has to be configured with the +respective switch header. + +For example:: + + -a 0002:02:00.0,switch_header="vlan_exdsa" + +The below fields of ``struct rte_flow_item_raw`` shall be used to specify the +pattern. + +- ``relative`` Selects the layer at which parsing is done. + + - 0 for ``exdsa`` and ``vlan_exdsa``. + + - 1 for ``NGIO``. + +- ``offset`` The offset in the header where the pattern should be matched. +- ``length`` Length of the pattern. +- ``pattern`` Pattern as a byte string. + +Example usage in testpmd:: + + ./dpdk-testpmd -c 3 -w 0002:02:00.0,switch_header=exdsa -- -i \ + --rx-offloads=0x0008 --rxq 8 --txq 8 + testpmd> flow create 0 ingress pattern eth / raw relative is 0 pattern \ + spec ab pattern mask ab offset is 4 / end actions queue index 1 / end + Debugging Options - diff --git a/doc/guides/nics/features/cnxk.ini b/doc/guides/nics/features/cnxk.ini index 23cad293d..5d456257b 100644 --- a/doc/guides/nics/features/cnxk.ini +++ b/doc/guides/nics/features/cnxk.ini @@ -65,6 +65,7 @@ ipv6 = Y ipv6_ext = Y mpls = Y nvgre= Y +raw = Y sctp = Y tcp = Y udp = Y diff --git a/doc/guides/nics/features/cnxk_vec.ini b/doc/guides/nics/features/cnxk_vec.ini index aa899d358..abf2b8d70 100644 --- a/doc/guides/nics/features/cnxk_vec.ini +++ b/doc/guides/nics/features/cnxk_vec.ini @@ -61,6 +61,7 @@ ipv6 = Y ipv6_ext = Y mpls = Y nvgre= Y +raw = Y sctp = Y tcp = Y udp = Y diff --git a/doc/guides/nics/features/cnxk_vf.ini b/doc/guides/nics/features/cnxk_vf.ini index 09dd6ad48..7b4299f0b 100644 --- a/doc/guides/nics/features/cnxk_vf.ini +++ b/doc/guides/nics/features/cnxk_vf.ini @@ -57,6 +57,7 @@ ipv6 = Y ipv6_ext = Y mpls = Y nvgre= Y +raw = Y sctp = Y tcp = Y udp = Y diff --git a/drivers/net/cnxk/cnxk_ethdev_devargs.c b/drivers/net/cnxk/cnxk_ethdev_devargs.c index c76b6281c..36b437a18 100644 --- a/drivers/net/cnxk/cnxk_ethdev_devargs.c +++ b/drivers/net/cnxk/cnxk_ethdev_devargs.c @@ -99,6 +99,13 @@ parse_switch_header_type(const char *key, const char *value, void *extra_args) if (strcmp(value, "chlen90b") == 0) *(uint16_t *)extra_args = ROC_PRIV_FLAGS_LEN_90B; + + if (strcmp(value, "exdsa") == 0) + *(uint16_t *)extra_args = ROC_PRIV_FLAGS_EXDSA; + + if (strcmp(value, "vlan_exdsa") == 0) + *(uint16_t *)extra_args = ROC_PRIV_FLAGS_VLAN_EXDSA; + return 0; } diff --git a/drivers/net/cnxk/cnxk_rte_flow.c b/drivers/net/cnxk/cnxk_rte_flow.c index 213125b56..32c1b5dee 100644 --- a/drivers/net/cnxk/cnxk_rte_flow.c +++ b/drivers/net/cnxk/cnxk_rte_flow.c @@ -15,8 +15,8 @@ const struct cnxk_rte_flow_term_info term[] = { [RTE_FLOW_ITEM_TYPE_IPV6] = {ROC_NPC_ITEM_TYPE_IPV6, sizeof(struct rte_flow_item_ipv6)}, [RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4] = { - ROC_NPC_ITEM_TYPE_ARP_ETH_IPV4, - sizeof(struct rte_flow_item_arp_eth_ipv4)}, + ROC_NPC_ITEM_TYPE_ARP_ETH_IPV4, + sizeof(struct rte_flow_item_
[dpdk-dev] [PATCH] common/cnxk: support for dual VLAN insert and strip actions
From: Satheesh Paul Add roc API to configure dual VLAN tag addition and removal. Signed-off-by: Satheesh Paul --- drivers/common/cnxk/roc_npc.c | 339 ++--- drivers/common/cnxk/roc_npc.h | 1 + drivers/common/cnxk/roc_npc_priv.h | 11 +- 3 files changed, 267 insertions(+), 84 deletions(-) diff --git a/drivers/common/cnxk/roc_npc.c b/drivers/common/cnxk/roc_npc.c index aff4eef554..52a54b3990 100644 --- a/drivers/common/cnxk/roc_npc.c +++ b/drivers/common/cnxk/roc_npc.c @@ -10,7 +10,7 @@ roc_npc_vtag_actions_get(struct roc_npc *roc_npc) { struct npc *npc = roc_npc_to_npc_priv(roc_npc); - return npc->vtag_actions; + return npc->vtag_strip_actions; } int @@ -18,8 +18,8 @@ roc_npc_vtag_actions_sub_return(struct roc_npc *roc_npc, uint32_t count) { struct npc *npc = roc_npc_to_npc_priv(roc_npc); - npc->vtag_actions -= count; - return npc->vtag_actions; + npc->vtag_strip_actions -= count; + return npc->vtag_strip_actions; } int @@ -481,6 +481,23 @@ npc_parse_actions(struct npc *npc, const struct roc_npc_attr *attr, goto err_exit; } + if (req_act & + ~(ROC_NPC_ACTION_TYPE_VLAN_INSERT | + ROC_NPC_ACTION_TYPE_VLAN_ETHTYPE_INSERT | + ROC_NPC_ACTION_TYPE_VLAN_PCP_INSERT | + ROC_NPC_ACTION_TYPE_DROP | ROC_NPC_ACTION_TYPE_COUNT)) { + plt_err("Only VLAN insert, drop, count supported on Egress"); + errcode = NPC_ERR_ACTION_NOTSUP; + goto err_exit; + } + + if (vlan_insert_action && + (req_act & ROC_NPC_ACTION_TYPE_DROP)) { + plt_err("Both VLAN insert and drop actions cannot be supported"); + errcode = NPC_ERR_ACTION_NOTSUP; + goto err_exit; + } + if (req_act & ROC_NPC_ACTION_TYPE_DROP) { flow->npc_action = NIX_TX_ACTIONOP_DROP; } else if ((req_act & ROC_NPC_ACTION_TYPE_COUNT) || @@ -526,14 +543,14 @@ npc_parse_actions(struct npc *npc, const struct roc_npc_attr *attr, } if (req_act & ROC_NPC_ACTION_TYPE_VLAN_STRIP) - npc->vtag_actions++; - - /* Only VLAN action is provided */ - if (req_act == ROC_NPC_ACTION_TYPE_VLAN_STRIP) - flow->npc_action = NIX_RX_ACTIONOP_UCAST; + npc->vtag_strip_actions++; /* Set NIX_RX_ACTIONOP */ - if (req_act & (ROC_NPC_ACTION_TYPE_PF | ROC_NPC_ACTION_TYPE_VF)) { + if (req_act == ROC_NPC_ACTION_TYPE_VLAN_STRIP) { + /* Only VLAN action is provided */ + flow->npc_action = NIX_RX_ACTIONOP_UCAST; + } else if (req_act & + (ROC_NPC_ACTION_TYPE_PF | ROC_NPC_ACTION_TYPE_VF)) { flow->npc_action = NIX_RX_ACTIONOP_UCAST; if (req_act & ROC_NPC_ACTION_TYPE_QUEUE) flow->npc_action |= (uint64_t)rq << 20; @@ -872,6 +889,11 @@ npc_vtag_cfg_delete(struct roc_npc *roc_npc, struct roc_npc_flow *flow) vtag_cfg->tx.vtag0_idx = tx_vtag_action.act.vtag0_def; vtag_cfg->tx.free_vtag0 = true; + if (flow->vtag_insert_count == 2) { + vtag_cfg->tx.vtag1_idx = tx_vtag_action.act.vtag1_def; + vtag_cfg->tx.free_vtag1 = true; + } + rc = mbox_process_msg(mbox, (void *)&rsp); if (rc) return rc; @@ -880,120 +902,271 @@ npc_vtag_cfg_delete(struct roc_npc *roc_npc, struct roc_npc_flow *flow) } static int -npc_vtag_action_program(struct roc_npc *roc_npc, - const struct roc_npc_action actions[], - struct roc_npc_flow *flow) +npc_vtag_insert_action_parse(const struct roc_npc_action actions[], +struct roc_npc_flow *flow, +struct npc_action_vtag_info *vlan_info, +int *parsed_cnt) { - uint16_t vlan_id = 0, vlan_ethtype = ROC_ETHER_TYPE_VLAN; - struct npc *npc = roc_npc_to_npc_priv(roc_npc); - struct roc_nix *roc_nix = roc_npc->roc_nix; - struct nix_vtag_config *vtag_cfg; - struct nix_vtag_config_rsp *rsp; - uint64_t rx_vtag_action = 0; - uint8_t vlan_pcp = 0; - struct mbox *mbox; - struct nix *nix; - int rc; - - union { - uint64_t reg; - struct nix_tx_vtag_action_s act; - } tx_vtag_action; - - nix = roc_nix_to_nix_priv(roc_nix); - mbox = (&nix->dev)->mbox; - - flow->vtag_insert_enabled = false; - - for (; actions->type != ROC_NPC_ACTION_TYPE_END; actions++) { - if (actions->type == ROC_NPC_ACTION_TYPE_VLAN_STRIP) { - if (npc->vtag_actions == 1) { - vtag
[dpdk-dev] [PATCH ] common/cnxk: fix nibble parsing order when dumping MCAM
From: Satheesh Paul Fix the order in which layer flags and layer type fields are parsed when dumping the MCAM data. Fixes: 9869c39918 ("common/cnxk: support flow entry dump") Cc: sta...@dpdk.org Signed-off-by: Satheesh Paul --- drivers/common/cnxk/roc_npc_mcam_dump.c | 40 - 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/drivers/common/cnxk/roc_npc_mcam_dump.c b/drivers/common/cnxk/roc_npc_mcam_dump.c index 19b4901a52..278056591e 100644 --- a/drivers/common/cnxk/roc_npc_mcam_dump.c +++ b/drivers/common/cnxk/roc_npc_mcam_dump.c @@ -159,6 +159,12 @@ npc_flow_print_parse_nibbles(FILE *file, struct roc_npc_flow *flow, offset += 4; } + if (rx_parse->laflags) { + data = npc_get_nibbles(flow, 2, offset); + fprintf(file, "\tNPC_PARSE_NIBBLE_LA_FLAGS:%#02X\n", data); + offset += 8; + } + if (rx_parse->latype) { data = npc_get_nibbles(flow, 1, offset); fprintf(file, "\tNPC_PARSE_NIBBLE_LA_LTYPE:%s\n", @@ -166,9 +172,9 @@ npc_flow_print_parse_nibbles(FILE *file, struct roc_npc_flow *flow, offset += 4; } - if (rx_parse->laflags) { + if (rx_parse->lbflags) { data = npc_get_nibbles(flow, 2, offset); - fprintf(file, "\tNPC_PARSE_NIBBLE_LA_FLAGS:%#02X\n", data); + fprintf(file, "\tNPC_PARSE_NIBBLE_LB_FLAGS:%#02X\n", data); offset += 8; } @@ -179,9 +185,9 @@ npc_flow_print_parse_nibbles(FILE *file, struct roc_npc_flow *flow, offset += 4; } - if (rx_parse->lbflags) { + if (rx_parse->lcflags) { data = npc_get_nibbles(flow, 2, offset); - fprintf(file, "\tNPC_PARSE_NIBBLE_LB_FLAGS:%#02X\n", data); + fprintf(file, "\tNPC_PARSE_NIBBLE_LC_FLAGS:%#02X\n", data); offset += 8; } @@ -192,9 +198,9 @@ npc_flow_print_parse_nibbles(FILE *file, struct roc_npc_flow *flow, offset += 4; } - if (rx_parse->lcflags) { + if (rx_parse->ldflags) { data = npc_get_nibbles(flow, 2, offset); - fprintf(file, "\tNPC_PARSE_NIBBLE_LC_FLAGS:%#02X\n", data); + fprintf(file, "\tNPC_PARSE_NIBBLE_LD_FLAGS:%#02X\n", data); offset += 8; } @@ -205,9 +211,9 @@ npc_flow_print_parse_nibbles(FILE *file, struct roc_npc_flow *flow, offset += 4; } - if (rx_parse->ldflags) { + if (rx_parse->leflags) { data = npc_get_nibbles(flow, 2, offset); - fprintf(file, "\tNPC_PARSE_NIBBLE_LD_FLAGS:%#02X\n", data); + fprintf(file, "\tNPC_PARSE_NIBBLE_LE_FLAGS:%#02X\n", data); offset += 8; } @@ -218,9 +224,9 @@ npc_flow_print_parse_nibbles(FILE *file, struct roc_npc_flow *flow, offset += 4; } - if (rx_parse->leflags) { + if (rx_parse->lfflags) { data = npc_get_nibbles(flow, 2, offset); - fprintf(file, "\tNPC_PARSE_NIBBLE_LE_FLAGS:%#02X\n", data); + fprintf(file, "\tNPC_PARSE_NIBBLE_LF_FLAGS:%#02X\n", data); offset += 8; } @@ -231,9 +237,9 @@ npc_flow_print_parse_nibbles(FILE *file, struct roc_npc_flow *flow, offset += 4; } - if (rx_parse->lfflags) { + if (rx_parse->lgflags) { data = npc_get_nibbles(flow, 2, offset); - fprintf(file, "\tNPC_PARSE_NIBBLE_LF_FLAGS:%#02X\n", data); + fprintf(file, "\tNPC_PARSE_NIBBLE_LG_FLAGS:%#02X\n", data); offset += 8; } @@ -244,10 +250,9 @@ npc_flow_print_parse_nibbles(FILE *file, struct roc_npc_flow *flow, offset += 4; } - if (rx_parse->lgflags) { + if (rx_parse->lhflags) { data = npc_get_nibbles(flow, 2, offset); - fprintf(file, "\tNPC_PARSE_NIBBLE_LG_FLAGS:%#02X\n", data); - offset += 8; + fprintf(file, "\tNPC_PARSE_NIBBLE_LH_FLAGS:%#02X\n", data); } if (rx_parse->lhtype) { @@ -256,11 +261,6 @@ npc_flow_print_parse_nibbles(FILE *file, struct roc_npc_flow *flow, ltype_str[NPC_LID_LH][data]); offset += 4; } - - if (rx_parse->lhflags) { - data = npc_get_nibbles(flow, 2, offset); - fprintf(file, "\tNPC_PARSE_NIBBLE_LH_FLAGS:%#02X\n", data); - } } static void -- 2.25.4
[dpdk-dev] [PATCH 1/4] drivers: add support for switch header type pre L2
From: Kiran Kumar K Adding changes to configure switch header type pre L2 for cnxk. Along with switch header type user needs to provide the offset with in the custom header that holds the size of the custom header and mask for the size with in the size offset. ci: skip_roc_check skip_checkformat Signed-off-by: Kiran Kumar K Change-Id: I1f114570c6ba451a8d57c27715cb4c5b65d5b2cb Reviewed-on: https://sj1git1.cavium.com/c/IP/SW/dataplane/dpdk/+/64820 Tested-by: sa_ip-toolkits-Jenkins Reviewed-by: Satheesh Paul Reviewed-on: https://sj1git1.cavium.com/c/IP/SW/dataplane/dpdk/+/67029 --- doc/guides/nics/cnxk.rst | 25 +++- drivers/common/cnxk/hw/npc.h | 11 --- drivers/common/cnxk/roc_mbox.h | 1 + drivers/common/cnxk/roc_nix.h | 5 +++- drivers/common/cnxk/roc_nix_ops.c | 12 +++- drivers/common/cnxk/roc_npc.h | 8 + drivers/net/cnxk/cnxk_ethdev.c | 7 +++-- drivers/net/cnxk/cnxk_ethdev_devargs.c | 41 ++ 8 files changed, 99 insertions(+), 11 deletions(-) diff --git a/doc/guides/nics/cnxk.rst b/doc/guides/nics/cnxk.rst index 2927c6cb7e..7c82cb55e1 100644 --- a/doc/guides/nics/cnxk.rst +++ b/doc/guides/nics/cnxk.rst @@ -167,7 +167,30 @@ Runtime Config Options With the above configuration, higig2 will be enabled on that port and the traffic on this port should be higig2 traffic only. Supported switch header - types are "chlen24b", "chlen90b", "dsa", "exdsa", "higig2" and "vlan_exdsa". + types are "chlen24b", "chlen90b", "dsa", "exdsa", "higig2", "vlan_exdsa" and "pre_l2". + +- ``Flow pre l2 info`` (default ``0x0/0x0/0x0``) + + In case of custom pre l2 headers, an offset, mask with in the offset and shift direction + has to be provided within the custom header that holds the size of the custom header. + This is valid only with switch header pre l2. Maximum supported offset range is 0 to 255 + and mask range is 1 to 255 and shift direction, 0: left shift, 1: right shift. + Info format will be "offset/mask/shift direction". All parameters has to be in hexadecimal + format and mask should be contiguous. Info can be configured using + ``flow_pre_l2_info`` ``devargs`` parameter. + + For example:: + + -a 0002:02:00.0,switch_header="pre_l2",flow_pre_l2_info=0x2/0x7e/0x1 + + With the above configuration, custom pre l2 header will be enabled on that port and size + of the header is placed at byte offset 0x2 in the packet with mask 0x7e and right shift will + be used to get the size. i.e size will be (pkt[0x2] & 0x7e) >> shift count. + Shift count will be calculated based on mask and shift direction. For example if mask is 0x7c + and shift direction is 1, i.e right shift, then the shift count will be 2 i.e absolute + position of the right most set bit. If the mask is 0x7c and shift direction is 0, i.e left + shift, then the shift count will be 1, i.e 8-n, where n is the absolute position of + left most set bit. - ``RSS tag as XOR`` (default ``0``) diff --git a/drivers/common/cnxk/hw/npc.h b/drivers/common/cnxk/hw/npc.h index 68c5037e1c..6f896de9f0 100644 --- a/drivers/common/cnxk/hw/npc.h +++ b/drivers/common/cnxk/hw/npc.h @@ -169,13 +169,12 @@ enum npc_kpu_la_ltype { NPC_LT_LA_8023 = 1, NPC_LT_LA_ETHER, NPC_LT_LA_IH_NIX_ETHER, - NPC_LT_LA_IH_8_ETHER, - NPC_LT_LA_IH_4_ETHER, - NPC_LT_LA_IH_2_ETHER, - NPC_LT_LA_HIGIG2_ETHER, + NPC_LT_LA_HIGIG2_ETHER = 7, NPC_LT_LA_IH_NIX_HIGIG2_ETHER, - NPC_LT_LA_CH_LEN_90B_ETHER, + NPC_LT_LA_CUSTOM_L2_90B_ETHER, NPC_LT_LA_CPT_HDR, + NPC_LT_LA_CUSTOM_L2_24B_ETHER, + NPC_LT_LA_CUSTOM_PRE_L2_ETHER, NPC_LT_LA_CUSTOM0 = 0xE, NPC_LT_LA_CUSTOM1 = 0xF, }; @@ -185,7 +184,7 @@ enum npc_kpu_lb_ltype { NPC_LT_LB_CTAG, NPC_LT_LB_STAG_QINQ, NPC_LT_LB_BTAG, - NPC_LT_LB_ITAG, + NPC_LT_LB_PPPOE, NPC_LT_LB_DSA, NPC_LT_LB_DSA_VLAN, NPC_LT_LB_EDSA, diff --git a/drivers/common/cnxk/roc_mbox.h b/drivers/common/cnxk/roc_mbox.h index b63fe108c9..4cffe9b182 100644 --- a/drivers/common/cnxk/roc_mbox.h +++ b/drivers/common/cnxk/roc_mbox.h @@ -313,6 +313,7 @@ struct npc_set_pkind { #define ROC_PRIV_FLAGS_LEN_90B BIT_ULL(3) #define ROC_PRIV_FLAGS_EXDSA BIT_ULL(4) #define ROC_PRIV_FLAGS_VLAN_EXDSA BIT_ULL(5) +#define ROC_PRIV_FLAGS_PRE_L2BIT_ULL(6) #define ROC_PRIV_FLAGS_CUSTOMBIT_ULL(63) uint64_t __io mode; #define PKIND_TX BIT_ULL(0) diff --git a/drivers/common/cnxk/roc_nix.h b/drivers/common/cnxk/roc_nix.h index 69a5e8e7b4..3f195f191a 100644 --- a/drivers/common/cnxk/roc_nix.h +++ b/drivers/common/cnxk/roc_nix.h @@ -714,7 +714,10 @@ void __roc_api roc_nix_mac_link_info_get_cb_unregister(struct roc_nix *roc_nix); /* Ops */ int __roc_api roc_nix_switch_hdr_set(struct roc_nix *roc_nix, -uint64_t swit
[dpdk-dev] [PATCH 2/4] common/cnxk: support custom pre L2 header parsing as raw
From: Kiran Kumar K Add roc API for parsing custom pre L2 headers as raw data. Only relative offset is supported and search and limit is not supported with this raw item type. ci: skip_klocwork Signed-off-by: Kiran Kumar K Change-Id: I2840244715e2c849e8b96145dc1b642dd8e3583b Reviewed-on: https://sj1git1.cavium.com/c/IP/SW/dataplane/dpdk/+/65070 Tested-by: sa_ip-toolkits-Jenkins Reviewed-by: Satheesh Paul Reviewed-on: https://sj1git1.cavium.com/c/IP/SW/dataplane/dpdk/+/67030 Tested-by: Jerin Jacob Kollanukkaran --- drivers/common/cnxk/roc_npc.c | 8 +- drivers/common/cnxk/roc_npc_mcam_dump.c | 2 + drivers/common/cnxk/roc_npc_parse.c | 103 +--- drivers/common/cnxk/roc_npc_priv.h | 1 + 4 files changed, 81 insertions(+), 33 deletions(-) diff --git a/drivers/common/cnxk/roc_npc.c b/drivers/common/cnxk/roc_npc.c index d18dfd4259..e3961bfbc6 100644 --- a/drivers/common/cnxk/roc_npc.c +++ b/drivers/common/cnxk/roc_npc.c @@ -566,10 +566,10 @@ npc_parse_pattern(struct npc *npc, const struct roc_npc_item_info pattern[], struct roc_npc_flow *flow, struct npc_parse_state *pst) { npc_parse_stage_func_t parse_stage_funcs[] = { - npc_parse_meta_items, npc_parse_cpt_hdr, npc_parse_higig2_hdr, - npc_parse_la, npc_parse_lb, npc_parse_lc, - npc_parse_ld, npc_parse_le, npc_parse_lf, - npc_parse_lg, npc_parse_lh, + npc_parse_meta_items, npc_parse_pre_l2, npc_parse_cpt_hdr, + npc_parse_higig2_hdr, npc_parse_la, npc_parse_lb, + npc_parse_lc, npc_parse_ld, npc_parse_le, + npc_parse_lf, npc_parse_lg, npc_parse_lh, }; uint8_t layer = 0; int key_offset; diff --git a/drivers/common/cnxk/roc_npc_mcam_dump.c b/drivers/common/cnxk/roc_npc_mcam_dump.c index 278056591e..679e3d7657 100644 --- a/drivers/common/cnxk/roc_npc_mcam_dump.c +++ b/drivers/common/cnxk/roc_npc_mcam_dump.c @@ -69,6 +69,8 @@ static const char *const ltype_str[NPC_MAX_LID][NPC_MAX_LT] = { [NPC_LID_LA][NPC_LT_LA_IH_NIX_ETHER] = "LA_IH_NIX_ETHER", [NPC_LID_LA][NPC_LT_LA_HIGIG2_ETHER] = "LA_HIGIG2_ETHER", [NPC_LID_LA][NPC_LT_LA_IH_NIX_HIGIG2_ETHER] = "LA_IH_NIX_HIGIG2_ETHER", + [NPC_LID_LA][NPC_LT_LA_CUSTOM_PRE_L2_ETHER] = + "NPC_LT_LA_CUSTOM_PRE_L2_ETHER", [NPC_LID_LB][0] = "NONE", [NPC_LID_LB][NPC_LT_LB_CTAG] = "LB_CTAG", [NPC_LID_LB][NPC_LT_LB_STAG_QINQ] = "LB_STAG_QINQ", diff --git a/drivers/common/cnxk/roc_npc_parse.c b/drivers/common/cnxk/roc_npc_parse.c index 8125035dd8..c9ab9aef28 100644 --- a/drivers/common/cnxk/roc_npc_parse.c +++ b/drivers/common/cnxk/roc_npc_parse.c @@ -21,6 +21,80 @@ npc_parse_meta_items(struct npc_parse_state *pst) return 0; } +static int +npc_flow_raw_item_prepare(const struct roc_npc_flow_item_raw *raw_spec, + const struct roc_npc_flow_item_raw *raw_mask, + struct npc_parse_item_info *info, uint8_t *spec_buf, + uint8_t *mask_buf) +{ + + memset(spec_buf, 0, NPC_MAX_RAW_ITEM_LEN); + memset(mask_buf, 0, NPC_MAX_RAW_ITEM_LEN); + + memcpy(spec_buf + raw_spec->offset, raw_spec->pattern, + raw_spec->length); + + if (raw_mask && raw_mask->pattern) { + memcpy(mask_buf + raw_spec->offset, raw_mask->pattern, + raw_spec->length); + } else { + memset(mask_buf + raw_spec->offset, 0xFF, raw_spec->length); + } + + info->len = NPC_MAX_RAW_ITEM_LEN; + info->spec = spec_buf; + info->mask = mask_buf; + return 0; +} + +int +npc_parse_pre_l2(struct npc_parse_state *pst) +{ + uint8_t raw_spec_buf[NPC_MAX_RAW_ITEM_LEN] = {0}; + uint8_t raw_mask_buf[NPC_MAX_RAW_ITEM_LEN] = {0}; + uint8_t hw_mask[NPC_MAX_EXTRACT_HW_LEN] = {0}; + const struct roc_npc_flow_item_raw *raw_spec; + struct npc_parse_item_info info; + int lid, lt, len; + int rc; + + if (pst->npc->switch_header_type != ROC_PRIV_FLAGS_PRE_L2) + return 0; + + /* Identify the pattern type into lid, lt */ + if (pst->pattern->type != ROC_NPC_ITEM_TYPE_RAW) + return 0; + + lid = NPC_LID_LA; + lt = NPC_LT_LA_CUSTOM_PRE_L2_ETHER; + info.hw_hdr_len = 0; + + raw_spec = pst->pattern->spec; + len = raw_spec->length + raw_spec->offset; + if (len > NPC_MAX_RAW_ITEM_LEN) + return -EINVAL; + + if (raw_spec->relative == 0 || raw_spec->search || raw_spec->limit || + raw_spec->offset < 0) + return -EINVAL; + + npc_flow_raw_item_prepare( + (const struct roc_npc_flow_item_raw *)pst->pattern->spec, + (const struct roc_npc_flow_item_raw *)pst->pattern->mask, &info, + ra
[dpdk-dev] [PATCH 3/4] common/cnxk: support matching VLAN existence in RTE Flow
From: Satheesh Paul Support matching existence of VLAN after RTE_FLOW_ITEM_TYPE_ETH and RTE_FLOW_ITEM_TYPE_VLAN items. ci: skip_checkformat Signed-off-by: Satheesh Paul Change-Id: Ieebeaee5f13e58e7db20a171ea878bb33ddd57bb Reviewed-on: https://sj1git1.cavium.com/c/IP/SW/dataplane/dpdk/+/67088 Tested-by: sa_ip-toolkits-Jenkins Reviewed-by: Kiran Kumar Kokkilagadda --- drivers/common/cnxk/roc_npc.h | 58 - drivers/common/cnxk/roc_npc_mcam.c | 37 -- drivers/common/cnxk/roc_npc_parse.c | 56 +--- drivers/common/cnxk/roc_npc_priv.h | 7 drivers/common/cnxk/roc_platform.h | 6 ++- 5 files changed, 151 insertions(+), 13 deletions(-) diff --git a/drivers/common/cnxk/roc_npc.h b/drivers/common/cnxk/roc_npc.h index 8b57678863..634c67e6f6 100644 --- a/drivers/common/cnxk/roc_npc.h +++ b/drivers/common/cnxk/roc_npc.h @@ -58,6 +58,60 @@ struct roc_npc_flow_item_raw { const uint8_t *pattern; /**< Byte string to look for. */ }; +struct roc_ether_addr { + uint8_t addr_bytes[PLT_ETHER_ADDR_LEN]; /**< Addr bytes in tx order */ +} __plt_aligned(2); + +struct roc_ether_hdr { + struct roc_ether_addr d_addr; /**< Destination address. */ + PLT_STD_C11 + union { + struct roc_ether_addr s_addr; /**< Source address. */ + struct { + struct roc_ether_addr S_addr; + } S_un; /**< Do not use directly; use s_addr instead.*/ + }; + uint16_t ether_type; /**< Frame type. */ +} __plt_aligned(2); + +PLT_STD_C11 +struct roc_npc_flow_item_eth { + union { + struct { + /* +* These fields are retained +* for compatibility. +* Please switch to the new header field below. +*/ + struct roc_ether_addr dst; /**< Destination MAC. */ + struct roc_ether_addr src; /**< Source MAC. */ + uint16_t type; /**< EtherType or TPID. */ + }; + struct roc_ether_hdr hdr; + }; + uint32_t has_vlan : 1; /**< Packet header contains at least one VLAN. */ + uint32_t reserved : 31; /**< Reserved, must be zero. */ +}; + +struct roc_vlan_hdr { + uint16_t vlan_tci; /**< Priority (3) + CFI (1) + Identifier Code (12) */ + uint16_t eth_proto; /**< Ethernet type of encapsulated frame. */ +} __plt_packed; + +PLT_STD_C11 +struct roc_npc_flow_item_vlan { + union { + struct { + uint16_t tci;/**< Tag control information. */ + uint16_t inner_type; /**< Inner EtherType or TPID. */ + }; + struct roc_vlan_hdr hdr; + }; + uint32_t has_more_vlan : 1; + /**< Packet header contains at least one more VLAN, after this VLAN. */ + uint32_t reserved : 31; /**< Reserved, must be zero. */ +}; + #define ROC_NPC_MAX_ACTION_COUNT 19 enum roc_npc_action_type { @@ -97,7 +151,7 @@ struct roc_npc_action_vf { }; struct roc_npc_action_port_id { - uint32_t original : 1; /**< Use original DPDK port ID if possible. */ + uint32_t original : 1; /**< Use original port ID if possible. */ uint32_t reserved : 31; /**< Reserved, must be zero. */ uint32_t id;/**< port ID. */ }; @@ -167,7 +221,7 @@ enum roc_npc_rss_hash_function { struct roc_npc_action_rss { enum roc_npc_rss_hash_function func; uint32_t level; - uint64_t types;/**< Specific RSS hash types (see RTE_ETH_RSS_*). */ + uint64_t types;/**< Specific RSS hash types (see ETH_RSS_*). */ uint32_t key_len; /**< Hash key length in bytes. */ uint32_t queue_num;/**< Number of entries in @p queue. */ const uint8_t *key;/**< Hash key. */ diff --git a/drivers/common/cnxk/roc_npc_mcam.c b/drivers/common/cnxk/roc_npc_mcam.c index 80851d6f9f..2349317c5c 100644 --- a/drivers/common/cnxk/roc_npc_mcam.c +++ b/drivers/common/cnxk/roc_npc_mcam.c @@ -613,6 +613,28 @@ npc_mcam_alloc_and_write(struct npc *npc, struct roc_npc_flow *flow, return 0; } +static void +npc_set_vlan_ltype(struct npc_parse_state *pst) +{ + uint64_t val, mask; + uint8_t lb_offset; + + lb_offset = + __builtin_popcount(pst->npc->keyx_supp_nmask[pst->nix_intf] & + ((1ULL << NPC_LTYPE_LB_OFFSET) - 1)); + lb_offset *= 4; + + mask = ~((0xfULL << lb_offset)); + pst->flow->mcam_data[0] &= mask; + pst->flow->mcam_mask[0] &= mask; + /* NPC_LT_LB_CTAG: 0b0010, NPC_LT_LB_STAG_QINQ: 0b0011 +* Set LB layertype/mask as 0b0010/0b1110 to match both. +*/ + val = ((uint64_t)(NPC_LT_LB_CTAG & NPC_LT_LB_STAG_QINQ)) << lb_offset; + pst->flow->mcam_data[0] |= val; + pst->
[dpdk-dev] [PATCH 4/4] common/cnxk: support extensions attributes in IPv6 item
From: Satheesh Paul Support matching existence of specific extension headers after RTE_FLOW_ITEM_TYPE_IPV6 item. Signed-off-by: Satheesh Paul Change-Id: I8c7d58af242d6d991b718787a6c9b8e79c6ff409 Reviewed-on: https://sj1git1.cavium.com/c/IP/SW/dataplane/dpdk/+/66900 Tested-by: sa_ip-toolkits-Jenkins Reviewed-by: Kiran Kumar Kokkilagadda Reviewed-on: https://sj1git1.cavium.com/c/IP/SW/dataplane/dpdk/+/67409 --- drivers/common/cnxk/hw/npc.h| 17 drivers/common/cnxk/roc_npc.h | 33 +++ drivers/common/cnxk/roc_npc_mcam.c | 47 - drivers/common/cnxk/roc_npc_parse.c | 65 +++-- drivers/common/cnxk/roc_npc_priv.h | 6 +++ 5 files changed, 162 insertions(+), 6 deletions(-) diff --git a/drivers/common/cnxk/hw/npc.h b/drivers/common/cnxk/hw/npc.h index 6f896de9f0..b8218e25af 100644 --- a/drivers/common/cnxk/hw/npc.h +++ b/drivers/common/cnxk/hw/npc.h @@ -320,6 +320,23 @@ enum npc_kpu_lc_uflag { NPC_F_LC_U_IP6_FRAG = 0x40, }; +enum npc_kpu_lc_lflag { + NPC_F_LC_L_IP_IN_IP = 1, + NPC_F_LC_L_6TO4, + NPC_F_LC_L_MPLS_IN_IP, + NPC_F_LC_L_IP6_TUN_IP6, + NPC_F_LC_L_IP6_MPLS_IN_IP, + NPC_F_LC_L_MPLS_4_LABELS, + NPC_F_LC_L_MPLS_3_LABELS, + NPC_F_LC_L_MPLS_2_LABELS, + NPC_F_LC_L_EXT_HOP, + NPC_F_LC_L_EXT_DEST, + NPC_F_LC_L_EXT_ROUT, + NPC_F_LC_L_EXT_MOBILITY, + NPC_F_LC_L_EXT_HOSTID, + NPC_F_LC_L_EXT_SHIM6, +}; + /* Structures definitions */ struct npc_kpu_profile_cam { uint8_t state; diff --git a/drivers/common/cnxk/roc_npc.h b/drivers/common/cnxk/roc_npc.h index 634c67e6f6..2098810ee3 100644 --- a/drivers/common/cnxk/roc_npc.h +++ b/drivers/common/cnxk/roc_npc.h @@ -112,6 +112,39 @@ struct roc_npc_flow_item_vlan { uint32_t reserved : 31; /**< Reserved, must be zero. */ }; +struct roc_ipv6_hdr { + uint32_t vtc_flow;/**< IP version, traffic class & flow label. */ + uint16_t payload_len; /**< IP payload size, including ext. headers */ + uint8_t proto;/**< Protocol, next header. */ + uint8_t hop_limits; /**< Hop limits. */ + uint8_t src_addr[16]; /**< IP address of source host. */ + uint8_t dst_addr[16]; /**< IP address of destination host(s). */ +} __plt_packed; + +struct roc_npc_flow_item_ipv6 { + struct roc_ipv6_hdr hdr; /**< IPv6 header definition. */ + uint32_t has_hop_ext : 1; + /**< Header contains Hop-by-Hop Options extension header. */ + uint32_t has_route_ext : 1; + /**< Header contains Routing extension header. */ + uint32_t has_frag_ext : 1; + /**< Header contains Fragment extension header. */ + uint32_t has_auth_ext : 1; + /**< Header contains Authentication extension header. */ + uint32_t has_esp_ext : 1; + /**< Header contains Encapsulation Security Payload extension header. */ + uint32_t has_dest_ext : 1; + /**< Header contains Destination Options extension header. */ + uint32_t has_mobil_ext : 1; + /**< Header contains Mobility extension header. */ + uint32_t has_hip_ext : 1; + /**< Header contains Host Identity Protocol extension header. */ + uint32_t has_shim6_ext : 1; + /**< Header contains Shim6 Protocol extension header. */ + uint32_t reserved : 23; + /**< Reserved for future extension headers, must be zero. */ +}; + #define ROC_NPC_MAX_ACTION_COUNT 19 enum roc_npc_action_type { diff --git a/drivers/common/cnxk/roc_npc_mcam.c b/drivers/common/cnxk/roc_npc_mcam.c index 2349317c5c..da5815ada0 100644 --- a/drivers/common/cnxk/roc_npc_mcam.c +++ b/drivers/common/cnxk/roc_npc_mcam.c @@ -283,8 +283,8 @@ npc_get_kex_capability(struct npc *npc) /* Custom L3 frame: varied offset and lengths */ kex_cap.bit.custom_l3 = npc_is_kex_enabled(npc, NPC_LID_LC, NPC_LT_LC_CUSTOM0, 0, 0); - kex_cap.bit.custom_l3 |= - npc_is_kex_enabled(npc, NPC_LID_LC, NPC_LT_LC_CUSTOM1, 0, 0); + kex_cap.bit.custom_l3 |= (uint64_t)npc_is_kex_enabled( + npc, NPC_LID_LC, NPC_LT_LC_CUSTOM1, 0, 0); /* SCTP sport : offset 0B, len 2B */ kex_cap.bit.sctp_sport = npc_is_kex_enabled( npc, NPC_LID_LD, NPC_LT_LD_SCTP, 0 * 8, 2 * 8); @@ -635,6 +635,46 @@ npc_set_vlan_ltype(struct npc_parse_state *pst) pst->flow->mcam_mask[0] |= (0xeULL << lb_offset); } +static void +npc_set_ipv6ext_ltype_mask(struct npc_parse_state *pst) +{ + uint8_t lc_offset, lcflag_offset; + uint64_t val, mask; + + lc_offset = + __builtin_popcount(pst->npc->keyx_supp_nmask[pst->nix_intf] & + ((1ULL << NPC_LTYPE_LC_OFFSET) - 1)); + lc_offset *= 4; + + mask = ~((0xfULL << lc_offset)); + pst->flow->mcam_data[0] &= mask; + pst->flow->mcam_mask[0] &= mask; + /* NPC_LT_LC_IP6: 0b0100, NPC_LT_LC_IP6_EXT: 0b0
[dpdk-dev] [PATCH v2 1/4] drivers: add support for switch header type pre L2
From: Kiran Kumar K Adding changes to configure switch header type pre L2 for cnxk. Along with switch header type user needs to provide the offset with in the custom header that holds the size of the custom header and mask for the size with in the size offset. Signed-off-by: Kiran Kumar K Reviewed-by: Satheesh Paul --- v2: * Fixed checkpatch errors in commit messages doc/guides/nics/cnxk.rst | 25 +++- drivers/common/cnxk/hw/npc.h | 11 --- drivers/common/cnxk/roc_mbox.h | 1 + drivers/common/cnxk/roc_nix.h | 5 +++- drivers/common/cnxk/roc_nix_ops.c | 12 +++- drivers/common/cnxk/roc_npc.h | 8 + drivers/net/cnxk/cnxk_ethdev.c | 7 +++-- drivers/net/cnxk/cnxk_ethdev_devargs.c | 41 ++ 8 files changed, 99 insertions(+), 11 deletions(-) diff --git a/doc/guides/nics/cnxk.rst b/doc/guides/nics/cnxk.rst index 2927c6cb7e..7c82cb55e1 100644 --- a/doc/guides/nics/cnxk.rst +++ b/doc/guides/nics/cnxk.rst @@ -167,7 +167,30 @@ Runtime Config Options With the above configuration, higig2 will be enabled on that port and the traffic on this port should be higig2 traffic only. Supported switch header - types are "chlen24b", "chlen90b", "dsa", "exdsa", "higig2" and "vlan_exdsa". + types are "chlen24b", "chlen90b", "dsa", "exdsa", "higig2", "vlan_exdsa" and "pre_l2". + +- ``Flow pre l2 info`` (default ``0x0/0x0/0x0``) + + In case of custom pre l2 headers, an offset, mask with in the offset and shift direction + has to be provided within the custom header that holds the size of the custom header. + This is valid only with switch header pre l2. Maximum supported offset range is 0 to 255 + and mask range is 1 to 255 and shift direction, 0: left shift, 1: right shift. + Info format will be "offset/mask/shift direction". All parameters has to be in hexadecimal + format and mask should be contiguous. Info can be configured using + ``flow_pre_l2_info`` ``devargs`` parameter. + + For example:: + + -a 0002:02:00.0,switch_header="pre_l2",flow_pre_l2_info=0x2/0x7e/0x1 + + With the above configuration, custom pre l2 header will be enabled on that port and size + of the header is placed at byte offset 0x2 in the packet with mask 0x7e and right shift will + be used to get the size. i.e size will be (pkt[0x2] & 0x7e) >> shift count. + Shift count will be calculated based on mask and shift direction. For example if mask is 0x7c + and shift direction is 1, i.e right shift, then the shift count will be 2 i.e absolute + position of the right most set bit. If the mask is 0x7c and shift direction is 0, i.e left + shift, then the shift count will be 1, i.e 8-n, where n is the absolute position of + left most set bit. - ``RSS tag as XOR`` (default ``0``) diff --git a/drivers/common/cnxk/hw/npc.h b/drivers/common/cnxk/hw/npc.h index 68c5037e1c..6f896de9f0 100644 --- a/drivers/common/cnxk/hw/npc.h +++ b/drivers/common/cnxk/hw/npc.h @@ -169,13 +169,12 @@ enum npc_kpu_la_ltype { NPC_LT_LA_8023 = 1, NPC_LT_LA_ETHER, NPC_LT_LA_IH_NIX_ETHER, - NPC_LT_LA_IH_8_ETHER, - NPC_LT_LA_IH_4_ETHER, - NPC_LT_LA_IH_2_ETHER, - NPC_LT_LA_HIGIG2_ETHER, + NPC_LT_LA_HIGIG2_ETHER = 7, NPC_LT_LA_IH_NIX_HIGIG2_ETHER, - NPC_LT_LA_CH_LEN_90B_ETHER, + NPC_LT_LA_CUSTOM_L2_90B_ETHER, NPC_LT_LA_CPT_HDR, + NPC_LT_LA_CUSTOM_L2_24B_ETHER, + NPC_LT_LA_CUSTOM_PRE_L2_ETHER, NPC_LT_LA_CUSTOM0 = 0xE, NPC_LT_LA_CUSTOM1 = 0xF, }; @@ -185,7 +184,7 @@ enum npc_kpu_lb_ltype { NPC_LT_LB_CTAG, NPC_LT_LB_STAG_QINQ, NPC_LT_LB_BTAG, - NPC_LT_LB_ITAG, + NPC_LT_LB_PPPOE, NPC_LT_LB_DSA, NPC_LT_LB_DSA_VLAN, NPC_LT_LB_EDSA, diff --git a/drivers/common/cnxk/roc_mbox.h b/drivers/common/cnxk/roc_mbox.h index b63fe108c9..4cffe9b182 100644 --- a/drivers/common/cnxk/roc_mbox.h +++ b/drivers/common/cnxk/roc_mbox.h @@ -313,6 +313,7 @@ struct npc_set_pkind { #define ROC_PRIV_FLAGS_LEN_90B BIT_ULL(3) #define ROC_PRIV_FLAGS_EXDSA BIT_ULL(4) #define ROC_PRIV_FLAGS_VLAN_EXDSA BIT_ULL(5) +#define ROC_PRIV_FLAGS_PRE_L2BIT_ULL(6) #define ROC_PRIV_FLAGS_CUSTOMBIT_ULL(63) uint64_t __io mode; #define PKIND_TX BIT_ULL(0) diff --git a/drivers/common/cnxk/roc_nix.h b/drivers/common/cnxk/roc_nix.h index 69a5e8e7b4..3f195f191a 100644 --- a/drivers/common/cnxk/roc_nix.h +++ b/drivers/common/cnxk/roc_nix.h @@ -714,7 +714,10 @@ void __roc_api roc_nix_mac_link_info_get_cb_unregister(struct roc_nix *roc_nix); /* Ops */ int __roc_api roc_nix_switch_hdr_set(struct roc_nix *roc_nix, -uint64_t switch_header_type); +uint64_t switch_header_type, +uint8_t pre_l2_size_offset, +uint8_t pre_l2_size_offset_mask,
[dpdk-dev] [PATCH v2 2/4] common/cnxk: support custom pre L2 header parsing as raw
From: Kiran Kumar K Add roc API for parsing custom pre L2 headers as raw data. Only relative offset is supported and search and limit is not supported with this raw item type. Signed-off-by: Kiran Kumar K Reviewed-by: Satheesh Paul --- drivers/common/cnxk/roc_npc.c | 8 +- drivers/common/cnxk/roc_npc_mcam_dump.c | 2 + drivers/common/cnxk/roc_npc_parse.c | 103 +--- drivers/common/cnxk/roc_npc_priv.h | 1 + 4 files changed, 81 insertions(+), 33 deletions(-) diff --git a/drivers/common/cnxk/roc_npc.c b/drivers/common/cnxk/roc_npc.c index d18dfd4259..e3961bfbc6 100644 --- a/drivers/common/cnxk/roc_npc.c +++ b/drivers/common/cnxk/roc_npc.c @@ -566,10 +566,10 @@ npc_parse_pattern(struct npc *npc, const struct roc_npc_item_info pattern[], struct roc_npc_flow *flow, struct npc_parse_state *pst) { npc_parse_stage_func_t parse_stage_funcs[] = { - npc_parse_meta_items, npc_parse_cpt_hdr, npc_parse_higig2_hdr, - npc_parse_la, npc_parse_lb, npc_parse_lc, - npc_parse_ld, npc_parse_le, npc_parse_lf, - npc_parse_lg, npc_parse_lh, + npc_parse_meta_items, npc_parse_pre_l2, npc_parse_cpt_hdr, + npc_parse_higig2_hdr, npc_parse_la, npc_parse_lb, + npc_parse_lc, npc_parse_ld, npc_parse_le, + npc_parse_lf, npc_parse_lg, npc_parse_lh, }; uint8_t layer = 0; int key_offset; diff --git a/drivers/common/cnxk/roc_npc_mcam_dump.c b/drivers/common/cnxk/roc_npc_mcam_dump.c index 278056591e..679e3d7657 100644 --- a/drivers/common/cnxk/roc_npc_mcam_dump.c +++ b/drivers/common/cnxk/roc_npc_mcam_dump.c @@ -69,6 +69,8 @@ static const char *const ltype_str[NPC_MAX_LID][NPC_MAX_LT] = { [NPC_LID_LA][NPC_LT_LA_IH_NIX_ETHER] = "LA_IH_NIX_ETHER", [NPC_LID_LA][NPC_LT_LA_HIGIG2_ETHER] = "LA_HIGIG2_ETHER", [NPC_LID_LA][NPC_LT_LA_IH_NIX_HIGIG2_ETHER] = "LA_IH_NIX_HIGIG2_ETHER", + [NPC_LID_LA][NPC_LT_LA_CUSTOM_PRE_L2_ETHER] = + "NPC_LT_LA_CUSTOM_PRE_L2_ETHER", [NPC_LID_LB][0] = "NONE", [NPC_LID_LB][NPC_LT_LB_CTAG] = "LB_CTAG", [NPC_LID_LB][NPC_LT_LB_STAG_QINQ] = "LB_STAG_QINQ", diff --git a/drivers/common/cnxk/roc_npc_parse.c b/drivers/common/cnxk/roc_npc_parse.c index 8125035dd8..c9ab9aef28 100644 --- a/drivers/common/cnxk/roc_npc_parse.c +++ b/drivers/common/cnxk/roc_npc_parse.c @@ -21,6 +21,80 @@ npc_parse_meta_items(struct npc_parse_state *pst) return 0; } +static int +npc_flow_raw_item_prepare(const struct roc_npc_flow_item_raw *raw_spec, + const struct roc_npc_flow_item_raw *raw_mask, + struct npc_parse_item_info *info, uint8_t *spec_buf, + uint8_t *mask_buf) +{ + + memset(spec_buf, 0, NPC_MAX_RAW_ITEM_LEN); + memset(mask_buf, 0, NPC_MAX_RAW_ITEM_LEN); + + memcpy(spec_buf + raw_spec->offset, raw_spec->pattern, + raw_spec->length); + + if (raw_mask && raw_mask->pattern) { + memcpy(mask_buf + raw_spec->offset, raw_mask->pattern, + raw_spec->length); + } else { + memset(mask_buf + raw_spec->offset, 0xFF, raw_spec->length); + } + + info->len = NPC_MAX_RAW_ITEM_LEN; + info->spec = spec_buf; + info->mask = mask_buf; + return 0; +} + +int +npc_parse_pre_l2(struct npc_parse_state *pst) +{ + uint8_t raw_spec_buf[NPC_MAX_RAW_ITEM_LEN] = {0}; + uint8_t raw_mask_buf[NPC_MAX_RAW_ITEM_LEN] = {0}; + uint8_t hw_mask[NPC_MAX_EXTRACT_HW_LEN] = {0}; + const struct roc_npc_flow_item_raw *raw_spec; + struct npc_parse_item_info info; + int lid, lt, len; + int rc; + + if (pst->npc->switch_header_type != ROC_PRIV_FLAGS_PRE_L2) + return 0; + + /* Identify the pattern type into lid, lt */ + if (pst->pattern->type != ROC_NPC_ITEM_TYPE_RAW) + return 0; + + lid = NPC_LID_LA; + lt = NPC_LT_LA_CUSTOM_PRE_L2_ETHER; + info.hw_hdr_len = 0; + + raw_spec = pst->pattern->spec; + len = raw_spec->length + raw_spec->offset; + if (len > NPC_MAX_RAW_ITEM_LEN) + return -EINVAL; + + if (raw_spec->relative == 0 || raw_spec->search || raw_spec->limit || + raw_spec->offset < 0) + return -EINVAL; + + npc_flow_raw_item_prepare( + (const struct roc_npc_flow_item_raw *)pst->pattern->spec, + (const struct roc_npc_flow_item_raw *)pst->pattern->mask, &info, + raw_spec_buf, raw_mask_buf); + + info.hw_mask = &hw_mask; + npc_get_hw_supp_mask(pst, &info, lid, lt); + + /* Basic validation of item parameters */ + rc = npc_parse_item_basic(pst->pattern, &info); + if (rc) + return rc; + + /* Update pst
[dpdk-dev] [PATCH v2 3/4] common/cnxk: support matching VLAN existence in RTE Flow
From: Satheesh Paul Support matching existence of VLAN after RTE_FLOW_ITEM_TYPE_ETH and RTE_FLOW_ITEM_TYPE_VLAN items. Signed-off-by: Satheesh Paul Reviewed-by: Kiran Kumar Kokkilagadda --- drivers/common/cnxk/roc_npc.h | 56 - drivers/common/cnxk/roc_npc_mcam.c | 37 --- drivers/common/cnxk/roc_npc_parse.c | 56 + drivers/common/cnxk/roc_npc_priv.h | 7 drivers/common/cnxk/roc_platform.h | 6 +++- 5 files changed, 150 insertions(+), 12 deletions(-) diff --git a/drivers/common/cnxk/roc_npc.h b/drivers/common/cnxk/roc_npc.h index 8b57678863..6ab185e188 100644 --- a/drivers/common/cnxk/roc_npc.h +++ b/drivers/common/cnxk/roc_npc.h @@ -58,6 +58,60 @@ struct roc_npc_flow_item_raw { const uint8_t *pattern; /**< Byte string to look for. */ }; +struct roc_ether_addr { + uint8_t addr_bytes[PLT_ETHER_ADDR_LEN]; /**< Addr bytes in tx order */ +} plt_aligned(2); + +struct roc_ether_hdr { + struct roc_ether_addr d_addr; /**< Destination address. */ + PLT_STD_C11 + union { + struct roc_ether_addr s_addr; /**< Source address. */ + struct { + struct roc_ether_addr S_addr; + } S_un; /**< Do not use directly; use s_addr instead.*/ + }; + uint16_t ether_type; /**< Frame type. */ +} plt_aligned(2); + +PLT_STD_C11 +struct roc_npc_flow_item_eth { + union { + struct { + /* +* These fields are retained +* for compatibility. +* Please switch to the new header field below. +*/ + struct roc_ether_addr dst; /**< Destination MAC. */ + struct roc_ether_addr src; /**< Source MAC. */ + uint16_t type; /**< EtherType or TPID. */ + }; + struct roc_ether_hdr hdr; + }; + uint32_t has_vlan : 1; /**< Packet header contains at least one VLAN. */ + uint32_t reserved : 31; /**< Reserved, must be zero. */ +}; + +struct roc_vlan_hdr { + uint16_t vlan_tci; /**< Priority (3) + CFI (1) + Identifier Code (12) */ + uint16_t eth_proto; /**< Ethernet type of encapsulated frame. */ +} __plt_packed; + +PLT_STD_C11 +struct roc_npc_flow_item_vlan { + union { + struct { + uint16_t tci;/**< Tag control information. */ + uint16_t inner_type; /**< Inner EtherType or TPID. */ + }; + struct roc_vlan_hdr hdr; + }; + uint32_t has_more_vlan : 1; + /**< Packet header contains at least one more VLAN, after this VLAN. */ + uint32_t reserved : 31; /**< Reserved, must be zero. */ +}; + #define ROC_NPC_MAX_ACTION_COUNT 19 enum roc_npc_action_type { @@ -97,7 +151,7 @@ struct roc_npc_action_vf { }; struct roc_npc_action_port_id { - uint32_t original : 1; /**< Use original DPDK port ID if possible. */ + uint32_t original : 1; /**< Use original port ID if possible. */ uint32_t reserved : 31; /**< Reserved, must be zero. */ uint32_t id;/**< port ID. */ }; diff --git a/drivers/common/cnxk/roc_npc_mcam.c b/drivers/common/cnxk/roc_npc_mcam.c index 80851d6f9f..2349317c5c 100644 --- a/drivers/common/cnxk/roc_npc_mcam.c +++ b/drivers/common/cnxk/roc_npc_mcam.c @@ -613,6 +613,28 @@ npc_mcam_alloc_and_write(struct npc *npc, struct roc_npc_flow *flow, return 0; } +static void +npc_set_vlan_ltype(struct npc_parse_state *pst) +{ + uint64_t val, mask; + uint8_t lb_offset; + + lb_offset = + __builtin_popcount(pst->npc->keyx_supp_nmask[pst->nix_intf] & + ((1ULL << NPC_LTYPE_LB_OFFSET) - 1)); + lb_offset *= 4; + + mask = ~((0xfULL << lb_offset)); + pst->flow->mcam_data[0] &= mask; + pst->flow->mcam_mask[0] &= mask; + /* NPC_LT_LB_CTAG: 0b0010, NPC_LT_LB_STAG_QINQ: 0b0011 +* Set LB layertype/mask as 0b0010/0b1110 to match both. +*/ + val = ((uint64_t)(NPC_LT_LB_CTAG & NPC_LT_LB_STAG_QINQ)) << lb_offset; + pst->flow->mcam_data[0] |= val; + pst->flow->mcam_mask[0] |= (0xeULL << lb_offset); +} + int npc_program_mcam(struct npc *npc, struct npc_parse_state *pst, bool mcam_alloc) { @@ -651,12 +673,16 @@ npc_program_mcam(struct npc *npc, struct npc_parse_state *pst, bool mcam_alloc) if (layer_info) { for (idx = 0; idx <= 2; idx++) { if (layer_info & (1 << idx)) { - if (idx == 2) + if (idx == 2) { data = lt; - else if (idx == 1) + mask = 0xf
[dpdk-dev] [PATCH v2 4/4] common/cnxk: support extensions attributes in IPv6 item
From: Satheesh Paul Support matching existence of specific extension headers after RTE_FLOW_ITEM_TYPE_IPV6 item. Signed-off-by: Satheesh Paul Reviewed-by: Kiran Kumar Kokkilagadda --- drivers/common/cnxk/hw/npc.h| 17 drivers/common/cnxk/roc_npc.h | 33 +++ drivers/common/cnxk/roc_npc_mcam.c | 43 +++ drivers/common/cnxk/roc_npc_parse.c | 65 +++-- drivers/common/cnxk/roc_npc_priv.h | 6 +++ 5 files changed, 160 insertions(+), 4 deletions(-) diff --git a/drivers/common/cnxk/hw/npc.h b/drivers/common/cnxk/hw/npc.h index 6f896de9f0..b8218e25af 100644 --- a/drivers/common/cnxk/hw/npc.h +++ b/drivers/common/cnxk/hw/npc.h @@ -320,6 +320,23 @@ enum npc_kpu_lc_uflag { NPC_F_LC_U_IP6_FRAG = 0x40, }; +enum npc_kpu_lc_lflag { + NPC_F_LC_L_IP_IN_IP = 1, + NPC_F_LC_L_6TO4, + NPC_F_LC_L_MPLS_IN_IP, + NPC_F_LC_L_IP6_TUN_IP6, + NPC_F_LC_L_IP6_MPLS_IN_IP, + NPC_F_LC_L_MPLS_4_LABELS, + NPC_F_LC_L_MPLS_3_LABELS, + NPC_F_LC_L_MPLS_2_LABELS, + NPC_F_LC_L_EXT_HOP, + NPC_F_LC_L_EXT_DEST, + NPC_F_LC_L_EXT_ROUT, + NPC_F_LC_L_EXT_MOBILITY, + NPC_F_LC_L_EXT_HOSTID, + NPC_F_LC_L_EXT_SHIM6, +}; + /* Structures definitions */ struct npc_kpu_profile_cam { uint8_t state; diff --git a/drivers/common/cnxk/roc_npc.h b/drivers/common/cnxk/roc_npc.h index 6ab185e188..b836e264c6 100644 --- a/drivers/common/cnxk/roc_npc.h +++ b/drivers/common/cnxk/roc_npc.h @@ -112,6 +112,39 @@ struct roc_npc_flow_item_vlan { uint32_t reserved : 31; /**< Reserved, must be zero. */ }; +struct roc_ipv6_hdr { + uint32_t vtc_flow;/**< IP version, traffic class & flow label. */ + uint16_t payload_len; /**< IP payload size, including ext. headers */ + uint8_t proto;/**< Protocol, next header. */ + uint8_t hop_limits; /**< Hop limits. */ + uint8_t src_addr[16]; /**< IP address of source host. */ + uint8_t dst_addr[16]; /**< IP address of destination host(s). */ +} __plt_packed; + +struct roc_npc_flow_item_ipv6 { + struct roc_ipv6_hdr hdr; /**< IPv6 header definition. */ + uint32_t has_hop_ext : 1; + /**< Header contains Hop-by-Hop Options extension header. */ + uint32_t has_route_ext : 1; + /**< Header contains Routing extension header. */ + uint32_t has_frag_ext : 1; + /**< Header contains Fragment extension header. */ + uint32_t has_auth_ext : 1; + /**< Header contains Authentication extension header. */ + uint32_t has_esp_ext : 1; + /**< Header contains Encapsulation Security Payload extension header. */ + uint32_t has_dest_ext : 1; + /**< Header contains Destination Options extension header. */ + uint32_t has_mobil_ext : 1; + /**< Header contains Mobility extension header. */ + uint32_t has_hip_ext : 1; + /**< Header contains Host Identity Protocol extension header. */ + uint32_t has_shim6_ext : 1; + /**< Header contains Shim6 Protocol extension header. */ + uint32_t reserved : 23; + /**< Reserved for future extension headers, must be zero. */ +}; + #define ROC_NPC_MAX_ACTION_COUNT 19 enum roc_npc_action_type { diff --git a/drivers/common/cnxk/roc_npc_mcam.c b/drivers/common/cnxk/roc_npc_mcam.c index 2349317c5c..2063b5c59a 100644 --- a/drivers/common/cnxk/roc_npc_mcam.c +++ b/drivers/common/cnxk/roc_npc_mcam.c @@ -635,6 +635,46 @@ npc_set_vlan_ltype(struct npc_parse_state *pst) pst->flow->mcam_mask[0] |= (0xeULL << lb_offset); } +static void +npc_set_ipv6ext_ltype_mask(struct npc_parse_state *pst) +{ + uint8_t lc_offset, lcflag_offset; + uint64_t val, mask; + + lc_offset = + __builtin_popcount(pst->npc->keyx_supp_nmask[pst->nix_intf] & + ((1ULL << NPC_LTYPE_LC_OFFSET) - 1)); + lc_offset *= 4; + + mask = ~((0xfULL << lc_offset)); + pst->flow->mcam_data[0] &= mask; + pst->flow->mcam_mask[0] &= mask; + /* NPC_LT_LC_IP6: 0b0100, NPC_LT_LC_IP6_EXT: 0b0101 +* Set LC layertype/mask as 0b0100/0b1110 to match both. +*/ + val = ((uint64_t)(NPC_LT_LC_IP6 & NPC_LT_LC_IP6_EXT)) << lc_offset; + pst->flow->mcam_data[0] |= val; + pst->flow->mcam_mask[0] |= (0xeULL << lc_offset); + + /* If LC LFLAG is non-zero, set the LC LFLAG mask to 0xF. In general +* case flag mask is set same as the value in data. For example, to +* match 3 VLANs, flags have to match a range of values. But, for IPv6 +* extended attributes matching, we need an exact match. Hence, set the +* mask as 0xF. This is done only if LC LFLAG value is non-zero, +* because for AH and ESP, LC LFLAG is zero and we don't want to match +* zero in LFLAG. +*/ + lcflag_offset = + __builtin_popcount(pst->npc->keyx_supp_nmask[pst->nix_i
[dpdk-dev] [PATCH] net/octeontx2: support for rte_flow_dev_dump api
From: Satheesh Paul Add support to dump hardware internal representation information of rte flow to file. Every flow rule added will be dumped in the below format. MCAM Index:1881 Interface :NIX-RX (0) Priority :1 NPC RX Action:0X404001 ActionOp:NIX_RX_ACTIONOP_UCAST (1) PF_FUNC: 0X400 RQ Index:0X004 Match Id: Flow Key Alg:0 NPC RX VTAG Action:0X008100 VTAG0:relptr:0 lid:0X1 type:0 Patterns: NPC_PARSE_NIBBLE_CHAN:000 NPC_PARSE_NIBBLE_LA_LTYPE:LA_ETHER NPC_PARSE_NIBBLE_LB_LTYPE:NONE NPC_PARSE_NIBBLE_LC_LTYPE:LC_IP NPC_PARSE_NIBBLE_LD_LTYPE:LD_TCP NPC_PARSE_NIBBLE_LE_LTYPE:NONE LA_ETHER, hdr offset:0, len:0X6, key offset:0X8,\ Data:0X4AE124FC7FFF, Mask:0X LA_ETHER, hdr offset:0XC, len:0X2, key offset:0X4, Data:0XCA5A,\ Mask:0X LC_IP, hdr offset:0XC, len:0X8, key offset:0X10,\ Data:0X0A010103, Mask:0X LD_TCP, hdr offset:0, len:0X4, key offset:0X18, Data:0X0345,\ Mask:0X MCAM Raw Data : DW0 :CA5A01202000 DW0_Mask:0FF0F000 DW1 :4AE124FC7FFF DW1_Mask: DW2 :0A010103 DW2_Mask: DW3 :0345 DW3_Mask: DW4 : DW4_Mask: DW5 : DW5_Mask: DW6 : DW6_Mask: Signed-off-by: Satheesh Paul --- drivers/net/octeontx2/meson.build | 1 + drivers/net/octeontx2/otx2_flow.c | 33 ++ drivers/net/octeontx2/otx2_flow.h | 10 + drivers/net/octeontx2/otx2_flow_dump.c | 592 drivers/net/octeontx2/otx2_flow_utils.c | 4 + 5 files changed, 640 insertions(+) create mode 100644 drivers/net/octeontx2/otx2_flow_dump.c diff --git a/drivers/net/octeontx2/meson.build b/drivers/net/octeontx2/meson.build index e2c139a8b..779a75b5d 100644 --- a/drivers/net/octeontx2/meson.build +++ b/drivers/net/octeontx2/meson.build @@ -28,6 +28,7 @@ sources = files('otx2_rx.c', 'otx2_lookup.c', 'otx2_ethdev.c', 'otx2_flow_ctrl.c', + 'otx2_flow_dump.c', 'otx2_flow_parse.c', 'otx2_flow_utils.c', 'otx2_ethdev_irq.c', diff --git a/drivers/net/octeontx2/otx2_flow.c b/drivers/net/octeontx2/otx2_flow.c index a5900f349..14ac9bc76 100644 --- a/drivers/net/octeontx2/otx2_flow.c +++ b/drivers/net/octeontx2/otx2_flow.c @@ -805,6 +805,38 @@ otx2_flow_query(struct rte_eth_dev *dev, return -rte_errno; } +static int +otx2_flow_dev_dump(struct rte_eth_dev *dev, + FILE *file, + struct rte_flow_error *error) +{ + struct otx2_eth_dev *hw = dev->data->dev_private; + struct otx2_flow_list *list; + struct rte_flow *flow_iter; + uint32_t max_prio, i; + + if (file == NULL) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, + NULL, + "Invalid file"); + return -EINVAL; + } + + max_prio = hw->npc_flow.flow_max_priority; + + for (i = 0; i < max_prio; i++) { + list = &hw->npc_flow.flow_list[i]; + + /* List in ascending order of mcam entries */ + TAILQ_FOREACH(flow_iter, list, next) { + otx2_flow_dump(file, hw, flow_iter); + } + } + + return 0; +} + const struct rte_flow_ops otx2_flow_ops = { .validate = otx2_flow_validate, .create = otx2_flow_create, @@ -812,6 +844,7 @@ const struct rte_flow_ops otx2_flow_ops = { .flush = otx2_flow_flush, .query = otx2_flow_query, .isolate = otx2_flow_isolate, + .dev_dump = otx2_flow_dev_dump, }; static int diff --git a/drivers/net/octeontx2/otx2_flow.h b/drivers/net/octeontx2/otx2_flow.h index 30a823c8a..f8a19055b 100644 --- a/drivers/net/octeontx2/otx2_flow.h +++ b/drivers/net/octeontx2/otx2_flow.h @@ -149,6 +149,11 @@ struct otx2_mcam_ents_info { uint32_t live_ent; }; +struct otx2_flow_dump_data { + uint8_t lid; + uint16_t ltype; +}; + struct rte_flow { uint8_t nix_intf; uint32_t mcam_id; @@ -159,6 +164,8 @@ struct rte_flow { uint64_t mcam_mask[OTX2_MAX_MCAM_WIDTH_DWORDS]; uint64_t npc_action; uint64_t vtag_action; + struct otx2_flow_dump_data dump_data[32]; + uint16_t num_patterns; TAILQ_ENTRY(rte_flow) next; }; @@ -401,4 +408,7 @@ int otx2_flow_parse_actions(struct rte_eth_dev *dev, int otx2_flow_free_all_resources(struct otx2_eth_dev *hw);
[dpdk-dev] [PATCH] net/octeontx2: fix vlan filter on port
From: Satheesh Paul This patch fixes incorrect MCAM key preparation when creating MCAM entry to allow VLAN IDs after vlan filtering is enabled on port. Fixes: ba1b3b081e ("net/octeontx2: support VLAN offloads") Cc: sta...@dpdk.org Signed-off-by: Satheesh Paul --- drivers/net/octeontx2/otx2_vlan.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/octeontx2/otx2_vlan.c b/drivers/net/octeontx2/otx2_vlan.c index 7357b0669..f5161e17a 100644 --- a/drivers/net/octeontx2/otx2_vlan.c +++ b/drivers/net/octeontx2/otx2_vlan.c @@ -306,12 +306,12 @@ nix_vlan_mcam_config(struct rte_eth_dev *eth_dev, (0xF & ~(NPC_LT_LB_CTAG ^ NPC_LT_LB_STAG_QINQ)) << mkex->lb_lt_offset; - mcam_data = ((uint32_t)vlan_id << 16); - mcam_mask = (BIT_ULL(16) - 1) << 16; + mcam_data = (uint16_t)vlan_id; + mcam_mask = (BIT_ULL(16) - 1); otx2_mbox_memcpy(key_data + mkex->lb_xtract.key_off, -&mcam_data, mkex->lb_xtract.len + 1); +&mcam_data, mkex->lb_xtract.len); otx2_mbox_memcpy(key_mask + mkex->lb_xtract.key_off, -&mcam_mask, mkex->lb_xtract.len + 1); +&mcam_mask, mkex->lb_xtract.len); } /* Adds LB STAG flag to MCAM KW */ -- 2.25.4
[dpdk-dev] [PATCH 1/3] common/cnxk: fix channel mask for SDP interfaces
From: Satheesh Paul Fix channel mask of SDP interfaces on CN10K. Fixes: f137566333 ("common/cnxk: support setting channel mask for SDP interfaces") Cc: sta...@dpdk.org Signed-off-by: Satheesh Paul Reviewed-by: Kiran Kumar K --- drivers/common/cnxk/roc_npc.c | 9 +++-- drivers/common/cnxk/roc_npc_priv.h | 3 +++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/common/cnxk/roc_npc.c b/drivers/common/cnxk/roc_npc.c index c872548230..9edccb5258 100644 --- a/drivers/common/cnxk/roc_npc.c +++ b/drivers/common/cnxk/roc_npc.c @@ -1380,8 +1380,13 @@ roc_npc_flow_create(struct roc_npc *roc_npc, const struct roc_npc_attr *attr, /* By default set the channel and mask to cover * the whole SDP channel range. */ - npc->sdp_channel = (uint16_t)NIX_CHAN_SDP_CH_START; - npc->sdp_channel_mask = (uint16_t)NIX_CHAN_SDP_CH_START; + if (roc_model_is_cn10k()) { + npc->sdp_channel = (uint16_t)CN10K_SDP_CH_START; + npc->sdp_channel_mask = (uint16_t)CN10K_SDP_CH_MASK; + } else { + npc->sdp_channel = (uint16_t)NIX_CHAN_SDP_CH_START; + npc->sdp_channel_mask = (uint16_t)NIX_CHAN_SDP_CH_START; + } } } diff --git a/drivers/common/cnxk/roc_npc_priv.h b/drivers/common/cnxk/roc_npc_priv.h index 2a7d3137fb..aa27228354 100644 --- a/drivers/common/cnxk/roc_npc_priv.h +++ b/drivers/common/cnxk/roc_npc_priv.h @@ -77,6 +77,9 @@ #define NPC_LFLAG_LC_OFFSET (NPC_LTYPE_OFFSET_START + 6) #define NPC_LTYPE_LC_OFFSET (NPC_LTYPE_OFFSET_START + 8) +#define CN10K_SDP_CH_START 0x80 +#define CN10K_SDP_CH_MASK 0xF80 + struct npc_action_vtag_info { uint16_t vlan_id; uint16_t vlan_ethtype; -- 2.35.3
[dpdk-dev] [PATCH 2/3] common/cnxk: fix printing IPsec flow rules
From: Satheesh Paul When dumping flow data, dump preallocated IPsec rules also. Fixes: 1aa86a170e ("drivers: support IPsec rule reservation scheme") Cc: sta...@dpdk.org Signed-off-by: Satheesh Paul Reviewed-by: Jerin Jacob Reviewed-by: Kiran Kumar K --- drivers/common/cnxk/roc_npc.c | 7 +- drivers/common/cnxk/roc_npc_mcam_dump.c | 154 ++-- 2 files changed, 120 insertions(+), 41 deletions(-) diff --git a/drivers/common/cnxk/roc_npc.c b/drivers/common/cnxk/roc_npc.c index 9edccb5258..579b3dce9a 100644 --- a/drivers/common/cnxk/roc_npc.c +++ b/drivers/common/cnxk/roc_npc.c @@ -1550,11 +1550,14 @@ roc_npc_flow_dump(FILE *file, struct roc_npc *roc_npc) roc_npc_flow_mcam_dump(file, roc_npc, flow_iter); } } + + TAILQ_FOREACH(flow_iter, &npc->ipsec_list, next) { + roc_npc_flow_mcam_dump(file, roc_npc, flow_iter); + } } int -roc_npc_mcam_merge_base_steering_rule(struct roc_npc *roc_npc, - struct roc_npc_flow *flow) +roc_npc_mcam_merge_base_steering_rule(struct roc_npc *roc_npc, struct roc_npc_flow *flow) { struct npc_mcam_read_base_rule_rsp *base_rule_rsp; struct npc *npc = roc_npc_to_npc_priv(roc_npc); diff --git a/drivers/common/cnxk/roc_npc_mcam_dump.c b/drivers/common/cnxk/roc_npc_mcam_dump.c index 40909b45e6..a88e166fbe 100644 --- a/drivers/common/cnxk/roc_npc_mcam_dump.c +++ b/drivers/common/cnxk/roc_npc_mcam_dump.c @@ -73,43 +73,93 @@ static const char *const ltype_str[NPC_MAX_LID][NPC_MAX_LT] = { [NPC_LID_LA][NPC_LT_LA_CPT_HDR] = "LA_CPT_HDR", [NPC_LID_LA][NPC_LT_LA_CUSTOM_L2_24B_ETHER] = "LA_CUSTOM_L2_24B_ETHER", [NPC_LID_LA][NPC_LT_LA_CUSTOM_PRE_L2_ETHER] = "NPC_LT_LA_CUSTOM_PRE_L2_ETHER", + [NPC_LID_LA][NPC_LT_LA_CUSTOM0] = "NPC_LT_LA_CUSTOM0", + [NPC_LID_LA][NPC_LT_LA_CUSTOM1] = "NPC_LT_LA_CUSTOM1", [NPC_LID_LB][0] = "NONE", + [NPC_LID_LB][NPC_LT_LB_ETAG] = "LB_ETAG", [NPC_LID_LB][NPC_LT_LB_CTAG] = "LB_CTAG", [NPC_LID_LB][NPC_LT_LB_STAG_QINQ] = "LB_STAG_QINQ", - [NPC_LID_LB][NPC_LT_LB_ETAG] = "LB_ETAG", + [NPC_LID_LB][NPC_LT_LB_BTAG] = "LB_BTAG", + [NPC_LID_LB][NPC_LT_LB_PPPOE] = "LB_PPPOE", + [NPC_LID_LB][NPC_LT_LB_DSA] = "LB_DSA", + [NPC_LID_LB][NPC_LT_LB_DSA_VLAN] = "LB_DSA_VLAN", + [NPC_LID_LB][NPC_LT_LB_EDSA] = "LB_EDSA", + [NPC_LID_LB][NPC_LT_LB_EDSA_VLAN] = "LB_EDSA_VLAN", [NPC_LID_LB][NPC_LT_LB_EXDSA] = "LB_EXDSA", + [NPC_LID_LB][NPC_LT_LB_EXDSA_VLAN] = "LB_EXDSA_VLAN", + [NPC_LID_LB][NPC_LT_LB_FDSA] = "LB_FDSA", [NPC_LID_LB][NPC_LT_LB_VLAN_EXDSA] = "LB_VLAN_EXDSA", + [NPC_LID_LB][NPC_LT_LB_CUSTOM0] = "LB_CUSTOM0", + [NPC_LID_LB][NPC_LT_LB_CUSTOM1] = "LB_CUSTOM1", [NPC_LID_LC][0] = "NONE", + [NPC_LID_LC][NPC_LT_LC_PTP] = "LC_PTP", [NPC_LID_LC][NPC_LT_LC_IP] = "LC_IP", + [NPC_LID_LC][NPC_LT_LC_IP_OPT] = "LC_IP_OPT", [NPC_LID_LC][NPC_LT_LC_IP6] = "LC_IP6", - [NPC_LID_LC][NPC_LT_LC_ARP] = "LC_ARP", [NPC_LID_LC][NPC_LT_LC_IP6_EXT] = "LC_IP6_EXT", + [NPC_LID_LC][NPC_LT_LC_ARP] = "LC_ARP", + [NPC_LID_LC][NPC_LT_LC_RARP] = "LC_RARP", + [NPC_LID_LC][NPC_LT_LC_MPLS] = "LC_MPLS", + [NPC_LID_LC][NPC_LT_LC_NSH] = "LC_NSH", + [NPC_LID_LC][NPC_LT_LC_FCOE] = "LC_FCOE", [NPC_LID_LC][NPC_LT_LC_NGIO] = "LC_NGIO", + [NPC_LID_LC][NPC_LT_LC_CUSTOM0] = "LC_CUSTOM0", + [NPC_LID_LC][NPC_LT_LC_CUSTOM1] = "LC_CUSTOM1", [NPC_LID_LD][0] = "NONE", - [NPC_LID_LD][NPC_LT_LD_ICMP] = "LD_ICMP", - [NPC_LID_LD][NPC_LT_LD_ICMP6] = "LD_ICMP6", - [NPC_LID_LD][NPC_LT_LD_UDP] = "LD_UDP", [NPC_LID_LD][NPC_LT_LD_TCP] = "LD_TCP", + [NPC_LID_LD][NPC_LT_LD_UDP] = "LD_UDP", [NPC_LID_LD][NPC_LT_LD_SCTP] = "LD_SCTP", + [NPC_LID_LD][NPC_LT_LD_ICMP6] = "LD_ICMP6", + [NPC_LID_LD][NPC_LT_LD_CUSTOM0] = "LD_CUSTOM0", + [NPC_LID_LD][NPC_LT_LD_CUSTOM1] = "LD_CUSTOM1", + [NPC_LID_LD][NPC_LT_LD_IGMP] = "LD_IGMP", + [NPC_LID_LD][NPC_LT_LD_AH] = "LD_AH", [NPC_LID_LD][NPC_LT_LD_GRE] = "LD_GRE", [NPC_LID_LD][NPC_LT_LD_NVGRE] = "LD_NVGRE", + [NPC_LID_LD][NPC_LT_LD_NSH] = "LD_NSH", + [NPC_LID_LD][NPC_LT_LD_TU_MPLS_IN_NSH] = "LD_TU_MPLS_IN_NSH", + [NPC_LID_LD][NPC_LT_LD_TU_MPLS_IN_IP] = "LD_TU_MPLS_IN_IP", + [NPC_LID_LD][NPC_LT_LD_ICMP] = "LD_ICMP", [NPC_LID_LE][0] = "NONE", [NPC_LID_LE][NPC_LT_LE_VXLAN] = "LE_VXLAN", + [NPC_LID_LE][NPC_LT_LE_GENEVE] = "LE_GENEVE", [NPC_LID_LE][NPC_LT_LE_ESP] = "LE_ESP", - [NPC_LID_LE][NPC_LT_LE_GTPC] = "LE_GTPC", [NPC_LID_LE][NPC_LT_LE_GTPU] = "LE_GTPU", - [NPC_LID_LE][NPC_LT_LE_GENEVE] = "LE_GENEVE", [NPC_LID_LE][NPC_LT_LE_VXLANGPE] = "LE_VXLANGPE", + [NPC_LID_LE][NPC_LT_LE_GTPC] = "LE_GTPC", + [NPC_LID_LE][NPC_LT_LE_NSH]
[dpdk-dev] [PATCH 3/3] common/cnxk: fix inline IPsec rule creation
From: Satheesh Paul Use inline IPsec device to create IPsec rules irrespective of RTE_ETH_RX_OFFLOAD_SECURITY offload flag. Fixes: 1aa86a170e ("drivers: support IPsec rule reservation scheme") Cc: sta...@dpdk.org Signed-off-by: Satheesh Paul Reviewed-by: Nithin Dabilpuram Reviewed-by: Kiran Kumar K --- drivers/common/cnxk/roc_npc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/common/cnxk/roc_npc.c b/drivers/common/cnxk/roc_npc.c index 579b3dce9a..d3efebe663 100644 --- a/drivers/common/cnxk/roc_npc.c +++ b/drivers/common/cnxk/roc_npc.c @@ -562,8 +562,10 @@ npc_parse_actions(struct roc_npc *roc_npc, const struct roc_npc_attr *attr, } rq = inl_rq->qid; pf_func = nix_inl_dev_pffunc_get(); - flow->is_inline_dev = 1; } + + if (roc_nix_inl_dev_is_probed()) + flow->is_inline_dev = 1; sec_action = actions; break; case ROC_NPC_ACTION_TYPE_VLAN_STRIP: -- 2.35.3
[dpdk-dev] [PATCH v2 1/3] common/cnxk: fix channel mask for SDP interfaces
From: Satheesh Paul Fix channel mask of SDP interfaces on CN10K. Fixes: f1375660 ("common/cnxk: support setting channel mask for SDP interfaces") Cc: sta...@dpdk.org Signed-off-by: Satheesh Paul Reviewed-by: Kiran Kumar K --- v2: * Corrected "Fixes:" tag with 12 char sha1 drivers/common/cnxk/roc_npc.c | 9 +++-- drivers/common/cnxk/roc_npc_priv.h | 3 +++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/common/cnxk/roc_npc.c b/drivers/common/cnxk/roc_npc.c index c872548230..9edccb5258 100644 --- a/drivers/common/cnxk/roc_npc.c +++ b/drivers/common/cnxk/roc_npc.c @@ -1380,8 +1380,13 @@ roc_npc_flow_create(struct roc_npc *roc_npc, const struct roc_npc_attr *attr, /* By default set the channel and mask to cover * the whole SDP channel range. */ - npc->sdp_channel = (uint16_t)NIX_CHAN_SDP_CH_START; - npc->sdp_channel_mask = (uint16_t)NIX_CHAN_SDP_CH_START; + if (roc_model_is_cn10k()) { + npc->sdp_channel = (uint16_t)CN10K_SDP_CH_START; + npc->sdp_channel_mask = (uint16_t)CN10K_SDP_CH_MASK; + } else { + npc->sdp_channel = (uint16_t)NIX_CHAN_SDP_CH_START; + npc->sdp_channel_mask = (uint16_t)NIX_CHAN_SDP_CH_START; + } } } diff --git a/drivers/common/cnxk/roc_npc_priv.h b/drivers/common/cnxk/roc_npc_priv.h index 2a7d3137fb..aa27228354 100644 --- a/drivers/common/cnxk/roc_npc_priv.h +++ b/drivers/common/cnxk/roc_npc_priv.h @@ -77,6 +77,9 @@ #define NPC_LFLAG_LC_OFFSET (NPC_LTYPE_OFFSET_START + 6) #define NPC_LTYPE_LC_OFFSET (NPC_LTYPE_OFFSET_START + 8) +#define CN10K_SDP_CH_START 0x80 +#define CN10K_SDP_CH_MASK 0xF80 + struct npc_action_vtag_info { uint16_t vlan_id; uint16_t vlan_ethtype; -- 2.35.3
[dpdk-dev] [PATCH v2 2/3] common/cnxk: fix printing IPsec flow rules
From: Satheesh Paul When dumping flow data, dump preallocated IPsec rules also. Fixes: 1aa86a170e27 ("drivers: support IPsec rule reservation scheme") Cc: sta...@dpdk.org Signed-off-by: Satheesh Paul Reviewed-by: Jerin Jacob Reviewed-by: Kiran Kumar K --- drivers/common/cnxk/roc_npc.c | 7 +- drivers/common/cnxk/roc_npc_mcam_dump.c | 154 ++-- 2 files changed, 120 insertions(+), 41 deletions(-) diff --git a/drivers/common/cnxk/roc_npc.c b/drivers/common/cnxk/roc_npc.c index 9edccb5258..579b3dce9a 100644 --- a/drivers/common/cnxk/roc_npc.c +++ b/drivers/common/cnxk/roc_npc.c @@ -1550,11 +1550,14 @@ roc_npc_flow_dump(FILE *file, struct roc_npc *roc_npc) roc_npc_flow_mcam_dump(file, roc_npc, flow_iter); } } + + TAILQ_FOREACH(flow_iter, &npc->ipsec_list, next) { + roc_npc_flow_mcam_dump(file, roc_npc, flow_iter); + } } int -roc_npc_mcam_merge_base_steering_rule(struct roc_npc *roc_npc, - struct roc_npc_flow *flow) +roc_npc_mcam_merge_base_steering_rule(struct roc_npc *roc_npc, struct roc_npc_flow *flow) { struct npc_mcam_read_base_rule_rsp *base_rule_rsp; struct npc *npc = roc_npc_to_npc_priv(roc_npc); diff --git a/drivers/common/cnxk/roc_npc_mcam_dump.c b/drivers/common/cnxk/roc_npc_mcam_dump.c index 40909b45e6..a88e166fbe 100644 --- a/drivers/common/cnxk/roc_npc_mcam_dump.c +++ b/drivers/common/cnxk/roc_npc_mcam_dump.c @@ -73,43 +73,93 @@ static const char *const ltype_str[NPC_MAX_LID][NPC_MAX_LT] = { [NPC_LID_LA][NPC_LT_LA_CPT_HDR] = "LA_CPT_HDR", [NPC_LID_LA][NPC_LT_LA_CUSTOM_L2_24B_ETHER] = "LA_CUSTOM_L2_24B_ETHER", [NPC_LID_LA][NPC_LT_LA_CUSTOM_PRE_L2_ETHER] = "NPC_LT_LA_CUSTOM_PRE_L2_ETHER", + [NPC_LID_LA][NPC_LT_LA_CUSTOM0] = "NPC_LT_LA_CUSTOM0", + [NPC_LID_LA][NPC_LT_LA_CUSTOM1] = "NPC_LT_LA_CUSTOM1", [NPC_LID_LB][0] = "NONE", + [NPC_LID_LB][NPC_LT_LB_ETAG] = "LB_ETAG", [NPC_LID_LB][NPC_LT_LB_CTAG] = "LB_CTAG", [NPC_LID_LB][NPC_LT_LB_STAG_QINQ] = "LB_STAG_QINQ", - [NPC_LID_LB][NPC_LT_LB_ETAG] = "LB_ETAG", + [NPC_LID_LB][NPC_LT_LB_BTAG] = "LB_BTAG", + [NPC_LID_LB][NPC_LT_LB_PPPOE] = "LB_PPPOE", + [NPC_LID_LB][NPC_LT_LB_DSA] = "LB_DSA", + [NPC_LID_LB][NPC_LT_LB_DSA_VLAN] = "LB_DSA_VLAN", + [NPC_LID_LB][NPC_LT_LB_EDSA] = "LB_EDSA", + [NPC_LID_LB][NPC_LT_LB_EDSA_VLAN] = "LB_EDSA_VLAN", [NPC_LID_LB][NPC_LT_LB_EXDSA] = "LB_EXDSA", + [NPC_LID_LB][NPC_LT_LB_EXDSA_VLAN] = "LB_EXDSA_VLAN", + [NPC_LID_LB][NPC_LT_LB_FDSA] = "LB_FDSA", [NPC_LID_LB][NPC_LT_LB_VLAN_EXDSA] = "LB_VLAN_EXDSA", + [NPC_LID_LB][NPC_LT_LB_CUSTOM0] = "LB_CUSTOM0", + [NPC_LID_LB][NPC_LT_LB_CUSTOM1] = "LB_CUSTOM1", [NPC_LID_LC][0] = "NONE", + [NPC_LID_LC][NPC_LT_LC_PTP] = "LC_PTP", [NPC_LID_LC][NPC_LT_LC_IP] = "LC_IP", + [NPC_LID_LC][NPC_LT_LC_IP_OPT] = "LC_IP_OPT", [NPC_LID_LC][NPC_LT_LC_IP6] = "LC_IP6", - [NPC_LID_LC][NPC_LT_LC_ARP] = "LC_ARP", [NPC_LID_LC][NPC_LT_LC_IP6_EXT] = "LC_IP6_EXT", + [NPC_LID_LC][NPC_LT_LC_ARP] = "LC_ARP", + [NPC_LID_LC][NPC_LT_LC_RARP] = "LC_RARP", + [NPC_LID_LC][NPC_LT_LC_MPLS] = "LC_MPLS", + [NPC_LID_LC][NPC_LT_LC_NSH] = "LC_NSH", + [NPC_LID_LC][NPC_LT_LC_FCOE] = "LC_FCOE", [NPC_LID_LC][NPC_LT_LC_NGIO] = "LC_NGIO", + [NPC_LID_LC][NPC_LT_LC_CUSTOM0] = "LC_CUSTOM0", + [NPC_LID_LC][NPC_LT_LC_CUSTOM1] = "LC_CUSTOM1", [NPC_LID_LD][0] = "NONE", - [NPC_LID_LD][NPC_LT_LD_ICMP] = "LD_ICMP", - [NPC_LID_LD][NPC_LT_LD_ICMP6] = "LD_ICMP6", - [NPC_LID_LD][NPC_LT_LD_UDP] = "LD_UDP", [NPC_LID_LD][NPC_LT_LD_TCP] = "LD_TCP", + [NPC_LID_LD][NPC_LT_LD_UDP] = "LD_UDP", [NPC_LID_LD][NPC_LT_LD_SCTP] = "LD_SCTP", + [NPC_LID_LD][NPC_LT_LD_ICMP6] = "LD_ICMP6", + [NPC_LID_LD][NPC_LT_LD_CUSTOM0] = "LD_CUSTOM0", + [NPC_LID_LD][NPC_LT_LD_CUSTOM1] = "LD_CUSTOM1", + [NPC_LID_LD][NPC_LT_LD_IGMP] = "LD_IGMP", + [NPC_LID_LD][NPC_LT_LD_AH] = "LD_AH", [NPC_LID_LD][NPC_LT_LD_GRE] = "LD_GRE", [NPC_LID_LD][NPC_LT_LD_NVGRE] = "LD_NVGRE", + [NPC_LID_LD][NPC_LT_LD_NSH] = "LD_NSH", + [NPC_LID_LD][NPC_LT_LD_TU_MPLS_IN_NSH] = "LD_TU_MPLS_IN_NSH", + [NPC_LID_LD][NPC_LT_LD_TU_MPLS_IN_IP] = "LD_TU_MPLS_IN_IP", + [NPC_LID_LD][NPC_LT_LD_ICMP] = "LD_ICMP", [NPC_LID_LE][0] = "NONE", [NPC_LID_LE][NPC_LT_LE_VXLAN] = "LE_VXLAN", + [NPC_LID_LE][NPC_LT_LE_GENEVE] = "LE_GENEVE", [NPC_LID_LE][NPC_LT_LE_ESP] = "LE_ESP", - [NPC_LID_LE][NPC_LT_LE_GTPC] = "LE_GTPC", [NPC_LID_LE][NPC_LT_LE_GTPU] = "LE_GTPU", - [NPC_LID_LE][NPC_LT_LE_GENEVE] = "LE_GENEVE", [NPC_LID_LE][NPC_LT_LE_VXLANGPE] = "LE_VXLANGPE", + [NPC_LID_LE][NPC_LT_LE_GTPC] = "LE_GTPC", + [NPC_LID_LE][NPC_LT_LE_NS
[dpdk-dev] [PATCH v2 3/3] common/cnxk: fix inline IPsec rule creation
From: Satheesh Paul Use inline IPsec device to create IPsec rules irrespective of RTE_ETH_RX_OFFLOAD_SECURITY offload flag. Fixes: 1aa86a170e27 ("drivers: support IPsec rule reservation scheme") Cc: sta...@dpdk.org Signed-off-by: Satheesh Paul Reviewed-by: Nithin Dabilpuram Reviewed-by: Kiran Kumar K --- drivers/common/cnxk/roc_npc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/common/cnxk/roc_npc.c b/drivers/common/cnxk/roc_npc.c index 579b3dce9a..d3efebe663 100644 --- a/drivers/common/cnxk/roc_npc.c +++ b/drivers/common/cnxk/roc_npc.c @@ -562,8 +562,10 @@ npc_parse_actions(struct roc_npc *roc_npc, const struct roc_npc_attr *attr, } rq = inl_rq->qid; pf_func = nix_inl_dev_pffunc_get(); - flow->is_inline_dev = 1; } + + if (roc_nix_inl_dev_is_probed()) + flow->is_inline_dev = 1; sec_action = actions; break; case ROC_NPC_ACTION_TYPE_VLAN_STRIP: -- 2.35.3
[dpdk-dev] [PATCH] common/cnxk: support IPv6 field hash in RTE Flow
From: Satheesh Paul CN103xx has the field hash feature which can hash 128 bit values to 32 bit values. The hashed value can be used in MCAM keys thereby freeing up space in the key. This patch adds support to make use of this hardware feature to hash IPv6 addresses and put them in the MCAM keys. Signed-off-by: Satheesh Paul Reviewed-by: Kiran Kumar K --- drivers/common/cnxk/roc_constants.h | 2 + drivers/common/cnxk/roc_mbox.h | 21 ++- drivers/common/cnxk/roc_npc.c | 4 + drivers/common/cnxk/roc_npc.h | 2 +- drivers/common/cnxk/roc_npc_mcam.c | 23 +++ drivers/common/cnxk/roc_npc_parse.c | 53 +-- drivers/common/cnxk/roc_npc_priv.h | 31 ++-- drivers/common/cnxk/roc_npc_utils.c | 230 +++- 8 files changed, 337 insertions(+), 29 deletions(-) diff --git a/drivers/common/cnxk/roc_constants.h b/drivers/common/cnxk/roc_constants.h index 0495965daa..c94916db6d 100644 --- a/drivers/common/cnxk/roc_constants.h +++ b/drivers/common/cnxk/roc_constants.h @@ -4,6 +4,8 @@ #ifndef _ROC_CONSTANTS_H_ #define _ROC_CONSTANTS_H_ +#define ROC_IPV6_ADDR_LEN 16 + /* ROC Cache */ #define ROC_CACHE_LINE_SZ 128 #define ROC_ALIGNROC_CACHE_LINE_SZ diff --git a/drivers/common/cnxk/roc_mbox.h b/drivers/common/cnxk/roc_mbox.h index 0bddb1ddfd..a6091a98c1 100644 --- a/drivers/common/cnxk/roc_mbox.h +++ b/drivers/common/cnxk/roc_mbox.h @@ -208,6 +208,8 @@ struct mbox_msghdr { npc_mcam_read_base_rule_rsp) \ M(NPC_MCAM_GET_STATS, 0x6012, npc_mcam_entry_stats,\ npc_mcam_get_stats_req, npc_mcam_get_stats_rsp) \ + M(NPC_GET_FIELD_HASH_INFO, 0x6013, npc_get_field_hash_info,\ + npc_get_field_hash_info_req, npc_get_field_hash_info_rsp)\ /* NIX mbox IDs (range 0x8000 - 0x) */ \ M(NIX_LF_ALLOC, 0x8000, nix_lf_alloc, nix_lf_alloc_req,\ nix_lf_alloc_rsp)\ @@ -1929,6 +1931,22 @@ enum tim_gpio_edge { TIM_GPIO_INVALID, }; +struct npc_get_field_hash_info_req { + struct mbox_msghdr hdr; + uint8_t intf; +}; + +struct npc_get_field_hash_info_rsp { + struct mbox_msghdr hdr; + uint64_t __io secret_key[3]; +#define NPC_MAX_HASH 2 +#define NPC_MAX_HASH_MASK 2 + /* NPC_AF_INTF(0..1)_HASH(0..1)_MASK(0..1) */ + uint64_t __io hash_mask[NPC_MAX_INTF][NPC_MAX_HASH][NPC_MAX_HASH_MASK]; + /* NPC_AF_INTF(0..1)_HASH(0..1)_RESULT_CTRL */ + uint64_t __io hash_ctrl[NPC_MAX_INTF][NPC_MAX_HASH]; +}; + enum ptp_op { PTP_OP_ADJFINE = 0, /* adjfine(req.scaled_ppm); */ PTP_OP_GET_CLOCK = 1, /* rsp.clk = get_clock() */ @@ -1951,7 +1969,8 @@ struct get_hw_cap_rsp { struct mbox_msghdr hdr; /* Schq mapping fixed or flexible */ uint8_t __io nix_fixed_txschq_mapping; - uint8_t __io nix_shaping; /* Is shaping and coloring supported */ + uint8_t __io nix_shaping; /* Is shaping and coloring supported */ + uint8_t __io npc_hash_extract; /* Is hash extract supported */ }; struct ndc_sync_op { diff --git a/drivers/common/cnxk/roc_npc.c b/drivers/common/cnxk/roc_npc.c index d3efebe663..a795114326 100644 --- a/drivers/common/cnxk/roc_npc.c +++ b/drivers/common/cnxk/roc_npc.c @@ -247,6 +247,10 @@ roc_npc_init(struct roc_npc *roc_npc) if (rc) goto done; + rc = npc_mcam_fetch_hw_cap(npc, &npc->hash_extract_cap); + if (rc) + goto done; + roc_npc->kex_capability = npc_get_kex_capability(npc); roc_npc->rx_parse_nibble = npc->keyx_supp_nmask[NPC_MCAM_RX]; diff --git a/drivers/common/cnxk/roc_npc.h b/drivers/common/cnxk/roc_npc.h index c7e8b4ac92..cea627e16c 100644 --- a/drivers/common/cnxk/roc_npc.h +++ b/drivers/common/cnxk/roc_npc.h @@ -337,7 +337,7 @@ struct roc_npc { uint16_t sdp_channel; uint16_t sdp_channel_mask; -#define ROC_NPC_MEM_SZ (5 * 1024) +#define ROC_NPC_MEM_SZ (6 * 1024) uint8_t reserved[ROC_NPC_MEM_SZ]; } __plt_cache_aligned; diff --git a/drivers/common/cnxk/roc_npc_mcam.c b/drivers/common/cnxk/roc_npc_mcam.c index 06f3212e8d..948c446312 100644 --- a/drivers/common/cnxk/roc_npc_mcam.c +++ b/drivers/common/cnxk/roc_npc_mcam.c @@ -309,6 +309,7 @@ npc_get_kex_capability(struct npc *npc) static void npc_update_kex_info(struct npc_xtract_info *xtract_info, uint64_t val) { + xtract_info->use_hash = ((val >> 20) & 0x1); xtract_info->len = ((val >> BYTESM1_SHIFT) & 0xf) + 1; xtract_info->hdr_off = (val >> HDR_OFF_SHIFT) & 0xff; xtract_info->key_off = val & 0x3f; @@ -502,6 +503,28 @@ npc_mcam_process_mkex_cfg(struct npc *npc, struct npc_get_kex_cfg_rsp *kex_rsp) npc->prx_lfcfg[1].i = kex_rsp->kex_ld_flags[1]; } +int +npc_mcam_fetch_hw_cap(struct npc *npc, uint8_t *npc_h
[dpdk-dev] [PATCH] common/cnxk: fix IPv6 extension header parsing
From: Satheesh Paul RTE_FLOW_ITEM_TYPE_IPV6_EXT and RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT pattern items can be specified following a RTE_FLOW_ITEM_TYPE_IPV6. Modified layer C parsing logic to handle this. Fixes: a800675b06f9 ("net/cnxk: support IPv6 fragment flow pattern item") Cc: sta...@dpdk.org Signed-off-by: Satheesh Paul Reviewed-by: Kiran Kumar K --- drivers/common/cnxk/roc_npc.h | 11 ++ drivers/common/cnxk/roc_npc_parse.c | 150 drivers/common/cnxk/roc_npc_priv.h | 2 +- drivers/common/cnxk/roc_npc_utils.c | 4 +- 4 files changed, 123 insertions(+), 44 deletions(-) diff --git a/drivers/common/cnxk/roc_npc.h b/drivers/common/cnxk/roc_npc.h index cea627e16c..5e07e26a91 100644 --- a/drivers/common/cnxk/roc_npc.h +++ b/drivers/common/cnxk/roc_npc.h @@ -123,6 +123,17 @@ struct roc_ipv6_hdr { uint8_t dst_addr[16]; /**< IP address of destination host(s). */ } __plt_packed; +struct roc_ipv6_fragment_ext { + uint8_t next_header; /**< Next header type */ + uint8_t reserved;/**< Reserved */ + uint16_t frag_data; /**< All fragmentation data */ + uint32_t id; /**< Packet ID */ +} __plt_packed; + +struct roc_flow_item_ipv6_ext { + uint8_t next_hdr; /**< Next header. */ +}; + struct roc_npc_flow_item_ipv6 { struct roc_ipv6_hdr hdr; /**< IPv6 header definition. */ uint32_t has_hop_ext : 1; diff --git a/drivers/common/cnxk/roc_npc_parse.c b/drivers/common/cnxk/roc_npc_parse.c index 085fb4618f..f746b9cb6d 100644 --- a/drivers/common/cnxk/roc_npc_parse.c +++ b/drivers/common/cnxk/roc_npc_parse.c @@ -664,41 +664,123 @@ npc_handle_ipv6ext_attr(const struct roc_npc_flow_item_ipv6 *ipv6_spec, } static int -npc_process_ipv6_item(const struct roc_npc_flow_item_ipv6 *ipv6_spec, - const struct roc_npc_flow_item_ipv6 *ipv6_mask, struct npc_parse_state *pst) +npc_process_ipv6_item(struct npc_parse_state *pst) { - uint8_t hw_mask[NPC_MAX_EXTRACT_HW_LEN]; - struct npc_parse_item_info info; - int rc, lid, lt; - uint8_t flags = 0; + uint8_t ipv6_hdr_mask[sizeof(struct roc_ipv6_hdr) + sizeof(struct roc_ipv6_fragment_ext)]; + uint8_t ipv6_hdr_buf[sizeof(struct roc_ipv6_hdr) + sizeof(struct roc_ipv6_fragment_ext)]; + const struct roc_npc_flow_item_ipv6 *ipv6_spec, *ipv6_mask; + const struct roc_npc_item_info *pattern = pst->pattern; + int offset = 0, rc = 0, lid, item_count = 0; + struct npc_parse_item_info parse_info; + char hw_mask[NPC_MAX_EXTRACT_HW_LEN]; + uint8_t flags = 0, ltype; + + memset(ipv6_hdr_buf, 0, sizeof(ipv6_hdr_buf)); + memset(ipv6_hdr_mask, 0, sizeof(ipv6_hdr_mask)); + + ipv6_spec = pst->pattern->spec; + ipv6_mask = pst->pattern->mask; + + parse_info.def_mask = NULL; + parse_info.spec = ipv6_hdr_buf; + parse_info.mask = ipv6_hdr_mask; + parse_info.def_mask = NULL; + parse_info.hw_hdr_len = 0; + parse_info.len = sizeof(ipv6_spec->hdr); + + pst->set_ipv6ext_ltype_mask = true; - info.def_mask = NULL; - info.hw_mask = &hw_mask; - info.spec = NULL; - info.mask = NULL; - info.hw_hdr_len = 0; lid = NPC_LID_LC; + ltype = NPC_LT_LC_IP6; + + if (pattern->type == ROC_NPC_ITEM_TYPE_IPV6) { + item_count++; + if (ipv6_spec) { + memcpy(ipv6_hdr_buf, &ipv6_spec->hdr, sizeof(struct roc_ipv6_hdr)); + rc = npc_handle_ipv6ext_attr(ipv6_spec, pst, &flags); + if (rc) + return rc; + } + if (ipv6_mask) + memcpy(ipv6_hdr_mask, &ipv6_mask->hdr, sizeof(struct roc_ipv6_hdr)); + } - lt = NPC_LT_LC_IP6; - if (ipv6_spec) { - rc = npc_handle_ipv6ext_attr(ipv6_spec, pst, &flags); - if (rc) - return rc; + offset = sizeof(struct roc_ipv6_hdr); + + while (pattern->type != ROC_NPC_ITEM_TYPE_END) { + /* Don't support ranges */ + if (pattern->last != NULL) + return NPC_ERR_INVALID_RANGE; + + /* If spec is NULL, both mask and last must be NULL, this +* makes it to match ANY value (eq to mask = 0). +* Setting either mask or last without spec is +* an error +*/ + if (pattern->spec == NULL) { + if (pattern->last != NULL && pattern->mask != NULL) + return NPC_ERR_INVALID_SPEC; + } + /* Either one ROC_NPC_ITEM_TYPE_IPV6_EXT or +* one ROC_NPC_ITEM_TYPE_IPV6_FRAG_EXT is supported +* following an ROC_NPC_ITEM_TYPE_IPV6 item. +*/ + if (pattern->type == ROC_NPC_ITEM_TYPE_IPV6_EXT) { +
[dpdk-dev] [PATCH 1/2] common/cnxk: fix setting channel mask for SDP interfaces
From: Satheesh Paul Channel mask for SDP interfaces are by default set to a constant value. Fix this by setting mask calculated from the channel base and channel count configured in NIX LF. Fixes: f1375660 ("common/cnxk: support setting channel mask for SDP interfaces") Cc: sta...@dpdk.org Signed-off-by: Satheesh Paul Reviewed-by: Kiran Kumar K --- drivers/common/cnxk/roc_npc.c | 40 ++- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/drivers/common/cnxk/roc_npc.c b/drivers/common/cnxk/roc_npc.c index ba75207955..d556b4c3a5 100644 --- a/drivers/common/cnxk/roc_npc.c +++ b/drivers/common/cnxk/roc_npc.c @@ -1388,12 +1388,39 @@ npc_inline_dev_ipsec_action_free(struct npc *npc, struct roc_npc_flow *flow) return 1; } +static void +roc_npc_sdp_channel_get(struct roc_npc *roc_npc, uint16_t *chan_base, uint16_t *chan_mask) +{ + struct roc_nix *roc_nix = roc_npc->roc_nix; + struct nix *nix = roc_nix_to_nix_priv(roc_nix); + uint16_t num_chan, range, num_bits = 0; + uint16_t mask = 0; + + *chan_base = nix->rx_chan_base; + num_chan = nix->rx_chan_cnt - 1; + if (num_chan) { + range = *chan_base ^ (*chan_base + num_chan); + num_bits = (sizeof(uint32_t) * 8) - __builtin_clz(range) - 1; + /* Set mask for (15 - numbits) MSB bits */ + *chan_mask = (uint16_t)~GENMASK(num_bits, 0); + } else { + *chan_mask = (uint16_t)GENMASK(15, 0); + } + + mask = (uint16_t)GENMASK(num_bits, 0); + if (mask > num_chan + 1) + plt_warn( + "npc: SDP channel base:%x, channel count:%x. channel mask:%x covers more than channel count", + *chan_base, nix->rx_chan_cnt, *chan_mask); +} + struct roc_npc_flow * roc_npc_flow_create(struct roc_npc *roc_npc, const struct roc_npc_attr *attr, const struct roc_npc_item_info pattern[], const struct roc_npc_action actions[], int *errcode) { struct npc *npc = roc_npc_to_npc_priv(roc_npc); + uint16_t sdp_chan_base = 0, sdp_chan_mask = 0; struct roc_npc_flow *flow, *flow_iter; struct npc_parse_state parse_state; struct npc_flow_list *list; @@ -1406,16 +1433,9 @@ roc_npc_flow_create(struct roc_npc *roc_npc, const struct roc_npc_attr *attr, npc->sdp_channel = roc_npc->sdp_channel; npc->sdp_channel_mask = roc_npc->sdp_channel_mask; } else { - /* By default set the channel and mask to cover -* the whole SDP channel range. -*/ - if (roc_model_is_cn10k()) { - npc->sdp_channel = (uint16_t)CN10K_SDP_CH_START; - npc->sdp_channel_mask = (uint16_t)CN10K_SDP_CH_MASK; - } else { - npc->sdp_channel = (uint16_t)NIX_CHAN_SDP_CH_START; - npc->sdp_channel_mask = (uint16_t)NIX_CHAN_SDP_CH_START; - } + roc_npc_sdp_channel_get(roc_npc, &sdp_chan_base, &sdp_chan_mask); + npc->sdp_channel = sdp_chan_base; + npc->sdp_channel_mask = sdp_chan_mask; } } -- 2.39.2
[dpdk-dev] [PATCH 2/2] common/cnxk: fix uninitialized pointer read
From: Satheesh Paul Fix uninitialized pointer read reported in coverity scan. Coverity issue: 375811 Fixes: 84d2ea9d4fb3 ("common/cnxk: support custom pre L2 header parsing as raw") Cc: sta...@dpdk.org Signed-off-by: Satheesh Paul Reviewed-by: Kiran Kumar K --- drivers/common/cnxk/roc_npc_parse.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/common/cnxk/roc_npc_parse.c b/drivers/common/cnxk/roc_npc_parse.c index f746b9cb6d..571fdb36fc 100644 --- a/drivers/common/cnxk/roc_npc_parse.c +++ b/drivers/common/cnxk/roc_npc_parse.c @@ -97,6 +97,7 @@ npc_parse_pre_l2(struct npc_parse_state *pst) (const struct roc_npc_flow_item_raw *)pst->pattern->mask, &info, raw_spec_buf, raw_mask_buf); + info.def_mask = NULL; info.hw_mask = &hw_mask; npc_get_hw_supp_mask(pst, &info, lid, lt); -- 2.39.2
[dpdk-dev] [PATCH 1/2] common/cnxk: support Tx queue flow pattern in ROC API
From: Satheesh Paul Added ROC API changes to support Tx queue flow pattern item. Signed-off-by: Satheesh Paul Reviewed-by: Kiran Kumar K --- Depends-on: series-28056 ("ethdev: add Tx queue flow matching item") drivers/common/cnxk/roc_npc.c | 16 +--- drivers/common/cnxk/roc_npc.h | 1 + drivers/common/cnxk/roc_npc_mcam.c | 61 +++-- drivers/common/cnxk/roc_npc_parse.c | 52 drivers/common/cnxk/roc_npc_priv.h | 2 + 5 files changed, 115 insertions(+), 17 deletions(-) diff --git a/drivers/common/cnxk/roc_npc.c b/drivers/common/cnxk/roc_npc.c index ba75207955..4b5be65b72 100644 --- a/drivers/common/cnxk/roc_npc.c +++ b/drivers/common/cnxk/roc_npc.c @@ -779,11 +779,10 @@ npc_parse_pattern(struct npc *npc, const struct roc_npc_item_info pattern[], struct roc_npc_flow *flow, struct npc_parse_state *pst) { npc_parse_stage_func_t parse_stage_funcs[] = { - npc_parse_meta_items, npc_parse_mark_item, npc_parse_pre_l2, - npc_parse_cpt_hdr,npc_parse_higig2_hdr, npc_parse_la, - npc_parse_lb, npc_parse_lc, npc_parse_ld, - npc_parse_le, npc_parse_lf, npc_parse_lg, - npc_parse_lh, + npc_parse_meta_items, npc_parse_mark_item, npc_parse_pre_l2, npc_parse_cpt_hdr, + npc_parse_higig2_hdr, npc_parse_tx_queue, npc_parse_la, npc_parse_lb, + npc_parse_lc, npc_parse_ld,npc_parse_le, npc_parse_lf, + npc_parse_lg, npc_parse_lh, }; uint8_t layer = 0; int key_offset; @@ -792,9 +791,9 @@ npc_parse_pattern(struct npc *npc, const struct roc_npc_item_info pattern[], if (pattern == NULL) return NPC_ERR_PARAM; - memset(pst, 0, sizeof(*pst)); pst->npc = npc; pst->flow = flow; + pst->nix_intf = flow->nix_intf; /* Use integral byte offset */ key_offset = pst->npc->keyx_len[flow->nix_intf]; @@ -864,8 +863,12 @@ npc_parse_rule(struct roc_npc *roc_npc, const struct roc_npc_attr *attr, struct npc_parse_state *pst) { struct npc *npc = roc_npc_to_npc_priv(roc_npc); + struct roc_nix *roc_nix = roc_npc->roc_nix; + struct nix *nix = roc_nix_to_nix_priv(roc_nix); int err; + pst->nb_tx_queues = nix->nb_tx_queues; + /* Check attr */ err = npc_parse_attr(npc, attr, flow); if (err) @@ -1425,6 +1428,7 @@ roc_npc_flow_create(struct roc_npc *roc_npc, const struct roc_npc_attr *attr, return NULL; } memset(flow, 0, sizeof(*flow)); + memset(&parse_state, 0, sizeof(parse_state)); rc = npc_parse_rule(roc_npc, attr, pattern, actions, flow, &parse_state); diff --git a/drivers/common/cnxk/roc_npc.h b/drivers/common/cnxk/roc_npc.h index 26a43c12cb..5984da1c1a 100644 --- a/drivers/common/cnxk/roc_npc.h +++ b/drivers/common/cnxk/roc_npc.h @@ -39,6 +39,7 @@ enum roc_npc_item_type { ROC_NPC_ITEM_TYPE_QINQ, ROC_NPC_ITEM_TYPE_RAW, ROC_NPC_ITEM_TYPE_MARK, + ROC_NPC_ITEM_TYPE_TX_QUEUE, ROC_NPC_ITEM_TYPE_END, }; diff --git a/drivers/common/cnxk/roc_npc_mcam.c b/drivers/common/cnxk/roc_npc_mcam.c index 72892be300..e0019818c7 100644 --- a/drivers/common/cnxk/roc_npc_mcam.c +++ b/drivers/common/cnxk/roc_npc_mcam.c @@ -587,9 +587,47 @@ npc_mcam_set_channel(struct roc_npc_flow *flow, flow->mcam_mask[0] |= (uint64_t)mask; } +static int +npc_mcam_set_pf_func(struct npc *npc, struct roc_npc_flow *flow, uint16_t pf_func) +{ +#define NPC_PF_FUNC_WIDTH2 +#define NPC_KEX_PF_FUNC_MASK 0x + uint16_t nr_bytes, hdr_offset, key_offset, pf_func_offset; + uint8_t *flow_mcam_data, *flow_mcam_mask; + struct npc_lid_lt_xtract_info *xinfo; + bool pffunc_found = false; + uint16_t mask = 0x; + int i; + + flow_mcam_data = (uint8_t *)flow->mcam_data; + flow_mcam_mask = (uint8_t *)flow->mcam_mask; + + xinfo = &npc->prx_dxcfg[NIX_INTF_TX][NPC_LID_LA][NPC_LT_LA_IH_NIX_ETHER]; + + for (i = 0; i < NPC_MAX_LD; i++) { + nr_bytes = xinfo->xtract[i].len; + hdr_offset = xinfo->xtract[i].hdr_off; + key_offset = xinfo->xtract[i].key_off; + + if (hdr_offset > 0 || nr_bytes < NPC_PF_FUNC_WIDTH) + continue; + else + pffunc_found = true; + + pf_func_offset = key_offset + nr_bytes - NPC_PF_FUNC_WIDTH; + memcpy((void *)&flow_mcam_data[pf_func_offset], (uint8_t *)&pf_func, + NPC_PF_FUNC_WIDTH); + memcpy((void *)&flow_mcam_mask[pf_func_offset], (uint8_t *)&mask, + NPC_PF_FUNC_WIDTH); + } + if (!pffunc_found) + return -EINVAL; + +
[dpdk-dev] [PATCH 2/2] net/cnxk: support Tx queue flow pattern item
From: Satheesh Paul Added support for Tx queue flow pattern item. Signed-off-by: Satheesh Paul Reviewed-by: Kiran Kumar K --- drivers/net/cnxk/cnxk_flow.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/cnxk/cnxk_flow.c b/drivers/net/cnxk/cnxk_flow.c index f13d8e5582..9595fe9386 100644 --- a/drivers/net/cnxk/cnxk_flow.c +++ b/drivers/net/cnxk/cnxk_flow.c @@ -58,7 +58,9 @@ const struct cnxk_rte_flow_term_info term[] = { [RTE_FLOW_ITEM_TYPE_RAW] = {ROC_NPC_ITEM_TYPE_RAW, sizeof(struct rte_flow_item_raw)}, [RTE_FLOW_ITEM_TYPE_MARK] = {ROC_NPC_ITEM_TYPE_MARK, -sizeof(struct rte_flow_item_mark)}}; +sizeof(struct rte_flow_item_mark)}, + [RTE_FLOW_ITEM_TYPE_TX_QUEUE] = {ROC_NPC_ITEM_TYPE_TX_QUEUE, +sizeof(struct rte_flow_item_tx_queue)}}; static int npc_rss_action_validate(struct rte_eth_dev *eth_dev, -- 2.39.2
[dpdk-dev] [PATCH v2 1/2] common/cnxk: support Tx queue flow pattern in ROC API
From: Satheesh Paul Added ROC API changes to support Tx queue flow pattern item. Signed-off-by: Satheesh Paul Reviewed-by: Kiran Kumar K --- v2: * Updated documentation for Tx queue pattern item and verified generated documents as well. drivers/common/cnxk/roc_npc.c | 16 +--- drivers/common/cnxk/roc_npc.h | 1 + drivers/common/cnxk/roc_npc_mcam.c | 61 +++-- drivers/common/cnxk/roc_npc_parse.c | 52 drivers/common/cnxk/roc_npc_priv.h | 2 + 5 files changed, 115 insertions(+), 17 deletions(-) diff --git a/drivers/common/cnxk/roc_npc.c b/drivers/common/cnxk/roc_npc.c index d556b4c3a5..1baa71fc45 100644 --- a/drivers/common/cnxk/roc_npc.c +++ b/drivers/common/cnxk/roc_npc.c @@ -779,11 +779,10 @@ npc_parse_pattern(struct npc *npc, const struct roc_npc_item_info pattern[], struct roc_npc_flow *flow, struct npc_parse_state *pst) { npc_parse_stage_func_t parse_stage_funcs[] = { - npc_parse_meta_items, npc_parse_mark_item, npc_parse_pre_l2, - npc_parse_cpt_hdr,npc_parse_higig2_hdr, npc_parse_la, - npc_parse_lb, npc_parse_lc, npc_parse_ld, - npc_parse_le, npc_parse_lf, npc_parse_lg, - npc_parse_lh, + npc_parse_meta_items, npc_parse_mark_item, npc_parse_pre_l2, npc_parse_cpt_hdr, + npc_parse_higig2_hdr, npc_parse_tx_queue, npc_parse_la, npc_parse_lb, + npc_parse_lc, npc_parse_ld,npc_parse_le, npc_parse_lf, + npc_parse_lg, npc_parse_lh, }; uint8_t layer = 0; int key_offset; @@ -792,9 +791,9 @@ npc_parse_pattern(struct npc *npc, const struct roc_npc_item_info pattern[], if (pattern == NULL) return NPC_ERR_PARAM; - memset(pst, 0, sizeof(*pst)); pst->npc = npc; pst->flow = flow; + pst->nix_intf = flow->nix_intf; /* Use integral byte offset */ key_offset = pst->npc->keyx_len[flow->nix_intf]; @@ -864,8 +863,12 @@ npc_parse_rule(struct roc_npc *roc_npc, const struct roc_npc_attr *attr, struct npc_parse_state *pst) { struct npc *npc = roc_npc_to_npc_priv(roc_npc); + struct roc_nix *roc_nix = roc_npc->roc_nix; + struct nix *nix = roc_nix_to_nix_priv(roc_nix); int err; + pst->nb_tx_queues = nix->nb_tx_queues; + /* Check attr */ err = npc_parse_attr(npc, attr, flow); if (err) @@ -1445,6 +1448,7 @@ roc_npc_flow_create(struct roc_npc *roc_npc, const struct roc_npc_attr *attr, return NULL; } memset(flow, 0, sizeof(*flow)); + memset(&parse_state, 0, sizeof(parse_state)); rc = npc_parse_rule(roc_npc, attr, pattern, actions, flow, &parse_state); diff --git a/drivers/common/cnxk/roc_npc.h b/drivers/common/cnxk/roc_npc.h index 26a43c12cb..5984da1c1a 100644 --- a/drivers/common/cnxk/roc_npc.h +++ b/drivers/common/cnxk/roc_npc.h @@ -39,6 +39,7 @@ enum roc_npc_item_type { ROC_NPC_ITEM_TYPE_QINQ, ROC_NPC_ITEM_TYPE_RAW, ROC_NPC_ITEM_TYPE_MARK, + ROC_NPC_ITEM_TYPE_TX_QUEUE, ROC_NPC_ITEM_TYPE_END, }; diff --git a/drivers/common/cnxk/roc_npc_mcam.c b/drivers/common/cnxk/roc_npc_mcam.c index 72892be300..e0019818c7 100644 --- a/drivers/common/cnxk/roc_npc_mcam.c +++ b/drivers/common/cnxk/roc_npc_mcam.c @@ -587,9 +587,47 @@ npc_mcam_set_channel(struct roc_npc_flow *flow, flow->mcam_mask[0] |= (uint64_t)mask; } +static int +npc_mcam_set_pf_func(struct npc *npc, struct roc_npc_flow *flow, uint16_t pf_func) +{ +#define NPC_PF_FUNC_WIDTH2 +#define NPC_KEX_PF_FUNC_MASK 0x + uint16_t nr_bytes, hdr_offset, key_offset, pf_func_offset; + uint8_t *flow_mcam_data, *flow_mcam_mask; + struct npc_lid_lt_xtract_info *xinfo; + bool pffunc_found = false; + uint16_t mask = 0x; + int i; + + flow_mcam_data = (uint8_t *)flow->mcam_data; + flow_mcam_mask = (uint8_t *)flow->mcam_mask; + + xinfo = &npc->prx_dxcfg[NIX_INTF_TX][NPC_LID_LA][NPC_LT_LA_IH_NIX_ETHER]; + + for (i = 0; i < NPC_MAX_LD; i++) { + nr_bytes = xinfo->xtract[i].len; + hdr_offset = xinfo->xtract[i].hdr_off; + key_offset = xinfo->xtract[i].key_off; + + if (hdr_offset > 0 || nr_bytes < NPC_PF_FUNC_WIDTH) + continue; + else + pffunc_found = true; + + pf_func_offset = key_offset + nr_bytes - NPC_PF_FUNC_WIDTH; + memcpy((void *)&flow_mcam_data[pf_func_offset], (uint8_t *)&pf_func, + NPC_PF_FUNC_WIDTH); + memcpy((void *)&flow_mcam_mask[pf_func_offset], (uint8_t *)&mask, + NPC_PF_FUNC_WIDTH); + } + if (!pffunc_found) +
[dpdk-dev] [PATCH v2 2/2] net/cnxk: support Tx queue flow pattern item
From: Satheesh Paul Added support for Tx queue flow pattern item. Signed-off-by: Satheesh Paul Reviewed-by: Kiran Kumar K --- doc/guides/nics/features/cnxk.ini | 1 + doc/guides/nics/features/cnxk_vec.ini | 1 + doc/guides/nics/features/cnxk_vf.ini | 1 + doc/guides/nics/features/default.ini | 1 + drivers/net/cnxk/cnxk_flow.c | 4 +++- 5 files changed, 7 insertions(+), 1 deletion(-) diff --git a/doc/guides/nics/features/cnxk.ini b/doc/guides/nics/features/cnxk.ini index 7947c044bb..838e781d6d 100644 --- a/doc/guides/nics/features/cnxk.ini +++ b/doc/guides/nics/features/cnxk.ini @@ -73,6 +73,7 @@ nvgre= Y raw = Y sctp = Y tcp = Y +tx_queue = Y udp = Y vlan = Y vxlan= Y diff --git a/doc/guides/nics/features/cnxk_vec.ini b/doc/guides/nics/features/cnxk_vec.ini index 5d0976e6ce..e2cac64e4b 100644 --- a/doc/guides/nics/features/cnxk_vec.ini +++ b/doc/guides/nics/features/cnxk_vec.ini @@ -68,6 +68,7 @@ nvgre= Y raw = Y sctp = Y tcp = Y +tx_queue = Y udp = Y vlan = Y vxlan= Y diff --git a/doc/guides/nics/features/cnxk_vf.ini b/doc/guides/nics/features/cnxk_vf.ini index 873e1dcc0a..470c45ce59 100644 --- a/doc/guides/nics/features/cnxk_vf.ini +++ b/doc/guides/nics/features/cnxk_vf.ini @@ -64,6 +64,7 @@ nvgre= Y raw = Y sctp = Y tcp = Y +tx_queue = Y udp = Y vlan = Y vxlan= Y diff --git a/doc/guides/nics/features/default.ini b/doc/guides/nics/features/default.ini index 1a5087abad..52a57d0805 100644 --- a/doc/guides/nics/features/default.ini +++ b/doc/guides/nics/features/default.ini @@ -142,6 +142,7 @@ represented_port = sctp = tag = tcp = +tx_queue = udp = vlan = vxlan= diff --git a/drivers/net/cnxk/cnxk_flow.c b/drivers/net/cnxk/cnxk_flow.c index f13d8e5582..9595fe9386 100644 --- a/drivers/net/cnxk/cnxk_flow.c +++ b/drivers/net/cnxk/cnxk_flow.c @@ -58,7 +58,9 @@ const struct cnxk_rte_flow_term_info term[] = { [RTE_FLOW_ITEM_TYPE_RAW] = {ROC_NPC_ITEM_TYPE_RAW, sizeof(struct rte_flow_item_raw)}, [RTE_FLOW_ITEM_TYPE_MARK] = {ROC_NPC_ITEM_TYPE_MARK, -sizeof(struct rte_flow_item_mark)}}; +sizeof(struct rte_flow_item_mark)}, + [RTE_FLOW_ITEM_TYPE_TX_QUEUE] = {ROC_NPC_ITEM_TYPE_TX_QUEUE, +sizeof(struct rte_flow_item_tx_queue)}}; static int npc_rss_action_validate(struct rte_eth_dev *eth_dev, -- 2.39.2
[dpdk-dev] [PATCH v2 1/2] common/cnxk: support Tx queue flow pattern in ROC API
From: Satheesh Paul Added ROC API changes to support Tx queue flow pattern item. Signed-off-by: Satheesh Paul Reviewed-by: Kiran Kumar K --- v2: * Updated documentation for Tx queue pattern item and verified generated documents as well. drivers/common/cnxk/roc_npc.c | 16 +--- drivers/common/cnxk/roc_npc.h | 1 + drivers/common/cnxk/roc_npc_mcam.c | 61 +++-- drivers/common/cnxk/roc_npc_parse.c | 52 drivers/common/cnxk/roc_npc_priv.h | 2 + 5 files changed, 115 insertions(+), 17 deletions(-) diff --git a/drivers/common/cnxk/roc_npc.c b/drivers/common/cnxk/roc_npc.c index d556b4c3a5..1baa71fc45 100644 --- a/drivers/common/cnxk/roc_npc.c +++ b/drivers/common/cnxk/roc_npc.c @@ -779,11 +779,10 @@ npc_parse_pattern(struct npc *npc, const struct roc_npc_item_info pattern[], struct roc_npc_flow *flow, struct npc_parse_state *pst) { npc_parse_stage_func_t parse_stage_funcs[] = { - npc_parse_meta_items, npc_parse_mark_item, npc_parse_pre_l2, - npc_parse_cpt_hdr,npc_parse_higig2_hdr, npc_parse_la, - npc_parse_lb, npc_parse_lc, npc_parse_ld, - npc_parse_le, npc_parse_lf, npc_parse_lg, - npc_parse_lh, + npc_parse_meta_items, npc_parse_mark_item, npc_parse_pre_l2, npc_parse_cpt_hdr, + npc_parse_higig2_hdr, npc_parse_tx_queue, npc_parse_la, npc_parse_lb, + npc_parse_lc, npc_parse_ld,npc_parse_le, npc_parse_lf, + npc_parse_lg, npc_parse_lh, }; uint8_t layer = 0; int key_offset; @@ -792,9 +791,9 @@ npc_parse_pattern(struct npc *npc, const struct roc_npc_item_info pattern[], if (pattern == NULL) return NPC_ERR_PARAM; - memset(pst, 0, sizeof(*pst)); pst->npc = npc; pst->flow = flow; + pst->nix_intf = flow->nix_intf; /* Use integral byte offset */ key_offset = pst->npc->keyx_len[flow->nix_intf]; @@ -864,8 +863,12 @@ npc_parse_rule(struct roc_npc *roc_npc, const struct roc_npc_attr *attr, struct npc_parse_state *pst) { struct npc *npc = roc_npc_to_npc_priv(roc_npc); + struct roc_nix *roc_nix = roc_npc->roc_nix; + struct nix *nix = roc_nix_to_nix_priv(roc_nix); int err; + pst->nb_tx_queues = nix->nb_tx_queues; + /* Check attr */ err = npc_parse_attr(npc, attr, flow); if (err) @@ -1445,6 +1448,7 @@ roc_npc_flow_create(struct roc_npc *roc_npc, const struct roc_npc_attr *attr, return NULL; } memset(flow, 0, sizeof(*flow)); + memset(&parse_state, 0, sizeof(parse_state)); rc = npc_parse_rule(roc_npc, attr, pattern, actions, flow, &parse_state); diff --git a/drivers/common/cnxk/roc_npc.h b/drivers/common/cnxk/roc_npc.h index 26a43c12cb..5984da1c1a 100644 --- a/drivers/common/cnxk/roc_npc.h +++ b/drivers/common/cnxk/roc_npc.h @@ -39,6 +39,7 @@ enum roc_npc_item_type { ROC_NPC_ITEM_TYPE_QINQ, ROC_NPC_ITEM_TYPE_RAW, ROC_NPC_ITEM_TYPE_MARK, + ROC_NPC_ITEM_TYPE_TX_QUEUE, ROC_NPC_ITEM_TYPE_END, }; diff --git a/drivers/common/cnxk/roc_npc_mcam.c b/drivers/common/cnxk/roc_npc_mcam.c index 72892be300..e0019818c7 100644 --- a/drivers/common/cnxk/roc_npc_mcam.c +++ b/drivers/common/cnxk/roc_npc_mcam.c @@ -587,9 +587,47 @@ npc_mcam_set_channel(struct roc_npc_flow *flow, flow->mcam_mask[0] |= (uint64_t)mask; } +static int +npc_mcam_set_pf_func(struct npc *npc, struct roc_npc_flow *flow, uint16_t pf_func) +{ +#define NPC_PF_FUNC_WIDTH2 +#define NPC_KEX_PF_FUNC_MASK 0x + uint16_t nr_bytes, hdr_offset, key_offset, pf_func_offset; + uint8_t *flow_mcam_data, *flow_mcam_mask; + struct npc_lid_lt_xtract_info *xinfo; + bool pffunc_found = false; + uint16_t mask = 0x; + int i; + + flow_mcam_data = (uint8_t *)flow->mcam_data; + flow_mcam_mask = (uint8_t *)flow->mcam_mask; + + xinfo = &npc->prx_dxcfg[NIX_INTF_TX][NPC_LID_LA][NPC_LT_LA_IH_NIX_ETHER]; + + for (i = 0; i < NPC_MAX_LD; i++) { + nr_bytes = xinfo->xtract[i].len; + hdr_offset = xinfo->xtract[i].hdr_off; + key_offset = xinfo->xtract[i].key_off; + + if (hdr_offset > 0 || nr_bytes < NPC_PF_FUNC_WIDTH) + continue; + else + pffunc_found = true; + + pf_func_offset = key_offset + nr_bytes - NPC_PF_FUNC_WIDTH; + memcpy((void *)&flow_mcam_data[pf_func_offset], (uint8_t *)&pf_func, + NPC_PF_FUNC_WIDTH); + memcpy((void *)&flow_mcam_mask[pf_func_offset], (uint8_t *)&mask, + NPC_PF_FUNC_WIDTH); + } + if (!pffunc_found) +
[dpdk-dev] [PATCH v2 2/2] net/cnxk: support Tx queue flow pattern item
From: Satheesh Paul Added support for Tx queue flow pattern item. Signed-off-by: Satheesh Paul Reviewed-by: Kiran Kumar K --- doc/guides/nics/features/cnxk.ini | 1 + doc/guides/nics/features/cnxk_vec.ini | 1 + doc/guides/nics/features/cnxk_vf.ini | 1 + doc/guides/nics/features/default.ini | 1 + drivers/net/cnxk/cnxk_flow.c | 4 +++- 5 files changed, 7 insertions(+), 1 deletion(-) diff --git a/doc/guides/nics/features/cnxk.ini b/doc/guides/nics/features/cnxk.ini index 7947c044bb..838e781d6d 100644 --- a/doc/guides/nics/features/cnxk.ini +++ b/doc/guides/nics/features/cnxk.ini @@ -73,6 +73,7 @@ nvgre= Y raw = Y sctp = Y tcp = Y +tx_queue = Y udp = Y vlan = Y vxlan= Y diff --git a/doc/guides/nics/features/cnxk_vec.ini b/doc/guides/nics/features/cnxk_vec.ini index 5d0976e6ce..e2cac64e4b 100644 --- a/doc/guides/nics/features/cnxk_vec.ini +++ b/doc/guides/nics/features/cnxk_vec.ini @@ -68,6 +68,7 @@ nvgre= Y raw = Y sctp = Y tcp = Y +tx_queue = Y udp = Y vlan = Y vxlan= Y diff --git a/doc/guides/nics/features/cnxk_vf.ini b/doc/guides/nics/features/cnxk_vf.ini index 873e1dcc0a..470c45ce59 100644 --- a/doc/guides/nics/features/cnxk_vf.ini +++ b/doc/guides/nics/features/cnxk_vf.ini @@ -64,6 +64,7 @@ nvgre= Y raw = Y sctp = Y tcp = Y +tx_queue = Y udp = Y vlan = Y vxlan= Y diff --git a/doc/guides/nics/features/default.ini b/doc/guides/nics/features/default.ini index 1a5087abad..52a57d0805 100644 --- a/doc/guides/nics/features/default.ini +++ b/doc/guides/nics/features/default.ini @@ -142,6 +142,7 @@ represented_port = sctp = tag = tcp = +tx_queue = udp = vlan = vxlan= diff --git a/drivers/net/cnxk/cnxk_flow.c b/drivers/net/cnxk/cnxk_flow.c index f13d8e5582..9595fe9386 100644 --- a/drivers/net/cnxk/cnxk_flow.c +++ b/drivers/net/cnxk/cnxk_flow.c @@ -58,7 +58,9 @@ const struct cnxk_rte_flow_term_info term[] = { [RTE_FLOW_ITEM_TYPE_RAW] = {ROC_NPC_ITEM_TYPE_RAW, sizeof(struct rte_flow_item_raw)}, [RTE_FLOW_ITEM_TYPE_MARK] = {ROC_NPC_ITEM_TYPE_MARK, -sizeof(struct rte_flow_item_mark)}}; +sizeof(struct rte_flow_item_mark)}, + [RTE_FLOW_ITEM_TYPE_TX_QUEUE] = {ROC_NPC_ITEM_TYPE_TX_QUEUE, +sizeof(struct rte_flow_item_tx_queue)}}; static int npc_rss_action_validate(struct rte_eth_dev *eth_dev, -- 2.39.2
[dpdk-dev] [PATCH] common/cnxk: fix Coverity issues
From: Satheesh Paul Fix Out-of-bounds access and remove dead code reported by Coverity. Coverity issue: 384431, 384439, 380992 Fixes: 585bb3e538f9 ("common/cnxk: add VF support to base device class") Fixes: da1ec39060b2 ("common/cnxk: delay inline device RQ enable to dev start") Cc: sta...@dpdk.org Signed-off-by: Satheesh Paul Reviewed-by: Nithin Dabilpuram Reviewed-by: Harman Kalra --- drivers/common/cnxk/roc_dev.c | 2 ++ drivers/common/cnxk/roc_nix_inl.c | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/common/cnxk/roc_dev.c b/drivers/common/cnxk/roc_dev.c index 084343c3b4..14aff233d5 100644 --- a/drivers/common/cnxk/roc_dev.c +++ b/drivers/common/cnxk/roc_dev.c @@ -502,6 +502,8 @@ pf_vf_mbox_send_up_msg(struct dev *dev, void *rec_msg) size_t size; size = PLT_ALIGN(mbox_id2size(msg->hdr.id), MBOX_MSG_ALIGN); + if (size < sizeof(struct mbox_msghdr)) + return; /* Send UP message to all VF's */ for (vf = 0; vf < vf_mbox->ndevs; vf++) { /* VF active */ diff --git a/drivers/common/cnxk/roc_nix_inl.c b/drivers/common/cnxk/roc_nix_inl.c index a205c658e9..7dbeae5017 100644 --- a/drivers/common/cnxk/roc_nix_inl.c +++ b/drivers/common/cnxk/roc_nix_inl.c @@ -677,8 +677,7 @@ roc_nix_reassembly_configure(uint32_t max_wait_time, uint16_t max_frags) return -EFAULT; PLT_SET_USED(max_frags); - if (idev == NULL) - return -ENOTSUP; + roc_cpt = idev->cpt; if (!roc_cpt) { plt_err("Cannot support inline inbound, cryptodev not probed"); -- 2.39.2
[dpdk-dev] [PATCH v2 1/2] common/cnxk: remove dead code
From: Satheesh Paul Removed dead code reported by Coverity. Coverity issue: 380992 Fixes: da1ec39060b2 ("common/cnxk: delay inline device RQ enable to dev start") Cc: sta...@dpdk.org Signed-off-by: Satheesh Paul Reviewed-by: Nithin Dabilpuram --- v2: * Split the patch and updated commit message. drivers/common/cnxk/roc_nix_inl.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/common/cnxk/roc_nix_inl.c b/drivers/common/cnxk/roc_nix_inl.c index a205c658e9..7dbeae5017 100644 --- a/drivers/common/cnxk/roc_nix_inl.c +++ b/drivers/common/cnxk/roc_nix_inl.c @@ -677,8 +677,7 @@ roc_nix_reassembly_configure(uint32_t max_wait_time, uint16_t max_frags) return -EFAULT; PLT_SET_USED(max_frags); - if (idev == NULL) - return -ENOTSUP; + roc_cpt = idev->cpt; if (!roc_cpt) { plt_err("Cannot support inline inbound, cryptodev not probed"); -- 2.39.2
[dpdk-dev] [PATCH v2 2/2] common/cnxk: fix possible out-of-bounds access
From: Satheesh Paul The subtraction expression in mbox_memcpy() can wrap around causing an out-of-bounds access. Added a check on 'size' to fix this. Coverity issue: 384431, 384439 Fixes: 585bb3e538f9 ("common/cnxk: add VF support to base device class") Cc: sta...@dpdk.org Signed-off-by: Satheesh Paul Reviewed-by: Harman Kalra --- drivers/common/cnxk/roc_dev.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/common/cnxk/roc_dev.c b/drivers/common/cnxk/roc_dev.c index 084343c3b4..14aff233d5 100644 --- a/drivers/common/cnxk/roc_dev.c +++ b/drivers/common/cnxk/roc_dev.c @@ -502,6 +502,8 @@ pf_vf_mbox_send_up_msg(struct dev *dev, void *rec_msg) size_t size; size = PLT_ALIGN(mbox_id2size(msg->hdr.id), MBOX_MSG_ALIGN); + if (size < sizeof(struct mbox_msghdr)) + return; /* Send UP message to all VF's */ for (vf = 0; vf < vf_mbox->ndevs; vf++) { /* VF active */ -- 2.39.2
[dpdk-dev] [PATCH 1/2] common/cnxk: support PPPoE flow item type in ROC API
From: Satheesh Paul Added ROC API changes to parse RTE_FLOW_ITEM_TYPE_PPPOES rte_flow item type. Signed-off-by: Satheesh Paul Reviewed-by: Kiran Kumar K --- drivers/common/cnxk/roc_npc.h | 1 + drivers/common/cnxk/roc_npc_parse.c | 5 + 2 files changed, 6 insertions(+) diff --git a/drivers/common/cnxk/roc_npc.h b/drivers/common/cnxk/roc_npc.h index 459fa33de9..cb59db2220 100644 --- a/drivers/common/cnxk/roc_npc.h +++ b/drivers/common/cnxk/roc_npc.h @@ -33,6 +33,7 @@ enum roc_npc_item_type { ROC_NPC_ITEM_TYPE_VXLAN_GPE, ROC_NPC_ITEM_TYPE_IPV6_EXT, ROC_NPC_ITEM_TYPE_GRE_KEY, + ROC_NPC_ITEM_TYPE_PPPOES, ROC_NPC_ITEM_TYPE_HIGIG2, ROC_NPC_ITEM_TYPE_CPT_HDR, ROC_NPC_ITEM_TYPE_L3_CUSTOM, diff --git a/drivers/common/cnxk/roc_npc_parse.c b/drivers/common/cnxk/roc_npc_parse.c index ecd1b3e13b..9ceb707ebb 100644 --- a/drivers/common/cnxk/roc_npc_parse.c +++ b/drivers/common/cnxk/roc_npc_parse.c @@ -525,6 +525,11 @@ npc_parse_lb(struct npc_parse_state *pst) info.len = pattern->size; lt = NPC_LT_LB_STAG_QINQ; lflags = NPC_F_STAG_CTAG; + } else if (pst->pattern->type == ROC_NPC_ITEM_TYPE_PPPOES) { + info.hw_mask = NULL; + info.len = pattern->size; + info.hw_hdr_len = 2; + lt = NPC_LT_LB_PPPOE; } else if (pst->pattern->type == ROC_NPC_ITEM_TYPE_RAW) { raw_spec = pst->pattern->spec; if (raw_spec->relative) -- 2.39.2
[dpdk-dev] [PATCH 2/2] net/cnxk: support PPPoE flow item type
From: Satheesh Paul Support to parse RTE_FLOW_ITEM_TYPE_PPPOES rte_flow item type for cnxk device. Signed-off-by: Satheesh Paul Reviewed-by: Kiran Kumar K --- doc/guides/nics/features/cnxk.ini | 1 + doc/guides/nics/features/cnxk_vec.ini | 1 + doc/guides/nics/features/cnxk_vf.ini | 1 + drivers/net/cnxk/cnxk_flow.c | 7 --- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/doc/guides/nics/features/cnxk.ini b/doc/guides/nics/features/cnxk.ini index ac7de9a0f0..cc7deaeaa9 100644 --- a/doc/guides/nics/features/cnxk.ini +++ b/doc/guides/nics/features/cnxk.ini @@ -71,6 +71,7 @@ ipv6_routing_ext = Y mark = Y mpls = Y nvgre= Y +pppoes = Y raw = Y sctp = Y tcp = Y diff --git a/doc/guides/nics/features/cnxk_vec.ini b/doc/guides/nics/features/cnxk_vec.ini index e2cac64e4b..6086b3d73f 100644 --- a/doc/guides/nics/features/cnxk_vec.ini +++ b/doc/guides/nics/features/cnxk_vec.ini @@ -65,6 +65,7 @@ ipv6_frag_ext= Y mark = Y mpls = Y nvgre= Y +pppoes = Y raw = Y sctp = Y tcp = Y diff --git a/doc/guides/nics/features/cnxk_vf.ini b/doc/guides/nics/features/cnxk_vf.ini index b03e8b35c3..53aa2a3d0c 100644 --- a/doc/guides/nics/features/cnxk_vf.ini +++ b/doc/guides/nics/features/cnxk_vf.ini @@ -62,6 +62,7 @@ ipv6_routing_ext = Y mark = Y mpls = Y nvgre= Y +pppoes = Y raw = Y sctp = Y tcp = Y diff --git a/drivers/net/cnxk/cnxk_flow.c b/drivers/net/cnxk/cnxk_flow.c index 08ab75e2bb..2eee44ed09 100644 --- a/drivers/net/cnxk/cnxk_flow.c +++ b/drivers/net/cnxk/cnxk_flow.c @@ -62,11 +62,12 @@ const struct cnxk_rte_flow_term_info term[] = { [RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT] = {ROC_NPC_ITEM_TYPE_IPV6_ROUTING_EXT, sizeof(struct rte_flow_item_ipv6_routing_ext)}, [RTE_FLOW_ITEM_TYPE_TX_QUEUE] = {ROC_NPC_ITEM_TYPE_TX_QUEUE, -sizeof(struct rte_flow_item_tx_queue)}}; +sizeof(struct rte_flow_item_tx_queue)}, + [RTE_FLOW_ITEM_TYPE_PPPOES] = {ROC_NPC_ITEM_TYPE_PPPOES, +sizeof(struct rte_flow_item_pppoe)}}; static int -npc_rss_action_validate(struct rte_eth_dev *eth_dev, - const struct rte_flow_attr *attr, +npc_rss_action_validate(struct rte_eth_dev *eth_dev, const struct rte_flow_attr *attr, const struct rte_flow_action *act) { const struct rte_flow_action_rss *rss; -- 2.39.2
[dpdk-dev] [PATCH 1/3] common/cnxk: support mirror flow action
From: Satheesh Paul Add ROC API to support mirror flow action. Signed-off-by: Satheesh Paul Reviewed-by: Kiran Kumar K --- drivers/common/cnxk/roc_mbox.h | 56 + drivers/common/cnxk/roc_nix.h | 8 ++- drivers/common/cnxk/roc_nix_mcast.c | 86 ++ drivers/common/cnxk/roc_npc.c | 94 + drivers/common/cnxk/roc_npc.h | 19 +- drivers/common/cnxk/roc_npc_mcam.c | 56 + drivers/common/cnxk/roc_npc_priv.h | 3 +- drivers/common/cnxk/version.map | 2 + 8 files changed, 295 insertions(+), 29 deletions(-) diff --git a/drivers/common/cnxk/roc_mbox.h b/drivers/common/cnxk/roc_mbox.h index 05434aec5a..3257a370bc 100644 --- a/drivers/common/cnxk/roc_mbox.h +++ b/drivers/common/cnxk/roc_mbox.h @@ -298,6 +298,11 @@ struct mbox_msghdr { M(NIX_FREE_BPIDS, 0x8029, nix_free_bpids, nix_bpids, msg_rsp) \ M(NIX_RX_CHAN_CFG, 0x802a, nix_rx_chan_cfg, nix_rx_chan_cfg, \ nix_rx_chan_cfg) \ + M(NIX_MCAST_GRP_CREATE, 0x802b, nix_mcast_grp_create, nix_mcast_grp_create_req,\ + nix_mcast_grp_create_rsp) \ + M(NIX_MCAST_GRP_DESTROY, 0x802c, nix_mcast_grp_destroy, nix_mcast_grp_destroy_req, msg_rsp)\ + M(NIX_MCAST_GRP_UPDATE, 0x802d, nix_mcast_grp_update, nix_mcast_grp_update_req,\ + nix_mcast_grp_update_rsp) \ /* MCS mbox IDs (range 0xa000 - 0xbFFF) */ \ M(MCS_ALLOC_RESOURCES, 0xa000, mcs_alloc_resources, mcs_alloc_rsrc_req, \ mcs_alloc_rsrc_rsp) \ @@ -1768,6 +1773,57 @@ struct nix_rx_chan_cfg { uint64_t __io rsvd; }; +struct nix_mcast_grp_create_req { + struct mbox_msghdr hdr; +#define NIX_MCAST_INGRESS 0 +#define NIX_MCAST_EGRESS 1 + uint8_t __io dir; + uint8_t __io reserved[11]; + /* Reserving few bytes for future requirement */ +}; + +struct nix_mcast_grp_create_rsp { + struct mbox_msghdr hdr; + /* This mcast_grp_idx should be passed during MCAM +* write entry for multicast. AF will identify the +* corresponding multicast table index associated +* with the group id and program the same to MCAM entry. +* This group id is also needed during group delete +* and update request. +*/ + uint32_t __io mcast_grp_idx; +}; +struct nix_mcast_grp_destroy_req { + struct mbox_msghdr hdr; + /* Group id returned by nix_mcast_grp_create_rsp */ + uint32_t __io mcast_grp_idx; +}; + +struct nix_mcast_grp_update_req { + struct mbox_msghdr hdr; + /* Group id returned by nix_mcast_grp_create_rsp */ + uint32_t __io mcast_grp_idx; + /* Number of multicast/mirror entries requested */ + uint32_t __io num_mce_entry; +#define NIX_MCE_ENTRY_MAX 64 +#define NIX_RX_RQ0 +#define NIX_RX_RSS 1 + /* Receive queue or RSS index within pf_func */ + uint32_t __io rq_rss_index[NIX_MCE_ENTRY_MAX]; + uint16_t __io pcifunc[NIX_MCE_ENTRY_MAX]; + uint16_t __io channel[NIX_MCE_ENTRY_MAX]; +#define NIX_MCAST_OP_ADD_ENTRY 0 +#define NIX_MCAST_OP_DEL_ENTRY 1 + /* Destination type. 0:Receive queue, 1:RSS*/ + uint8_t __io dest_type[NIX_MCE_ENTRY_MAX]; + uint8_t __io op; +}; + +struct nix_mcast_grp_update_rsp { + struct mbox_msghdr hdr; + uint32_t __io mce_start_index; +}; + /* Global NIX inline IPSec configuration */ struct nix_inline_ipsec_cfg { struct mbox_msghdr hdr; diff --git a/drivers/common/cnxk/roc_nix.h b/drivers/common/cnxk/roc_nix.h index 82997c38ce..c1ebf971f7 100644 --- a/drivers/common/cnxk/roc_nix.h +++ b/drivers/common/cnxk/roc_nix.h @@ -1005,6 +1005,10 @@ int __roc_api roc_nix_mcast_mcam_entry_write(struct roc_nix *roc_nix, struct mcam_entry *entry, uint32_t index, uint8_t intf, uint64_t action); -int __roc_api roc_nix_mcast_mcam_entry_ena_dis(struct roc_nix *roc_nix, - uint32_t index, bool enable); +int __roc_api roc_nix_mcast_mcam_entry_ena_dis(struct roc_nix *roc_nix, uint32_t index, + bool enable); +int __roc_api roc_nix_mcast_list_setup(struct mbox *mbox, uint8_t intf, int nb_entries, + uint16_t *pf_funcs, uint16_t *channels, uint32_t *rqs, + uint32_t *grp_index, uint32_t *start_index); +int __roc_api roc_nix_mcast_list_free(struct mbox *mbox, uint32_t mcast_grp_index); #endi
[dpdk-dev] [PATCH 2/3] net/cnxk: support mirror flow action
From: Satheesh Paul Added RTE_FLOW_ACTION_TYPE_SAMPLE action type for cnxk device. Signed-off-by: Satheesh Paul Reviewed-by: Kiran Kumar K --- doc/guides/nics/features/cnxk.ini | 1 + drivers/net/cnxk/cnxk_flow.c | 121 -- 2 files changed, 115 insertions(+), 7 deletions(-) diff --git a/doc/guides/nics/features/cnxk.ini b/doc/guides/nics/features/cnxk.ini index cc7deaeaa9..94e7a6ab8d 100644 --- a/doc/guides/nics/features/cnxk.ini +++ b/doc/guides/nics/features/cnxk.ini @@ -97,6 +97,7 @@ port_id = Y queue= Y represented_port = Y rss = Y +sample = Y security = Y skip_cman= Y vf = Y diff --git a/drivers/net/cnxk/cnxk_flow.c b/drivers/net/cnxk/cnxk_flow.c index 2eee44ed09..11670d37e0 100644 --- a/drivers/net/cnxk/cnxk_flow.c +++ b/drivers/net/cnxk/cnxk_flow.c @@ -114,14 +114,102 @@ npc_rss_flowkey_get(struct cnxk_eth_dev *eth_dev, *flowkey_cfg = cnxk_rss_ethdev_to_nix(eth_dev, rss->types, rss->level); } +static int +npc_parse_port_id_action(struct rte_eth_dev *eth_dev, const struct rte_flow_action *action, +uint16_t *dst_pf_func, uint16_t *dst_channel) +{ + const struct rte_flow_action_port_id *port_act; + struct rte_eth_dev *portid_eth_dev; + char if_name[RTE_ETH_NAME_MAX_LEN]; + struct cnxk_eth_dev *hw_dst; + struct roc_npc *roc_npc_dst; + int rc = 0; + + port_act = (const struct rte_flow_action_port_id *)action->conf; + + rc = rte_eth_dev_get_name_by_port(port_act->id, if_name); + if (rc) { + plt_err("Name not found for output port id"); + goto err_exit; + } + portid_eth_dev = rte_eth_dev_allocated(if_name); + if (!portid_eth_dev) { + plt_err("eth_dev not found for output port id"); + goto err_exit; + } + if (strcmp(portid_eth_dev->device->driver->name, eth_dev->device->driver->name) != 0) { + plt_err("Output port not under same driver"); + goto err_exit; + } + hw_dst = portid_eth_dev->data->dev_private; + roc_npc_dst = &hw_dst->npc; + *dst_pf_func = roc_npc_dst->pf_func; + *dst_channel = hw_dst->npc.channel; + + return 0; + +err_exit: + return -EINVAL; +} + +static int +roc_npc_parse_sample_subaction(struct rte_eth_dev *eth_dev, const struct rte_flow_action actions[], + struct roc_npc_action_sample *sample_action) +{ + uint16_t dst_pf_func = 0, dst_channel = 0; + const struct roc_npc_action_vf *vf_act; + int rc = 0, count = 0; + bool is_empty = true; + + if (sample_action->ratio != 1) { + plt_err("Sample ratio must be 1"); + return -EINVAL; + } + + for (; actions->type != RTE_FLOW_ACTION_TYPE_END; actions++) { + is_empty = false; + switch (actions->type) { + case RTE_FLOW_ACTION_TYPE_PF: + count++; + sample_action->action_type |= ROC_NPC_ACTION_TYPE_PF; + break; + case RTE_FLOW_ACTION_TYPE_VF: + count++; + vf_act = (const struct roc_npc_action_vf *)actions->conf; + sample_action->action_type |= ROC_NPC_ACTION_TYPE_VF; + sample_action->pf_func = vf_act->id & NPC_PFVF_FUNC_MASK; + break; + case RTE_FLOW_ACTION_TYPE_PORT_ID: + rc = npc_parse_port_id_action(eth_dev, actions, &dst_pf_func, &dst_channel); + if (rc) + return -EINVAL; + + count++; + sample_action->action_type |= ROC_NPC_ACTION_TYPE_PORT_ID; + sample_action->pf_func = dst_pf_func; + sample_action->channel = dst_channel; + break; + default: + continue; + } + } + + if (count > 1 || is_empty) + return -EINVAL; + + return 0; +} + static int cnxk_map_actions(struct rte_eth_dev *eth_dev, const struct rte_flow_attr *attr, const struct rte_flow_action actions[], struct roc_npc_action in_actions[], -uint32_t *flowkey_cfg, uint16_t *dst_pf_func) +struct roc_npc_action_sample *in_sample_actions, uint32_t *flowkey_cfg, +uint16_t *dst_pf_func) { struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev); const struct rte_flow_action_queue *act_q = NULL; const struct rte_flow_action_ethdev *act_ethdev; + const struct rte_flow_action_sample *act_sample; const struct rte_flow_action_port_id *port_act; struct rte_eth_dev *portid_eth_dev; char if_name[
[dpdk-dev] [PATCH 3/3] common/cnxk: add egress mirror support
From: Satha Rao Added ROC api to send packets on multiple links when egress mirror enabled. Signed-off-by: Satha Rao Reviewed-by: Nithin Dabilpuram Reviewed-by: Kiran Kumar K Reviewed-by: Satheesh Paul --- drivers/common/cnxk/roc_nix.h| 2 + drivers/common/cnxk/roc_nix_tm_ops.c | 70 drivers/common/cnxk/roc_npc.c| 26 +++ drivers/common/cnxk/version.map | 1 + 4 files changed, 99 insertions(+) diff --git a/drivers/common/cnxk/roc_nix.h b/drivers/common/cnxk/roc_nix.h index c1ebf971f7..84e6fc3df5 100644 --- a/drivers/common/cnxk/roc_nix.h +++ b/drivers/common/cnxk/roc_nix.h @@ -755,6 +755,8 @@ int __roc_api roc_nix_tm_mark_config(struct roc_nix *roc_nix, int mark_red); uint64_t __roc_api roc_nix_tm_mark_format_get(struct roc_nix *roc_nix, uint64_t *flags); +int __roc_api roc_nix_tm_egress_link_cfg_set(struct roc_nix *roc_nix, uint64_t dst_pf_func, +bool enable); /* Ingress Policer API */ int __roc_api roc_nix_bpf_timeunit_get(struct roc_nix *roc_nix, diff --git a/drivers/common/cnxk/roc_nix_tm_ops.c b/drivers/common/cnxk/roc_nix_tm_ops.c index 2c53472047..900b182c76 100644 --- a/drivers/common/cnxk/roc_nix_tm_ops.c +++ b/drivers/common/cnxk/roc_nix_tm_ops.c @@ -1316,3 +1316,73 @@ roc_nix_tm_root_has_sp(struct roc_nix *roc_nix) return false; return true; } + +static inline struct nix * +pf_func_to_nix_get(uint16_t pf_func) +{ + struct roc_nix *roc_nix_tmp = NULL; + struct roc_nix_list *nix_list; + + nix_list = roc_idev_nix_list_get(); + if (nix_list == NULL) + return NULL; + + /* Find the NIX of given pf_func */ + TAILQ_FOREACH(roc_nix_tmp, nix_list, next) { + struct nix *nix = roc_nix_to_nix_priv(roc_nix_tmp); + + if (nix->dev.pf_func == pf_func) + return nix; + } + + return NULL; +} + +int +roc_nix_tm_egress_link_cfg_set(struct roc_nix *roc_nix, uint64_t dst_pf_func, bool enable) +{ + struct nix *src_nix = roc_nix_to_nix_priv(roc_nix), *dst_nix; + struct mbox *mbox = (&src_nix->dev)->mbox; + struct nix_txschq_config *req = NULL; + struct nix_tm_node_list *list; + struct nix_tm_node *node; + int rc = 0, k; + + dst_nix = pf_func_to_nix_get(dst_pf_func); + if (!dst_nix) + return -EINVAL; + + if (dst_nix == src_nix) + return 0; + + list = nix_tm_node_list(src_nix, src_nix->tm_tree); + TAILQ_FOREACH(node, list, node) { + if (node->hw_lvl != src_nix->tm_link_cfg_lvl) + continue; + + if (!(node->flags & NIX_TM_NODE_HWRES)) + continue; + + /* Allocating TL3 request */ + req = mbox_alloc_msg_nix_txschq_cfg(mbox_get(mbox)); + req->lvl = src_nix->tm_link_cfg_lvl; + k = 0; + + /* Enable PFC/pause on the identified TL3 */ + req->reg[k] = NIX_AF_TL3_TL2X_LINKX_CFG(node->hw_id, dst_nix->tx_link); + if (enable) + req->regval[k] |= BIT_ULL(12); + else + req->regval[k] &= ~(BIT_ULL(12)); + req->regval_mask[k] = ~(BIT_ULL(12)); + k++; + + req->num_regs = k; + rc = mbox_process(mbox); + mbox_put(mbox); + if (rc) + goto err; + } +err: + return rc; +} diff --git a/drivers/common/cnxk/roc_npc.c b/drivers/common/cnxk/roc_npc.c index 65f99549c9..9a0fe5f4e2 100644 --- a/drivers/common/cnxk/roc_npc.c +++ b/drivers/common/cnxk/roc_npc.c @@ -1595,6 +1595,21 @@ roc_npc_flow_create(struct roc_npc *roc_npc, const struct roc_npc_attr *attr, goto err_exit; } + /* If Egress mirror requested then enable TL3_TL2_LINK_CFG */ + if (flow->is_sampling_rule && (flow->nix_intf == NIX_INTF_TX)) { + if (flow->mcast_pf_funcs[0] == npc->pf_func) + rc = roc_nix_tm_egress_link_cfg_set(roc_npc->roc_nix, + flow->mcast_pf_funcs[1], true); + else + rc = roc_nix_tm_egress_link_cfg_set(roc_npc->roc_nix, + flow->mcast_pf_funcs[0], true); + if (rc) { + plt_err("Adding egress mirror failed"); + *errcode = rc; + goto err_exit; + } + } + rc = npc_rss_action_program(roc_npc, actions, flow); if (rc != 0) { *errcode = rc; @@ -1706,6 +1721,17 @@ roc_npc_flow_destroy(struct roc_npc *roc_npc, struct roc_npc_flow *flow) retur
[dpdk-dev] [PATCH v2 1/2] common/cnxk: support PPPoE flow item type in ROC API
From: Satheesh Paul Added ROC API changes to parse RTE_FLOW_ITEM_TYPE_PPPOES rte_flow item type. Signed-off-by: Satheesh Paul Reviewed-by: Kiran Kumar K --- v2: * Updated release notes. drivers/common/cnxk/roc_npc.h | 1 + drivers/common/cnxk/roc_npc_parse.c | 5 + 2 files changed, 6 insertions(+) diff --git a/drivers/common/cnxk/roc_npc.h b/drivers/common/cnxk/roc_npc.h index 459fa33de9..cb59db2220 100644 --- a/drivers/common/cnxk/roc_npc.h +++ b/drivers/common/cnxk/roc_npc.h @@ -33,6 +33,7 @@ enum roc_npc_item_type { ROC_NPC_ITEM_TYPE_VXLAN_GPE, ROC_NPC_ITEM_TYPE_IPV6_EXT, ROC_NPC_ITEM_TYPE_GRE_KEY, + ROC_NPC_ITEM_TYPE_PPPOES, ROC_NPC_ITEM_TYPE_HIGIG2, ROC_NPC_ITEM_TYPE_CPT_HDR, ROC_NPC_ITEM_TYPE_L3_CUSTOM, diff --git a/drivers/common/cnxk/roc_npc_parse.c b/drivers/common/cnxk/roc_npc_parse.c index ecd1b3e13b..9ceb707ebb 100644 --- a/drivers/common/cnxk/roc_npc_parse.c +++ b/drivers/common/cnxk/roc_npc_parse.c @@ -525,6 +525,11 @@ npc_parse_lb(struct npc_parse_state *pst) info.len = pattern->size; lt = NPC_LT_LB_STAG_QINQ; lflags = NPC_F_STAG_CTAG; + } else if (pst->pattern->type == ROC_NPC_ITEM_TYPE_PPPOES) { + info.hw_mask = NULL; + info.len = pattern->size; + info.hw_hdr_len = 2; + lt = NPC_LT_LB_PPPOE; } else if (pst->pattern->type == ROC_NPC_ITEM_TYPE_RAW) { raw_spec = pst->pattern->spec; if (raw_spec->relative) -- 2.39.2
[dpdk-dev] [PATCH v2 2/2] net/cnxk: support PPPoE flow item type
From: Satheesh Paul Support to parse RTE_FLOW_ITEM_TYPE_PPPOES rte_flow item type for cnxk device. Signed-off-by: Satheesh Paul Reviewed-by: Kiran Kumar K --- doc/guides/nics/features/cnxk.ini | 1 + doc/guides/nics/features/cnxk_vec.ini | 1 + doc/guides/nics/features/cnxk_vf.ini | 1 + doc/guides/rel_notes/release_24_03.rst | 3 +++ drivers/net/cnxk/cnxk_flow.c | 7 --- 5 files changed, 10 insertions(+), 3 deletions(-) diff --git a/doc/guides/nics/features/cnxk.ini b/doc/guides/nics/features/cnxk.ini index ac7de9a0f0..cc7deaeaa9 100644 --- a/doc/guides/nics/features/cnxk.ini +++ b/doc/guides/nics/features/cnxk.ini @@ -71,6 +71,7 @@ ipv6_routing_ext = Y mark = Y mpls = Y nvgre= Y +pppoes = Y raw = Y sctp = Y tcp = Y diff --git a/doc/guides/nics/features/cnxk_vec.ini b/doc/guides/nics/features/cnxk_vec.ini index e2cac64e4b..6086b3d73f 100644 --- a/doc/guides/nics/features/cnxk_vec.ini +++ b/doc/guides/nics/features/cnxk_vec.ini @@ -65,6 +65,7 @@ ipv6_frag_ext= Y mark = Y mpls = Y nvgre= Y +pppoes = Y raw = Y sctp = Y tcp = Y diff --git a/doc/guides/nics/features/cnxk_vf.ini b/doc/guides/nics/features/cnxk_vf.ini index b03e8b35c3..53aa2a3d0c 100644 --- a/doc/guides/nics/features/cnxk_vf.ini +++ b/doc/guides/nics/features/cnxk_vf.ini @@ -62,6 +62,7 @@ ipv6_routing_ext = Y mark = Y mpls = Y nvgre= Y +pppoes = Y raw = Y sctp = Y tcp = Y diff --git a/doc/guides/rel_notes/release_24_03.rst b/doc/guides/rel_notes/release_24_03.rst index 41b0eb8f1d..866dd60fbf 100644 --- a/doc/guides/rel_notes/release_24_03.rst +++ b/doc/guides/rel_notes/release_24_03.rst @@ -62,6 +62,9 @@ New Features * Added optimized SSE Rx routines. * Added optimized AVX2 Rx routines. +* **Updated Marvell cnxk net driver.** + + * Added support for ``RTE_FLOW_ITEM_TYPE_PPPOES`` flow item. Removed Items - diff --git a/drivers/net/cnxk/cnxk_flow.c b/drivers/net/cnxk/cnxk_flow.c index 08ab75e2bb..2eee44ed09 100644 --- a/drivers/net/cnxk/cnxk_flow.c +++ b/drivers/net/cnxk/cnxk_flow.c @@ -62,11 +62,12 @@ const struct cnxk_rte_flow_term_info term[] = { [RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT] = {ROC_NPC_ITEM_TYPE_IPV6_ROUTING_EXT, sizeof(struct rte_flow_item_ipv6_routing_ext)}, [RTE_FLOW_ITEM_TYPE_TX_QUEUE] = {ROC_NPC_ITEM_TYPE_TX_QUEUE, -sizeof(struct rte_flow_item_tx_queue)}}; +sizeof(struct rte_flow_item_tx_queue)}, + [RTE_FLOW_ITEM_TYPE_PPPOES] = {ROC_NPC_ITEM_TYPE_PPPOES, +sizeof(struct rte_flow_item_pppoe)}}; static int -npc_rss_action_validate(struct rte_eth_dev *eth_dev, - const struct rte_flow_attr *attr, +npc_rss_action_validate(struct rte_eth_dev *eth_dev, const struct rte_flow_attr *attr, const struct rte_flow_action *act) { const struct rte_flow_action_rss *rss; -- 2.39.2
[dpdk-dev] [PATCH v2 1/3] common/cnxk: support mirror flow action
From: Satheesh Paul Add ROC API to support mirror flow action. Signed-off-by: Satheesh Paul Reviewed-by: Kiran Kumar K --- v2: * Updated release notes. Depends-on: series-30556 ("common/cnxk: support PPPoE flow item type in ROC API") drivers/common/cnxk/roc_mbox.h | 56 + drivers/common/cnxk/roc_nix.h | 8 ++- drivers/common/cnxk/roc_nix_mcast.c | 86 ++ drivers/common/cnxk/roc_npc.c | 94 + drivers/common/cnxk/roc_npc.h | 19 +- drivers/common/cnxk/roc_npc_mcam.c | 56 + drivers/common/cnxk/roc_npc_priv.h | 3 +- drivers/common/cnxk/version.map | 2 + 8 files changed, 295 insertions(+), 29 deletions(-) diff --git a/drivers/common/cnxk/roc_mbox.h b/drivers/common/cnxk/roc_mbox.h index 05434aec5a..3257a370bc 100644 --- a/drivers/common/cnxk/roc_mbox.h +++ b/drivers/common/cnxk/roc_mbox.h @@ -298,6 +298,11 @@ struct mbox_msghdr { M(NIX_FREE_BPIDS, 0x8029, nix_free_bpids, nix_bpids, msg_rsp) \ M(NIX_RX_CHAN_CFG, 0x802a, nix_rx_chan_cfg, nix_rx_chan_cfg, \ nix_rx_chan_cfg) \ + M(NIX_MCAST_GRP_CREATE, 0x802b, nix_mcast_grp_create, nix_mcast_grp_create_req,\ + nix_mcast_grp_create_rsp) \ + M(NIX_MCAST_GRP_DESTROY, 0x802c, nix_mcast_grp_destroy, nix_mcast_grp_destroy_req, msg_rsp)\ + M(NIX_MCAST_GRP_UPDATE, 0x802d, nix_mcast_grp_update, nix_mcast_grp_update_req,\ + nix_mcast_grp_update_rsp) \ /* MCS mbox IDs (range 0xa000 - 0xbFFF) */ \ M(MCS_ALLOC_RESOURCES, 0xa000, mcs_alloc_resources, mcs_alloc_rsrc_req, \ mcs_alloc_rsrc_rsp) \ @@ -1768,6 +1773,57 @@ struct nix_rx_chan_cfg { uint64_t __io rsvd; }; +struct nix_mcast_grp_create_req { + struct mbox_msghdr hdr; +#define NIX_MCAST_INGRESS 0 +#define NIX_MCAST_EGRESS 1 + uint8_t __io dir; + uint8_t __io reserved[11]; + /* Reserving few bytes for future requirement */ +}; + +struct nix_mcast_grp_create_rsp { + struct mbox_msghdr hdr; + /* This mcast_grp_idx should be passed during MCAM +* write entry for multicast. AF will identify the +* corresponding multicast table index associated +* with the group id and program the same to MCAM entry. +* This group id is also needed during group delete +* and update request. +*/ + uint32_t __io mcast_grp_idx; +}; +struct nix_mcast_grp_destroy_req { + struct mbox_msghdr hdr; + /* Group id returned by nix_mcast_grp_create_rsp */ + uint32_t __io mcast_grp_idx; +}; + +struct nix_mcast_grp_update_req { + struct mbox_msghdr hdr; + /* Group id returned by nix_mcast_grp_create_rsp */ + uint32_t __io mcast_grp_idx; + /* Number of multicast/mirror entries requested */ + uint32_t __io num_mce_entry; +#define NIX_MCE_ENTRY_MAX 64 +#define NIX_RX_RQ0 +#define NIX_RX_RSS 1 + /* Receive queue or RSS index within pf_func */ + uint32_t __io rq_rss_index[NIX_MCE_ENTRY_MAX]; + uint16_t __io pcifunc[NIX_MCE_ENTRY_MAX]; + uint16_t __io channel[NIX_MCE_ENTRY_MAX]; +#define NIX_MCAST_OP_ADD_ENTRY 0 +#define NIX_MCAST_OP_DEL_ENTRY 1 + /* Destination type. 0:Receive queue, 1:RSS*/ + uint8_t __io dest_type[NIX_MCE_ENTRY_MAX]; + uint8_t __io op; +}; + +struct nix_mcast_grp_update_rsp { + struct mbox_msghdr hdr; + uint32_t __io mce_start_index; +}; + /* Global NIX inline IPSec configuration */ struct nix_inline_ipsec_cfg { struct mbox_msghdr hdr; diff --git a/drivers/common/cnxk/roc_nix.h b/drivers/common/cnxk/roc_nix.h index 82997c38ce..c1ebf971f7 100644 --- a/drivers/common/cnxk/roc_nix.h +++ b/drivers/common/cnxk/roc_nix.h @@ -1005,6 +1005,10 @@ int __roc_api roc_nix_mcast_mcam_entry_write(struct roc_nix *roc_nix, struct mcam_entry *entry, uint32_t index, uint8_t intf, uint64_t action); -int __roc_api roc_nix_mcast_mcam_entry_ena_dis(struct roc_nix *roc_nix, - uint32_t index, bool enable); +int __roc_api roc_nix_mcast_mcam_entry_ena_dis(struct roc_nix *roc_nix, uint32_t index, + bool enable); +int __roc_api roc_nix_mcast_list_setup(struct mbox *mbox, uint8_t intf, int nb_entries, + uint16_t *pf_funcs, uint16_t *channels, uint32_t *rqs, + uint32_t *grp_index, uin
[dpdk-dev] [PATCH v2 2/3] net/cnxk: support mirror flow action
From: Satheesh Paul Added RTE_FLOW_ACTION_TYPE_SAMPLE action type for cnxk device. Signed-off-by: Satheesh Paul Reviewed-by: Kiran Kumar K --- doc/guides/nics/features/cnxk.ini | 1 + doc/guides/rel_notes/release_24_03.rst | 1 + drivers/net/cnxk/cnxk_flow.c | 121 +++-- 3 files changed, 116 insertions(+), 7 deletions(-) diff --git a/doc/guides/nics/features/cnxk.ini b/doc/guides/nics/features/cnxk.ini index cc7deaeaa9..94e7a6ab8d 100644 --- a/doc/guides/nics/features/cnxk.ini +++ b/doc/guides/nics/features/cnxk.ini @@ -97,6 +97,7 @@ port_id = Y queue= Y represented_port = Y rss = Y +sample = Y security = Y skip_cman= Y vf = Y diff --git a/doc/guides/rel_notes/release_24_03.rst b/doc/guides/rel_notes/release_24_03.rst index 866dd60fbf..282a3f9c8c 100644 --- a/doc/guides/rel_notes/release_24_03.rst +++ b/doc/guides/rel_notes/release_24_03.rst @@ -65,6 +65,7 @@ New Features * **Updated Marvell cnxk net driver.** * Added support for ``RTE_FLOW_ITEM_TYPE_PPPOES`` flow item. + * Added support for ``RTE_FLOW_ACTION_TYPE_SAMPLE`` flow item. Removed Items - diff --git a/drivers/net/cnxk/cnxk_flow.c b/drivers/net/cnxk/cnxk_flow.c index 2eee44ed09..11670d37e0 100644 --- a/drivers/net/cnxk/cnxk_flow.c +++ b/drivers/net/cnxk/cnxk_flow.c @@ -114,14 +114,102 @@ npc_rss_flowkey_get(struct cnxk_eth_dev *eth_dev, *flowkey_cfg = cnxk_rss_ethdev_to_nix(eth_dev, rss->types, rss->level); } +static int +npc_parse_port_id_action(struct rte_eth_dev *eth_dev, const struct rte_flow_action *action, +uint16_t *dst_pf_func, uint16_t *dst_channel) +{ + const struct rte_flow_action_port_id *port_act; + struct rte_eth_dev *portid_eth_dev; + char if_name[RTE_ETH_NAME_MAX_LEN]; + struct cnxk_eth_dev *hw_dst; + struct roc_npc *roc_npc_dst; + int rc = 0; + + port_act = (const struct rte_flow_action_port_id *)action->conf; + + rc = rte_eth_dev_get_name_by_port(port_act->id, if_name); + if (rc) { + plt_err("Name not found for output port id"); + goto err_exit; + } + portid_eth_dev = rte_eth_dev_allocated(if_name); + if (!portid_eth_dev) { + plt_err("eth_dev not found for output port id"); + goto err_exit; + } + if (strcmp(portid_eth_dev->device->driver->name, eth_dev->device->driver->name) != 0) { + plt_err("Output port not under same driver"); + goto err_exit; + } + hw_dst = portid_eth_dev->data->dev_private; + roc_npc_dst = &hw_dst->npc; + *dst_pf_func = roc_npc_dst->pf_func; + *dst_channel = hw_dst->npc.channel; + + return 0; + +err_exit: + return -EINVAL; +} + +static int +roc_npc_parse_sample_subaction(struct rte_eth_dev *eth_dev, const struct rte_flow_action actions[], + struct roc_npc_action_sample *sample_action) +{ + uint16_t dst_pf_func = 0, dst_channel = 0; + const struct roc_npc_action_vf *vf_act; + int rc = 0, count = 0; + bool is_empty = true; + + if (sample_action->ratio != 1) { + plt_err("Sample ratio must be 1"); + return -EINVAL; + } + + for (; actions->type != RTE_FLOW_ACTION_TYPE_END; actions++) { + is_empty = false; + switch (actions->type) { + case RTE_FLOW_ACTION_TYPE_PF: + count++; + sample_action->action_type |= ROC_NPC_ACTION_TYPE_PF; + break; + case RTE_FLOW_ACTION_TYPE_VF: + count++; + vf_act = (const struct roc_npc_action_vf *)actions->conf; + sample_action->action_type |= ROC_NPC_ACTION_TYPE_VF; + sample_action->pf_func = vf_act->id & NPC_PFVF_FUNC_MASK; + break; + case RTE_FLOW_ACTION_TYPE_PORT_ID: + rc = npc_parse_port_id_action(eth_dev, actions, &dst_pf_func, &dst_channel); + if (rc) + return -EINVAL; + + count++; + sample_action->action_type |= ROC_NPC_ACTION_TYPE_PORT_ID; + sample_action->pf_func = dst_pf_func; + sample_action->channel = dst_channel; + break; + default: + continue; + } + } + + if (count > 1 || is_empty) + return -EINVAL; + + return 0; +} + static int cnxk_map_actions(struct rte_eth_dev *eth_dev, const struct rte_flow_attr *attr, const struct rte_flow_action actions[], struct roc_npc_action in_actions[], -uint32_t *flowkey_cfg, uint
[dpdk-dev] [PATCH v2 3/3] common/cnxk: add egress mirror support
From: Satha Rao Added ROC api to send packets on multiple links when egress mirror enabled. Signed-off-by: Satha Rao Reviewed-by: Nithin Dabilpuram Reviewed-by: Kiran Kumar K Reviewed-by: Satheesh Paul --- drivers/common/cnxk/roc_nix.h| 2 + drivers/common/cnxk/roc_nix_tm_ops.c | 70 drivers/common/cnxk/roc_npc.c| 26 +++ drivers/common/cnxk/version.map | 1 + 4 files changed, 99 insertions(+) diff --git a/drivers/common/cnxk/roc_nix.h b/drivers/common/cnxk/roc_nix.h index c1ebf971f7..84e6fc3df5 100644 --- a/drivers/common/cnxk/roc_nix.h +++ b/drivers/common/cnxk/roc_nix.h @@ -755,6 +755,8 @@ int __roc_api roc_nix_tm_mark_config(struct roc_nix *roc_nix, int mark_red); uint64_t __roc_api roc_nix_tm_mark_format_get(struct roc_nix *roc_nix, uint64_t *flags); +int __roc_api roc_nix_tm_egress_link_cfg_set(struct roc_nix *roc_nix, uint64_t dst_pf_func, +bool enable); /* Ingress Policer API */ int __roc_api roc_nix_bpf_timeunit_get(struct roc_nix *roc_nix, diff --git a/drivers/common/cnxk/roc_nix_tm_ops.c b/drivers/common/cnxk/roc_nix_tm_ops.c index 2c53472047..900b182c76 100644 --- a/drivers/common/cnxk/roc_nix_tm_ops.c +++ b/drivers/common/cnxk/roc_nix_tm_ops.c @@ -1316,3 +1316,73 @@ roc_nix_tm_root_has_sp(struct roc_nix *roc_nix) return false; return true; } + +static inline struct nix * +pf_func_to_nix_get(uint16_t pf_func) +{ + struct roc_nix *roc_nix_tmp = NULL; + struct roc_nix_list *nix_list; + + nix_list = roc_idev_nix_list_get(); + if (nix_list == NULL) + return NULL; + + /* Find the NIX of given pf_func */ + TAILQ_FOREACH(roc_nix_tmp, nix_list, next) { + struct nix *nix = roc_nix_to_nix_priv(roc_nix_tmp); + + if (nix->dev.pf_func == pf_func) + return nix; + } + + return NULL; +} + +int +roc_nix_tm_egress_link_cfg_set(struct roc_nix *roc_nix, uint64_t dst_pf_func, bool enable) +{ + struct nix *src_nix = roc_nix_to_nix_priv(roc_nix), *dst_nix; + struct mbox *mbox = (&src_nix->dev)->mbox; + struct nix_txschq_config *req = NULL; + struct nix_tm_node_list *list; + struct nix_tm_node *node; + int rc = 0, k; + + dst_nix = pf_func_to_nix_get(dst_pf_func); + if (!dst_nix) + return -EINVAL; + + if (dst_nix == src_nix) + return 0; + + list = nix_tm_node_list(src_nix, src_nix->tm_tree); + TAILQ_FOREACH(node, list, node) { + if (node->hw_lvl != src_nix->tm_link_cfg_lvl) + continue; + + if (!(node->flags & NIX_TM_NODE_HWRES)) + continue; + + /* Allocating TL3 request */ + req = mbox_alloc_msg_nix_txschq_cfg(mbox_get(mbox)); + req->lvl = src_nix->tm_link_cfg_lvl; + k = 0; + + /* Enable PFC/pause on the identified TL3 */ + req->reg[k] = NIX_AF_TL3_TL2X_LINKX_CFG(node->hw_id, dst_nix->tx_link); + if (enable) + req->regval[k] |= BIT_ULL(12); + else + req->regval[k] &= ~(BIT_ULL(12)); + req->regval_mask[k] = ~(BIT_ULL(12)); + k++; + + req->num_regs = k; + rc = mbox_process(mbox); + mbox_put(mbox); + if (rc) + goto err; + } +err: + return rc; +} diff --git a/drivers/common/cnxk/roc_npc.c b/drivers/common/cnxk/roc_npc.c index 65f99549c9..9a0fe5f4e2 100644 --- a/drivers/common/cnxk/roc_npc.c +++ b/drivers/common/cnxk/roc_npc.c @@ -1595,6 +1595,21 @@ roc_npc_flow_create(struct roc_npc *roc_npc, const struct roc_npc_attr *attr, goto err_exit; } + /* If Egress mirror requested then enable TL3_TL2_LINK_CFG */ + if (flow->is_sampling_rule && (flow->nix_intf == NIX_INTF_TX)) { + if (flow->mcast_pf_funcs[0] == npc->pf_func) + rc = roc_nix_tm_egress_link_cfg_set(roc_npc->roc_nix, + flow->mcast_pf_funcs[1], true); + else + rc = roc_nix_tm_egress_link_cfg_set(roc_npc->roc_nix, + flow->mcast_pf_funcs[0], true); + if (rc) { + plt_err("Adding egress mirror failed"); + *errcode = rc; + goto err_exit; + } + } + rc = npc_rss_action_program(roc_npc, actions, flow); if (rc != 0) { *errcode = rc; @@ -1706,6 +1721,17 @@ roc_npc_flow_destroy(struct roc_npc *roc_npc, struct roc_npc_flow *flow) retur
[dpdk-dev] [PATCH] net/cnxk: fix issue with RSS configuration for cnxk
From: Kiran Kumar K While creating a RSS rule, if no RSS types are specified, use RSS types from dev config. Fixes: bc778a17fa46 ("net/cnxk: support flow RSS") Cc: sta...@dpdk.org Signed-off-by: Kiran Kumar K Reviewed-by: Satheesh Paul --- drivers/net/cnxk/cnxk_flow.c | 15 ++- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/net/cnxk/cnxk_flow.c b/drivers/net/cnxk/cnxk_flow.c index 11670d37e0..a92b61c332 100644 --- a/drivers/net/cnxk/cnxk_flow.c +++ b/drivers/net/cnxk/cnxk_flow.c @@ -103,15 +103,19 @@ npc_rss_action_validate(struct rte_eth_dev *eth_dev, const struct rte_flow_attr } static void -npc_rss_flowkey_get(struct cnxk_eth_dev *eth_dev, - const struct roc_npc_action *rss_action, - uint32_t *flowkey_cfg) +npc_rss_flowkey_get(struct cnxk_eth_dev *eth_dev, const struct roc_npc_action *rss_action, + uint32_t *flowkey_cfg, uint64_t default_rss_types) { const struct roc_npc_action_rss *rss; + uint64_t rss_types; rss = (const struct roc_npc_action_rss *)rss_action->conf; + rss_types = rss->types; + /* If no RSS types are specified, use default one */ + if (rss_types == 0) + rss_types = default_rss_types; - *flowkey_cfg = cnxk_rss_ethdev_to_nix(eth_dev, rss->types, rss->level); + *flowkey_cfg = cnxk_rss_ethdev_to_nix(eth_dev, rss_types, rss->level); } static int @@ -293,7 +297,8 @@ cnxk_map_actions(struct rte_eth_dev *eth_dev, const struct rte_flow_attr *attr, goto err_exit; in_actions[i].type = ROC_NPC_ACTION_TYPE_RSS; in_actions[i].conf = actions->conf; - npc_rss_flowkey_get(dev, &in_actions[i], flowkey_cfg); + npc_rss_flowkey_get(dev, &in_actions[i], flowkey_cfg, + eth_dev->data->dev_conf.rx_adv_conf.rss_conf.rss_hf); break; case RTE_FLOW_ACTION_TYPE_SECURITY: -- 2.39.2
[dpdk-dev] [PATCH] net/cnxk: fix aged flows query
From: Satheesh Paul After all aged flows are destroyed, the aged_flows bitmap is free-ed. Querying aged flows tries to access this bitmap resulting in a segmentation fault. Fixing this by not accessing the bitmap if no aged flows are present. Fixes: 357f5ebc8a24 ("common/cnxk: support flow aging") Cc: sta...@dpdk.org Signed-off-by: Satheesh Paul Reviewed-by: Kiran Kumar K --- drivers/common/cnxk/roc_npc_aging.c | 4 drivers/net/cnxk/cnxk_flow.c| 3 +++ 2 files changed, 7 insertions(+) diff --git a/drivers/common/cnxk/roc_npc_aging.c b/drivers/common/cnxk/roc_npc_aging.c index 254dd2139b..e0f2dc2291 100644 --- a/drivers/common/cnxk/roc_npc_aging.c +++ b/drivers/common/cnxk/roc_npc_aging.c @@ -234,8 +234,11 @@ npc_age_flow_list_entry_delete(struct roc_npc *roc_npc, { struct npc *npc = roc_npc_to_npc_priv(roc_npc); struct npc_age_flow_list_head *list; + struct roc_npc_flow_age *flow_age; struct npc_age_flow_entry *curr; + flow_age = &roc_npc->flow_age; + list = &npc->age_flow_list; curr = TAILQ_FIRST(list); @@ -244,6 +247,7 @@ npc_age_flow_list_entry_delete(struct roc_npc *roc_npc, while (curr) { if (flow->mcam_id == curr->flow->mcam_id) { + plt_bitmap_clear(flow_age->aged_flows, flow->mcam_id); TAILQ_REMOVE(list, curr, next); plt_free(curr); break; diff --git a/drivers/net/cnxk/cnxk_flow.c b/drivers/net/cnxk/cnxk_flow.c index a92b61c332..4deccd1a67 100644 --- a/drivers/net/cnxk/cnxk_flow.c +++ b/drivers/net/cnxk/cnxk_flow.c @@ -616,6 +616,9 @@ cnxk_flow_get_aged_flows(struct rte_eth_dev *eth_dev, void **context, flow_age = &roc_npc->flow_age; + if (!flow_age->age_flow_refcnt) + return 0; + do { sn = plt_seqcount_read_begin(&flow_age->seq_cnt); -- 2.39.2
[dpdk-dev] [PATCH] common/cnxk: fix flow aging cleanup
From: Satheesh Paul The aged flows poll thread is not stopped before NPC cleanup resulting in a segmentation fault. Fixing this by stopping aged flows poll thread before proceeding with NPC cleanup. Fixes: 357f5ebc8a24 ("common/cnxk: support flow aging") Cc: sta...@dpdk.org Signed-off-by: Satheesh Paul Reviewed-by: Kiran Kumar K --- drivers/common/cnxk/roc_npc.c | 5 +++-- drivers/common/cnxk/roc_npc_aging.c | 8 +--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/common/cnxk/roc_npc.c b/drivers/common/cnxk/roc_npc.c index d6ad3756bb..37e1a6a7ef 100644 --- a/drivers/common/cnxk/roc_npc.c +++ b/drivers/common/cnxk/roc_npc.c @@ -389,6 +389,8 @@ roc_npc_fini(struct roc_npc *roc_npc) struct npc *npc = roc_npc_to_npc_priv(roc_npc); int rc; + npc_aging_ctrl_thread_destroy(roc_npc); + rc = npc_flow_free_all_resources(npc); if (rc) { plt_err("Error when deleting NPC MCAM entries, counters"); @@ -1810,8 +1812,7 @@ roc_npc_flow_destroy(struct roc_npc *roc_npc, struct roc_npc_flow *flow) if (flow->has_age_action) npc_age_flow_list_entry_delete(roc_npc, flow); - if (roc_npc->flow_age.age_flow_refcnt == 0 && - plt_thread_is_valid(roc_npc->flow_age.aged_flows_poll_thread)) + if (roc_npc->flow_age.age_flow_refcnt == 0) npc_aging_ctrl_thread_destroy(roc_npc); done: diff --git a/drivers/common/cnxk/roc_npc_aging.c b/drivers/common/cnxk/roc_npc_aging.c index e0f2dc2291..15f6e61d76 100644 --- a/drivers/common/cnxk/roc_npc_aging.c +++ b/drivers/common/cnxk/roc_npc_aging.c @@ -303,9 +303,11 @@ npc_aging_ctrl_thread_destroy(struct roc_npc *roc_npc) struct roc_npc_flow_age *flow_age; flow_age = &roc_npc->flow_age; - flow_age->aged_flows_get_thread_exit = true; - plt_thread_join(flow_age->aged_flows_poll_thread, NULL); - npc_aged_flows_bitmap_free(roc_npc); + if (plt_thread_is_valid(flow_age->aged_flows_poll_thread)) { + flow_age->aged_flows_get_thread_exit = true; + plt_thread_join(flow_age->aged_flows_poll_thread, NULL); + npc_aged_flows_bitmap_free(roc_npc); + } } void * -- 2.39.2
[dpdk-dev] [PATCH] common/cnxk: fix flow aging application exit
From: Kiran Kumar K If flow aging is enabled application termination may take time equivalent to aging timeout. This is because on termination flow thread uses a sleep call which is uninterruptible. Fixes: 357f5ebc8a24 ("common/cnxk: support flow aging") Cc: sta...@dpdk.org Signed-off-by: Kiran Kumar K Signed-off-by: Harman Kalra Reviewed-by: Jerin Jacob --- drivers/common/cnxk/roc_npc_aging.c | 17 - 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/common/cnxk/roc_npc_aging.c b/drivers/common/cnxk/roc_npc_aging.c index 15f6e61d76..66c953135a 100644 --- a/drivers/common/cnxk/roc_npc_aging.c +++ b/drivers/common/cnxk/roc_npc_aging.c @@ -133,6 +133,21 @@ npc_mcam_get_hit_status(struct npc *npc, uint64_t *mcam_ids, uint16_t start_id, return rc; } +static void +npc_age_wait_until(struct roc_npc_flow_age *flow_age) +{ +#define NPC_AGE_WAIT_TIMEOUT_MS 1000 +#define NPC_AGE_WAIT_TIMEOUT_US (NPC_AGE_WAIT_TIMEOUT_MS * NPC_AGE_WAIT_TIMEOUT_MS) + uint64_t timeout = 0; + uint64_t sleep = 10 * NPC_AGE_WAIT_TIMEOUT_MS; + + do { + plt_delay_us(sleep); + timeout += sleep; + } while (!flow_age->aged_flows_get_thread_exit && +(timeout < (flow_age->aging_poll_freq * NPC_AGE_WAIT_TIMEOUT_US))); +} + uint32_t npc_aged_flows_get(void *args) { @@ -197,7 +212,7 @@ npc_aged_flows_get(void *args) plt_seqcount_write_end(&flow_age->seq_cnt); lbl_sleep: - sleep(flow_age->aging_poll_freq); + npc_age_wait_until(flow_age); } return 0; -- 2.39.2
[dpdk-dev] [PATCH ] common/cnxk: fix setting default flow action
From: Satheesh Paul For MCAM rules with PF/VF action, the PF's default rule action is is copied and overwritten over the user provided action. Fixing this by setting default action only if no other action (like queue) is specified by user. Fixes: a07f7ced436def ("common/cnxk: add NPC init and fini") Cc: sta...@dpdk.org Signed-off-by: Satheesh Paul Reviewed-by: Kiran Kumar K --- drivers/common/cnxk/hw/nix.h| 1 + drivers/common/cnxk/roc_npc.c | 17 ++--- drivers/common/cnxk/roc_npc_mcam_dump.c | 4 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/drivers/common/cnxk/hw/nix.h b/drivers/common/cnxk/hw/nix.h index 26dcda680e..d2c80f3c74 100644 --- a/drivers/common/cnxk/hw/nix.h +++ b/drivers/common/cnxk/hw/nix.h @@ -619,6 +619,7 @@ #define NIX_RX_ACTIONOP_RSS (0x4ull) #define NIX_RX_ACTIONOP_PF_FUNC_DROP (0x5ull) #define NIX_RX_ACTIONOP_MIRROR (0x6ull) +#define NIX_RX_ACTIONOP_DEFAULT (0xfull) #define NIX_RX_VTAGACTION_VTAG0_RELPTR (0x0ull) #define NIX_RX_VTAGACTION_VTAG1_RELPTR (0x4ull) diff --git a/drivers/common/cnxk/roc_npc.c b/drivers/common/cnxk/roc_npc.c index 848086c8de..586bc55791 100644 --- a/drivers/common/cnxk/roc_npc.c +++ b/drivers/common/cnxk/roc_npc.c @@ -726,11 +726,15 @@ npc_parse_actions(struct roc_npc *roc_npc, const struct roc_npc_attr *attr, if (req_act == ROC_NPC_ACTION_TYPE_VLAN_STRIP) { /* Only VLAN action is provided */ flow->npc_action = NIX_RX_ACTIONOP_UCAST; - } else if (req_act & - (ROC_NPC_ACTION_TYPE_PF | ROC_NPC_ACTION_TYPE_VF)) { - flow->npc_action = NIX_RX_ACTIONOP_UCAST; - if (req_act & ROC_NPC_ACTION_TYPE_QUEUE) - flow->npc_action |= (uint64_t)rq << 20; + } else if (req_act & (ROC_NPC_ACTION_TYPE_PF | ROC_NPC_ACTION_TYPE_VF)) { + /* Check if any other action is set */ + if ((req_act == ROC_NPC_ACTION_TYPE_PF) || (req_act == ROC_NPC_ACTION_TYPE_VF)) { + flow->npc_action = NIX_RX_ACTIONOP_DEFAULT; + } else { + flow->npc_action = NIX_RX_ACTIONOP_UCAST; + if (req_act & ROC_NPC_ACTION_TYPE_QUEUE) + flow->npc_action |= (uint64_t)rq << 20; + } } else if (req_act & ROC_NPC_ACTION_TYPE_DROP) { flow->npc_action = NIX_RX_ACTIONOP_DROP; } else if (req_act & ROC_NPC_ACTION_TYPE_QUEUE) { @@ -741,8 +745,7 @@ npc_parse_actions(struct roc_npc *roc_npc, const struct roc_npc_attr *attr, } else if (req_act & ROC_NPC_ACTION_TYPE_SEC) { flow->npc_action = NIX_RX_ACTIONOP_UCAST_IPSEC; flow->npc_action |= (uint64_t)rq << 20; - } else if (req_act & - (ROC_NPC_ACTION_TYPE_FLAG | ROC_NPC_ACTION_TYPE_MARK)) { + } else if (req_act & (ROC_NPC_ACTION_TYPE_FLAG | ROC_NPC_ACTION_TYPE_MARK)) { flow->npc_action = NIX_RX_ACTIONOP_UCAST; } else if (req_act & ROC_NPC_ACTION_TYPE_COUNT) { /* Keep ROC_NPC_ACTION_TYPE_COUNT_ACT always at the end diff --git a/drivers/common/cnxk/roc_npc_mcam_dump.c b/drivers/common/cnxk/roc_npc_mcam_dump.c index 01c4212567..ebd2dd69c2 100644 --- a/drivers/common/cnxk/roc_npc_mcam_dump.c +++ b/drivers/common/cnxk/roc_npc_mcam_dump.c @@ -496,6 +496,10 @@ npc_flow_dump_rx_action(FILE *file, uint64_t npc_action) plt_strlcpy(index_name, "Multicast/mirror table index", NPC_MAX_FIELD_NAME_SIZE); break; + case NIX_RX_ACTIONOP_DEFAULT: + fprintf(file, "NIX_RX_ACTIONOP_DEFAULT (%" PRIu64 ")\n", + (uint64_t)NIX_RX_ACTIONOP_DEFAULT); + break; default: plt_err("Unknown NIX_RX_ACTIONOP found"); return; -- 2.39.2
[dpdk-dev] [PATCH ] common/cnxk: fix ROC naming convention
From: Satheesh Paul Fix ROC code naming convention. Fixes: d110c44d29e7 ("common/cnxk: support flow aging") Signed-off-by: Satheesh Paul Reviewed-by: Jerin Jacob --- drivers/common/cnxk/roc_npc.h | 2 +- drivers/common/cnxk/roc_npc_aging.c | 14 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/common/cnxk/roc_npc.h b/drivers/common/cnxk/roc_npc.h index 2fb0aa7a4e..84c92f4c28 100644 --- a/drivers/common/cnxk/roc_npc.h +++ b/drivers/common/cnxk/roc_npc.h @@ -224,7 +224,7 @@ struct roc_npc_action_port_id { struct roc_npc_action_age { uint32_t timeout : 24; /**< Time in seconds. */ uint32_t reserved : 8; /**< Reserved, must be zero. */ - /** The user flow context, NULL means the rte_flow pointer. */ + /** The user flow context, NULL means the flow pointer. */ void *context; }; diff --git a/drivers/common/cnxk/roc_npc_aging.c b/drivers/common/cnxk/roc_npc_aging.c index 94126fe9fd..874a7cd4ff 100644 --- a/drivers/common/cnxk/roc_npc_aging.c +++ b/drivers/common/cnxk/roc_npc_aging.c @@ -62,7 +62,7 @@ check_timeout_cycles(struct roc_npc *roc_npc, uint32_t mcam_id) list = &npc->age_flow_list; TAILQ_FOREACH(fl_iter, list, next) { if (fl_iter->flow->mcam_id == mcam_id && - fl_iter->flow->timeout_cycles < rte_get_timer_cycles()) { + fl_iter->flow->timeout_cycles < plt_tsc_cycles()) { /* update bitmap */ plt_bitmap_set(flow_age->aged_flows, mcam_id); if (!aging_enabled) { @@ -90,8 +90,8 @@ update_timeout_cycles(struct roc_npc *roc_npc, uint32_t mcam_id) list = &npc->age_flow_list; TAILQ_FOREACH(fl_iter, list, next) { if (fl_iter->flow->mcam_id == mcam_id) { - fl_iter->flow->timeout_cycles = rte_get_timer_cycles() + - fl_iter->flow->timeout * rte_get_timer_hz(); + fl_iter->flow->timeout_cycles = plt_tsc_cycles() + + fl_iter->flow->timeout * plt_tsc_hz(); break; } } @@ -214,6 +214,11 @@ npc_age_flow_list_entry_add(struct roc_npc *roc_npc, struct roc_npc_flow *flow) struct npc_age_flow_entry *new_entry; new_entry = plt_zmalloc(sizeof(*new_entry), 0); + if (new_entry == NULL) { + plt_err("flow entry alloc failed"); + return; + } + new_entry->flow = flow; roc_npc->flow_age.age_flow_refcnt++; /* List in ascending order of mcam entries */ @@ -269,8 +274,7 @@ npc_aging_ctrl_thread_create(struct roc_npc *roc_npc, flow->age_context = age->context == NULL ? flow : age->context; flow->timeout = age->timeout; - flow->timeout_cycles = rte_get_timer_cycles() + age->timeout * - rte_get_timer_hz(); + flow->timeout_cycles = plt_tsc_cycles() + age->timeout * plt_tsc_hz(); if (flow_age->age_flow_refcnt == 0) { flow_age->aged_flows_get_thread_exit = false; -- 2.39.2
[dpdk-dev] [PATCH] common/cnxk: fix setting channel mask for SDP interfaces
From: Satheesh Paul Channel mask field is incorrectly returned as 16 bits. Fixing it by truncating to 12 bits. Fixes: 2703f1fa3200 ("common/cnxk: fix setting channel mask for SDP interfaces") Cc: sta...@dpdk.org Signed-off-by: Satheesh Paul --- drivers/common/cnxk/roc_npc.c | 5 +++-- drivers/common/cnxk/roc_npc.h | 2 ++ drivers/common/cnxk/version.map | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/common/cnxk/roc_npc.c b/drivers/common/cnxk/roc_npc.c index 4173dd2933..0fd1081d43 100644 --- a/drivers/common/cnxk/roc_npc.c +++ b/drivers/common/cnxk/roc_npc.c @@ -1439,7 +1439,7 @@ npc_inline_dev_ipsec_action_free(struct npc *npc, struct roc_npc_flow *flow) return 1; } -static void +void roc_npc_sdp_channel_get(struct roc_npc *roc_npc, uint16_t *chan_base, uint16_t *chan_mask) { struct roc_nix *roc_nix = roc_npc->roc_nix; @@ -1454,8 +1454,9 @@ roc_npc_sdp_channel_get(struct roc_npc *roc_npc, uint16_t *chan_base, uint16_t * num_bits = (sizeof(uint32_t) * 8) - plt_clz32(range) - 1; /* Set mask for (15 - numbits) MSB bits */ *chan_mask = (uint16_t)~GENMASK(num_bits, 0); + *chan_mask &= 0xFFF; } else { - *chan_mask = (uint16_t)GENMASK(15, 0); + *chan_mask = (uint16_t)GENMASK(11, 0); } mask = (uint16_t)GENMASK(num_bits, 0); diff --git a/drivers/common/cnxk/roc_npc.h b/drivers/common/cnxk/roc_npc.h index ad88cf34a4..e9870a162a 100644 --- a/drivers/common/cnxk/roc_npc.h +++ b/drivers/common/cnxk/roc_npc.h @@ -451,4 +451,6 @@ int __roc_api roc_npc_validate_portid_action(struct roc_npc *roc_npc_src, int __roc_api roc_npc_mcam_init(struct roc_npc *roc_npc, struct roc_npc_flow *flow, int mcam_id); int __roc_api roc_npc_mcam_move(struct roc_npc *roc_npc, uint16_t old_ent, uint16_t new_ent); void *__roc_api roc_npc_aged_flow_ctx_get(struct roc_npc *roc_npc, uint32_t mcam_id); +void __roc_api roc_npc_sdp_channel_get(struct roc_npc *roc_npc, uint16_t *chan_base, + uint16_t *chan_mask); #endif /* _ROC_NPC_H_ */ diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map index fffd2064be..aa884a8fe2 100644 --- a/drivers/common/cnxk/version.map +++ b/drivers/common/cnxk/version.map @@ -459,6 +459,7 @@ INTERNAL { roc_npc_mcam_read_counter; roc_npc_inl_mcam_read_counter; roc_npc_profile_name_get; + roc_npc_sdp_channel_get; roc_npc_validate_portid_action; roc_ot_ipsec_inb_sa_init; roc_ot_ipsec_outb_sa_init; -- 2.39.2
[dpdk-dev] [PATCH] common/cnxk: add ROC API to get MKEX capability
From: Satheesh Paul Added ROC API to get MKEX capability. Signed-off-by: Satheesh Paul Reviewed-by: Kiran Kumar K --- drivers/common/cnxk/roc_npc.c | 24 drivers/common/cnxk/roc_npc.h | 1 + drivers/common/cnxk/version.map | 1 + 3 files changed, 26 insertions(+) diff --git a/drivers/common/cnxk/roc_npc.c b/drivers/common/cnxk/roc_npc.c index a0d88c0743..1958b3089d 100644 --- a/drivers/common/cnxk/roc_npc.c +++ b/drivers/common/cnxk/roc_npc.c @@ -235,6 +235,30 @@ roc_npc_profile_name_get(struct roc_npc *roc_npc) return (char *)npc->profile_name; } +int +roc_npc_kex_capa_get(struct roc_nix *roc_nix, uint64_t *kex_capability) +{ + struct nix *nix = roc_nix_to_nix_priv(roc_nix); + struct npc npc; + int rc = 0; + + memset(&npc, 0, sizeof(npc)); + + npc.mbox = (&nix->dev)->mbox; + + rc = npc_mcam_fetch_kex_cfg(&npc); + if (rc) + return rc; + + rc = npc_mcam_fetch_hw_cap(&npc, &npc.hash_extract_cap); + if (rc) + return rc; + + *kex_capability = npc_get_kex_capability(&npc); + + return 0; +} + int roc_npc_init(struct roc_npc *roc_npc) { diff --git a/drivers/common/cnxk/roc_npc.h b/drivers/common/cnxk/roc_npc.h index b71ddd1578..459fa33de9 100644 --- a/drivers/common/cnxk/roc_npc.h +++ b/drivers/common/cnxk/roc_npc.h @@ -399,6 +399,7 @@ struct roc_npc { int __roc_api roc_npc_init(struct roc_npc *roc_npc); int __roc_api roc_npc_fini(struct roc_npc *roc_npc); const char *__roc_api roc_npc_profile_name_get(struct roc_npc *roc_npc); +int __roc_api roc_npc_kex_capa_get(struct roc_nix *roc_nix, uint64_t *kex_capability); struct roc_npc_flow *__roc_api roc_npc_flow_create(struct roc_npc *roc_npc, const struct roc_npc_attr *attr, diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map index aa884a8fe2..1c7c65c51a 100644 --- a/drivers/common/cnxk/version.map +++ b/drivers/common/cnxk/version.map @@ -438,6 +438,7 @@ INTERNAL { roc_npc_flow_parse; roc_npc_get_low_priority_mcam; roc_npc_init; + roc_npc_kex_capa_get; roc_npc_mark_actions_get; roc_npc_mark_actions_sub_return; roc_npc_vtag_actions_get; -- 2.39.2
[dpdk-dev] [PATCH v2] drivers: add represented port flow item for cnxk
From: Satheesh Paul Adding support for represented port flow item for cnxk device. Signed-off-by: Kiran Kumar K Signed-off-by: Satheesh Paul --- v2: * Fix issue with flow key alg for cnxk. doc/guides/nics/features/cnxk.ini| 1 + doc/guides/nics/features/cnxk_vf.ini | 1 + drivers/common/cnxk/roc_npc.c| 61 --- drivers/common/cnxk/roc_npc.h| 13 +++- drivers/common/cnxk/roc_npc_mcam.c | 68 - drivers/common/cnxk/roc_npc_parse.c | 11 +++ drivers/common/cnxk/roc_npc_priv.h | 1 + drivers/net/cnxk/cnxk_flow.c | 106 ++- 8 files changed, 166 insertions(+), 96 deletions(-) diff --git a/doc/guides/nics/features/cnxk.ini b/doc/guides/nics/features/cnxk.ini index ac7de9a0f0..1c7d804aab 100644 --- a/doc/guides/nics/features/cnxk.ini +++ b/doc/guides/nics/features/cnxk.ini @@ -72,6 +72,7 @@ mark = Y mpls = Y nvgre= Y raw = Y +represented_port = Y sctp = Y tcp = Y tx_queue = Y diff --git a/doc/guides/nics/features/cnxk_vf.ini b/doc/guides/nics/features/cnxk_vf.ini index b03e8b35c3..96bfd86ac8 100644 --- a/doc/guides/nics/features/cnxk_vf.ini +++ b/doc/guides/nics/features/cnxk_vf.ini @@ -63,6 +63,7 @@ mark = Y mpls = Y nvgre= Y raw = Y +represented_port = Y sctp = Y tcp = Y tx_queue = Y diff --git a/drivers/common/cnxk/roc_npc.c b/drivers/common/cnxk/roc_npc.c index 1958b3089d..3712f1920c 100644 --- a/drivers/common/cnxk/roc_npc.c +++ b/drivers/common/cnxk/roc_npc.c @@ -522,6 +522,8 @@ npc_parse_actions(struct roc_npc *roc_npc, const struct roc_npc_attr *attr, flow->ctr_id = NPC_COUNTER_NONE; flow->mtr_id = ROC_NIX_MTR_ID_INVALID; pf_func = npc->pf_func; + if (flow->has_rep) + pf_func = flow->rep_pf_func; for (; actions->type != ROC_NPC_ACTION_TYPE_END; actions++) { switch (actions->type) { @@ -817,10 +819,14 @@ npc_parse_pattern(struct npc *npc, const struct roc_npc_item_info pattern[], struct roc_npc_flow *flow, struct npc_parse_state *pst) { npc_parse_stage_func_t parse_stage_funcs[] = { - npc_parse_meta_items, npc_parse_mark_item, npc_parse_pre_l2, npc_parse_cpt_hdr, - npc_parse_higig2_hdr, npc_parse_tx_queue, npc_parse_la, npc_parse_lb, - npc_parse_lc, npc_parse_ld,npc_parse_le, npc_parse_lf, - npc_parse_lg, npc_parse_lh, + npc_parse_meta_items, npc_parse_port_representor_id, + npc_parse_mark_item, npc_parse_pre_l2, + npc_parse_cpt_hdr,npc_parse_higig2_hdr, + npc_parse_tx_queue, npc_parse_la, + npc_parse_lb, npc_parse_lc, + npc_parse_ld, npc_parse_le, + npc_parse_lf, npc_parse_lg, + npc_parse_lh, }; uint8_t layer = 0; int key_offset; @@ -1059,15 +1065,20 @@ npc_rss_action_program(struct roc_npc *roc_npc, struct roc_npc_flow *flow) { const struct roc_npc_action_rss *rss; + struct roc_npc *npc = roc_npc; uint32_t rss_grp; uint8_t alg_idx; int rc; + if (flow->has_rep) { + npc = roc_npc->rep_npc; + npc->flowkey_cfg_state = roc_npc->flowkey_cfg_state; + } + for (; actions->type != ROC_NPC_ACTION_TYPE_END; actions++) { if (actions->type == ROC_NPC_ACTION_TYPE_RSS) { rss = (const struct roc_npc_action_rss *)actions->conf; - rc = npc_rss_action_configure(roc_npc, rss, &alg_idx, - &rss_grp, flow->mcam_id); + rc = npc_rss_action_configure(npc, rss, &alg_idx, &rss_grp, flow->mcam_id); if (rc) return rc; @@ -1090,7 +1101,7 @@ npc_vtag_cfg_delete(struct roc_npc *roc_npc, struct roc_npc_flow *flow) struct roc_nix *roc_nix = roc_npc->roc_nix; struct nix_vtag_config *vtag_cfg; struct nix_vtag_config_rsp *rsp; - struct mbox *mbox; + struct mbox *mbox, *ombox; struct nix *nix; int rc = 0; @@ -1100,7 +,10 @@ npc_vtag_cfg_delete(struct roc_npc *roc_npc, struct roc_npc_flow *flow) } tx_vtag_action; nix = roc_nix_to_nix_priv(roc_nix); - mbox = mbox_get((&nix->dev)->mbox); + ombox = (&nix->dev)->mbox; + if (flow->has_rep) + ombox = flow->rep_mbox; + mbox = mbox_get(ombox); tx_vtag_action.reg = flow->vtag_action; vtag_cfg = mbox_alloc_msg_nix_vtag_cfg(mbox); @@ -1351,6 +1365,8 @@ npc_vtag_action_program(struct roc
[dpdk-dev] [PATCH 1/2] common/cnxk: support SPI to SA translation action
From: Kiran Kumar K Support SPI to SA index translation action with SPI bits MS_28_25. Signed-off-by: Kiran Kumar K Reviewed-by: Satheesh Paul Reviewed-by: Nithin Dabilpuram --- drivers/common/cnxk/roc_npc.c | 4 drivers/common/cnxk/roc_npc.h | 1 + 2 files changed, 5 insertions(+) diff --git a/drivers/common/cnxk/roc_npc.c b/drivers/common/cnxk/roc_npc.c index 47536c8ce8..7228cffb57 100644 --- a/drivers/common/cnxk/roc_npc.c +++ b/drivers/common/cnxk/roc_npc.c @@ -438,6 +438,10 @@ npc_parse_spi_to_sa_action(struct roc_npc *roc_npc, const struct roc_npc_action vtag_act.act.vtag1_lid = ROC_NPC_SEC_ACTION_ALG2; break; case ROC_NPC_SEC_ACTION_ALG3: + vtag_act.act.vtag1_valid = false; + vtag_act.act.vtag1_lid = ROC_NPC_SEC_ACTION_ALG3; + break; + case ROC_NPC_SEC_ACTION_ALG4: vtag_act.act.vtag1_valid = false; vtag_act.act.vtag1_lid = 0; mbox = inl_dev->dev.mbox; diff --git a/drivers/common/cnxk/roc_npc.h b/drivers/common/cnxk/roc_npc.h index 61d0628f5f..26a43c12cb 100644 --- a/drivers/common/cnxk/roc_npc.h +++ b/drivers/common/cnxk/roc_npc.h @@ -235,6 +235,7 @@ enum roc_npc_sec_action_alg { ROC_NPC_SEC_ACTION_ALG1, ROC_NPC_SEC_ACTION_ALG2, ROC_NPC_SEC_ACTION_ALG3, + ROC_NPC_SEC_ACTION_ALG4, }; struct roc_npc_sec_action { -- 2.39.2
[dpdk-dev] [PATCH 2/2] common/cnxk: fix SPI to SA index destroy
From: Satheesh Paul While destroying SPI to SA index rule, inline device mbox should be used. Adding changes to fix this. Fixes: 04087b781484 ("common/cnxk: support SPI to SA index") Signed-off-by: Kiran Kumar K Signed-off-by: Satheesh Paul --- drivers/common/cnxk/roc_npc.c | 14 ++ drivers/common/cnxk/roc_npc_mcam.c | 8 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/drivers/common/cnxk/roc_npc.c b/drivers/common/cnxk/roc_npc.c index 7228cffb57..ba75207955 100644 --- a/drivers/common/cnxk/roc_npc.c +++ b/drivers/common/cnxk/roc_npc.c @@ -1503,16 +1503,22 @@ npc_rss_group_free(struct npc *npc, struct roc_npc_flow *flow) static int roc_npc_delete_spi_to_sa_action(struct roc_npc *roc_npc, struct roc_npc_flow *flow) { - struct roc_nix *roc_nix = roc_npc->roc_nix; struct nix_spi_to_sa_delete_req *req; + struct nix_inl_dev *inl_dev; + struct idev_cfg *idev; struct mbox *mbox; - struct nix *nix; + + PLT_SET_USED(roc_npc); if (!flow->spi_to_sa_info.has_action || flow->spi_to_sa_info.duplicate) return 0; - nix = roc_nix_to_nix_priv(roc_nix); - mbox = (&nix->dev)->mbox; + idev = idev_get_cfg(); + if (!idev) + return -1; + + inl_dev = idev->nix_inl_dev; + mbox = inl_dev->dev.mbox; req = mbox_alloc_msg_nix_spi_to_sa_delete(mbox); if (req == NULL) return -ENOSPC; diff --git a/drivers/common/cnxk/roc_npc_mcam.c b/drivers/common/cnxk/roc_npc_mcam.c index 948c446312..72892be300 100644 --- a/drivers/common/cnxk/roc_npc_mcam.c +++ b/drivers/common/cnxk/roc_npc_mcam.c @@ -96,10 +96,10 @@ int npc_mcam_free_all_entries(struct npc *npc) { struct npc_mcam_free_entry_req *req; - struct mbox *mbox = npc->mbox; + struct mbox *mbox = mbox_get(npc->mbox); int rc = -ENOSPC; - req = mbox_alloc_msg_npc_mcam_free_entry(mbox_get(mbox)); + req = mbox_alloc_msg_npc_mcam_free_entry(mbox); if (req == NULL) goto exit; req->all = 1; @@ -354,10 +354,10 @@ npc_mcam_alloc_entry(struct npc *npc, struct roc_npc_flow *mcam, { struct npc_mcam_alloc_entry_req *req; struct npc_mcam_alloc_entry_rsp *rsp; - struct mbox *mbox = npc->mbox; + struct mbox *mbox = mbox_get(npc->mbox); int rc = -ENOSPC; - req = mbox_alloc_msg_npc_mcam_alloc_entry(mbox_get(mbox)); + req = mbox_alloc_msg_npc_mcam_alloc_entry(mbox); if (req == NULL) goto exit; req->contig = 1; -- 2.39.2
[dpdk-dev] [PATCH] net/cnxk: add spec for SPI to SA action for cnxk
From: Kiran Kumar K Adding spec for MS_28_25 Flow action for cnxk device. Signed-off-by: Kiran Kumar K Reviewed-by: Nithin Kumar Dabilpuram --- drivers/net/cnxk/rte_pmd_cnxk.h | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/net/cnxk/rte_pmd_cnxk.h b/drivers/net/cnxk/rte_pmd_cnxk.h index 8770425dfb..d7eadd582d 100644 --- a/drivers/net/cnxk/rte_pmd_cnxk.h +++ b/drivers/net/cnxk/rte_pmd_cnxk.h @@ -34,12 +34,17 @@ enum rte_pmd_cnxk_sec_action_alg { * SA_alg = { 7'b0, SA_mcam[24:0] + SPI[27:25]} */ RTE_PMD_CNXK_SEC_ACTION_ALG2, + /** SPI<28:25> segment the sequence number space. +* Initial SA_index is from SA_XOR if enabled. +* SA_alg = { 7'b0, SA_mcam[24:0] + SPI[28:25]} +*/ + RTE_PMD_CNXK_SEC_ACTION_ALG3, /** The inbound SPI maybe "random", therefore we want the MCAM to be * capable of remapping the SPI to an arbitrary SA_index. * SPI to SA is done using a lookup in NIX/NPC cam entry with key as * SPI, MATCH_ID, LFID. */ - RTE_PMD_CNXK_SEC_ACTION_ALG3, + RTE_PMD_CNXK_SEC_ACTION_ALG4, }; struct rte_pmd_cnxk_sec_action { -- 2.39.2
[dpdk-dev] [PATCH] net/cnxk: support port ID flow action item
From: Satheesh Paul Currently PORT_ID action can redirect traffic only between VFs of a PF. This patch extends PORT_ID action to redirect traffic from one PF port to another PF port also. Signed-off-by: Satheesh Paul Reviewed-by: Kiran Kumar K --- drivers/common/cnxk/roc_npc.c | 29 ++ drivers/common/cnxk/roc_npc.h | 62 +++--- drivers/common/cnxk/roc_npc_priv.h | 1 + drivers/net/cnxk/cnxk_flow.c | 51 +--- 4 files changed, 55 insertions(+), 88 deletions(-) diff --git a/drivers/common/cnxk/roc_npc.c b/drivers/common/cnxk/roc_npc.c index d88c4d3bd6..848086c8de 100644 --- a/drivers/common/cnxk/roc_npc.c +++ b/drivers/common/cnxk/roc_npc.c @@ -472,10 +472,9 @@ npc_parse_spi_to_sa_action(struct roc_npc *roc_npc, const struct roc_npc_action static int npc_parse_actions(struct roc_npc *roc_npc, const struct roc_npc_attr *attr, - const struct roc_npc_action actions[], - struct roc_npc_flow *flow) + const struct roc_npc_action actions[], struct roc_npc_flow *flow, + uint16_t dst_pf_func) { - const struct roc_npc_action_port_id *act_portid; struct npc *npc = roc_npc_to_npc_priv(roc_npc); const struct roc_npc_action *sec_action = NULL; const struct roc_npc_action_mark *act_mark; @@ -545,10 +544,7 @@ npc_parse_actions(struct roc_npc *roc_npc, const struct roc_npc_attr *attr, break; case ROC_NPC_ACTION_TYPE_PORT_ID: - act_portid = (const struct roc_npc_action_port_id *) -actions->conf; - pf_func &= (0xfc00); - pf_func = (pf_func | (act_portid->id + 1)); + pf_func = dst_pf_func; req_act |= ROC_NPC_ACTION_TYPE_VF; break; @@ -859,9 +855,8 @@ npc_parse_attr(struct npc *npc, const struct roc_npc_attr *attr, static int npc_parse_rule(struct roc_npc *roc_npc, const struct roc_npc_attr *attr, - const struct roc_npc_item_info pattern[], - const struct roc_npc_action actions[], struct roc_npc_flow *flow, - struct npc_parse_state *pst) + const struct roc_npc_item_info pattern[], const struct roc_npc_action actions[], + struct roc_npc_flow *flow, struct npc_parse_state *pst) { struct npc *npc = roc_npc_to_npc_priv(roc_npc); struct roc_nix *roc_nix = roc_npc->roc_nix; @@ -881,7 +876,7 @@ npc_parse_rule(struct roc_npc *roc_npc, const struct roc_npc_attr *attr, return err; /* Check action */ - err = npc_parse_actions(roc_npc, attr, actions, flow); + err = npc_parse_actions(roc_npc, attr, actions, flow, pst->dst_pf_func); if (err) return err; return 0; @@ -897,8 +892,7 @@ roc_npc_flow_parse(struct roc_npc *roc_npc, const struct roc_npc_attr *attr, struct npc_parse_state parse_state = {0}; int rc; - rc = npc_parse_rule(roc_npc, attr, pattern, actions, flow, - &parse_state); + rc = npc_parse_rule(roc_npc, attr, pattern, actions, flow, &parse_state); if (rc) return rc; @@ -1420,8 +1414,8 @@ roc_npc_sdp_channel_get(struct roc_npc *roc_npc, uint16_t *chan_base, uint16_t * struct roc_npc_flow * roc_npc_flow_create(struct roc_npc *roc_npc, const struct roc_npc_attr *attr, - const struct roc_npc_item_info pattern[], - const struct roc_npc_action actions[], int *errcode) + const struct roc_npc_item_info pattern[], const struct roc_npc_action actions[], + uint16_t dst_pf_func, int *errcode) { struct npc *npc = roc_npc_to_npc_priv(roc_npc); uint16_t sdp_chan_base = 0, sdp_chan_mask = 0; @@ -1451,8 +1445,9 @@ roc_npc_flow_create(struct roc_npc *roc_npc, const struct roc_npc_attr *attr, memset(flow, 0, sizeof(*flow)); memset(&parse_state, 0, sizeof(parse_state)); - rc = npc_parse_rule(roc_npc, attr, pattern, actions, flow, - &parse_state); + parse_state.dst_pf_func = dst_pf_func; + + rc = npc_parse_rule(roc_npc, attr, pattern, actions, flow, &parse_state); if (rc != 0) { *errcode = rc; goto err_exit; diff --git a/drivers/common/cnxk/roc_npc.h b/drivers/common/cnxk/roc_npc.h index 5984da1c1a..07e6634aa7 100644 --- a/drivers/common/cnxk/roc_npc.h +++ b/drivers/common/cnxk/roc_npc.h @@ -358,41 +358,29 @@ int __roc_api roc_npc_init(struct roc_npc *roc_npc); int __roc_api roc_npc_fini(struct roc_npc *roc_npc); const char *__roc_api roc_npc_profile_name_get(struct roc_npc *roc_npc); -struct roc_npc_flow *__roc_api -roc_npc_flow_create(struct roc_npc *roc_npc, const struct roc_npc_attr *attr, - cons
[dpdk-dev] [PATCH v2] net/cnxk: support port ID flow action item
From: Satheesh Paul Currently PORT_ID action can redirect traffic only between VFs of a PF. This patch extends PORT_ID action to redirect traffic from one PF port to another PF port also. Signed-off-by: Satheesh Paul Reviewed-by: Kiran Kumar K --- v2: * Updated release notes. doc/guides/rel_notes/release_23_07.rst | 5 +++ drivers/common/cnxk/roc_npc.c | 29 +--- drivers/common/cnxk/roc_npc.h | 62 ++ drivers/common/cnxk/roc_npc_priv.h | 1 + drivers/net/cnxk/cnxk_flow.c | 51 - 5 files changed, 60 insertions(+), 88 deletions(-) diff --git a/doc/guides/rel_notes/release_23_07.rst b/doc/guides/rel_notes/release_23_07.rst index a86e9c4951..32eab60c0d 100644 --- a/doc/guides/rel_notes/release_23_07.rst +++ b/doc/guides/rel_notes/release_23_07.rst @@ -67,6 +67,11 @@ New Features for new capability registers, large passthrough BAR and some performance enhancements for UPT. +* **Extended port ID flow action item in CNXK.** + + ``RTE_FLOW_ACTION_TYPE_PORT_ID`` action used to redirect traffic to VFs only. + This has been extended to redirect traffic from one PF port to another PF + port also. Removed Items - diff --git a/drivers/common/cnxk/roc_npc.c b/drivers/common/cnxk/roc_npc.c index d88c4d3bd6..848086c8de 100644 --- a/drivers/common/cnxk/roc_npc.c +++ b/drivers/common/cnxk/roc_npc.c @@ -472,10 +472,9 @@ npc_parse_spi_to_sa_action(struct roc_npc *roc_npc, const struct roc_npc_action static int npc_parse_actions(struct roc_npc *roc_npc, const struct roc_npc_attr *attr, - const struct roc_npc_action actions[], - struct roc_npc_flow *flow) + const struct roc_npc_action actions[], struct roc_npc_flow *flow, + uint16_t dst_pf_func) { - const struct roc_npc_action_port_id *act_portid; struct npc *npc = roc_npc_to_npc_priv(roc_npc); const struct roc_npc_action *sec_action = NULL; const struct roc_npc_action_mark *act_mark; @@ -545,10 +544,7 @@ npc_parse_actions(struct roc_npc *roc_npc, const struct roc_npc_attr *attr, break; case ROC_NPC_ACTION_TYPE_PORT_ID: - act_portid = (const struct roc_npc_action_port_id *) -actions->conf; - pf_func &= (0xfc00); - pf_func = (pf_func | (act_portid->id + 1)); + pf_func = dst_pf_func; req_act |= ROC_NPC_ACTION_TYPE_VF; break; @@ -859,9 +855,8 @@ npc_parse_attr(struct npc *npc, const struct roc_npc_attr *attr, static int npc_parse_rule(struct roc_npc *roc_npc, const struct roc_npc_attr *attr, - const struct roc_npc_item_info pattern[], - const struct roc_npc_action actions[], struct roc_npc_flow *flow, - struct npc_parse_state *pst) + const struct roc_npc_item_info pattern[], const struct roc_npc_action actions[], + struct roc_npc_flow *flow, struct npc_parse_state *pst) { struct npc *npc = roc_npc_to_npc_priv(roc_npc); struct roc_nix *roc_nix = roc_npc->roc_nix; @@ -881,7 +876,7 @@ npc_parse_rule(struct roc_npc *roc_npc, const struct roc_npc_attr *attr, return err; /* Check action */ - err = npc_parse_actions(roc_npc, attr, actions, flow); + err = npc_parse_actions(roc_npc, attr, actions, flow, pst->dst_pf_func); if (err) return err; return 0; @@ -897,8 +892,7 @@ roc_npc_flow_parse(struct roc_npc *roc_npc, const struct roc_npc_attr *attr, struct npc_parse_state parse_state = {0}; int rc; - rc = npc_parse_rule(roc_npc, attr, pattern, actions, flow, - &parse_state); + rc = npc_parse_rule(roc_npc, attr, pattern, actions, flow, &parse_state); if (rc) return rc; @@ -1420,8 +1414,8 @@ roc_npc_sdp_channel_get(struct roc_npc *roc_npc, uint16_t *chan_base, uint16_t * struct roc_npc_flow * roc_npc_flow_create(struct roc_npc *roc_npc, const struct roc_npc_attr *attr, - const struct roc_npc_item_info pattern[], - const struct roc_npc_action actions[], int *errcode) + const struct roc_npc_item_info pattern[], const struct roc_npc_action actions[], + uint16_t dst_pf_func, int *errcode) { struct npc *npc = roc_npc_to_npc_priv(roc_npc); uint16_t sdp_chan_base = 0, sdp_chan_mask = 0; @@ -1451,8 +1445,9 @@ roc_npc_flow_create(struct roc_npc *roc_npc, const struct roc_npc_attr *attr, memset(flow, 0, sizeof(*flow)); memset(&parse_state, 0, sizeof(parse_state)); - rc = npc_parse_rule(roc_npc, attr, pattern, actions, flow, - &parse_state); + parse_state.dst_pf_func = dst_pf_fu
[dpdk-dev] [PATCH v3] net/cnxk: support port ID flow action item
From: Satheesh Paul Currently PORT_ID action can redirect traffic only between VFs of a PF. This patch extends PORT_ID action to redirect traffic from one PF port to another PF port also. Signed-off-by: Satheesh Paul Reviewed-by: Kiran Kumar K --- v2: * Updated release notes. v3: * Rebased and resolved conflicts. doc/guides/rel_notes/release_23_07.rst | 5 +++ drivers/common/cnxk/roc_npc.c | 29 +--- drivers/common/cnxk/roc_npc.h | 62 ++ drivers/common/cnxk/roc_npc_priv.h | 1 + drivers/net/cnxk/cnxk_flow.c | 51 - 5 files changed, 60 insertions(+), 88 deletions(-) diff --git a/doc/guides/rel_notes/release_23_07.rst b/doc/guides/rel_notes/release_23_07.rst index 027ae7bd2d..179092dc42 100644 --- a/doc/guides/rel_notes/release_23_07.rst +++ b/doc/guides/rel_notes/release_23_07.rst @@ -170,6 +170,11 @@ New Features See :doc:`../prog_guide/pdcp_lib` for more information. +* **Extended port ID flow action item in CNXK.** + + ``RTE_FLOW_ACTION_TYPE_PORT_ID`` action used to redirect traffic to VFs only. + This has been extended to redirect traffic from one PF port to another PF + port also. Removed Items - diff --git a/drivers/common/cnxk/roc_npc.c b/drivers/common/cnxk/roc_npc.c index d88c4d3bd6..848086c8de 100644 --- a/drivers/common/cnxk/roc_npc.c +++ b/drivers/common/cnxk/roc_npc.c @@ -472,10 +472,9 @@ npc_parse_spi_to_sa_action(struct roc_npc *roc_npc, const struct roc_npc_action static int npc_parse_actions(struct roc_npc *roc_npc, const struct roc_npc_attr *attr, - const struct roc_npc_action actions[], - struct roc_npc_flow *flow) + const struct roc_npc_action actions[], struct roc_npc_flow *flow, + uint16_t dst_pf_func) { - const struct roc_npc_action_port_id *act_portid; struct npc *npc = roc_npc_to_npc_priv(roc_npc); const struct roc_npc_action *sec_action = NULL; const struct roc_npc_action_mark *act_mark; @@ -545,10 +544,7 @@ npc_parse_actions(struct roc_npc *roc_npc, const struct roc_npc_attr *attr, break; case ROC_NPC_ACTION_TYPE_PORT_ID: - act_portid = (const struct roc_npc_action_port_id *) -actions->conf; - pf_func &= (0xfc00); - pf_func = (pf_func | (act_portid->id + 1)); + pf_func = dst_pf_func; req_act |= ROC_NPC_ACTION_TYPE_VF; break; @@ -859,9 +855,8 @@ npc_parse_attr(struct npc *npc, const struct roc_npc_attr *attr, static int npc_parse_rule(struct roc_npc *roc_npc, const struct roc_npc_attr *attr, - const struct roc_npc_item_info pattern[], - const struct roc_npc_action actions[], struct roc_npc_flow *flow, - struct npc_parse_state *pst) + const struct roc_npc_item_info pattern[], const struct roc_npc_action actions[], + struct roc_npc_flow *flow, struct npc_parse_state *pst) { struct npc *npc = roc_npc_to_npc_priv(roc_npc); struct roc_nix *roc_nix = roc_npc->roc_nix; @@ -881,7 +876,7 @@ npc_parse_rule(struct roc_npc *roc_npc, const struct roc_npc_attr *attr, return err; /* Check action */ - err = npc_parse_actions(roc_npc, attr, actions, flow); + err = npc_parse_actions(roc_npc, attr, actions, flow, pst->dst_pf_func); if (err) return err; return 0; @@ -897,8 +892,7 @@ roc_npc_flow_parse(struct roc_npc *roc_npc, const struct roc_npc_attr *attr, struct npc_parse_state parse_state = {0}; int rc; - rc = npc_parse_rule(roc_npc, attr, pattern, actions, flow, - &parse_state); + rc = npc_parse_rule(roc_npc, attr, pattern, actions, flow, &parse_state); if (rc) return rc; @@ -1420,8 +1414,8 @@ roc_npc_sdp_channel_get(struct roc_npc *roc_npc, uint16_t *chan_base, uint16_t * struct roc_npc_flow * roc_npc_flow_create(struct roc_npc *roc_npc, const struct roc_npc_attr *attr, - const struct roc_npc_item_info pattern[], - const struct roc_npc_action actions[], int *errcode) + const struct roc_npc_item_info pattern[], const struct roc_npc_action actions[], + uint16_t dst_pf_func, int *errcode) { struct npc *npc = roc_npc_to_npc_priv(roc_npc); uint16_t sdp_chan_base = 0, sdp_chan_mask = 0; @@ -1451,8 +1445,9 @@ roc_npc_flow_create(struct roc_npc *roc_npc, const struct roc_npc_attr *attr, memset(flow, 0, sizeof(*flow)); memset(&parse_state, 0, sizeof(parse_state)); - rc = npc_parse_rule(roc_npc, attr, pattern, actions, flow, - &parse_state); + parse_state.dst_pf_func = dst_pf_fu