Use UCAST_CPT in cn20k as opposed to UCAST_IPSEC in cn10k for inline IPsec rule.
Signed-off-by: Nithin Dabilpuram <ndabilpu...@marvell.com> --- drivers/common/cnxk/hw/nix.h | 1 + drivers/common/cnxk/roc_npc.c | 15 +++++++++++---- drivers/common/cnxk/roc_npc_mcam.c | 7 ++++--- drivers/common/cnxk/roc_npc_mcam_dump.c | 5 +++++ drivers/common/cnxk/roc_npc_priv.h | 8 ++++++++ 5 files changed, 29 insertions(+), 7 deletions(-) diff --git a/drivers/common/cnxk/hw/nix.h b/drivers/common/cnxk/hw/nix.h index e4d8d285d5..d16fa3b3ec 100644 --- a/drivers/common/cnxk/hw/nix.h +++ b/drivers/common/cnxk/hw/nix.h @@ -645,6 +645,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_UCAST_CPT (0x7ull) #define NIX_RX_ACTIONOP_DEFAULT (0xfull) #define NIX_RX_VTAGACTION_VTAG0_RELPTR (0x0ull) diff --git a/drivers/common/cnxk/roc_npc.c b/drivers/common/cnxk/roc_npc.c index 138f12f6d8..94d5cc84f8 100644 --- a/drivers/common/cnxk/roc_npc.c +++ b/drivers/common/cnxk/roc_npc.c @@ -568,6 +568,7 @@ npc_parse_actions(struct roc_npc *roc_npc, const struct roc_npc_attr *attr, struct npc *npc = roc_npc_to_npc_priv(roc_npc); const struct roc_npc_action *sec_action = NULL; const struct roc_npc_action_sample *act_sample; + struct roc_nix *roc_nix = roc_npc->roc_nix; const struct roc_npc_action_mark *act_mark; const struct roc_npc_action_meter *act_mtr; const struct roc_npc_action_queue *act_q; @@ -576,7 +577,6 @@ npc_parse_actions(struct roc_npc *roc_npc, const struct roc_npc_attr *attr, uint8_t has_spi_to_sa_act = 0; int sel_act, req_act = 0; uint16_t pf_func, vf_id; - struct roc_nix *roc_nix; int errcode = 0; int mark = 0; int rq = 0; @@ -885,8 +885,15 @@ npc_parse_actions(struct roc_npc *roc_npc, const struct roc_npc_attr *attr, } else if (req_act & ROC_NPC_ACTION_TYPE_RSS) { flow->npc_action = NIX_RX_ACTIONOP_UCAST; } else if (req_act & ROC_NPC_ACTION_TYPE_SEC) { - flow->npc_action = NIX_RX_ACTIONOP_UCAST_IPSEC; - flow->npc_action |= (uint64_t)rq << 20; + if (roc_model_is_cn20k()) { + flow->npc_action = NIX_RX_ACTIONOP_UCAST_CPT; + flow->npc_action |= (uint64_t)rq << 20; + flow->npc_action2 = + roc_nix_inl_inb_ipsec_profile_id_get(roc_nix, true) << 8; + } else { + 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)) { flow->npc_action = NIX_RX_ACTIONOP_UCAST; } else if (req_act & ROC_NPC_ACTION_TYPE_COUNT) { @@ -1550,7 +1557,7 @@ npc_inline_dev_ipsec_action_free(struct npc *npc, struct roc_npc_flow *flow) inl_dev = idev->nix_inl_dev; if (flow->nix_intf == NIX_INTF_RX && inl_dev && inl_dev->ipsec_index && - ((flow->npc_action & 0xF) == NIX_RX_ACTIONOP_UCAST_IPSEC)) { + roc_npc_action_is_rx_inline(flow->npc_action)) { inl_dev->curr_ipsec_idx--; inl_dev->ipsec_index[inl_dev->curr_ipsec_idx] = flow->mcam_id; flow->enable = 0; diff --git a/drivers/common/cnxk/roc_npc_mcam.c b/drivers/common/cnxk/roc_npc_mcam.c index 5db72c22ae..3aa7ff56a9 100644 --- a/drivers/common/cnxk/roc_npc_mcam.c +++ b/drivers/common/cnxk/roc_npc_mcam.c @@ -747,7 +747,7 @@ npc_mcam_set_channel(struct roc_npc_flow *flow, struct npc_cn20k_mcam_write_entr 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)) { + if (!roc_npc_action_is_rx_inline(flow->npc_action)) { /* * Clear bits 10 & 11 corresponding to CPT * channel. By default, rules should match @@ -951,6 +951,7 @@ npc_mcam_alloc_and_write(struct npc *npc, struct roc_npc_flow *flow, struct npc_ if (flow->nix_intf == NIX_INTF_RX) flow->npc_action |= (uint64_t)flow->recv_queue << 20; req.entry_data.action = flow->npc_action; + req.entry_data.action2 = flow->npc_action2; /* * Driver sets vtag action on per interface basis, not @@ -973,7 +974,7 @@ npc_mcam_alloc_and_write(struct npc *npc, struct roc_npc_flow *flow, struct npc_ if (flow->nix_intf == NIX_INTF_RX) { if (inl_dev && inl_dev->is_multi_channel && - (flow->npc_action & NIX_RX_ACTIONOP_UCAST_IPSEC)) { + roc_npc_action_is_rx_inline(flow->npc_action)) { pf_func = nix_inl_dev_pffunc_get(); req.entry_data.action &= ~(GENMASK(19, 4)); req.entry_data.action |= (uint64_t)pf_func << 4; @@ -1284,7 +1285,7 @@ npc_program_mcam(struct npc *npc, struct npc_parse_state *pst, bool mcam_alloc) if (idev) inl_dev = idev->nix_inl_dev; if (inl_dev && inl_dev->is_multi_channel && - (pst->flow->npc_action & NIX_RX_ACTIONOP_UCAST_IPSEC)) + roc_npc_action_is_rx_inline(pst->flow->npc_action)) skip_base_rule = true; if ((pst->is_vf || pst->flow->is_rep_vf) && pst->flow->nix_intf == NIX_INTF_RX && diff --git a/drivers/common/cnxk/roc_npc_mcam_dump.c b/drivers/common/cnxk/roc_npc_mcam_dump.c index fa2fd0d344..29221a2169 100644 --- a/drivers/common/cnxk/roc_npc_mcam_dump.c +++ b/drivers/common/cnxk/roc_npc_mcam_dump.c @@ -639,6 +639,11 @@ npc_flow_dump_rx_action(FILE *file, uint64_t npc_action) (uint64_t)NIX_RX_ACTIONOP_UCAST_IPSEC); plt_strlcpy(index_name, "RQ Index:", NPC_MAX_FIELD_NAME_SIZE); break; + case NIX_RX_ACTIONOP_UCAST_CPT: + fprintf(file, "NIX_RX_ACTIONOP_UCAST_CPT (%" PRIu64 ")\n", + (uint64_t)NIX_RX_ACTIONOP_UCAST_CPT); + plt_strlcpy(index_name, "RQ Index:", NPC_MAX_FIELD_NAME_SIZE); + break; case NIX_RX_ACTIONOP_MCAST: fprintf(file, "NIX_RX_ACTIONOP_MCAST (%" PRIu64 ")\n", (uint64_t)NIX_RX_ACTIONOP_MCAST); diff --git a/drivers/common/cnxk/roc_npc_priv.h b/drivers/common/cnxk/roc_npc_priv.h index b7d726caa1..56471a6ca9 100644 --- a/drivers/common/cnxk/roc_npc_priv.h +++ b/drivers/common/cnxk/roc_npc_priv.h @@ -466,6 +466,14 @@ roc_npc_to_npc_priv(struct roc_npc *npc) return (struct npc *)npc->reserved; } +static inline bool +roc_npc_action_is_rx_inline(uint64_t npc_action) +{ + uint64_t op = npc_action & 0xFULL; + + return (op == NIX_RX_ACTIONOP_UCAST_IPSEC || op == NIX_RX_ACTIONOP_UCAST_CPT); +} + int npc_mcam_get_stats(struct mbox *mbox, struct roc_npc_flow *flow, uint64_t *count); int npc_mcam_alloc_counter(struct mbox *mbox, uint16_t *ctr); int npc_mcam_free_counter(struct mbox *mbox, uint16_t ctr_id); -- 2.34.1