net/cnxk: fix port ID default action
PATCH 1/1 net/cnxk: fix port ID default action
From: Satheesh Paul <[email protected]>
The default action for port_id is set incorrectly. Fixing this by introducing a new kernel mbox to read the action set for the port's default rule and using the same action for the rule being created.
Fixes 15f0b8a5b9e1 ("common/cnxk: support port ID action")
Signed-off-by Satheesh Paul <[email protected]>
Reviewed-by Kiran Kumar K <[email protected]>
--- drivers/common/cnxk/roc_mbox.h | 2 + drivers/common/cnxk/roc_npc.c | 52 ++++++++++++++----- drivers/common/cnxk/roc_npc.h | 4 +- drivers/common/cnxk/roc_npc_priv.h | 1 + .../common/cnxk/roc_platform_base_symbols.c | 1 + drivers/net/cnxk/cnxk_flow.c | 36 ++++++++----- 6 files changed, 69 insertions(+), 27 deletions(-)
drivers/common/cnxk/roc_mbox.h +2 -0
@@ -268,6 +268,8 @@ struct mbox_msghdr {M (NPC_CN20K_MCAM_READ_BASE_RULE ,0x601c , \ npc_cn20k_read_base_steer_rule, msg_req, \ npc_cn20k_mcam_read_base_rule_rsp) \ +M (NPC_MCAM_READ_DEFAULT_RULE ,0x6023 , npc_read_default_rule, \ + msg_req, npc_mcam_read_base_rule_rsp) \ /* NIX mbox IDs (range 0x8000 - 0xFFFF) */ \M (NIX_LF_ALLOC ,0x8000 , nix_lf_alloc, nix_lf_alloc_req, \ nix_lf_alloc_rsp) \
drivers/common/cnxk/roc_npc.c +40 -12
100 lines not on this page · raw message
drivers/common/cnxk/roc_npc.h +3 -1
@@ -449,7 +449,8 @@ struct roc_npc_flow *__roc_api 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[], - uint16_t dst_pf_func, int *errcode); + uint16_t dst_pf_funct, + uint64_t npc_default_action, 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);
@@ -486,6 +487,7 @@ int __roc_api roc_npc_vtag_actions_get(struct roc_npc *roc_npc); 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_mcam_default_rule_action_get(struct roc_npc *roc_npc, uint64_t *action); 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 *flow, int mcam_id);
drivers/common/cnxk/roc_npc_priv.h +1 -0
@@ -219,6 +219,7 @@ struct npc_parse_state {uint8_t *mcam_mask;/* point to flow->mcam_mask + key_len */ bool is_vf;uint16_t dst_pf_func; +uint64_t npc_default_action;uint16_t nb_tx_queues; };
drivers/common/cnxk/roc_platform_base_symbols.c +1 -0
@@ -450,6 +450,7 @@ RTE_EXPORT_INTERNAL_SYMBOL(roc_npc_inl_mcam_clear_counter) RTE_EXPORT_INTERNAL_SYMBOL(roc_npc_mcam_alloc_counter) RTE_EXPORT_INTERNAL_SYMBOL(roc_npc_get_free_mcam_entry) RTE_EXPORT_INTERNAL_SYMBOL(roc_npc_mcam_read_counter) +RTE_EXPORT_INTERNAL_SYMBOL(roc_npc_mcam_default_rule_action_get) RTE_EXPORT_INTERNAL_SYMBOL(roc_npc_mcam_get_stats) RTE_EXPORT_INTERNAL_SYMBOL(roc_npc_mcam_clear_counter) RTE_EXPORT_INTERNAL_SYMBOL(roc_npc_mcam_free_entry)
drivers/net/cnxk/cnxk_flow.c +22 -14
@@ -464,8 +464,8 @@ 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[], struct roc_npc_action_sample *in_sample_actions, uint32_t *flowkey_cfg, - uint16_t *dst_pf_func, uint8_t has_tunnel_pattern, bool is_rep, - uint8_t rep_pattern, uint64_t *free_allocs) + uint16_t *dst_pf_func, uint64_t *npc_default_action, uint8_t has_tunnel_pattern, + bool is_rep, uint8_t rep_pattern, uint64_t *free_allocs) { struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);const struct rte_flow_action_queue *act_q =NULL ;
@@ -531,9 +531,10 @@ cnxk_map_actions(struct rte_eth_dev *eth_dev, const struct rte_flow_attr *attr, eth_dev->data->port_id, if_name, act_ethdev->port_id);if (cnxk_ethdev_is_representor (if_name)) {if (representor_rep_portid_action (in_actions, eth_dev, - portid_eth_dev, actions->type, rep_pattern, - dst_pf_func, is_rep, has_tunnel_pattern, - free_allocs, &i, flowkey_cfg)) { + portid_eth_dev, actions->type, + rep_pattern, dst_pf_func, + is_rep, has_tunnel_pattern, + free_allocs, &i, flowkey_cfg)) {plt_err ("Representor port action set failed" ); goto err_exit; }
@@ -583,6 +584,8 @@ cnxk_map_actions(struct rte_eth_dev *eth_dev, const struct rte_flow_attr *attr, } hw_dst = portid_eth_dev->data->dev_private; +roc_npc_mcam_default_rule_action_get (&hw_dst->npc, + npc_default_action); roc_npc_dst = &hw_dst->npc; *dst_pf_func = roc_npc_dst->pf_func; }
@@ -800,7 +803,7 @@ cnxk_map_flow_data(struct rte_eth_dev *eth_dev, const struct rte_flow_attr *attr struct roc_npc_attr *in_attr, struct roc_npc_item_info in_pattern[], struct roc_npc_action in_actions[], struct roc_npc_action_sample *in_sample_actions, uint32_t *flowkey_cfg, - uint16_t *dst_pf_func, bool is_rep, uint64_t *free_allocs) + uint16_t *dst_pf_func, uint64_t *def_action, bool is_rep, uint64_t *free_allocs) { uint8_t has_tunnel_pattern = 0, rep_pattern = 0;int rc;
@@ -838,7 +841,8 @@ cnxk_map_flow_data(struct rte_eth_dev *eth_dev, const struct rte_flow_attr *attr }return cnxk_map_actions (eth_dev, attr, actions, in_actions, in_sample_actions, flowkey_cfg, - dst_pf_func, has_tunnel_pattern, is_rep, rep_pattern, free_allocs); + dst_pf_func, def_action, has_tunnel_pattern, is_rep, rep_pattern, + free_allocs); }int
@@ -850,14 +854,15 @@ cnxk_flow_validate_common(struct rte_eth_dev *eth_dev, const struct rte_flow_attstruct roc_npc_item_info in_pattern[ROC_NPC_ITEM_TYPE_END +1 ];struct roc_npc_action in_actions[ROC_NPC_MAX_ACTION_COUNT ];struct roc_npc_action_sample in_sample_action; +uint64_t npc_default_action =0 ;struct cnxk_rep_dev *rep_dev;struct roc_npc_attr in_attr;uint64_t *free_allocs, sz;struct cnxk_eth_dev *dev;struct roc_npc_flow flow; -uint32_t flowkey_cfg =0 ;uint16_t dst_pf_func =0 ; -struct roc_npc *npc; +uint32_t flowkey_cfg =0 ; +struct roc_npc *npc =0 ;int rc, j;/* is_rep set for operation performed via representor ports */
@@ -885,7 +890,8 @@ cnxk_flow_validate_common(struct rte_eth_dev *eth_dev, const struct rte_flow_attreturn -ENOMEM ; } rc =cnxk_map_flow_data (eth_dev, attr, pattern, actions, &in_attr, in_pattern, in_actions, - &in_sample_action, &flowkey_cfg, &dst_pf_func, is_rep, free_allocs); + &in_sample_action, &flowkey_cfg, &dst_pf_func, &npc_default_action, + is_rep, free_allocs);if (rc) {rte_flow_error_set (error,0 ,RTE_FLOW_ERROR_TYPE_ACTION_NUM ,NULL ,"Failed to map flow data" );
@@ -928,10 +934,11 @@ cnxk_flow_create_common(struct rte_eth_dev *eth_dev, const struct rte_flow_attrstruct cnxk_rep_dev *rep_dev =NULL ;struct roc_npc_flow *flow =NULL ;struct cnxk_eth_dev *dev =NULL ; +uint64_t npc_default_action =0 ;struct roc_npc_attr in_attr; +struct roc_npc *npc =NULL ;uint64_t *free_allocs, sz;uint16_t dst_pf_func =0 ; -struct roc_npc *npc;int errcode =0 ;int rc, j;
@@ -954,15 +961,16 @@ cnxk_flow_create_common(struct rte_eth_dev *eth_dev, const struct rte_flow_attrmemset (&in_sample_action,0 ,sizeof (in_sample_action));memset (&in_attr,0 ,sizeof (struct roc_npc_attr )); rc =cnxk_map_flow_data (eth_dev, attr, pattern, actions, &in_attr, in_pattern, in_actions, - &in_sample_action, &npc->flowkey_cfg_state, &dst_pf_func, is_rep, - free_allocs); + &in_sample_action, &npc->flowkey_cfg_state, &dst_pf_func, + &npc_default_action, is_rep, free_allocs);if (rc) {rte_flow_error_set (error, rc,RTE_FLOW_ERROR_TYPE_ACTION_NUM ,NULL ,"Failed to map flow data" ); goto clean; } - flow =roc_npc_flow_create (npc, &in_attr, in_pattern, in_actions, dst_pf_func, &errcode); + flow =roc_npc_flow_create (npc, &in_attr, in_pattern, in_actions, dst_pf_func, + npc_default_action, &errcode);if (errcode !=0 ) {rte_flow_error_set (error, errcode, errcode,NULL ,roc_error_msg_get (errcode)); goto clean;
Signature · 1 line
2.51.0
Jerin Jacob
AppliedQuoted 8 lines · On Thu, Oct 30, 2025 at 9:31 AM <[email protected]> wrote:
From: Satheesh Paul <[email protected]>
The default action for
port_idis set incorrectly. Fixing this by introducing a new kernel mbox to read the action set for the port's default rule and using the same action for the rule being created.
Quoted 5 lines
Fixes 15f0b8a5b9e1 ("common/cnxk: support port ID action")Signed-off-by Satheesh Paul <[email protected]>Reviewed-by Kiran Kumar K <[email protected]>
Applied to dpdk-next-net-mrvl/for-main. Thanks