net/dpaa2: features and fixes for NXP DPAA2 drivers
Subsystems (4)
PATCH v2 38/47 net/dpaa2: support flow meter and policer actions
In reply to Prashant GuptaFrom: Hemant Agrawal <[email protected]>
Add support for the METER and METER_MARK flow actions. A meter flow is programmed per traffic class and configures the DPNI policer from the meter profile and policy that were created through the meter ops.
Meter flows carry a single action and are tracked separately from the regular QoS and flow steering entries, so flow create, destroy and action update dispatch them through a dedicated path.
--- drivers/net/dpaa2/dpaa2_flow.c | 316 +++++++++++++++++++++++++++++++++ 1 file changed, 316 insertions(+)
drivers/net/dpaa2/dpaa2_flow.c +316 -0
@@ -111,6 +111,7 @@ struct dpaa2_dev_flow {struct dpaa2_generic_flow *qos_flow;struct dpaa2_generic_flow *fs_flow;struct dpaa2_dev_priv *priv; +int is_meter_flow; };struct rte_dpaa2_flow_item {
@@ -158,6 +159,10 @@ static const enum rte_flow_action_type dpaa2_supported_qos_action_type[] = { RTE_FLOW_ACTION_TYPE_DROP }; +static const enum rte_flow_action_type dpaa2_supported_meter_action_type[] = { +RTE_FLOW_ACTION_TYPE_METER_MARK , +RTE_FLOW_ACTION_TYPE_METER +};#define DPAA2_FLOW_HDR_HEX_DUMP_SIZE \ (RTE_MAX(sizeof(struct rte_flow_item_eth), \
@@ -3619,6 +3624,10 @@ dpaa2_flow_verify_fs_action(struct dpaa2_dev_priv *priv,/* Skip this action, have to add for vxlan*/ case RTE_FLOW_ACTION_TYPE_DROP :break ; +case RTE_FLOW_ACTION_TYPE_METER_MARK : +break ; +case RTE_FLOW_ACTION_TYPE_METER : +break ;case RTE_FLOW_ACTION_TYPE_END : end_of_list =1 ;break ;
@@ -4062,7 +4071,146 @@ dpaa2_flow_table_update(struct dpaa2_dev_priv *priv,return 0 ; } +static int +dpaa2_flow_action_meter_mark_init (struct dpaa2_dev_priv *priv, +uint32_t mtr_id,struct rte_flow_action_meter_mark *meter_mark) +{ +struct dpaa2_dev_meter *meter; +struct dpaa2_dev_meter_profile *profile; +struct dpaa2_dev_meter_policy *policy; +int found =0 ; + + meter =LIST_FIRST (&priv->meters); +while (meter) { +if (meter->meter_id == mtr_id) { + found =1 ; +break ; + } + meter =LIST_NEXT (meter, next); + } + +if (!found) { +DPAA2_PMD_ERR ("Meter ID(%d) is not found!" , mtr_id); +return -ENXIO ; + } + + found =0 ; + profile =LIST_FIRST (&priv->profiles); +while (profile) { +if (profile->profile_id == meter->profile_id) { + found =1 ; +break ; + } + profile =LIST_NEXT (profile, next); + } +if (!found) { +DPAA2_PMD_ERR ("Meter ID(%d)'s profile(%d) not exist!" , + mtr_id, meter->profile_id); +return -ENXIO ; + } + + found =0 ; + policy =LIST_FIRST (&priv->policies); +while (policy) { +if (policy->policy_id == meter->policy_id) { + found =1 ; +break ; + } + policy =LIST_NEXT (policy, next); + } +if (!found) { +/** Option.*/ +DPAA2_PMD_WARN ("Meter ID(%d)'s policy(%d) not exist!" , + mtr_id, meter->policy_id); + policy =NULL ; + } + meter_mark->profile = (void *)profile; + meter_mark->policy = (void *)policy; + meter_mark->color_mode =1 ; + +return 0 ; +} + +static int +dpaa2_flow_set_police_action (struct dpaa2_dev_priv *priv, +uint8_t tc_id,const struct rte_flow_action_meter_mark *meter_mark) +{ +struct rte_dpaa2_device *dpaa2_dev; +struct dpni_rx_tc_policing_cfg policing_cfg = {0 }; +const struct dpaa2_dev_meter_profile *dpaa2_profile; +const struct dpaa2_dev_meter_policy *dpaa2_policy =NULL ; +int ret; + +if (!(priv->options &DPNI_OPT_HAS_POLICING )) { +DPAA2_PMD_ERR ("POLICING(0x%08x) was not added in DPNI creating options(0x%08x)" , +DPNI_OPT_HAS_POLICING , priv->options); +return -ENOTSUP ; + } + + dpaa2_dev =DPAA2_DEV_PRIV_TO_DPAA2_DEV (priv); + + dpaa2_profile = (void *)meter_mark->profile; +if (!dpaa2_profile) { +DPAA2_PMD_ERR ("Meter profile not specified!" ); +return -EINVAL ; + } + +/** Blind as default.*/ + policing_cfg.options =0 ; +if (meter_mark->color_mode) + policing_cfg.options =DPNI_POLICER_OPT_COLOR_AWARE ; +if (meter_mark->policy) + dpaa2_policy = (void *)meter_mark->policy; +if (dpaa2_policy && dpaa2_policy->red_drop) { + policing_cfg.options |=DPNI_POLICER_OPT_DISCARD_RED ; + }else if (!dpaa2_policy) { +/** Default: Red is discarded if no policy specified.*/ + policing_cfg.options |=DPNI_POLICER_OPT_DISCARD_RED ; + } + +if (priv->flow_profile.mtr_flow[tc_id]) { +/** Update existing policer.*/ + dpaa2_dev =DPAA2_DEV_PRIV_TO_DPAA2_DEV (priv); + policing_cfg.options |=DPNI_POLICER_OPT_DO_NOT_RESET_COUNTERS ; +if (dpaa2_dev->bus_info->mc_rev <DPAA2_POLICER_NOT_RESET_COUNTER_MC_REV ) +DPAA2_PMD_WARN ("The existing policer's counters will be cleaned." ); + } + + policing_cfg.mode = dpaa2_profile->mode; +if (policing_cfg.mode <DPNI_POLICER_MODE_NONE || + policing_cfg.mode >DPNI_POLICER_MODE_RFC_4115 ) { +DPAA2_PMD_ERR ("Invalid policer mode(%d)" , + policing_cfg.mode); +return -EINVAL ; + } + policing_cfg.units = dpaa2_profile->policer_unit; +if (policing_cfg.units <DPNI_POLICER_UNIT_BYTES_L3 || + policing_cfg.units >DPNI_POLICER_UNIT_BYTES_L2_WITHOUT_FCS ) { +DPAA2_PMD_ERR ("Invalid policer units(%d)" , + policing_cfg.units); +return -EINVAL ; + } + policing_cfg.cir = dpaa2_profile->cir; + policing_cfg.cbs = dpaa2_profile->cbs; + policing_cfg.eir = dpaa2_profile->pir; + policing_cfg.ebs = dpaa2_profile->pbs; + +if (dpaa2_dev->bus_info->mc_rev <DPAA2_POLICER_SET_V2_MC_REV ) { + ret =dpni_set_rx_tc_policing_v1 (priv->hw,CMD_PRI_LOW , + priv->token, tc_id, &policing_cfg); + }else { + ret =dpni_set_rx_tc_policing (priv->hw,CMD_PRI_LOW , + priv->token, tc_id, &policing_cfg); + } +DPAA2_PMD_INFO ("%s RX TC%d policer configure %s." , + priv->eth_dev->data->name, tc_id, + ret ?"failed" :"successfully" ); +if (!ret) + priv->flow_profile.tc_mtr_profile[tc_id] = (void *)meter_mark->profile; + +return ret; +} static int dpaa2_flow_action_single_type_check(const struct rte_flow_action actions[],
@@ -4119,6 +4267,8 @@ dpaa2_flow_fs_action_update(struct dpaa2_dev_priv *priv, const struct rte_flow_action actions[]) {int end_of_list =0 , ret =0 , i =0 ; +const struct rte_flow_action_meter *meter; +struct rte_flow_action_meter_mark meter_mark;union dpaa2_dev_flow_action flow_action_rollback; rte_memcpy(&flow_action_rollback, &fs_flow->flow_action,
@@ -4136,6 +4286,26 @@ dpaa2_flow_fs_action_update(struct dpaa2_dev_priv *priv,if (ret) goto end_action_set; +break ; +case RTE_FLOW_ACTION_TYPE_METER_MARK : +rte_memcpy (&meter_mark, actions[i].conf, +sizeof (meter_mark)); + ret =dpaa2_flow_set_police_action (priv, + fs_flow->tc_id, &meter_mark); +if (ret) + goto end_action_set; +break ; +case RTE_FLOW_ACTION_TYPE_METER : + meter = actions[i].conf; + ret =dpaa2_flow_action_meter_mark_init (priv, + meter->mtr_id, &meter_mark); +if (ret) + goto end_action_set; + ret =dpaa2_flow_set_police_action (priv, + fs_flow->tc_id, &meter_mark); +if (ret) + goto end_action_set; +break ;case RTE_FLOW_ACTION_TYPE_PF :/* Skip this action, have to add for vxlan*/
@@ -4557,6 +4727,29 @@ dpaa2_flow_validate(struct rte_eth_dev *dev, } } + supported = dpaa2_supported_meter_action_type; + supported_len =RTE_DIM (dpaa2_supported_meter_action_type); +if (dpaa2_flow_check_actions_support (actions, supported, supported_len)) { +DPAA2_PMD_DEBUG ("This is meter flow." ); +if (group_type ==RTE_DPAA2_QOS_GROUP_FLOW ) { + err_str ="Meter flow's type can't be QoS flow." ; + cause = actions; + err_type =RTE_FLOW_ERROR_TYPE_ACTION ; + ret = -EPERM ; + goto invalid_params; + } +if (actions[1 ].type !=RTE_FLOW_ACTION_TYPE_END ) { + err_str ="Meter flow can't support multi-actions." ; + cause = actions; + err_type =RTE_FLOW_ERROR_TYPE_ACTION_NUM ; + ret = -EPERM ; + goto invalid_params; + } +if (pattern) +DPAA2_PMD_WARN ("Meter flow ingores flow items!" ); +return 0 ; + } +/* Verify input action list */ if (group_type ==RTE_DPAA2_ONE_LEVEL_GROUP_FLOW || group_type ==RTE_DPAA2_FS_GROUP_FLOW ) {
@@ -5383,6 +5576,51 @@ dpaa2_flow_generic_flow_create(struct rte_eth_dev *dev,return NULL ; } +static struct rte_flow * +dpaa2_flow_create_meter_flow (struct rte_eth_dev *dev, +const struct rte_flow_attr *attr, +const struct rte_flow_action meter_action[]) +{ +struct dpaa2_dev_priv *priv = dev->data->dev_private; +struct dpaa2_dev_flow *flow =NULL ; +struct dpaa2_generic_flow *fs_flow =NULL ; +int ret; + +if (attr->group >= priv->num_rx_tc) +return NULL ; + +if (priv->flow_profile.mtr_flow[attr->group]) +return NULL ; + + fs_flow =rte_zmalloc (NULL ,sizeof (struct dpaa2_generic_flow ), +RTE_CACHE_LINE_SIZE ); +if (!fs_flow) { +DPAA2_PMD_ERR ("Failure to allocate memory for flow" ); +return NULL ; + } + flow =rte_zmalloc (NULL ,sizeof (struct dpaa2_dev_flow ), +RTE_CACHE_LINE_SIZE ); +if (!flow) { +rte_free (fs_flow); +DPAA2_PMD_ERR ("Failure to allocate memory for flow" ); +return NULL ; + } + fs_flow->tc_id = attr->group; + fs_flow->priv = priv; + flow->fs_flow = fs_flow; + flow->priv = priv; + + ret =dpaa2_flow_fs_action_update (priv, fs_flow, meter_action); +if (ret) { +rte_free (fs_flow); +rte_free (flow); +return NULL ; + } + flow->is_meter_flow = true; + priv->flow_profile.mtr_flow[fs_flow->tc_id] = flow; + +return (struct rte_flow *)flow; +}static struct rte_flow * dpaa2_flow_create(struct rte_eth_dev *dev,
@@ -5447,6 +5685,30 @@ dpaa2_flow_create(struct rte_eth_dev *dev, rss_item = true; } +if (dpaa2_flow_check_actions_support (actions, + dpaa2_supported_meter_action_type, +RTE_DIM (dpaa2_supported_meter_action_type))) { +/** Assume it's meter flow per TC.*/ +if (group_type ==RTE_DPAA2_QOS_GROUP_FLOW ) { + error_type =RTE_FLOW_ERROR_TYPE_ATTR_GROUP ; + err_code = -EINVAL ; + err_str ="Failed to converts RSS config type to RSS items!" ; + goto flow_failure; + } +if (actions[1 ].type !=RTE_FLOW_ACTION_TYPE_END ) { + error_type =RTE_FLOW_ERROR_TYPE_ACTION_NUM ; + err_code = -EPERM ; + err_str ="Meter flow can't support multi-actions." ; + goto flow_failure; + } + flow = (void *)dpaa2_flow_create_meter_flow (dev, &local_attr, actions); +if (flow) +return (struct rte_flow *)flow; + error_type =RTE_FLOW_ERROR_TYPE_ACTION ; + err_code = -EINVAL ; + err_str ="Failed to create meter flow!" ; + goto flow_failure; + }DPAA2_PMD_DEBUG ("Port %s-%s: group type:%d, group id:%d, total RX TCs:%d" , dev->data->name, __func__, group_type, group_id, priv->num_rx_tc);
@@ -5573,6 +5835,38 @@ dpaa2_flow_create(struct rte_eth_dev *dev,return NULL ; } +static int +dpaa2_flow_destroy_meter_flow (struct rte_eth_dev *dev, +struct dpaa2_dev_flow *flow) +{ +struct rte_dpaa2_device *dpaa2_dev; +struct dpaa2_dev_priv *priv = dev->data->dev_private; +struct dpni_rx_tc_policing_cfg cfg; +int ret; +uint8_t tc_id; + +RTE_ASSERT (!flow->qos_flow && flow->fs_flow); + dpaa2_dev =DPAA2_DEV_PRIV_TO_DPAA2_DEV (priv); + tc_id = flow->fs_flow->tc_id; +RTE_ASSERT (priv->flow_profile.mtr_flow[tc_id] == flow); +memset (&cfg,0 ,sizeof (cfg)); + cfg.mode =DPNI_POLICER_MODE_NONE ; +if (dpaa2_dev->bus_info->mc_rev <DPAA2_POLICER_SET_V2_MC_REV ) { + ret =dpni_set_rx_tc_policing_v1 (priv->hw,CMD_PRI_LOW , + priv->token, tc_id, &cfg); + }else { + ret =dpni_set_rx_tc_policing (priv->hw,CMD_PRI_LOW , + priv->token, tc_id, &cfg); + } +if (ret) +return ret; + priv->flow_profile.tc_mtr_profile[tc_id] =NULL ; + priv->flow_profile.mtr_flow[tc_id] =NULL ; +rte_free (flow->fs_flow); +rte_free (flow); + +return 0 ; +} static int dpaa2_flow_destroy(struct rte_eth_dev *dev,
@@ -5587,6 +5881,8 @@ dpaa2_flow_destroy(struct rte_eth_dev *dev,RTE_SET_USED (error); flow = (struct dpaa2_dev_flow *)_flow; +if (flow->is_meter_flow) +return dpaa2_flow_destroy_meter_flow (dev, flow);LIST_REMOVE (flow, next);
@@ -5663,6 +5959,26 @@ dpaa2_flow_actions_update(struct rte_eth_dev *dev,/* check for the valid flow */ flow = (void *)_flow; +if (flow->is_meter_flow) { +RTE_ASSERT (flow->fs_flow); + tc_id = flow->fs_flow->tc_id; +RTE_ASSERT (priv->flow_profile.mtr_flow[tc_id] == flow); + supported = dpaa2_supported_meter_action_type; + supported_len =RTE_DIM (dpaa2_supported_meter_action_type); +if (!dpaa2_flow_check_actions_support (actions, supported, supported_len)) { + error_type =RTE_FLOW_ERROR_TYPE_ACTION ; + err_str ="Failed to verify meter action!" ; + err_code = -ENOTSUP ; + goto quit; + } + ret =dpaa2_flow_fs_action_update (priv, flow->fs_flow, actions); +if (ret) { + error_type =RTE_FLOW_ERROR_TYPE_ACTION ; + err_str ="Failed to update meter action!" ; + err_code = ret; + } + goto quit; + } LIST_FOREACH(flow, &priv->flows, next) {if ((struct rte_flow *)flow == _flow) goto action_update;
Signature · 1 line
2.43.0
PATCH v2 39/47 net/dpaa2: support flow table miss actions
In reply to Prashant GuptaFrom: Hemant Agrawal <[email protected]>
Implement the group_set_miss_actions callback so that the default action of the QoS and flow steering tables can be configured. A table miss either drops the frame, steers it to a default queue, or jumps to a default traffic class.
The default action is applied while the port is configured, so that the tables have a defined miss behaviour before any flow rule is added.
--- drivers/net/dpaa2/dpaa2_ethdev.c | 58 ++++++++ drivers/net/dpaa2/dpaa2_flow.c | 237 +++++++++++++++++++++++++++++++ 2 files changed, 295 insertions(+)
drivers/net/dpaa2/dpaa2_ethdev.c +58 -0
@@ -354,6 +354,52 @@ static int dpaa2_dev_link_update(struct rte_eth_dev *dev,static int dpaa2_dev_set_link_up (struct rte_eth_dev *dev);static int dpaa2_dev_set_link_down (struct rte_eth_dev *dev);static int dpaa2_dev_mtu_set (struct rte_eth_dev *dev,uint16_t mtu); +static int +dpaa2_setup_table_miss_action (struct rte_eth_dev *eth_dev, +uint8_t tc_index) +{ +struct dpaa2_dev_priv *priv = eth_dev->data->dev_private; +struct rte_flow_group_attr attr; +struct rte_flow_action actions[2 ]; +struct dpaa2_flow_tbl_profile *tbl_profile; + +memset (&attr,0 ,sizeof (attr)); + attr.ingress =1 ; +if (tc_index < priv->num_rx_tc) { + tbl_profile = &priv->flow_profile.tc_profile[tc_index]; +if (tbl_profile->default_drop) { + actions[0 ].type =RTE_FLOW_ACTION_TYPE_DROP ; + }else if (tbl_profile->default_queue.index >= eth_dev->data->nb_rx_queues) { +DPAA2_PMD_DEBUG ("%s-tc%d-default-rxq(%d) >= max rxq(%d), Force to drop." , + eth_dev->data->name, tc_index, tbl_profile->default_queue.index, + eth_dev->data->nb_rx_queues); + tbl_profile->default_drop = true; + actions[0 ].type =RTE_FLOW_ACTION_TYPE_DROP ; + }else { + actions[0 ].type =RTE_FLOW_ACTION_TYPE_QUEUE ; + actions[0 ].conf = &tbl_profile->default_queue; + } + }else { + tbl_profile = &priv->flow_profile.qos_profile; +if (tbl_profile->default_drop) { + actions[0 ].type =RTE_FLOW_ACTION_TYPE_DROP ; + }else if (tbl_profile->default_jump.group >= priv->num_rx_tc) { +DPAA2_PMD_DEBUG ("%s-default-tc(%d) >= max tc(%d), Force to drop." , + eth_dev->data->name, tbl_profile->default_jump.group, + priv->num_rx_tc); + tbl_profile->default_drop = true; + actions[0 ].type =RTE_FLOW_ACTION_TYPE_DROP ; + }else { + actions[0 ].type =RTE_FLOW_ACTION_TYPE_JUMP ; + actions[0 ].conf = &tbl_profile->default_jump; + } + } + actions[1 ].type =RTE_FLOW_ACTION_TYPE_END ; + +return rte_flow_group_set_miss_actions (eth_dev->data->port_id, + tc_index, &attr, actions,NULL ); +} +static int dpaa2_setup_flow_rss_dist (struct rte_eth_dev *eth_dev,uint64_t req_dist_set,int tc_index)
@@ -1087,6 +1133,13 @@ dpaa2_eth_dev_configure(struct rte_eth_dev *dev) def_act_conf->default_flows[tc_index]; } } +if (priv->fs_entries) { + ret =dpaa2_setup_table_miss_action (dev, tc_index); +if (ret) { +DPAA2_PMD_ERR ("Error(%d) to set miss action of %s-tc%d table" , + ret, dev->data->name, tc_index); + } + } }if (def_act_conf) { tbl_profile = &priv->flow_profile.qos_profile;
@@ -1097,6 +1150,11 @@ dpaa2_eth_dev_configure(struct rte_eth_dev *dev) tbl_profile->default_jump.group = def_act_conf->default_tc; } } + ret =dpaa2_setup_table_miss_action (dev, priv->num_rx_tc); +if (ret) { +DPAA2_PMD_ERR ("Error(%d) to set miss action of %s-QoS table" , + ret, dev->data->name); + }if (eth_conf->rxmode.mq_mode &RTE_ETH_MQ_RX_RSS ) {for (tc_index =0 ; tc_index < priv->num_rx_tc; tc_index++) {
drivers/net/dpaa2/dpaa2_flow.c +237 -0
261 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH v2 40/47 net/dpaa2: support Rx mempool per traffic class
In reply to Prashant GuptaFrom: Jun Yang <[email protected]>
Support configuring RX mempool per TC.
This patch isolates mempools by traffic class to avoid individual TC's performance being impacted by lack of memory.
--- drivers/net/dpaa2/dpaa2_ethdev.c | 119 ++++++++++++++++++++++++++++++- drivers/net/dpaa2/dpaa2_ethdev.h | 2 +- 2 files changed, 119 insertions(+), 2 deletions(-)
drivers/net/dpaa2/dpaa2_ethdev.c +118 -1
@@ -546,6 +546,101 @@ dpaa2_update_flow_rss_dist(struct rte_eth_dev *eth_dev,return ret; } +static int +dpaa2_attach_bp_list (struct dpaa2_dev_priv *priv, +struct fsl_mc_io *dpni,void *blist,uint8_t tc_id) +{ +/* Function to attach a DPNI with a buffer pool list. Buffer pool list +* handle is passed in blist. +*/ +int32_t retcode; +struct dpni_pools_cfg *bpool_cfg = &priv->pools_cfg; +struct dpaa2_bp_list *bp_list = blist; +struct dpni_buffer_layout layout; +int tot_size, out_min_hdr_room, in_min_hdr_room; +uint8_t bp_idx; +struct rte_mempool *mp = bp_list->mp; + +if (priv->flow_profile.mempool[tc_id] != mp) { +if (!priv->flow_profile.mempool[tc_id]) { + bp_idx = bpool_cfg->num_dpbp; + bpool_cfg->num_dpbp++; + priv->flow_profile.bp_idx[tc_id] = bp_idx; + }else { + bp_idx = priv->flow_profile.bp_idx[tc_id]; + } + priv->flow_profile.mempool[tc_id] = mp; + }else { + bp_idx = priv->flow_profile.bp_idx[tc_id]; + } + +/* ... rx buffer layout . +* Check alignment for buffer layouts first +*/ + +/* ... rx buffer layout ... */ +if (priv->tx_conf_type ==DPAA2_TX_DYNAMIC_CONF ) { +/** Additional headroom layout for IPSec with TX configure +* dynamic enabled. +*/ + in_min_hdr_room =DPAA2_RX_MIN_FD_OFFSET + +DPAA2_SEC_SIMPLE_FD_IB_MIN ; + out_min_hdr_room =DPAA2_DYN_TX_MIN_FD_OFFSET + +DPAA2_SEC_SIMPLE_FD_OB_MIN ; + tot_size =RTE_MAX (in_min_hdr_room, out_min_hdr_room); +if (tot_size <RTE_PKTMBUF_HEADROOM ) + tot_size =RTE_PKTMBUF_HEADROOM ; + }else { + tot_size =RTE_PKTMBUF_HEADROOM ; + } + tot_size =RTE_ALIGN_CEIL (tot_size,DPAA2_PACKET_LAYOUT_ALIGN ); + +memset (&layout,0 ,sizeof (struct dpni_buffer_layout )); + layout.options =DPNI_BUF_LAYOUT_OPT_DATA_HEAD_ROOM | +DPNI_BUF_LAYOUT_OPT_FRAME_STATUS | +DPNI_BUF_LAYOUT_OPT_PARSER_RESULT | +DPNI_BUF_LAYOUT_OPT_DATA_ALIGN | +DPNI_BUF_LAYOUT_OPT_TIMESTAMP | +DPNI_BUF_LAYOUT_OPT_PRIVATE_DATA_SIZE ; + + layout.pass_timestamp = true; + layout.pass_frame_status =1 ; + layout.private_data_size =DPAA2_FD_PTA_SIZE ; + layout.pass_parser_result =1 ; + layout.data_align =DPAA2_PACKET_LAYOUT_ALIGN ; + layout.data_head_room = tot_size -DPAA2_FD_PTA_SIZE - +DPAA2_MBUF_HW_ANNOTATION ; + retcode =dpni_set_buffer_layout (dpni,CMD_PRI_LOW , priv->token, +DPNI_QUEUE_RX , &layout); +if (retcode) { +DPAA2_PMD_ERR ("Error configuring buffer pool Rx layout (%d)" , + retcode); +return retcode; + } + +/*Attach buffer pool to the network interface as described by the user*/ + bpool_cfg->pools[bp_idx].dpbp_id = bp_list->buf_pool.dpbp_node->dpbp_id; + bpool_cfg->pools[bp_idx].backup_pool =0 ; + bpool_cfg->pools[bp_idx].buffer_size =RTE_ALIGN_CEIL (bp_list->buf_pool.size, +DPAA2_PACKET_LAYOUT_ALIGN ); +/* priority_mask is a bitmask of the traffic classes served by this +* buffer pool, not a traffic class index. MC treats a zero mask as +* 0xff (all traffic classes). +*/ + bpool_cfg->pools[bp_idx].priority_mask =RTE_BIT32 (tc_id); + + retcode =dpni_set_pools (dpni,CMD_PRI_LOW , priv->token, bpool_cfg); +if (retcode) { +DPAA2_PMD_ERR ("Error(%d) configuring pools[%d](id=%d) on %s." , + retcode, bp_idx, bpool_cfg->pools[bp_idx].dpbp_id, + priv->eth_dev->data->name); +return retcode; + } + + priv->bp_list = bp_list; +return 0 ; +} +static int dpaa2_vlan_filter_set (struct rte_eth_dev *dev,uint16_t vlan_id,int on) {
@@ -1321,7 +1416,8 @@ dpaa2_dev_rx_queue_setup(struct rte_eth_dev *dev,struct dpni_taildrop taildrop;uint8_t qopt =0 ;uint16_t flow_id; -int ret; +uint32_t bpid; +int ret, ops_idx;PMD_INIT_FUNC_TRACE ();
@@ -1346,6 +1442,27 @@ dpaa2_dev_rx_queue_setup(struct rte_eth_dev *dev, dev->data->rx_queues[rx_queue_id] = dpaa2_q;return 0 ; } + + ops_idx =rte_dpaa2_mpool_get_ops_idx (); +if (ops_idx != mb_pool->ops_index) { +DPAA2_PMD_ERR ("MP(%s)'s ops index(%d) != %d" , + mb_pool->name, mb_pool->ops_index, ops_idx); +return -EINVAL ; + } + +if (!priv->bp_list || priv->bp_list->mp != mb_pool) { +if (rte_eal_process_type () !=RTE_PROC_PRIMARY ) { + ret =rte_dpaa2_bpid_info_init (mb_pool); +if (ret) +return ret; + } + bpid =mempool_to_bpid (mb_pool); + ret =dpaa2_attach_bp_list (priv, dpni, + rte_dpaa2_bpid_info[bpid].bp_list, + dpaa2_q->tc_index); +if (ret) +return ret; + } cfg =rte_zmalloc (NULL ,sizeof (struct dpni_queue ),0 );if (!cfg)return -ENOMEM ;
drivers/net/dpaa2/dpaa2_ethdev.h +1 -1
@@ -405,7 +405,7 @@ struct dpaa2_dev_priv {/** RXQs in same TC share same cgid.*/ uint8_t cgid_in_use[MAX_TCS ];rte_spinlock_t meter_lock; - +struct dpni_pools_cfg pools_cfg;/* Current hash distribution size per RX TC, written by * dpaa2_setup_flow_dist_size() and read by reta_query / reta_update. * Zero means "use default" (= nb_rx_queues clamped to dist_queues).
Signature · 1 line
2.43.0
PATCH v2 41/47 drivers: consume dpaa2 DQRR entries in batches
In reply to Prashant GuptaFrom: Hemant Agrawal <[email protected]>
Each DQRR entry consumed by the software portal costs a write to the cache-invalidate DCAP register. The DCAP register also supports a vector mode where a bitmap of DQRR indices is consumed with a single write, so accumulate the indices and flush the vector once half the ring is pending. A smaller threshold gives little benefit, and a threshold close to the ring size starves WRIOP of DQRR space.
Because entries are now released in batches, a caller that stops polling a portal must flush the pending vector explicitly. Pass a NULL dequeue result to qbman_swp_dqrr_consume() to do that when the eventdev dequeue finds the portal dry, when the net PMD finishes draining a portal, and when a portal is released back to the bus.
--- drivers/bus/fslmc/portal/dpaa2_hw_dpio.c | 4 ++ .../fslmc/qbman/include/fsl_qbman_portal.h | 5 +- drivers/bus/fslmc/qbman/qbman_portal.c | 68 +++++++++++++++++-- drivers/bus/fslmc/qbman/qbman_portal.h | 11 ++- drivers/event/dpaa2/dpaa2_eventdev.c | 4 ++ drivers/net/dpaa2/dpaa2_ethdev.c | 2 + 6 files changed, 86 insertions(+), 8 deletions(-)
drivers/bus/fslmc/portal/dpaa2_hw_dpio.c +4 -0
@@ -305,6 +305,10 @@ dpaa2_configure_stashing(struct dpaa2_dpio_dev *dpio_dev, int cpu_id, bool ethrxstatic void dpaa2_put_qbman_swp (struct dpaa2_dpio_dev *dpio_dev) {if (dpio_dev) { +/* consume indices may still be pending in the portal's DQRR +* consume vector; flush them before the portal is released. +*/ +qbman_swp_dqrr_consume (dpio_dev->sw_portal,NULL );/* rx-queue interrupts (net PMD) can arm a portal without the * event driver; tear it down unconditionally. Safe when never * armed: intr_deinit returns early if intr is not enabled.
drivers/bus/fslmc/qbman/include/fsl_qbman_portal.h +4 -1
@@ -451,7 +451,10 @@ void qbman_swp_prefetch_dqrr_next(struct qbman_swp *s);* qbman_swp_dqrr_consume() - Consume DQRR entries previously returned from * qbman_swp_dqrr_next(). * @s: the software portal object. -* @dq: the DQRR entry to be consumed. +* @dq: the DQRR entry to be consumed, NULL to consume the entries accumulated +* so far. Entries are accumulated and consumed in batches, so a caller which +* stops polling the portal must call this with a NULL dq to release the +* entries it has already processed. */ __rte_internal void qbman_swp_dqrr_consume(struct qbman_swp *s, const struct qbman_result *dq);
drivers/bus/fslmc/qbman/qbman_portal.c +62 -6
108 lines not on this page · raw message
drivers/bus/fslmc/qbman/qbman_portal.h +10 -1
@@ -1,7 +1,7 @@/* SPDX-License-Identifier: BSD-3-Clause * * Copyright (C) 2014-2016 Freescale Semiconductor, Inc. -* Copyright 2018-2020 NXP +* Copyright 2018-2020, 2026 NXP * */
@@ -93,6 +93,15 @@ struct qbman_swp {uint32_t valid_bit;uint8_t dqrr_size;int reset_bug; +/* Consume index vector: instead of writing DCAP once per +* consumed entry, the indices are accumulated in ci_vector +* and written with a single DCAP access once ci_count +* reaches ci_flush_th. +*/ +bool ci_vec_en; +uint8_t ci_count; +uint8_t ci_flush_th; +uint32_t ci_vector; } dqrr;struct {uint32_t pi;
drivers/event/dpaa2/dpaa2_eventdev.c +4 -0
@@ -320,6 +320,10 @@ dpaa2_eventdev_dequeue_burst(void *port, struct rte_event ev[], do { dq = qbman_swp_dqrr_next(swp); if (!dq) { + /* portal is dry: consume whatever is still pending in + * the DQRR consume vector before leaving it idle. + */ + qbman_swp_dqrr_consume(swp, NULL); if (!num_pkts && timeout_ticks) { dpaa2_eventdev_dequeue_wait(timeout_ticks); timeout_ticks = 0;
drivers/net/dpaa2/dpaa2_ethdev.c +2 -0
@@ -3518,6 +3518,8 @@ dpaa2_napi_drain_portal(struct dpaa2_dpio_dev *dpio)while ((dq =qbman_swp_dqrr_next (dpio->sw_portal)))qbman_swp_dqrr_consume (dpio->sw_portal, dq); +/* flush the indices still pending in the DQRR consume vector */ +qbman_swp_dqrr_consume (dpio->sw_portal,NULL );qbman_swp_interrupt_clear_status (dpio->sw_portal,0xffffffff ); }
Signature · 1 line
2.43.0
PATCH v2 42/47 drivers: resolve dpaa2 endpoint in the net driver
In reply to Prashant GuptaFrom: Hemant Agrawal <[email protected]>
The DPRC object driver walked every device on the bus and, for each DPNI, issued dprc_get_connection() to find the object it is wired to. Two things are wrong with that. The bus keeps the result in struct rte_dpaa2_device even though only the net driver consumes it, and a failure to resolve one DPNI's endpoint aborted the creation of the whole container. The endpoint name was also formatted from endpoint2 outside the DPNI branch, so non-DPNI devices got a name built from uninitialised or stale data.
Move the lookup to dpaa2_dev_init(), which already knows it is dealing with a DPNI and can fail the probe of that one port. This also fills in priv->ep_dev_type, priv->ep_object_id and priv->ep_name, which the net driver reads for MAC-level operations, recycle/loopback configuration and rte_pmd_dpaa2_ep_name(), but which nothing assigned. dpsw endpoints are now recognised, and dpdmux/dpsw names carry the interface index because those endpoints are per-interface.
--- drivers/bus/fslmc/bus_fslmc_driver.h | 3 -- drivers/bus/fslmc/portal/dpaa2_hw_dprc.c | 45 +++--------------- drivers/net/dpaa2/dpaa2_ethdev.c | 58 +++++++++++++++++++++++- drivers/net/dpaa2/dpaa2_recycle.c | 15 +++--- 4 files changed, 70 insertions(+), 51 deletions(-)
drivers/bus/fslmc/bus_fslmc_driver.h +0 -3
@@ -104,10 +104,7 @@ struct rte_dpaa2_device {struct rte_device device;/**< Inherit core device */ enum rte_dpaa2_dev_type dev_type;/**< Device Type */ uint16_t object_id;/**< DPAA2 Object ID */ -enum rte_dpaa2_dev_type ep_dev_type;/**< Endpoint Device Type */ struct dpaa2_dprc_dev *container; -uint16_t ep_object_id;/**< Endpoint DPAA2 Object ID */ -char ep_name[RTE_DEV_NAME_MAX_LEN ];struct rte_intr_handle *intr_handle;/**< Interrupt handle */ char name[FSLMC_OBJECT_MAX_LEN ];/**< DPAA2 Object name*/ const struct rte_fslmc_bus_info *bus_info;
drivers/bus/fslmc/portal/dpaa2_hw_dprc.c +6 -39
58 lines not on this page · raw message
drivers/net/dpaa2/dpaa2_ethdev.c +57 -1
76 lines not on this page · raw message
drivers/net/dpaa2/dpaa2_recycle.c +7 -8
@@ -628,18 +628,18 @@ dpaa2_dev_recycle_config(struct rte_eth_dev *eth_dev)return 0 ; } -if (dpaa2_dev->ep_dev_type ==DPAA2_MAC ) { +if (priv->ep_dev_type ==DPAA2_MAC ) {/** For dpmac-dpni connection, * try setting serdes loopback as recycle device at first. */ if (dpaa2_svr_family ==SVR_LS2088A ) { - ret =ls_serdes_eth_lpbk (dpaa2_dev->ep_object_id,1 ); + ret =ls_serdes_eth_lpbk (priv->ep_object_id,1 );if (!ret) { priv->flags |=DPAA2_TX_SERDES_LOOPBACK_MODE ;return 0 ; } }else if (dpaa2_svr_family ==SVR_LX2160A ) { - ret =lx_serdes_eth_lpbk (dpaa2_dev->ep_object_id,1 ); + ret =lx_serdes_eth_lpbk (priv->ep_object_id,1 );if (!ret) { priv->flags |=DPAA2_TX_SERDES_LOOPBACK_MODE ;return 0 ;
@@ -668,8 +668,8 @@ dpaa2_dev_recycle_config(struct rte_eth_dev *eth_dev)return 0 ; } -if (dpaa2_dev->ep_dev_type ==DPAA2_ETH && - dpaa2_dev->object_id == dpaa2_dev->ep_object_id) { +if (priv->ep_dev_type ==DPAA2_ETH && + dpaa2_dev->object_id == priv->ep_object_id) { priv->flags |=DPAA2_TX_DPNI_LOOPBACK_MODE ;return 0 ;
@@ -682,7 +682,6 @@ int dpaa2_dev_recycle_deconfig(struct rte_eth_dev *eth_dev) {struct dpaa2_dev_priv *priv = eth_dev->data->dev_private; -struct rte_dpaa2_device *dpaa2_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *dpaa2_dev);struct fsl_mc_io *dpni_dev = eth_dev->process_private;struct dpni_port_cfg port_cfg;int ret =0 ;
@@ -692,7 +691,7 @@ dpaa2_dev_recycle_deconfig(struct rte_eth_dev *eth_dev)if (priv->flags &DPAA2_TX_SERDES_LOOPBACK_MODE ) {if (dpaa2_svr_family ==SVR_LS2088A ) { - ret =ls_serdes_eth_lpbk (dpaa2_dev->ep_object_id,0 ); + ret =ls_serdes_eth_lpbk (priv->ep_object_id,0 );if (ret) {DPAA2_PMD_WARN ("Error(%d) to disable Serdes loopback" , ret);
@@ -700,7 +699,7 @@ dpaa2_dev_recycle_deconfig(struct rte_eth_dev *eth_dev) priv->flags &= ~DPAA2_TX_SERDES_LOOPBACK_MODE ; } }else if (dpaa2_svr_family ==SVR_LX2160A ) { - ret =lx_serdes_eth_lpbk (dpaa2_dev->ep_object_id,0 ); + ret =lx_serdes_eth_lpbk (priv->ep_object_id,0 );if (ret) {DPAA2_PMD_WARN ("Error(%d) to disable Serdes loopback" , ret);
Signature · 1 line
2.43.0
PATCH v2 43/47 drivers: align dpaa2 event port depths with hardware rings
In reply to Prashant GuptaFrom: Hemant Agrawal <[email protected]>
The event port dequeue and enqueue depths were fixed at 8. A dequeue drains the portal DQRR and an enqueue fills the EQCR, so the real limits are the sizes of those two rings, which differ per SoC and are known at run time. Report them instead, adding qbman_swp_portal_dqrr_size() to query the DQRR size (the EQCR size is already available as dpaa2_eqcr_size).
The Tx adapter enqueue helpers sized their on-stack mbuf arrays from the advertised enqueue depth, which no longer bounds the burst the adapter may hand them, so bound the copy by the array itself and transmit in chunks.
--- .../fslmc/qbman/include/fsl_qbman_portal.h | 7 ++ drivers/bus/fslmc/qbman/qbman_portal.c | 15 ++++ drivers/event/dpaa2/dpaa2_eventdev.c | 72 ++++++++++++------- drivers/event/dpaa2/dpaa2_eventdev.h | 4 +- 4 files changed, 69 insertions(+), 29 deletions(-)
drivers/bus/fslmc/qbman/include/fsl_qbman_portal.h +7 -0
@@ -1222,6 +1222,13 @@ __rte_internalint qbman_swp_acquire (struct qbman_swp *s,uint16_t bpid,uint64_t *buffers,unsigned int num_buffers); +/** +* qbman_swp_portal_dqrr_size() - Number of entries in a portal's DQRR. +* @p: the software portal object, NULL to query the SoC's DQRR size. +*/ +__rte_internal +uint32_t qbman_swp_portal_dqrr_size(struct qbman_swp *p); +/*****************/ /* FQ management */ /*****************/
drivers/bus/fslmc/qbman/qbman_portal.c +15 -0
@@ -73,6 +73,11 @@ enum qbman_sdqcr_fc {static struct qbman_swp *portal_idx_map[MAX_QBMAN_PORTALS ];uint32_t qman_version; +/* DQRR size of the portals initialised so far. All portals of a SoC have the +* same size, so this doubles as the SoC's DQRR size for callers that have no +* portal at hand. +*/ +static uint32_t dpaa2_portal_dqrr_size =8 ;/* Internal Function declaration */ static int
@@ -239,6 +244,15 @@ static int (*qbman_swp_release_ptr)(struct qbman_swp *s, const uint64_t *buffers, unsigned int num_buffers) = qbman_swp_release_direct; +RTE_EXPORT_INTERNAL_SYMBOL (qbman_swp_portal_dqrr_size) +uint32_t qbman_swp_portal_dqrr_size(struct qbman_swp *p) +{ +if (p !=NULL ) +return p->dqrr.dqrr_size; + +return dpaa2_portal_dqrr_size; +} +/*********************************/ /* Portal constructor/destructor */ /*********************************/
@@ -303,6 +317,7 @@ struct qbman_swp *qbman_swp_init(const struct qbman_swp_desc *d) p->dqrr.ci_vec_en = p->dqrr.dqrr_size <= (32 -DQRR_DCAP_CI_VEC_OFFSET ); p->dqrr.ci_flush_th = p->dqrr.dqrr_size /2 ; + dpaa2_portal_dqrr_size = p->dqrr.dqrr_size; ret =qbman_swp_sys_init (&p->sys, d, p->dqrr.dqrr_size);if (ret) {
drivers/event/dpaa2/dpaa2_eventdev.c +46 -26
110 lines not on this page · raw message
drivers/event/dpaa2/dpaa2_eventdev.h +1 -3
@@ -1,5 +1,5 @@/* SPDX-License-Identifier: BSD-3-Clause -* Copyright 2017 NXP +* Copyright 2017,2026 NXP */ #ifndef __DPAA2_EVENTDEV_H__
@@ -22,8 +22,6 @@#define DPAA2_EVENT_MAX_QUEUE_FLOWS 2048#define DPAA2_EVENT_MAX_QUEUE_PRIORITY_LEVELS 8#define DPAA2_EVENT_MAX_EVENT_PRIORITY_LEVELS 0 -#define DPAA2_EVENT_MAX_PORT_DEQUEUE_DEPTH 8 -#define DPAA2_EVENT_MAX_PORT_ENQUEUE_DEPTH 8#define DPAA2_EVENT_MAX_NUM_EVENTS (INT32_MAX - 1)#define DPAA2_EVENT_QUEUE_ATOMIC_FLOWS 2048
Signature · 1 line
2.43.0
PATCH v2 44/47 net/dpaa2: read MC version from device private data
In reply to Prashant GuptaFrom: Hemant Agrawal <[email protected]>
The flow engine reached back to the bus device to read the MC firmware version. The bus_info pointer behind it is only attached by the primary process, so a secondary process that creates a flow dereferences a pointer it never set up.
The version is already cached in priv->mc_rev at probe time and the rest of the driver reads it from there, so use that here too. This removes the last user of DPAA2_DEV_PRIV_TO_DPAA2_DEV(), so drop the macro.
--- drivers/net/dpaa2/dpaa2_ethdev.h | 4 --- drivers/net/dpaa2/dpaa2_flow.c | 61 ++++++++++---------------------- 2 files changed, 19 insertions(+), 46 deletions(-)
drivers/net/dpaa2/dpaa2_ethdev.h +0 -4
@@ -44,10 +44,6 @@#define MAX_DPNI 8#define DPAA2_MAX_CHANNELS 16 -#define DPAA2_DEV_PRIV_TO_DPAA2_DEV (priv) \ - container_of((((struct dpaa2_dev_priv *)priv)->eth_dev->device), \ - struct rte_dpaa2_device, device) -#define DPAA2_EXTRACT_PARAM_MAX_SIZE \ RTE_ALIGN(sizeof(struct dpni_ext_set_rx_tc_dist), 256)
drivers/net/dpaa2/dpaa2_flow.c +19 -42
213 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH v2 45/47 net/dpaa2: do not overwrite mbuf hash with drop priority
In reply to Prashant GuptaFrom: Hemant Agrawal <[email protected]>
dpaa2_eth_fd_to_mbuf() wrote the frame descriptor's drop priority into mbuf->hash.sched.color unconditionally. hash.sched shares the union with hash.rss and hash.fdir, so this clobbered whatever the parse step had placed there. The scheduler color is only meaningful when the frame came out of a flow-steering table, and dpaa2_dev_rx_mbuf_sched_set() already sets the whole sched field (queue, traffic class and colour) in that case, so drop the unconditional write.
--- drivers/net/dpaa2/dpaa2_rxtx.c | 1 - 1 file changed, 1 deletion(-)
drivers/net/dpaa2/dpaa2_rxtx.c +0 -1
@@ -488,7 +488,6 @@ dpaa2_eth_fd_to_mbuf(struct dpaa2_dev_priv *priv, const struct qbman_fd *fd) mbuf->pkt_len = mbuf->data_len; mbuf->port = priv->eth_dev->data->port_id; mbuf->next =NULL ; - mbuf->hash.sched.color =DPAA2_GET_FD_DROPP (fd);rte_mbuf_refcnt_set (mbuf,1 );#ifdef RTE_LIBRTE_MEMPOOL_DEBUG rte_mempool_check_cookies(rte_mempool_from_obj((void *)mbuf),
Signature · 1 line
2.43.0
PATCH v2 46/47 bus/fslmc: reduce probe-time logging and MC traffic
In reply to Prashant GuptaFrom: Hemant Agrawal <[email protected]>
Every DMA map logged its virtual, IOVA and physical addresses at NOTICE. An application that maps many memory segments prints one such line per segment during initialisation, which drowns out messages the operator actually needs; the neighbouring mapping paths already use debug level.
fslmc_vfio_get_bus_info() also issued mc_get_soc_version() twice in a row into the same structure, so the second command only overwrote the first result with an identical one. Keep a single query.
--- drivers/bus/fslmc/fslmc_vfio.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-)
drivers/bus/fslmc/fslmc_vfio.c +1 -9
@@ -281,13 +281,6 @@ fslmc_vfio_get_bus_info(void *regs, struct rte_fslmc_bus_info *bus_info)return ret; } -memset (&mc_plat_info,0 ,sizeof (struct mc_soc_version )); - ret =mc_get_soc_version (&mc_io,CMD_PRI_LOW , &mc_plat_info); -if (ret) { -DPAA2_BUS_ERR ("Unable to get SoC version err:%d" , ret); -return ret; - } -for (i =0 ; i <RTE_DIM (s_soc_type); i++) {if ((mc_plat_info.svr &DPAA2_SVR_MASK ) == s_soc_type[i].svr) { dpaa2_svr_family = s_soc_type[i].svr;
@@ -1041,8 +1034,7 @@ fslmc_map_dma(uint64_t vaddr, rte_iova_t iovaddr, size_t len) fslmc_mem_va2iova =RTE_BAD_IOVA ;TAILQ_INSERT_TAIL (&fslmc_memsegs, dmaseg, next); } -DPAA2_BUS_LOG (NOTICE , -"%s(%zx): VA(%" PRIx64"):IOVA(%" PRIx64"):PHY(%" PRIx64")" , +DPAA2_BUS_DEBUG ("%s(%zx): VA(%" PRIx64"):IOVA(%" PRIx64"):PHY(%" PRIx64")" , is_io ?"DMA I/O map size" :"DMA MEM map size" , len, vaddr, iovaddr, phy);
Signature · 1 line
2.43.0
PATCH v2 47/47 net/dpaa2: reject Rx queue deferred start
In reply to Prashant GuptaFrom: Hemant Agrawal <[email protected]>
The driver has no way to hold an Rx queue down while the port is started, and dpaa2_rxq_info_get() already reports rx_deferred_start as 0. The Tx side rejects the request; do the same for Rx instead of silently accepting a configuration that will not be honoured.
--- drivers/net/dpaa2/dpaa2_ethdev.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/net/dpaa2/dpaa2_ethdev.c +7 -0
@@ -1424,6 +1424,13 @@ dpaa2_dev_rx_queue_setup(struct rte_eth_dev *dev,DPAA2_PMD_DEBUG ("dev =%p, queue =%d, pool = %p, conf =%p" , dev, rx_queue_id, mb_pool, rx_conf); +/* Rx deferred start is not supported */ +if (rx_conf->rx_deferred_start) { +DPAA2_PMD_ERR ("%s: Rx deferred start not supported" , + dev->data->name); +return -EINVAL ; + } + total_nb_rx_desc += nb_rx_desc;if (total_nb_rx_desc >MAX_NB_RX_DESC_IN_PEB && (priv->options &DPNI_OPT_V1_PFDR_IN_PEB )) {
Signature · 1 line
2.43.0
cover net/dpaa2: flow, meter and parser features
This is the second of four series upstreaming the missing NXP dpaa2 driver changes. It does not depend on series 1 and can be applied independently. It adds the net/dpaa2 flow, metering and parser features:
- fix an integer overflow in the CCSR region mapping,
- set Tx confirmation on device init and support a larger burst size,
- support MPLS and PPPoE flow distribution, meter and policing, and the flow drop action, with a per-device default flow miss action,
- identify Rx mbuf hash information by FLC and add minimum key size support,
- restructure the parser processing, parse tunnel and fragmented packet types, remove the unused soft parser driver and rename the Rx queue flags.
Every commit builds cleanly (including the aarch64 DPAA cross build with -Werror) and the series is bisectable.
Gagandeep Singh (7):
net/dpaa2: set Tx confirmation on device init net/dpaa2: support larger burst size net/dpaa2: support MPLS and PPPoE flow distribution net/dpaa2: support meter and policing net/dpaa2: support flow drop action net/dpaa2: set default flow miss action per device net/dpaa2: identify Rx mbuf hash information by FLC
Hemant Agrawal (4):
net/dpaa2: fix integer overflow in CCSR region mapping net/dpaa2: add minimum key size support net/dpaa2: restructure dpaa2 parser processing net/dpaa2: parse tunnel and fragmented packet types
Jun Yang (2):
net/dpaa2: remove unused soft parser driver
net/dpaa2: rename Rx queue flags
doc/guides/nics/dpaa2.rst | 1 + doc/guides/nics/features/dpaa2.ini | 3 + doc/guides/rel_notes/release_26_11.rst | 6 + drivers/net/dpaa2/dpaa2_ethdev.c | 82 +- drivers/net/dpaa2/dpaa2_ethdev.h | 212 +++- drivers/net/dpaa2/dpaa2_flow.c | 268 +++- drivers/net/dpaa2/dpaa2_meter.c | 579 +++++++++ drivers/net/dpaa2/dpaa2_parse_dump.h | 374 ------ drivers/net/dpaa2/dpaa2_parser_decode.h | 1539 +++++++++++++++++++++++ drivers/net/dpaa2/dpaa2_pmd_logs.h | 67 + drivers/net/dpaa2/dpaa2_recycle.c | 28 +- drivers/net/dpaa2/dpaa2_rxtx.c | 334 +++-- drivers/net/dpaa2/dpaa2_sparser.c | 137 -- drivers/net/dpaa2/dpaa2_sparser.h | 202 --- drivers/net/dpaa2/dpaa2_tm.c | 16 +- drivers/net/dpaa2/mc/dpni.c | 11 +- drivers/net/dpaa2/mc/fsl_dpni.h | 31 +- drivers/net/dpaa2/mc/fsl_dpni_cmd.h | 3 +- drivers/net/dpaa2/meson.build | 2 +- 19 files changed, 2911 insertions(+), 984 deletions(-) create mode 100644 drivers/net/dpaa2/dpaa2_meter.c delete mode 100644 drivers/net/dpaa2/dpaa2_parse_dump.h create mode 100644 drivers/net/dpaa2/dpaa2_parser_decode.h delete mode 100644 drivers/net/dpaa2/dpaa2_sparser.c delete mode 100644 drivers/net/dpaa2/dpaa2_sparser.h
Signature · 1 line
2.43.0
PATCH 1/13 net/dpaa2: fix integer overflow in CCSR region mapping
From: Hemant Agrawal <[email protected]>
In lsx_ccsr_map_region, PAGE_SIZE is defined as sysconf(_SC_PAGESIZE) which may be negative on error. The value was used directly in size_t comparisons and passed to mmap, causing an integer overflow (Coverity CID 49765682).
Use sysconf() explicitly with a signed long, check for errors, and compute map_len separately with unsigned arithmetic before passing to mmap.
Coverity issue: 49765682
--- drivers/net/dpaa2/dpaa2_recycle.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-)
drivers/net/dpaa2/dpaa2_recycle.c +19 -8
@@ -176,6 +176,9 @@ static void *lsx_ccsr_map_region(uint64_t addr, size_t len)void *tmp;uint64_t start;uint64_t offset; +uint64_t page_mask; +long page_size; +size_t map_len; fd =open ("/dev/mem" ,O_RDWR );if (fd <0 ) {
@@ -183,20 +186,28 @@ static void *lsx_ccsr_map_region(uint64_t addr, size_t len)return NULL ; } - start = addr &PAGE_MASK ; + page_size =sysconf (_SC_PAGESIZE); +if (page_size <=0 ) { +close (fd); +return NULL ; + } + page_mask = ~((uint64_t )page_size -1 ); + start = addr & page_mask; offset = addr - start; - len = len &PAGE_MASK ; -if (len < (size_t )PAGE_SIZE ) - len =PAGE_SIZE ; + len = len & page_mask; + + map_len = len; +if (map_len < (size_t )page_size) + map_len = (size_t )page_size; - tmp =mmap (NULL , len,PROT_READ |PROT_WRITE ,MAP_SHARED , fd, start); + tmp =mmap (NULL , map_len,PROT_READ |PROT_WRITE ,MAP_SHARED , fd, start);close (fd); -if (tmp !=MAP_FAILED ) -return (uint8_t *)tmp + offset; -else +if (tmp ==MAP_FAILED )return NULL ; + +return (uint8_t *)tmp + offset; }static const uint8_t ls_sd1_prot_idx_map[] = {
Signature · 1 line
2.43.0
PATCH 2/13 net/dpaa2: set Tx confirmation on device init
In reply to Prashant GuptaFrom: Gagandeep Singh <[email protected]>
Move TX confirmation mode setting from TXQ setup to device initialization because TXQ0 is not always set up by the user.
--- drivers/net/dpaa2/dpaa2_ethdev.c | 40 ++++++++++++-------------------- 1 file changed, 15 insertions(+), 25 deletions(-)
drivers/net/dpaa2/dpaa2_ethdev.c +15 -25
@@ -1153,7 +1153,6 @@ dpaa2_dev_tx_queue_setup(struct rte_eth_dev *dev,struct dpni_queue tx_conf_cfg;struct dpni_queue tx_flow_cfg;uint8_t options =0 , flow_id; -uint8_t ceetm_ch_idx;uint16_t channel_id;struct dpni_queue_id qid;uint32_t tc_id;
@@ -1174,30 +1173,6 @@ dpaa2_dev_tx_queue_setup(struct rte_eth_dev *dev,memset (&tx_conf_cfg,0 ,sizeof (struct dpni_queue ));memset (&tx_flow_cfg,0 ,sizeof (struct dpni_queue )); -if (!tx_queue_id) { -for (ceetm_ch_idx =0 ; - ceetm_ch_idx <= (priv->num_channels -1 ); - ceetm_ch_idx++) { -/*Set tx-conf and error configuration*/ -if (priv->flags &DPAA2_TX_CONF_ENABLE ) { - ret =dpni_set_tx_confirmation_mode (dpni, -CMD_PRI_LOW , priv->token, - ceetm_ch_idx, -DPNI_CONF_AFFINE ); - }else { - ret =dpni_set_tx_confirmation_mode (dpni, -CMD_PRI_LOW , priv->token, - ceetm_ch_idx, -DPNI_CONF_DISABLE ); - } -if (ret) { -DPAA2_PMD_ERR ("Error(%d) in tx conf setting" , - ret); -return ret; - } - } - } - tc_id = tx_queue_id % priv->num_tx_tc; channel_id = (uint8_t )(tx_queue_id / priv->num_tx_tc) % priv->num_channels; flow_id =0 ;
@@ -3624,6 +3599,21 @@ dpaa2_dev_init(struct rte_eth_dev *eth_dev) goto init_err; } +for (i =0 ; i < priv->num_channels; i++) { +/*Set tx-conf and error configuration*/ +if (priv->flags &DPAA2_TX_CONF_ENABLE ) { + ret =dpni_set_tx_confirmation_mode (dpni_dev, +CMD_PRI_LOW , priv->token, i,DPNI_CONF_AFFINE ); + }else { + ret =dpni_set_tx_confirmation_mode (dpni_dev, +CMD_PRI_LOW , priv->token, i,DPNI_CONF_DISABLE ); + } +if (ret) { +DPAA2_PMD_ERR ("Error(%d) in tx conf setting" , ret); + goto init_err; + } + } +/* Allocate memory for storing MAC addresses. * Table of mac_filter_entries size is allocated so that RTE ether lib * can add MAC entries when rte_eth_dev_mac_addr_add is called.
Signature · 1 line
2.43.0
PATCH 3/13 net/dpaa2: support larger burst size
In reply to Prashant GuptaFrom: Gagandeep Singh <[email protected]>
Make burst size checks and MC command fields SoC-aware, enabling bursts larger than 64K on LX2160A with dpni version 8.7+.
The max_burst_size field in dpni_tx_shaping_cfg is widened to uint32_t and the MC command struct is updated to split the value across two 16-bit fields using the new DPNI_BURST_LO/HI macros.
--- drivers/net/dpaa2/dpaa2_tm.c | 16 +++++++++++----- drivers/net/dpaa2/mc/dpni.c | 11 +++++++++-- drivers/net/dpaa2/mc/fsl_dpni.h | 8 ++++++-- drivers/net/dpaa2/mc/fsl_dpni_cmd.h | 3 ++- 4 files changed, 28 insertions(+), 10 deletions(-)
drivers/net/dpaa2/dpaa2_tm.c +11 -5
@@ -1,5 +1,5 @@/* SPDX-License-Identifier: BSD-3-Clause -* Copyright 2020-2024 NXP +* Copyright 2020-2026 NXP */ #include <rte_ethdev.h>
@@ -10,14 +10,20 @@#include "dpaa2_pmd_logs.h" #include <dpaa2_hw_dpio.h> -#define DPAA2_BURST_MAX (64 * 1024) -#define DPAA2_SHAPER_MIN_RATE 0#define DPAA2_SHAPER_MAX_RATE 107374182400ull#define DPAA2_WEIGHT_MAX 24701#define DPAA2_PKT_ADJUST_LEN_MIN 0#define DPAA2_PKT_ADJUST_LEN_MAX 0x7ff +static inline uint32_t dpaa2_get_burst_max (struct dpaa2_dev_priv *priv) +{ +if (dpaa2_dev_cmp_dpni_ver (priv,8 ,7 ) >=0 ) +return (dpaa2_svr_family ==SVR_LX2160A ) ?229375 :0xF7FF ; + +return 0xF7FF ; +} +int dpaa2_tm_init (struct rte_eth_dev *dev) {
@@ -283,7 +289,7 @@ dpaa2_shaper_profile_add(struct rte_eth_dev *dev, uint32_t shaper_profile_id,RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PEAK_RATE , NULL, "committed rate is out of range\n"); -if (params->committed.size >DPAA2_BURST_MAX ) +if (params->committed.size >dpaa2_get_burst_max (priv))return -rte_tm_error_set (error,EINVAL ,RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PEAK_SIZE ,NULL ,"committed size is out of range\n" );
@@ -293,7 +299,7 @@ dpaa2_shaper_profile_add(struct rte_eth_dev *dev, uint32_t shaper_profile_id,RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PEAK_RATE , NULL, "Peak rate is out of range\n"); -if (params->peak.size >DPAA2_BURST_MAX ) +if (params->peak.size >dpaa2_get_burst_max (priv))return -rte_tm_error_set (error,EINVAL ,RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PEAK_SIZE ,NULL ,"Peak size is out of range\n" );
drivers/net/dpaa2/mc/dpni.c +9 -2
@@ -1106,6 +1106,7 @@ int dpni_set_tx_shaping(struct fsl_mc_io *mc_io, {struct dpni_cmd_set_tx_shaping *cmd_params;struct mc_command cmd = {0 }; +uint32_t tx_cr_burst, tx_er_burst;int coupled, lni_shaper;uint8_t channel_id;uint16_t oal;
@@ -1115,10 +1116,16 @@ int dpni_set_tx_shaping(struct fsl_mc_io *mc_io, cmd_flags, token); cmd_params = (struct dpni_cmd_set_tx_shaping *)cmd.params; + tx_cr_burst = tx_cr_shaper->max_burst_size; + tx_er_burst = tx_er_shaper->max_burst_size; cmd_params->tx_cr_max_burst_size = -cpu_to_le16 (tx_cr_shaper->max_burst_size); +cpu_to_le16 (DPNI_BURST_LO (tx_cr_burst)); cmd_params->tx_er_max_burst_size = -cpu_to_le16 (tx_er_shaper->max_burst_size); +cpu_to_le16 (DPNI_BURST_LO (tx_er_burst)); + cmd_params->tx_cr_max_burst_size_hi = +cpu_to_le16 (DPNI_BURST_HI (tx_cr_burst)); + cmd_params->tx_er_max_burst_size_hi = +cpu_to_le16 (DPNI_BURST_HI (tx_er_burst)); cmd_params->tx_cr_rate_limit =cpu_to_le32 (tx_cr_shaper->rate_limit); cmd_params->tx_er_rate_limit =
drivers/net/dpaa2/mc/fsl_dpni.h +6 -2
@@ -830,14 +830,18 @@ int dpni_get_link_state(struct fsl_mc_io *mc_io,uint16_t token, struct dpni_link_state *state); +#define DPNI_BURST_LO (burst) ((burst) & GENMASK(15, 0)) +#define DPNI_BURST_HI (burst) ((burst) >> 16) +/** * struct dpni_tx_shaping - Structure representing DPNI tx shaping configuration * @rate_limit: Rate in Mbits/s -* @max_burst_size: Burst size in bytes (up to 64KB) +* @max_burst_size: Burst size in bytes. Limits depend on the SoC (0x37FFF +* for LX2160A, 0xF7FF for all others) */ struct dpni_tx_shaping_cfg {uint32_t rate_limit; -uint16_t max_burst_size; +uint32_t max_burst_size; };/**
drivers/net/dpaa2/mc/fsl_dpni_cmd.h +2 -1
@@ -394,7 +394,8 @@ struct dpni_rsp_get_link_state {struct dpni_cmd_set_tx_shaping {uint16_t tx_cr_max_burst_size;uint16_t tx_er_max_burst_size; -uint32_t pad; +uint16_t tx_cr_max_burst_size_hi; +uint16_t tx_er_max_burst_size_hi;uint32_t tx_cr_rate_limit;uint32_t tx_er_rate_limit;/* from LSB: coupled:1, lni_shaper: 1*/
Signature · 1 line
2.43.0
PATCH 4/13 net/dpaa2: support MPLS and PPPoE flow distribution
In reply to Prashant GuptaFrom: Gagandeep Singh <[email protected]>
Add rte_flow pattern support for MPLS and PPPoE items in the dpaa2 PMD flow engine.
For a pattern with no spec/mask, the frame is identified by its Frame Attribute Flag (FAF_MPLS_FRAM / FAF_PPPOE_PPP_FRAM) for both the QoS and flow steering tables. When a spec is present, the MPLS label (NH_FLD_MPLS_MPLSL_1) or the PPPoE session id (NH_FLD_PPPOE_SID) is added as a header extract rule for both tables.
--- doc/guides/nics/features/dpaa2.ini | 2 + drivers/net/dpaa2/dpaa2_flow.c | 196 +++++++++++++++++++++++++++++ 2 files changed, 198 insertions(+)
doc/guides/nics/features/dpaa2.ini +2 -0
@@ -43,6 +43,8 @@ gtp = Y icmp = Y ipv4 = Y ipv6 = Y +mpls = Y +pppoes = Y raw = Y sctp = Y tcp = Y
drivers/net/dpaa2/dpaa2_flow.c +196 -0
228 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH 5/13 net/dpaa2: support meter and policing
In reply to Prashant GuptaFrom: Gagandeep Singh <[email protected]>
Add support for the traffic metering and policing (rte_mtr) API to the dpaa2 PMD. The implementation registers the rte_mtr operations through the ".mtr_ops_get" dev_ops hook and maintains software bookkeeping of meter profiles, policies and meter objects under a per-device spinlock.
Supported algorithms are trTCM RFC 2698 and trTCM RFC 4115 in both byte and packet modes. Meter policies support drop and pass-through actions on the red color.
--- doc/guides/nics/dpaa2.rst | 1 + doc/guides/nics/features/dpaa2.ini | 1 + doc/guides/rel_notes/release_26_11.rst | 6 + drivers/net/dpaa2/dpaa2_ethdev.c | 2 + drivers/net/dpaa2/dpaa2_ethdev.h | 29 ++ drivers/net/dpaa2/dpaa2_meter.c | 579 +++++++++++++++++++++++++ drivers/net/dpaa2/mc/fsl_dpni.h | 23 +- drivers/net/dpaa2/meson.build | 1 + 8 files changed, 638 insertions(+), 4 deletions(-) create mode 100644 drivers/net/dpaa2/dpaa2_meter.c
doc/guides/nics/dpaa2.rst +1 -0
@@ -407,6 +407,7 @@ Features of the DPAA2 PMD are: - Link flow control - Scattered and gather for TX and RX - Rx queue interrupts +- Traffic metering and policing - :ref:`dpaa2_dptmapi`
doc/guides/nics/features/dpaa2.ini +1 -0
@@ -19,6 +19,7 @@ RSS hash = Y RSS reta update = Y VLAN filter = Y Flow control = Y +Rate limitation = Y Traffic manager = Y VLAN offload = Y L3 checksum offload = Y
doc/guides/rel_notes/release_26_11.rst +6 -0
@@ -55,6 +55,12 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Updated NXP DPAA2 net driver.** + + * Added support for flow classification on more protocol fields. + * Added Tx queue based flow control and confirmation queue handling. + * Added software parser based packet dump for debugging. + * Added support for traffic metering and policing. Removed Items -------------
drivers/net/dpaa2/dpaa2_ethdev.c +2 -0
@@ -3320,6 +3320,7 @@ static struct eth_dev_ops dpaa2_ethdev_ops = { .rxq_info_get = dpaa2_rxq_info_get, .txq_info_get = dpaa2_txq_info_get, .tm_ops_get = dpaa2_tm_ops_get, + .mtr_ops_get = dpaa2_mtr_ops_get,#if defined(RTE_LIBRTE_IEEE1588 ) .timesync_enable = dpaa2_timesync_enable, .timesync_disable = dpaa2_timesync_disable,
@@ -3543,6 +3544,7 @@ dpaa2_dev_init(struct rte_eth_dev *eth_dev) priv->num_channels = attr.num_channels; priv->channel_inuse =0 ;rte_spinlock_init (&priv->lpbk_qp_lock); +rte_spinlock_init (&priv->meter_lock);/* only if the custom CG is enabled */ if (attr.options &DPNI_OPT_CUSTOM_CG )
drivers/net/dpaa2/dpaa2_ethdev.h +29 -0
@@ -385,6 +385,30 @@ struct extract_s {uint8_t *tc_extract_param[MAX_TCS ]; }; +struct dpaa2_dev_meter_profile { +LIST_ENTRY (dpaa2_dev_meter_profile) next; +uint32_t profile_id; +uint64_t cir; +uint64_t cbs; +uint64_t pir; +uint64_t pbs; +enum dpni_policer_mode mode; +enum dpni_policer_unit policer_unit; +}; + +struct dpaa2_dev_meter_policy { +LIST_ENTRY (dpaa2_dev_meter_policy) next; +uint32_t policy_id; +bool red_drop; +}; + +struct dpaa2_dev_meter { +LIST_ENTRY (dpaa2_dev_meter) next; +uint32_t meter_id; +uint32_t profile_id; +uint32_t policy_id; +}; +struct dpaa2_dev_priv {void *hw;int32_t hw_id;
@@ -411,6 +435,7 @@ struct dpaa2_dev_priv {uint8_t en_loose_ordered;uint8_t max_cgs;uint8_t cgid_in_use[MAX_RX_QUEUES ]; +rte_spinlock_t meter_lock;/* Current hash distribution size per RX TC, written by * dpaa2_setup_flow_dist_size() and read by reta_query / reta_update.
@@ -456,6 +481,9 @@ struct dpaa2_dev_priv {struct dpaa2_dev_flow *curr; LIST_HEAD(, dpaa2_dev_flow) flows; + LIST_HEAD(, dpaa2_dev_meter_profile) profiles; + LIST_HEAD(, dpaa2_dev_meter_policy) policies; + LIST_HEAD(, dpaa2_dev_meter) meters; LIST_HEAD(nodes, dpaa2_tm_node) nodes; LIST_HEAD(shaper_profiles, dpaa2_tm_shaper_profile) shaper_profiles; };
@@ -548,6 +576,7 @@ int dpaa2_timesync_read_tx_timestamp(struct rte_eth_dev *dev,int dpaa2_dev_recycle_config (struct rte_eth_dev *eth_dev);int dpaa2_dev_recycle_deconfig (struct rte_eth_dev *eth_dev); +int dpaa2_mtr_ops_get (struct rte_eth_dev *dev,void *ops);int dpaa2_soft_parser_loaded (void );void
drivers/net/dpaa2/dpaa2_meter.c new file +579 -0
579 lines not on this page · raw message
drivers/net/dpaa2/mc/fsl_dpni.h +19 -4
@@ -1111,6 +1111,11 @@ int dpni_set_rx_tc_dist(struct fsl_mc_io *mc_io,*/ #define DPNI_POLICER_OPT_DISCARD_RED 0x00000002 +/** +* Do NOT reset counters generally for policer update +*/ +#define DPNI_POLICER_OPT_DO_NOT_RESET_COUNTERS 0x00000004 +/** * enum dpni_policer_mode - selecting the policer mode * @DPNI_POLICER_MODE_NONE: Policer is disabled
@@ -1127,12 +1132,17 @@ enum dpni_policer_mode {/** * enum dpni_policer_unit - DPNI policer units -* @DPNI_POLICER_UNIT_BYTES: bytes units +* @DPNI_POLICER_UNIT_BYTES_L3: bytes units (for each frame takes into account +* FD length - L3 offset) * @DPNI_POLICER_UNIT_FRAMES: frames units +* @DPNI_POLICER_UNIT_BYTES_L2_WITHOUT_FCS: bytes units (for each frame takes +* into account FD length - L2 offset, which means L2 size without the 4 bytes +* for the FCS) */ enum dpni_policer_unit { -DPNI_POLICER_UNIT_BYTES =0 , -DPNI_POLICER_UNIT_FRAMES +DPNI_POLICER_UNIT_BYTES_L3 =0 , +DPNI_POLICER_UNIT_FRAMES , +DPNI_POLICER_UNIT_BYTES_L2_WITHOUT_FCS , };/**
@@ -1173,13 +1183,18 @@ struct dpni_rx_tc_policing_cfg {uint32_t ebs; }; -int dpni_set_rx_tc_policing (struct fsl_mc_io *mc_io,uint32_t cmd_flags,uint16_t token,uint8_t tc_id,const struct dpni_rx_tc_policing_cfg *cfg); +int dpni_set_rx_tc_policing_v1 (struct fsl_mc_io *mc_io, +uint32_t cmd_flags, +uint16_t token, +uint8_t tc_id, +const struct dpni_rx_tc_policing_cfg *cfg); + int dpni_get_rx_tc_policing(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token,
drivers/net/dpaa2/meson.build +1 -0
@@ -11,6 +11,7 @@ sources = files( 'base/dpaa2_hw_dpni.c', 'base/dpaa2_tlu_hash.c', 'dpaa2_tm.c', + 'dpaa2_meter.c', 'dpaa2_mux.c', 'dpaa2_ethdev.c', 'dpaa2_flow.c',
Signature · 1 line
2.43.0
PATCH 6/13 net/dpaa2: support flow drop action
In reply to Prashant GuptaFrom: Gagandeep Singh <[email protected]>
Add support for the RTE_FLOW_ACTION_TYPE_DROP action in the dpaa2 flow engine. A flow rule with a drop action is programmed into the flow steering (FS) table with the DPNI_FS_OPT_DISCARD option so that matching frames are discarded by hardware.
The drop action is added to the supported action list, accepted during action verification, configured in the FS action path, handled in the generic flow-set action loop, and cleaned up in the flow destroy path.
--- drivers/net/dpaa2/dpaa2_flow.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/net/dpaa2/dpaa2_flow.c +7 -1
@@ -97,7 +97,8 @@ enum rte_flow_action_type dpaa2_supported_action_type[] = {RTE_FLOW_ACTION_TYPE_QUEUE ,RTE_FLOW_ACTION_TYPE_PORT_ID ,RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT , - RTE_FLOW_ACTION_TYPE_RSS +RTE_FLOW_ACTION_TYPE_RSS , + RTE_FLOW_ACTION_TYPE_DROP };#ifndef __cplusplus
@@ -4421,6 +4422,7 @@ dpaa2_flow_verify_action(struct dpaa2_dev_priv *priv,break ;case RTE_FLOW_ACTION_TYPE_PF :/* Skip this action, have to add for vxlan */ +case RTE_FLOW_ACTION_TYPE_DROP :break ;case RTE_FLOW_ACTION_TYPE_END : end_of_list =1 ;
@@ -4468,6 +4470,8 @@ dpaa2_configure_flow_fs_action(struct dpaa2_dev_priv *priv, flow->fs_action_cfg.redirect_obj_token = dest_priv->token; flow->fs_action_cfg.flow_id = dest_q->flow_id; + }else if (flow->action_type ==RTE_FLOW_ACTION_TYPE_DROP ) { + flow->fs_action_cfg.options =DPNI_FS_OPT_DISCARD ; }return 0 ;
@@ -4945,6 +4949,7 @@ dpaa2_generic_flow_set(struct dpaa2_dev_flow *flow,case RTE_FLOW_ACTION_TYPE_QUEUE :case RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT :case RTE_FLOW_ACTION_TYPE_PORT_ID : +case RTE_FLOW_ACTION_TYPE_DROP : ret =dpaa2_configure_flow_fs_action (priv, flow, &actions[j]);if (ret)
@@ -5346,6 +5351,7 @@ dpaa2_flow_destroy(struct rte_eth_dev *dev, struct rte_flow *_flow,case RTE_FLOW_ACTION_TYPE_QUEUE :case RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT :case RTE_FLOW_ACTION_TYPE_PORT_ID : +case RTE_FLOW_ACTION_TYPE_DROP :if (priv->num_rx_tc >1 ) {/* Remove entry from QoS table first */ ret = dpni_remove_qos_entry(dpni, CMD_PRI_LOW,
Signature · 1 line
2.43.0
PATCH 7/13 net/dpaa2: set default flow miss action per device
In reply to Prashant GuptaFrom: Gagandeep Singh <[email protected]>
The flow steering miss flow id was a file-scope global configured only via the DPAA2_FLOW_CONTROL_MISS_FLOW environment variable and defaulted to 0. Replace it with a per-device default_flow computed at probe time as the lowest priority flow of the FS table, so that unmatched frames are directed there without depending on an environment variable.
--- drivers/net/dpaa2/dpaa2_ethdev.c | 2 ++ drivers/net/dpaa2/dpaa2_ethdev.h | 2 ++ drivers/net/dpaa2/dpaa2_flow.c | 14 +------------- 3 files changed, 5 insertions(+), 13 deletions(-)
drivers/net/dpaa2/dpaa2_ethdev.c +2 -0
@@ -3543,6 +3543,8 @@ dpaa2_dev_init(struct rte_eth_dev *eth_dev) priv->dist_queues = attr.num_queues; priv->num_channels = attr.num_channels; priv->channel_inuse =0 ; + priv->default_flow =RTE_MIN (priv->fs_entries, + priv->dist_queues) -1 ;rte_spinlock_init (&priv->lpbk_qp_lock);rte_spinlock_init (&priv->meter_lock);
drivers/net/dpaa2/dpaa2_ethdev.h +2 -0
@@ -436,6 +436,8 @@ struct dpaa2_dev_priv {uint8_t max_cgs;uint8_t cgid_in_use[MAX_RX_QUEUES ];rte_spinlock_t meter_lock; +/* Lowest priority FS flow id to receive flow steering miss frames. */ +uint16_t default_flow;/* Current hash distribution size per RX TC, written by * dpaa2_setup_flow_dist_size() and read by reta_query / reta_update.
drivers/net/dpaa2/dpaa2_flow.c +1 -13
@@ -24,7 +24,6 @@#include <dpaa2_pmd_logs.h> static char *dpaa2_flow_control_log; -static uint16_t dpaa2_flow_miss_flow_id;/* Default miss flow id is 0. */ static int dpaa2_sp_loaded =-1 ;enum dpaa2_flow_entry_size {
@@ -4590,7 +4589,7 @@ dpaa2_configure_fs_rss_table(struct dpaa2_dev_priv *priv,return 0 ; tc_cfg.enable = true; - tc_cfg.fs_miss_flow_id = dpaa2_flow_miss_flow_id; + tc_cfg.fs_miss_flow_id = priv->default_flow; ret =dpni_set_rx_fs_dist (dpni,CMD_PRI_LOW , priv->token, &tc_cfg);if (ret <0 ) {
@@ -5224,17 +5223,6 @@ dpaa2_flow_create(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, dpaa2_flow_control_log =getenv ("DPAA2_FLOW_CONTROL_LOG" ); -if (getenv ("DPAA2_FLOW_CONTROL_MISS_FLOW" )) { - dpaa2_flow_miss_flow_id = - (uint16_t )atoi (getenv ("DPAA2_FLOW_CONTROL_MISS_FLOW" )); -if (dpaa2_flow_miss_flow_id >= priv->dist_queues) { -DPAA2_PMD_ERR ("Missed flow ID %d >= dist size(%d)" , - dpaa2_flow_miss_flow_id, - priv->dist_queues); -return NULL ; - } - } - flow =rte_zmalloc (NULL ,sizeof (struct dpaa2_dev_flow ),RTE_CACHE_LINE_SIZE );if (!flow) {
Signature · 1 line
2.43.0
PATCH 8/13 net/dpaa2: identify Rx mbuf hash information by FLC
In reply to Prashant GuptaFrom: Gagandeep Singh <[email protected]>
For default RSS distribution, mbuf is marked with RTE_MBUF_F_RX_RSS_HASH and the hash value from the high word of FLC.
Configure the flow steering action with FLC enabled to align the stashing setting with the RSS configuration. The TC ID and flow ID are packed into the FLC for mbuf Rx scheduling. An Rx mbuf received from the FS table is marked with RTE_MBUF_F_RX_FDIR along with the TC and flow ID decoded from the FLC low word.
--- drivers/net/dpaa2/dpaa2_ethdev.h | 12 +++++++++ drivers/net/dpaa2/dpaa2_flow.c | 42 ++++++++++++++++++++++++++++++++ drivers/net/dpaa2/dpaa2_rxtx.c | 18 ++++++++++++-- 3 files changed, 70 insertions(+), 2 deletions(-)
drivers/net/dpaa2/dpaa2_ethdev.h +12 -0
@@ -282,6 +282,18 @@ enum dpaa2_ecpri_fafe_type {/* ECPRI shares SP context with VXLAN*/ #define DPAA2_ECPRI_MSG_OFFSET DPAA2_VXLAN_VNI_OFFSET +#define DPAA2_FS_FLC_FS_MARK_OFFSET \ + (DPAA2_FLC_DATA_STASHING + DPAA2_FLC_STASHING_MAX_BIT_SIZE) + +#define DPAA2_FS_FLC_TC_OFFSET \ + (DPAA2_FS_FLC_FS_MARK_OFFSET + DPAA2_FLC_STASHING_MAX_BIT_SIZE) + +#define DPAA2_FS_FLC_TC_BIT_SIZE (sizeof(uint8_t) * 8) +#define DPAA2_FS_FLC_TC_MASK ((1 << DPAA2_FS_FLC_TC_BIT_SIZE) - 1) + +#define DPAA2_FS_FLC_FLOW_OFFSET \ + (DPAA2_FS_FLC_TC_OFFSET + DPAA2_FS_FLC_TC_BIT_SIZE) +#define DPAA2_ECPRI_MAX_EXTRACT_NB 8struct ipv4_sd_addr_extract_rule {
drivers/net/dpaa2/dpaa2_flow.c +42 -0
61 lines not on this page · raw message
drivers/net/dpaa2/dpaa2_rxtx.c +16 -2
@@ -58,6 +58,7 @@ dpaa2_dev_rx_parse_new(struct rte_mbuf *m, const struct qbman_fd *fd,uint16_t frc =DPAA2_GET_FD_FRC_PARSE_SUM (fd);struct dpaa2_annot_hdr *annotation = (struct dpaa2_annot_hdr *)hw_annot_addr; +uint32_t flc_lo, tc, flow;if (unlikely (dpaa2_print_parser_result))dpaa2_print_parse_result (annotation);
@@ -118,8 +119,21 @@ dpaa2_dev_rx_parse_new(struct rte_mbuf *m, const struct qbman_fd *fd,default : m->packet_type =dpaa2_dev_rx_parse_slow (m, annotation); } - m->hash.rss = fd->simple.flc_hi; - m->ol_flags |=RTE_MBUF_F_RX_RSS_HASH ; + flc_lo = fd->simple.flc_lo; +if (flc_lo & (1 <<DPAA2_FS_FLC_FS_MARK_OFFSET )) { + m->ol_flags |=RTE_MBUF_F_RX_FDIR ; + tc = (flc_lo >>DPAA2_FS_FLC_TC_OFFSET ) & +DPAA2_FS_FLC_TC_MASK ; + flow = flc_lo >>DPAA2_FS_FLC_FLOW_OFFSET ; +rte_mbuf_sched_set (m, flow, tc,0 ); +DPAA2_PMD_DP_DEBUG ("FS frame received from TC[%d]->flow%d" , + tc, flow); + }else { + m->hash.rss = fd->simple.flc_hi; + m->ol_flags |=RTE_MBUF_F_RX_RSS_HASH ; +DPAA2_PMD_DP_DEBUG ("Hash frame received with RSS(%08x)" , + m->hash.rss); + }if (dpaa2_enable_ts[m->port]) { *dpaa2_timestamp_dynfield (m) = annotation->word2;
Signature · 1 line
2.43.0
PATCH 9/13 net/dpaa2: add minimum key size support
In reply to Prashant GuptaFrom: Hemant Agrawal <[email protected]>
The default size for a QoS key is 24 bytes. If the key size is smaller than the maximum, use the default (minimum) key size instead of always returning the maximum size (56 bytes). This allows smaller flow tables to be used when the extracted key fits within the default size.
--- drivers/net/dpaa2/dpaa2_flow.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/net/dpaa2/dpaa2_flow.c +5 -3
@@ -26,8 +26,11 @@static char *dpaa2_flow_control_log;static int dpaa2_sp_loaded =-1 ; +/* Default size of a key */ +#define DPNI_DEFAULT_KEY_SIZE 24 +enum dpaa2_flow_entry_size { -DPAA2_FLOW_ENTRY_MIN_SIZE = (DPNI_MAX_KEY_SIZE /2 ), +DPAA2_FLOW_ENTRY_MIN_SIZE =DPNI_DEFAULT_KEY_SIZE ,DPAA2_FLOW_ENTRY_MAX_SIZE =DPNI_MAX_KEY_SIZE };
@@ -4532,8 +4535,7 @@ dpaa2_flow_entry_size(uint16_t key_max_size)if (key_max_size >DPAA2_FLOW_ENTRY_MIN_SIZE )return DPAA2_FLOW_ENTRY_MAX_SIZE ; -/* Current MC only support fixed entry size(56)*/ -return DPAA2_FLOW_ENTRY_MAX_SIZE ; +return DPAA2_FLOW_ENTRY_MIN_SIZE ; } static inline int
Signature · 1 line
2.43.0
PATCH 10/13 net/dpaa2: restructure dpaa2 parser processing
In reply to Prashant GuptaFrom: Hemant Agrawal <[email protected]>
Move the parse-result decoding into a dedicated header so that the hardware parser fields are described in one place and shared between the flow code and the Rx path. No functional change is intended.
--- drivers/net/dpaa2/dpaa2_ethdev.h | 172 ++- drivers/net/dpaa2/dpaa2_parse_dump.h | 374 ------ drivers/net/dpaa2/dpaa2_parser_decode.h | 1539 +++++++++++++++++++++++ drivers/net/dpaa2/dpaa2_pmd_logs.h | 67 + drivers/net/dpaa2/dpaa2_rxtx.c | 332 ++--- 5 files changed, 1906 insertions(+), 578 deletions(-) delete mode 100644 drivers/net/dpaa2/dpaa2_parse_dump.h create mode 100644 drivers/net/dpaa2/dpaa2_parser_decode.h
drivers/net/dpaa2/dpaa2_ethdev.h +113 -59
@@ -21,6 +21,8 @@#include <mc/fsl_dpmac.h> #include "base/dpaa2_hw_dpni_annot.h" +#include "dpaa2_parser_decode.h" +#define DPAA2_MIN_RX_BUF_SIZE 512#define DPAA2_MAX_RX_PKT_LEN 10240/*WRIOP support*/
@@ -101,6 +103,7 @@#define DPAA2_DATA_STASHING_OFF RTE_BIT32(10)#define DPAAX_RX_ERROR_QUEUE_FLAG RTE_BIT32(11) +#define DPAA2_RX_PRINT_PSR_RESULT_FLAG RTE_BIT32(12)/* DPDMUX index for DPMAC */ #define DPAA2_DPDMUX_DPMAC_IDX 0
@@ -124,31 +127,62 @@ RTE_ETH_RSS_PPPOE)/* LX2 FRC Parsed values (Little Endian) */ -#define DPAA2_PKT_TYPE_ETHER 0x0060 -#define DPAA2_PKT_TYPE_IPV4 0x0000 -#define DPAA2_PKT_TYPE_IPV6 0x0020 +#define DPAA2_PKT_TYPE_ETHER \ + (DPAA2_PSR_SUMMARY_NONIP << DPAA2_PSR_SUMMARY_NON_IP_L2_BIT_SIZE) +#define DPAA2_PKT_TYPE_IPV4 \ + (DPAA2_PSR_SUMMARY_IPV4 << DPAA2_PSR_SUMMARY_L4_BIT_SIZE) +#define DPAA2_PKT_TYPE_IPV6 \ + (DPAA2_PSR_SUMMARY_IPV6 << DPAA2_PSR_SUMMARY_L4_BIT_SIZE) + +/**Tunnel*/ +#define DPAA2_PKT_TYPE_L3_EXT \ + (DPAA2_PSR_SUMMARY_L4_EXT << DPAA2_PSR_SUMMARY_L4_EXT_L3_POS) +#define DPAA2_PKT_TYPE_L3_EXT_IPV4 \ + (DPAA2_PSR_SUMMARY_IPV4 << DPAA2_PSR_SUMMARY_L4_EXT_BIT_SIZE) +#define DPAA2_PKT_TYPE_L3_EXT_IPV6 \ + (DPAA2_PSR_SUMMARY_IPV6 << DPAA2_PSR_SUMMARY_L4_EXT_BIT_SIZE)#define DPAA2_PKT_TYPE_IPV4_EXT \ - (0x0001 | DPAA2_PKT_TYPE_IPV4) + (DPAA2_PKT_TYPE_L3_EXT | DPAA2_PKT_TYPE_L3_EXT_IPV4)#define DPAA2_PKT_TYPE_IPV6_EXT \ - (0x0001 | DPAA2_PKT_TYPE_IPV6) + (DPAA2_PKT_TYPE_L3_EXT | DPAA2_PKT_TYPE_L3_EXT_IPV6) +#define DPAA2_PKT_TYPE_IPV4_EXT_GRE_IPV4 \ + (DPAA2_PKT_TYPE_IPV4_EXT | DPAA2_PSR_SUMMARY_GRE_IPV4) +#define DPAA2_PKT_TYPE_IPV4_EXT_GRE_IPV4_UDP_TCP \ + (DPAA2_PKT_TYPE_IPV4_EXT | DPAA2_PSR_SUMMARY_GRE_IPV4_UDP_TCP) +#define DPAA2_PKT_TYPE_IPV4_EXT_GRE_IPV6 \ + (DPAA2_PKT_TYPE_IPV4_EXT | DPAA2_PSR_SUMMARY_GRE_IPV6) +#define DPAA2_PKT_TYPE_IPV4_EXT_GRE_IPV6_UDP_TCP \ + (DPAA2_PKT_TYPE_IPV4_EXT | DPAA2_PSR_SUMMARY_GRE_IPV6_UDP_TCP) +#define DPAA2_PKT_TYPE_IPV6_EXT_GRE_IPV4 \ + (DPAA2_PKT_TYPE_IPV6_EXT | DPAA2_PSR_SUMMARY_GRE_IPV4) +#define DPAA2_PKT_TYPE_IPV6_EXT_GRE_IPV4_UDP_TCP \ + (DPAA2_PKT_TYPE_IPV6_EXT | DPAA2_PSR_SUMMARY_GRE_IPV4_UDP_TCP) +#define DPAA2_PKT_TYPE_IPV6_EXT_GRE_IPV6 \ + (DPAA2_PKT_TYPE_IPV6_EXT | DPAA2_PSR_SUMMARY_GRE_IPV6) +#define DPAA2_PKT_TYPE_IPV6_EXT_GRE_IPV6_UDP_TCP \ + (DPAA2_PKT_TYPE_IPV6_EXT | DPAA2_PSR_SUMMARY_GRE_IPV6_UDP_TCP) +#define DPAA2_PKT_TYPE_IPV4_TCP \ - (0x000e | DPAA2_PKT_TYPE_IPV4) + (DPAA2_PSR_SUMMARY_TCP | DPAA2_PKT_TYPE_IPV4)#define DPAA2_PKT_TYPE_IPV6_TCP \ - (0x000e | DPAA2_PKT_TYPE_IPV6) + (DPAA2_PSR_SUMMARY_TCP | DPAA2_PKT_TYPE_IPV6)#define DPAA2_PKT_TYPE_IPV4_UDP \ - (0x0010 | DPAA2_PKT_TYPE_IPV4) + (DPAA2_PSR_SUMMARY_UDP | DPAA2_PKT_TYPE_IPV4)#define DPAA2_PKT_TYPE_IPV6_UDP \ - (0x0010 | DPAA2_PKT_TYPE_IPV6) -#define DPAA2_PKT_TYPE_IPV4_SCTP \ - (0x000f | DPAA2_PKT_TYPE_IPV4) -#define DPAA2_PKT_TYPE_IPV6_SCTP \ - (0x000f | DPAA2_PKT_TYPE_IPV6) + (DPAA2_PSR_SUMMARY_UDP | DPAA2_PKT_TYPE_IPV6) +#define DPAA2_PKT_TYPE_IPV4_SCTP \ + (DPAA2_PSR_SUMMARY_SCTP | DPAA2_PKT_TYPE_IPV4) +#define DPAA2_PKT_TYPE_IPV6_SCTP \ + (DPAA2_PSR_SUMMARY_SCTP | DPAA2_PKT_TYPE_IPV6)#define DPAA2_PKT_TYPE_IPV4_ICMP \ - (0x0003 | DPAA2_PKT_TYPE_IPV4_EXT) + (DPAA2_PSR_SUMMARY_ICMP | DPAA2_PKT_TYPE_IPV4)#define DPAA2_PKT_TYPE_IPV6_ICMP \ - (0x0003 | DPAA2_PKT_TYPE_IPV6_EXT) -#define DPAA2_PKT_TYPE_VLAN_1 0x0160 -#define DPAA2_PKT_TYPE_VLAN_2 0x0260 + (DPAA2_PSR_SUMMARY_ICMP | DPAA2_PKT_TYPE_IPV6) + +#define DPAA2_PKT_TYPE_VLAN_1 0x0100 +#define DPAA2_PKT_TYPE_VLAN_2 0x0200 +#define DPAA2_PKT_TYPE_VLAN \ + (DPAA2_PKT_TYPE_VLAN_1 | DPAA2_PKT_TYPE_VLAN_2)/* mac counters */ #define DPAA2_MAC_NUM_STATS (DPMAC_CNT_EGR_CONTROL_FRAME + 1)
@@ -173,17 +207,33 @@ struct sw_buf_free {struct rte_mbuf *seg; }; -/* enable timestamp in mbuf*/ -extern bool dpaa2_enable_ts[]; -extern uint64_t dpaa2_timestamp_rx_dynflag; -extern int dpaa2_timestamp_dynfield_offset; -/* Externally defined */ extern const struct rte_flow_ops dpaa2_flow_ops;extern const struct rte_tm_ops dpaa2_tm_ops; -extern bool dpaa2_print_parser_result; +struct dpaa2_dyn_rx_protocol_pos { +uint8_t l3_offset; +uint8_t l4_offset; +uint8_t l5_offset; +uint8_t rsv; +}; + +#define L3_OFFSET_OF_MBUF_DYN 0 +#define L4_OFFSET_OF_MBUF_DYN 1 +#define L5_OFFSET_OF_MBUF_DYN 2 + +#define DPAA2_FS_FLC_FS_MARK_OFFSET \ + (DPAA2_FLC_DATA_STASHING + DPAA2_FLC_STASHING_MAX_BIT_SIZE) + +#define DPAA2_FS_FLC_TC_OFFSET \ + (DPAA2_FS_FLC_FS_MARK_OFFSET + DPAA2_FLC_STASHING_MAX_BIT_SIZE) + +#define DPAA2_FS_FLC_TC_BIT_SIZE (sizeof(uint8_t) * 8) +#define DPAA2_FS_FLC_TC_MASK ((1 << DPAA2_FS_FLC_TC_BIT_SIZE) - 1) + +#define DPAA2_FS_FLC_FLOW_OFFSET \ + (DPAA2_FS_FLC_TC_OFFSET + DPAA2_FS_FLC_TC_BIT_SIZE)#define DPAA2_FAPR_SIZE \ (sizeof(struct dpaa2_annot_hdr) - \
@@ -258,42 +308,6 @@ enum dpaa2_ecpri_fafe_type {#define DPAA2_PR_L5_OFF_OFFSET 31#define DPAA2_PR_NXTHDR_OFF_OFFSET 34 -/* Set by SP for vxlan distribution start*/ -#define DPAA2_VXLAN_IN_TCI_OFFSET 16 - -#define DPAA2_VXLAN_IN_DADDR0_OFFSET 20 -#define DPAA2_VXLAN_IN_DADDR1_OFFSET 22 -#define DPAA2_VXLAN_IN_DADDR2_OFFSET 24 -#define DPAA2_VXLAN_IN_DADDR3_OFFSET 25 -#define DPAA2_VXLAN_IN_DADDR4_OFFSET 26 -#define DPAA2_VXLAN_IN_DADDR5_OFFSET 28 - -#define DPAA2_VXLAN_IN_SADDR0_OFFSET 29 -#define DPAA2_VXLAN_IN_SADDR1_OFFSET 32 -#define DPAA2_VXLAN_IN_SADDR2_OFFSET 33 -#define DPAA2_VXLAN_IN_SADDR3_OFFSET 35 -#define DPAA2_VXLAN_IN_SADDR4_OFFSET 41 -#define DPAA2_VXLAN_IN_SADDR5_OFFSET 42 - -#define DPAA2_VXLAN_VNI_OFFSET 43 -#define DPAA2_VXLAN_IN_TYPE_OFFSET 46 -/* Set by SP for vxlan distribution end*/ - -/* ECPRI shares SP context with VXLAN*/ -#define DPAA2_ECPRI_MSG_OFFSET DPAA2_VXLAN_VNI_OFFSET - -#define DPAA2_FS_FLC_FS_MARK_OFFSET \ - (DPAA2_FLC_DATA_STASHING + DPAA2_FLC_STASHING_MAX_BIT_SIZE) - -#define DPAA2_FS_FLC_TC_OFFSET \ - (DPAA2_FS_FLC_FS_MARK_OFFSET + DPAA2_FLC_STASHING_MAX_BIT_SIZE) - -#define DPAA2_FS_FLC_TC_BIT_SIZE (sizeof(uint8_t) * 8) -#define DPAA2_FS_FLC_TC_MASK ((1 << DPAA2_FS_FLC_TC_BIT_SIZE) - 1) - -#define DPAA2_FS_FLC_FLOW_OFFSET \ - (DPAA2_FS_FLC_TC_OFFSET + DPAA2_FS_FLC_TC_BIT_SIZE) -#define DPAA2_ECPRI_MAX_EXTRACT_NB 8struct ipv4_sd_addr_extract_rule {
@@ -435,6 +449,7 @@ struct dpaa2_dev_priv {void *tx_conf_vq[MAX_TX_QUEUES *DPAA2_MAX_CHANNELS ];void *rx_err_vq;uint32_t flags;/*dpaa2 config flags */ +int psr_dynfield_offset;uint8_t max_mac_filters;uint8_t max_vlan_filters;uint8_t num_rx_tc;
@@ -474,6 +489,9 @@ struct dpaa2_dev_priv {uint64_t rx_timestamp;/*stores timestamp of last received tx confirmation packet on dev*/ uint64_t tx_timestamp; + +int rx_ts_offset; +uint64_t rx_ts_flag;/* stores pointer to next tx_conf queue that should be processed, * it corresponds to last packet transmitted */
@@ -482,6 +500,7 @@ struct dpaa2_dev_priv {struct rte_eth_dev *eth_dev;/**< Pointer back to holding ethdev */ rte_spinlock_t lpbk_qp_lock; +bool sp_protocol;uint8_t channel_inuse;/* Rx-interrupt mode latched at the first dev_configure */ uint8_t intr_mode;
@@ -513,6 +532,41 @@ static inline int dpaa2_dev_cmp_dpni_ver(struct dpaa2_dev_priv *priv,return priv->dpni_ver_major - ver_major; } +static inline void +dpaa2_dev_rx_print_parser_result (struct dpaa2_dev_priv *priv, +const struct qbman_fd *fd,const struct rte_mbuf *m) +{ +size_t fd_addr; +void *hw_annot_addr; + +if (likely (!(priv->flags &DPAA2_RX_PRINT_PSR_RESULT_FLAG ))) +return ; + +if (dpaa2_svr_family ==SVR_LX2160A ) +dpaa2_print_fd_frc (fd); + + fd_addr = (size_t )DPAA2_IOVA_TO_VADDR (DPAA2_GET_FD_ADDR (fd)); + hw_annot_addr = (void *)(fd_addr +DPAA2_FD_PTA_SIZE ); +dpaa2_print_parse_result (hw_annot_addr, priv->sp_protocol); +if (m->ol_flags &RTE_MBUF_F_RX_FDIR ) { +const struct rte_mbuf_sched *sched; +uint16_t i; +struct dpaa2_queue *rxq; + + sched = &m->hash.sched; +for (i =0 ; i <MAX_RX_QUEUES ; i++) { + rxq = priv->rx_vq[i]; +if (rxq->tc_index == sched->traffic_class && + rxq->flow_id == sched->queue_id) +break ; + } +DPAA2_PMD_DEBUG ("Directed to TC%d-flow%d(rxq%d), color(%d)" , + sched->traffic_class, sched->queue_id, i, sched->color); + }else if (m->ol_flags &RTE_MBUF_F_RX_RSS_HASH ) { +DPAA2_PMD_DEBUG ("Balanced with hash(0x%08x)" , m->hash.rss); + } +} +int dpaa2_distset_to_dpkg_profile_cfg (uint64_t req_dist_set,struct dpkg_profile_cfg *kg_cfg);
drivers/net/dpaa2/dpaa2_parse_dump.h deleted +0 -374
374 lines not on this page · raw message
drivers/net/dpaa2/dpaa2_parser_decode.h new file +1539 -0
1,539 lines not on this page · raw message
drivers/net/dpaa2/dpaa2_pmd_logs.h +67 -0
77 lines not on this page · raw message
drivers/net/dpaa2/dpaa2_rxtx.c +187 -145
504 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH 11/13 net/dpaa2: parse tunnel and fragmented packet types
In reply to Prashant GuptaFrom: Hemant Agrawal <[email protected]>
Extend the Rx parser to identify additional packet types decoded from the hardware parser summary: IPv4/IPv6 fragments, IPsec ESP, and GTP-U / GTP-C tunnels. The corresponding DPAA2_PKT_TYPE_* values are added and mapped to the matching RTE_PTYPE_* flags in the slow-path parser.
--- drivers/net/dpaa2/dpaa2_ethdev.h | 16 ++++++++++++++++ drivers/net/dpaa2/dpaa2_rxtx.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+)
drivers/net/dpaa2/dpaa2_ethdev.h +16 -0
@@ -162,6 +162,10 @@#define DPAA2_PKT_TYPE_IPV6_EXT_GRE_IPV6_UDP_TCP \ (DPAA2_PKT_TYPE_IPV6_EXT | DPAA2_PSR_SUMMARY_GRE_IPV6_UDP_TCP) +#define DPAA2_PKT_TYPE_IPV4_FRAG \ + (DPAA2_PSR_SUMMARY_IP_FRAG | DPAA2_PKT_TYPE_IPV4) +#define DPAA2_PKT_TYPE_IPV6_FRAG \ + (DPAA2_PSR_SUMMARY_IP_FRAG | DPAA2_PKT_TYPE_IPV6)#define DPAA2_PKT_TYPE_IPV4_TCP \ (DPAA2_PSR_SUMMARY_TCP | DPAA2_PKT_TYPE_IPV4)#define DPAA2_PKT_TYPE_IPV6_TCP \
@@ -178,6 +182,18 @@ (DPAA2_PSR_SUMMARY_ICMP | DPAA2_PKT_TYPE_IPV4)#define DPAA2_PKT_TYPE_IPV6_ICMP \ (DPAA2_PSR_SUMMARY_ICMP | DPAA2_PKT_TYPE_IPV6) +#define DPAA2_PKT_TYPE_IPV4_ESP \ + (DPAA2_PSR_SUMMARY_IPSEC_ESP | DPAA2_PKT_TYPE_IPV4) +#define DPAA2_PKT_TYPE_IPV6_ESP \ + (DPAA2_PSR_SUMMARY_IPSEC_ESP | DPAA2_PKT_TYPE_IPV6) +#define DPAA2_PKT_TYPE_IPV4_GTPU \ + (DPAA2_PSR_SUMMARY_GTPU | DPAA2_PKT_TYPE_IPV4) +#define DPAA2_PKT_TYPE_IPV6_GTPU \ + (DPAA2_PSR_SUMMARY_GTPU | DPAA2_PKT_TYPE_IPV6) +#define DPAA2_PKT_TYPE_IPV4_GTPC \ + (DPAA2_PSR_SUMMARY_GTPC | DPAA2_PKT_TYPE_IPV4) +#define DPAA2_PKT_TYPE_IPV6_GTPC \ + (DPAA2_PSR_SUMMARY_GTPC | DPAA2_PKT_TYPE_IPV6)#define DPAA2_PKT_TYPE_VLAN_1 0x0100#define DPAA2_PKT_TYPE_VLAN_2 0x0200
drivers/net/dpaa2/dpaa2_rxtx.c +32 -0
@@ -153,6 +153,38 @@ dpaa2_dev_rx_parse_new(struct dpaa2_dev_priv *priv, m->packet_type =RTE_PTYPE_L2_ETHER |RTE_PTYPE_L3_IPV6 ;break ; +case DPAA2_PKT_TYPE_IPV4_FRAG : + m->packet_type =RTE_PTYPE_L2_ETHER | +RTE_PTYPE_L3_IPV4 |RTE_PTYPE_L4_FRAG ; +break ; +case DPAA2_PKT_TYPE_IPV6_FRAG : + m->packet_type =RTE_PTYPE_L2_ETHER | +RTE_PTYPE_L3_IPV6 |RTE_PTYPE_L4_FRAG ; +break ; +case DPAA2_PKT_TYPE_IPV4_ESP : + m->packet_type =RTE_PTYPE_L2_ETHER | +RTE_PTYPE_L3_IPV4 |RTE_PTYPE_TUNNEL_ESP ; +break ; +case DPAA2_PKT_TYPE_IPV6_ESP : + m->packet_type =RTE_PTYPE_L2_ETHER | +RTE_PTYPE_L3_IPV6 |RTE_PTYPE_TUNNEL_ESP ; +break ; +case DPAA2_PKT_TYPE_IPV4_GTPU : + m->packet_type =RTE_PTYPE_L2_ETHER | +RTE_PTYPE_L3_IPV4 |RTE_PTYPE_TUNNEL_GTPU ; +break ; +case DPAA2_PKT_TYPE_IPV6_GTPU : + m->packet_type =RTE_PTYPE_L2_ETHER | +RTE_PTYPE_L3_IPV6 |RTE_PTYPE_TUNNEL_GTPU ; +break ; +case DPAA2_PKT_TYPE_IPV4_GTPC : + m->packet_type =RTE_PTYPE_L2_ETHER | +RTE_PTYPE_L3_IPV4 |RTE_PTYPE_TUNNEL_GTPC ; +break ; +case DPAA2_PKT_TYPE_IPV6_GTPC : + m->packet_type =RTE_PTYPE_L2_ETHER | +RTE_PTYPE_L3_IPV6 |RTE_PTYPE_TUNNEL_GTPC ; +break ;case DPAA2_PKT_TYPE_ETHER : m->packet_type =RTE_PTYPE_L2_ETHER ;break ;
Signature · 1 line
2.43.0
PATCH 12/13 net/dpaa2: remove unused soft parser driver
In reply to Prashant GuptaFrom: Jun Yang <[email protected]>
Softparser only supports to be loaded before Linux starts.
--- drivers/net/dpaa2/dpaa2_ethdev.c | 28 ----- drivers/net/dpaa2/dpaa2_recycle.c | 1 - drivers/net/dpaa2/dpaa2_sparser.c | 137 -------------------- drivers/net/dpaa2/dpaa2_sparser.h | 202 ------------------------------ drivers/net/dpaa2/meson.build | 1 - 5 files changed, 369 deletions(-) delete mode 100644 drivers/net/dpaa2/dpaa2_sparser.c delete mode 100644 drivers/net/dpaa2/dpaa2_sparser.h
drivers/net/dpaa2/dpaa2_ethdev.c +0 -28
@@ -29,7 +29,6 @@#include <mc/fsl_dpmng.h> #include <mc/fsl_dpcon.h> #include "dpaa2_ethdev.h" -#include "dpaa2_sparser.h" #include <fsl_qbman_debug.h> #define DRIVER_LOOPBACK_MODE "drv_loopback"
@@ -3719,33 +3718,6 @@ dpaa2_dev_init(struct rte_eth_dev *eth_dev) } eth_dev->data->mtu =RTE_ETHER_MTU ; -/*TODO To enable soft parser support DPAA2 driver needs to integrate -* with external entity to receive byte code for software sequence -* and same will be offload to the H/W using MC interface. -* Currently it is assumed that DPAA2 driver has byte code by some -* mean and same if offloaded to H/W. -*/ -if (getenv ("DPAA2_ENABLE_SOFT_PARSER" )) { -WRIOP_SS_INITIALIZER (priv); - ret =dpaa2_eth_load_wriop_soft_parser (priv,DPNI_SS_INGRESS ); -if (ret <0 ) { -DPAA2_PMD_ERR (" Error(%d) in loading softparser" , - ret); - goto init_err; - } - - ret =dpaa2_eth_enable_wriop_soft_parser (priv, -DPNI_SS_INGRESS ); -if (ret <0 ) { -DPAA2_PMD_ERR (" Error(%d) in enabling softparser" , - ret); - goto init_err; - } - } - - ret =dpaa2_soft_parser_loaded (); -if (ret >0 ) -DPAA2_PMD_INFO ("soft parser is loaded" );DPAA2_PMD_INFO ("%s: netdev created, connected to %s" , eth_dev->data->name, dpaa2_dev->ep_name);
drivers/net/dpaa2/dpaa2_recycle.c +0 -1
@@ -23,7 +23,6 @@#include <dpaa2_hw_dpio.h> #include <mc/fsl_dpmng.h> #include "dpaa2_ethdev.h" -#include "dpaa2_sparser.h" #include <fsl_qbman_debug.h> #include <rte_io.h>
drivers/net/dpaa2/dpaa2_sparser.c deleted +0 -137
137 lines not on this page · raw message
drivers/net/dpaa2/dpaa2_sparser.h deleted +0 -202
202 lines not on this page · raw message
drivers/net/dpaa2/meson.build +0 -1
@@ -17,7 +17,6 @@ sources = files( 'dpaa2_flow.c', 'dpaa2_recycle.c', 'dpaa2_rxtx.c', - 'dpaa2_sparser.c', 'dpaa2_ptp.c', 'mc/dprtc.c', 'mc/dpkg.c',
Signature · 1 line
2.43.0
PATCH 13/13 net/dpaa2: rename Rx queue flags
In reply to Prashant GuptaFrom: Jun Yang <[email protected]>
Rename the Rx-side device flags to a consistent DPAA2_RX_*_FLAG naming:DPAAX_RX_ERROR_QUEUE_FLAG becomes DPAA2_RX_ERROR_QUEUE_FLAG and DPAA2_DATA_STASHING_OFF becomes DPAA2_RX_DATA_STASHING_OFF_FLAG.
This is a mechanical rename with no functional change; it prepares the flag namespace for the Tx confirmation rework that follows.
--- drivers/net/dpaa2/dpaa2_ethdev.c | 10 +++++----- drivers/net/dpaa2/dpaa2_ethdev.h | 5 +++-- drivers/net/dpaa2/dpaa2_rxtx.c | 4 ++-- 3 files changed, 10 insertions(+), 9 deletions(-)
drivers/net/dpaa2/dpaa2_ethdev.c +5 -5
@@ -550,7 +550,7 @@ dpaa2_alloc_rx_tx_queues(struct rte_eth_dev *dev) goto fail; } -if (priv->flags &DPAAX_RX_ERROR_QUEUE_FLAG ) { +if (priv->flags &DPAA2_RX_ERROR_QUEUE_FLAG ) { priv->rx_err_vq =rte_zmalloc ("dpni_rx_err" ,sizeof (struct dpaa2_queue ),0 );if (!priv->rx_err_vq) {
@@ -1041,7 +1041,7 @@ dpaa2_dev_rx_queue_setup(struct rte_eth_dev *dev, options |=DPNI_QUEUE_OPT_FLC ; cfg.flc.stash_control = true;dpaa2_flc_stashing_clear_all (&cfg.flc.value); -if (priv->flags &DPAA2_DATA_STASHING_OFF ) { +if (priv->flags &DPAA2_RX_DATA_STASHING_OFF_FLAG ) {dpaa2_flc_stashing_set (DPAA2_FLC_DATA_STASHING ,0 , &cfg.flc.value); dpaa2_q->data_stashing_off =1 ;
@@ -1517,7 +1517,7 @@ dpaa2_dev_start(struct rte_eth_dev *dev) dpaa2_q->fqid = qid.fqid; } -if (priv->flags &DPAAX_RX_ERROR_QUEUE_FLAG ) { +if (priv->flags &DPAA2_RX_ERROR_QUEUE_FLAG ) { ret =dpni_get_queue (dpni,CMD_PRI_LOW , priv->token,DPNI_QUEUE_RX_ERR ,0 ,0 , &cfg, &qid);if (ret) {
@@ -3475,7 +3475,7 @@ dpaa2_dev_init(struct rte_eth_dev *eth_dev)if (dpaa2_get_devargs (dev->devargs,DRIVER_NO_DATA_STASHING ) ||getenv ("DPAA2_DATA_STASHING_OFF" )) { - priv->flags |=DPAA2_DATA_STASHING_OFF ; + priv->flags |=DPAA2_RX_DATA_STASHING_OFF_FLAG ;DPAA2_PMD_INFO ("Data stashing disabled" ); }
@@ -3582,7 +3582,7 @@ dpaa2_dev_init(struct rte_eth_dev *eth_dev) }if (dpaa2_get_devargs (dev->devargs,DRIVER_ERROR_QUEUE )) { - priv->flags |=DPAAX_RX_ERROR_QUEUE_FLAG ; + priv->flags |=DPAA2_RX_ERROR_QUEUE_FLAG ;DPAA2_PMD_INFO ("Enable error queue" ); }
drivers/net/dpaa2/dpaa2_ethdev.h +3 -2
@@ -100,9 +100,10 @@#define DPAA2_TX_DYNAMIC_CONF_ENABLE RTE_BIT32(9)/* Disable data stashing (prefetch of packet data into CPU cache) */ -#define DPAA2_DATA_STASHING_OFF RTE_BIT32(10) +#define DPAA2_RX_DATA_STASHING_OFF_FLAG RTE_BIT32(10) + +#define DPAA2_RX_ERROR_QUEUE_FLAG RTE_BIT32(11) -#define DPAAX_RX_ERROR_QUEUE_FLAG RTE_BIT32(11)#define DPAA2_RX_PRINT_PSR_RESULT_FLAG RTE_BIT32(12)/* DPDMUX index for DPMAC */
drivers/net/dpaa2/dpaa2_rxtx.c +2 -2
@@ -860,7 +860,7 @@ dpaa2_dev_prefetch_rx_common(void *queue, struct rte_mbuf **bufs, q_storage = dpaa2_q->q_storage[rte_lcore_id ()]; -if (unlikely (priv->flags &DPAAX_RX_ERROR_QUEUE_FLAG )) +if (unlikely (priv->flags &DPAA2_RX_ERROR_QUEUE_FLAG ))dump_err_pkts (priv->rx_err_vq);if (unlikely (!DPAA2_PER_LCORE_ETHRX_DPIO )) {
@@ -1132,7 +1132,7 @@ dpaa2_dev_rx_common(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts,struct rte_eth_dev_data *eth_data = dpaa2_q->eth_data;struct dpaa2_dev_priv *priv = eth_data->dev_private; -if (!by_channel &&unlikely (priv->flags &DPAAX_RX_ERROR_QUEUE_FLAG )) +if (!by_channel &&unlikely (priv->flags &DPAA2_RX_ERROR_QUEUE_FLAG ))dump_err_pkts (priv->rx_err_vq);if (by_channel) {
Signature · 1 line
2.43.0
cover net/dpaa2: bus, DMA, eventdev and datapath rework
In reply to Prashant GuptaThis is the third of four dpaa2 upstreaming sub-series, applied on top of v3-S1 and v3-S2. It reworks the fslmc bus, DMA, eventdev and the net datapath.
Highlights:
- add a DMA bypass memory translation option and optimize the Tx queue
and channel mapping;
- refresh the MC and SoC version information and identify the soft
parser protocol;
- assign the Rx CGID per traffic class and inherit the rxq config for
the event queue; - rework Tx confirmation and consume DQRR entries in batches;
- resolve the dpaa2 endpoint in the net driver and align the event port depths with the hardware rings.
Every commit builds cleanly (arm64, -Werror) and the series is bisectable.
Depends-on: series-39291 ("net/dpaa2: flow, meter and parser features")
Gagandeep Singh (2):
drivers: add dpaa2 DMA bypass memory translation option
drivers: optimize dpaa2 Tx queue and channel mapping
Jun Yang (8):
drivers: refresh dpaa2 MC and SoC version info
drivers: identify dpaa2 soft parser protocol
drivers: assign dpaa2 Rx CGID per traffic class
drivers: inherit dpaa2 rxq config for event queue
drivers: rework dpaa2 Tx confirmation
drivers: consume dpaa2 DQRR entries in batches
drivers: resolve dpaa2 endpoint in the net driver
drivers: align dpaa2 event port depths with hardware rings
doc/guides/nics/dpaa2.rst | 16 +- drivers/bus/fslmc/bus_fslmc_driver.h | 15 +- drivers/bus/fslmc/fslmc_bus.c | 93 +- drivers/bus/fslmc/fslmc_vfio.c | 193 ++- drivers/bus/fslmc/fslmc_vfio.h | 30 +- drivers/bus/fslmc/portal/dpaa2_hw_dpio.c | 83 +- drivers/bus/fslmc/portal/dpaa2_hw_dpio.h | 7 - drivers/bus/fslmc/portal/dpaa2_hw_dprc.c | 45 +- drivers/bus/fslmc/portal/dpaa2_hw_pvt.h | 7 +- drivers/bus/fslmc/private.h | 3 + .../fslmc/qbman/include/fsl_qbman_portal.h | 12 +- drivers/bus/fslmc/qbman/qbman_portal.c | 78 +- drivers/bus/fslmc/qbman/qbman_portal.h | 11 +- drivers/common/dpaax/rte_pmd_dpaax_qdma.h | 4 +- drivers/dma/dpaa2/dpaa2_qdma.c | 87 +- drivers/event/dpaa2/dpaa2_eventdev.c | 76 +- drivers/event/dpaa2/dpaa2_eventdev.h | 4 +- drivers/net/dpaa2/base/dpaa2_hw_dpni.c | 2 +- drivers/net/dpaa2/base/dpaa2_hw_dpni_annot.h | 6 +- drivers/net/dpaa2/dpaa2_ethdev.c | 516 +++--- drivers/net/dpaa2/dpaa2_ethdev.h | 38 +- drivers/net/dpaa2/dpaa2_flow.c | 129 +- drivers/net/dpaa2/dpaa2_ptp.c | 4 +- drivers/net/dpaa2/dpaa2_recycle.c | 15 +- drivers/net/dpaa2/dpaa2_rxtx.c | 1515 ++++++++--------- 25 files changed, 1579 insertions(+), 1410 deletions(-)
Signature · 1 line
2.43.0
PATCH 1/10 drivers: add dpaa2 DMA bypass memory translation option
From: Gagandeep Singh <[email protected]>
Add RTE_DPAAX_QDMA_BMT_FLAG flag to allow callers to bypass memory translation (BMT) for DMA operations. This is needed for some PCIe scenarios where IOMMU translation should be skipped.
The flag is propagated to all SG entry and FD populate helpers via a new 'bmt' parameter, defaulting to DISABLE when the flag is not set.
--- drivers/common/dpaax/rte_pmd_dpaax_qdma.h | 4 +- drivers/dma/dpaa2/dpaa2_qdma.c | 87 ++++++++++++----------- 2 files changed, 50 insertions(+), 41 deletions(-)
drivers/common/dpaax/rte_pmd_dpaax_qdma.h +3 -1
@@ -1,5 +1,5 @@/* SPDX-License-Identifier: BSD-3-Clause -* Copyright 2021-2024 NXP +* Copyright 2021-2024, 2026 NXP */ #ifndef RTE_PMD_DPAAX_QDMA_H
@@ -7,6 +7,8 @@#include <rte_compat.h> +#define RTE_DPAAX_QDMA_BMT_FLAG RTE_BIT64(7) +#define RTE_DPAAX_QDMA_COPY_IDX_OFFSET 8#define RTE_DPAAX_QDMA_SG_IDX_ADDR_ALIGN \ RTE_BIT64(RTE_DPAAX_QDMA_COPY_IDX_OFFSET)
drivers/dma/dpaa2/dpaa2_qdma.c +47 -40
248 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH 2/10 drivers: optimize dpaa2 Tx queue and channel mapping
In reply to Prashant GuptaFrom: Gagandeep Singh <[email protected]>
Allocate TX queues based on dpni attribute and align the bounds check with the RX queue logic:
- compute nb_tx_queues from num_tx_tcs * num_queues (respecting DPNI_OPT_SINGLE_SENDER) and cap at MAX_TX_QUEUES (128)
- cap nb_rx_queues at MAX_RX_QUEUES (128)
- cap num_channels at DPAA2_MAX_CHANNELS
- assign tc_index/flow_id at queue-allocation time instead of at queue-setup time
- replace the open-coded (channel << 8 | tc) with DPNI_BUILD_PARAM(channel, tc) throughout tx_queue_setup
- initialize fqid to DPAA2_INVALID_FQ_ID and use it as the already-configured guard (replacing DPAA2_INVALID_FLOW_ID)
- add a per-device tx_channels[] array for channel mapping
--- drivers/bus/fslmc/portal/dpaa2_hw_pvt.h | 1 + drivers/net/dpaa2/dpaa2_ethdev.c | 125 +++++++++++++++--------- drivers/net/dpaa2/dpaa2_ethdev.h | 5 +- 3 files changed, 84 insertions(+), 47 deletions(-)
drivers/bus/fslmc/portal/dpaa2_hw_pvt.h +1 -0
@@ -82,6 +82,7 @@#define DPAA2_DPCI_MAX_QUEUES 2#define DPAA2_INVALID_FLOW_ID 0xffff +#define DPAA2_INVALID_FQ_ID ((uint32_t)(-1))#define DPAA2_INVALID_CGID 0xff#define SEC_FLC_DHR_OUTBOUND (-114)
drivers/net/dpaa2/dpaa2_ethdev.c +80 -45
232 lines not on this page · raw message
drivers/net/dpaa2/dpaa2_ethdev.h +3 -2
@@ -30,7 +30,7 @@#define MAX_TCS DPNI_MAX_TC#define MAX_RX_QUEUES 128 -#define MAX_TX_QUEUES 16 +#define MAX_TX_QUEUES 128#define MAX_DPNI 8#define DPAA2_MAX_CHANNELS 16
@@ -457,13 +457,14 @@ struct dpaa2_dev_priv {int32_t hw_id;int32_t qdid;uint16_t token; +uint16_t tx_channels[DPAA2_MAX_CHANNELS ];uint8_t nb_tx_queues;uint8_t nb_rx_queues;uint32_t options;void *rx_vq[MAX_RX_QUEUES ];void *tx_vq[MAX_TX_QUEUES ];struct dpaa2_bp_list *bp_list;/**<Attached buffer pool list */ -void *tx_conf_vq[MAX_TX_QUEUES *DPAA2_MAX_CHANNELS ]; +void *tx_conf_vq[MAX_TX_QUEUES ];void *rx_err_vq;uint32_t flags;/*dpaa2 config flags */ int psr_dynfield_offset;
Signature · 1 line
2.43.0
PATCH 3/10 drivers: refresh dpaa2 MC and SoC version info
In reply to Prashant GuptaFrom: Jun Yang <[email protected]>
Fix MC revision typo to correct major to minor. Get MC/SoC rev info only once and save them in bus info as well as other information to reduce replicated variables.
--- drivers/bus/fslmc/bus_fslmc_driver.h | 12 +- drivers/bus/fslmc/fslmc_bus.c | 2 + drivers/bus/fslmc/fslmc_vfio.c | 193 ++++++++++++++++++----- drivers/bus/fslmc/fslmc_vfio.h | 30 +++- drivers/bus/fslmc/portal/dpaa2_hw_dpio.c | 79 +--------- drivers/bus/fslmc/portal/dpaa2_hw_dpio.h | 7 - drivers/bus/fslmc/private.h | 3 + drivers/net/dpaa2/dpaa2_ethdev.c | 18 +-- drivers/net/dpaa2/dpaa2_ethdev.h | 1 + drivers/net/dpaa2/dpaa2_rxtx.c | 10 +- 10 files changed, 219 insertions(+), 136 deletions(-)
drivers/bus/fslmc/bus_fslmc_driver.h +11 -1
@@ -1,6 +1,6 @@/* SPDX-License-Identifier: BSD-3-Clause * -* Copyright 2016,2021-2023 NXP +* Copyright 2016,2021-2026 NXP * */
@@ -89,6 +89,14 @@ enum rte_dpaa2_dev_type { DPAA2_DEVTYPE_MAX, }; +struct rte_fslmc_bus_info { +void *mem_pool; +int sp_protocol; +uint64_t mc_rev; +uint32_t svr; +uint32_t pvr; +}; +/** * A structure describing a DPAA2 device. */
@@ -102,6 +110,8 @@ struct rte_dpaa2_device {char ep_name[RTE_DEV_NAME_MAX_LEN ];struct rte_intr_handle *intr_handle;/**< Interrupt handle */ char name[FSLMC_OBJECT_MAX_LEN ];/**< DPAA2 Object name*/ +struct rte_dma_dev *dmadev;/**< DMA device */ +const struct rte_fslmc_bus_info *bus_info; }; typedef int (*rte_dpaa2_obj_create_t)(int vdev_fd,
drivers/bus/fslmc/fslmc_bus.c +2 -0
@@ -29,6 +29,7 @@struct rte_bus rte_fslmc_bus;static int fslmc_bus_device_count[DPAA2_DEVTYPE_MAX ]; +struct rte_fslmc_bus_info fslmc_bus_info;#define DPAA2_SEQN_DYNFIELD_NAME "dpaa2_seqn_dynfield"RTE_EXPORT_INTERNAL_SYMBOL (dpaa2_seqn_dynfield_offset)
@@ -199,6 +200,7 @@ scan_one_fslmc_device(char *dev_name) goto cleanup; } dev->device.devargs =rte_bus_find_devargs (&rte_fslmc_bus, dev_name); + dev->bus_info = &fslmc_bus_info;/* Update the device found into the device_count table */ fslmc_bus_device_count[dev->dev_type]++;
drivers/bus/fslmc/fslmc_vfio.c +155 -38
300 lines not on this page · raw message
drivers/bus/fslmc/fslmc_vfio.h +29 -1
@@ -1,7 +1,7 @@/* SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 2015-2016 Freescale Semiconductor, Inc. All rights reserved. -* Copyright 2016,2019-2023 NXP +* Copyright 2016,2019-2026 NXP * */
@@ -9,6 +9,8 @@#define _FSLMC_VFIO_H_#include <rte_compat.h> +#include <rte_vfio.h> +#include <rte_interrupts.h> /* Pathname of FSL-MC devices directory. */ #define SYSFS_FSL_MC_DEVICES "/sys/bus/fsl-mc/devices"
@@ -44,6 +46,30 @@ struct fslmc_vfio_container {extern char *fslmc_container; +extern uint32_t dpaa2_svr_family; +extern uint32_t dpaa2_dqrr_size; +extern uint32_t dpaa2_eqcr_size; +extern uint32_t dpaa2_cluster_base; +extern uint32_t dpaa2_cluster_size; + +#define DPAA2_SVR_MASK 0xffff0000 + +#define SVR_LS1080A 0x87030000 +#define SVR_LS2080A 0x87010000 +#define SVR_LS2088A 0x87090000 +#define SVR_LX2160A 0x87360000 + +#define MC_MAJOR_OFFSET 32 +#define MC_MINOR_OFFSET 16 +#define MC_MINOR_MASK ((((uint64_t)1) << (MC_MAJOR_OFFSET - MC_MINOR_OFFSET)) - 1) +#define MC_REVISION_MASK ((((uint64_t)1) << MC_MINOR_OFFSET) - 1) +#define RTE_FSL_MC_REV (major, minor, revision) \ + ((((uint64_t)(major)) << MC_MAJOR_OFFSET) + \ + (((uint64_t)(minor)) << MC_MINOR_OFFSET) + (revision)) +#define RTE_FSL_MC_REV_MAJOR (rev) ((uint32_t)((rev) >> MC_MAJOR_OFFSET)) +#define RTE_FSL_MC_REV_MINOR (rev) ((uint32_t)(((rev) >> MC_MINOR_OFFSET) & MC_MINOR_MASK)) +#define RTE_FSL_MC_REV_REVISION (rev) ((uint32_t)((rev) & MC_REVISION_MASK)) +__rte_internal int rte_dpaa2_intr_enable(struct rte_intr_handle *intr_handle, int index);
@@ -60,4 +86,6 @@ int fslmc_vfio_close_group(void);char *fslmc_get_container (void );int fslmc_get_container_group (const char *group_name,int *gropuid);int fslmc_vfio_dmamap (void ); +int fslmc_vfio_core_cluster_sdest (uint32_t cpu_id); +#endif /* _FSLMC_VFIO_H_ */
drivers/bus/fslmc/portal/dpaa2_hw_dpio.c +5 -74
119 lines not on this page · raw message
drivers/bus/fslmc/portal/dpaa2_hw_dpio.h +0 -7
@@ -35,13 +35,6 @@ RTE_DECLARE_PER_LCORE(struct dpaa2_io_portal_t, _dpaa2_io);#define DPAA2_PER_LCORE_DQRR_MBUF (i) \ RTE_PER_LCORE(_dpaa2_io).dpio_dev->dpaa2_held_bufs.mbuf[i] -/* Variable to store DPAA2 DQRR size */ -extern uint8_t dpaa2_dqrr_size; -/* Variable to store DPAA2 EQCR size */ -extern uint8_t dpaa2_eqcr_size; - -extern struct dpaa2_io_portal_t dpaa2_io_portal[RTE_MAX_LCORE ]; -/* Affine a DPIO portal to current processing thread */ __rte_internal int dpaa2_affine_qbman_swp(void);
drivers/bus/fslmc/private.h +3 -0
@@ -11,4 +11,7 @@extern struct rte_bus rte_fslmc_bus; +/* MC/SoC version and capability info, shared by the bus and VFIO code. */ +extern struct rte_fslmc_bus_info fslmc_bus_info; +#endif /* BUS_FSLMC_PRIVATE_H */
drivers/net/dpaa2/dpaa2_ethdev.c +8 -10
@@ -329,24 +329,21 @@ dpaa2_fw_version_get(struct rte_eth_dev *dev, char *fw_version, size_t fw_size) { int ret; +uint32_t major, minor, rev; +struct dpaa2_dev_priv *priv = dev->data->dev_private;struct fsl_mc_io *dpni = dev->process_private;struct mc_soc_version mc_plat_info = {0 }; -struct mc_version mc_ver_info = {0 };PMD_INIT_FUNC_TRACE (); + major =RTE_FSL_MC_REV_MAJOR (priv->mc_rev); + minor =RTE_FSL_MC_REV_MINOR (priv->mc_rev); + rev =RTE_FSL_MC_REV_REVISION (priv->mc_rev);if (mc_get_soc_version (dpni,CMD_PRI_LOW , &mc_plat_info))DPAA2_PMD_WARN ("\tmc_get_soc_version failed" ); -if (mc_get_version (dpni,CMD_PRI_LOW , &mc_ver_info)) -DPAA2_PMD_WARN ("\tmc_get_version failed" ); - - ret =snprintf (fw_version, fw_size, -"%x-%d.%d.%d" , - mc_plat_info.svr, - mc_ver_info.major, - mc_ver_info.minor, - mc_ver_info.revision); + ret =snprintf (fw_version, fw_size,"%x-%d.%d.%d" , + mc_plat_info.svr, major, minor, rev);if (ret <0 )return -EINVAL ;
@@ -3539,6 +3536,7 @@ dpaa2_dev_init(struct rte_eth_dev *eth_dev) goto init_err; } + priv->mc_rev = dpaa2_dev->bus_info->mc_rev; priv->num_rx_tc = attr.num_rx_tcs; priv->num_tx_tc = attr.num_tx_tcs; priv->qos_entries = attr.qos_entries;
drivers/net/dpaa2/dpaa2_ethdev.h +1 -0
@@ -529,6 +529,7 @@ struct dpaa2_dev_priv {uint32_t *cnt_idx_dma_mem;uint64_t *cnt_values_dma_mem;uint64_t cnt_idx_iova, cnt_values_iova; +uint64_t mc_rev;struct dpaa2_dev_flow *curr; LIST_HEAD(, dpaa2_dev_flow) flows;
drivers/net/dpaa2/dpaa2_rxtx.c +5 -5
@@ -1123,9 +1123,9 @@ dpaa2_dev_rx_common(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts,/* Function receive frames for a given device and VQ */ struct dpaa2_queue *dpaa2_q = queue;struct qbman_result *dq_storage; -uint32_t fqid = dpaa2_q->fqid; -int ret, num_rx =0 , next_pull = nb_pkts, num_pulled; -uint8_t pending, status; +uint32_t fqid = dpaa2_q->fqid, next_pull = nb_pkts; +int ret; +uint8_t pending, status, num_rx =0 , num_pulled;struct qbman_swp *swp;const struct qbman_fd *fd;struct qbman_pull_desc pulldesc;
@@ -1269,8 +1269,8 @@ uint16_t dpaa2_dev_tx_conf(void *queue)struct dpaa2_queue *dpaa2_q = (struct dpaa2_queue *)queue;struct qbman_result *dq_storage;uint32_t fqid = dpaa2_q->fqid; -int ret, num_tx_conf =0 , num_pulled; -uint8_t pending, status; +int ret, num_tx_conf =0 ; +uint8_t pending, status, num_pulled;struct qbman_swp *swp;const struct qbman_fd *fd;struct qbman_pull_desc pulldesc;
Signature · 1 line
2.43.0
Re: [PATCH v3-S3 03/10] drivers: refresh dpaa2 MC and SoC version info
drivers/bus/fslmc/bus_fslmc_driver.h struct rte_dpaa2_device { · line 115
Quoted 7 lines · Prashant Gupta
drivers/bus/fslmc/bus_fslmc_driver.h +2
-0@@ -102,6 +110,8 @@ struct rte_dpaa2_device {char ep_name[RTE_DEV_NAME_MAX_LEN ];struct rte_intr_handle *intr_handle;/**< Interrupt handle */ char name[FSLMC_OBJECT_MAX_LEN ];/**< DPAA2 Object name*/ +struct rte_dma_dev *dmadev;/**< DMA device */ +const struct rte_fslmc_bus_info *bus_info; };
No dmadev back reference in the bus device object.
Thanks.
Signature · 1 line
David Marchand
PATCH 4/10 drivers: identify dpaa2 soft parser protocol
In reply to Prashant GuptaFrom: Jun Yang <[email protected]>
Identify if soft parser protocol firmware is loaded by checking firmware magic number.
Enable flow/parser of ECPRI, GENEVE, ROCEv2 and VXLAN's spec only with soft parser protocol firmware being loaded.
--- drivers/bus/fslmc/fslmc_bus.c | 91 +++++++++++++++++++++- drivers/net/dpaa2/dpaa2_ethdev.c | 2 + drivers/net/dpaa2/dpaa2_flow.c | 129 ++++++++----------------------- drivers/net/dpaa2/dpaa2_rxtx.c | 10 +++ 4 files changed, 134 insertions(+), 98 deletions(-)
drivers/bus/fslmc/fslmc_bus.c +90 -1
@@ -1,6 +1,6 @@/* SPDX-License-Identifier: BSD-3-Clause * -* Copyright 2016,2018-2021 NXP +* Copyright 2016,2018-2026 NXP * */
@@ -8,6 +8,7 @@#include <dirent.h> #include <stdalign.h> #include <stdbool.h> +#include <sys/mman.h> #include <eal_export.h> #include <rte_log.h>
@@ -35,6 +36,93 @@ struct rte_fslmc_bus_info fslmc_bus_info;RTE_EXPORT_INTERNAL_SYMBOL (dpaa2_seqn_dynfield_offset) int dpaa2_seqn_dynfield_offset = -1; +/** For LX2160A, LS2088A and LS1088A*/ +#define WRIOP_CCSR_BASE 0x8b80000 +#define WRIOP_CCSR_CTLU_OFFSET 0 +#define WRIOP_CCSR_CTLU_PARSER_OFFSET 0 +#define WRIOP_CCSR_CTLU_PARSER_INGRESS_OFFSET 0 + +#define WRIOP_INGRESS_PARSER_PHY \ + (WRIOP_CCSR_BASE + WRIOP_CCSR_CTLU_OFFSET + \ + WRIOP_CCSR_CTLU_PARSER_OFFSET + \ + WRIOP_CCSR_CTLU_PARSER_INGRESS_OFFSET) + +struct __rte_packed_begin dpaa2_parser_ccsr { +uint32_t psr_cfg; +uint32_t psr_idle; +uint32_t psr_pclm; +uint8_t psr_ver_min; +uint8_t psr_ver_maj; +uint8_t psr_id1_l; +uint8_t psr_id1_h; +uint32_t psr_rev2; +uint8_t rsv[0x2c ]; +uint8_t sp_ins[4032 ]; +} __rte_packed_end; + +#define SP_PROTOCOL_MAGIC_DATA 0xabcd +#define SP_PROTOCOL_MAGIC_OFFSET 0x4 + +/** Number of soft parser firmware bytes reported for debugging. */ +#define SP_PRINT_LEN 128 +/** Firmware bytes logged per debug line. */ +#define SP_DUMP_BYTES_PER_LINE 16 + +static void +fslmc_soft_parser_protocol_supported (void ) +{ +int fd, i, pos =0 ; +void *map_addr =NULL ; +const struct dpaa2_parser_ccsr *parser_ccsr =NULL ; +const uint16_t *magic_num; +char line[SP_DUMP_BYTES_PER_LINE *3 +1 ]; + + fd =open ("/dev/mem" ,O_RDWR |O_SYNC ); +if (fd <0 ) { +DPAA2_BUS_ERR ("open \"/dev/mem\" ERROR(%d)" , fd); + goto exit; + } + + map_addr =mmap (NULL ,sizeof (struct dpaa2_parser_ccsr ), +PROT_READ |PROT_WRITE ,MAP_SHARED , fd, +WRIOP_INGRESS_PARSER_PHY ); + parser_ccsr = map_addr; +if (!parser_ccsr) { +DPAA2_BUS_ERR ("Map 0x%" PRIx64"(size=0x%zx) failed" , + (uint64_t )WRIOP_INGRESS_PARSER_PHY , +sizeof (struct dpaa2_parser_ccsr )); + goto exit; + } + +DPAA2_BUS_DEBUG ("Soft ParserID:0x%02x%02x, Rev:maj(%02x), min(%02x)" , + parser_ccsr->psr_id1_h, parser_ccsr->psr_id1_l, + parser_ccsr->psr_ver_maj, parser_ccsr->psr_ver_min); + + magic_num = (const void *)&parser_ccsr->sp_ins[SP_PROTOCOL_MAGIC_OFFSET ]; +if (*magic_num ==SP_PROTOCOL_MAGIC_DATA ) { + fslmc_bus_info.sp_protocol = true; +DPAA2_BUS_INFO ("Soft parser protocol support." ); +DPAA2_BUS_DEBUG ("First %d bytes of sp protocol firmware:" , +SP_PRINT_LEN ); +for (i =0 ; i <SP_PRINT_LEN ; i++) { + pos +=snprintf (&line[pos],sizeof (line) - pos, +"%02x " , parser_ccsr->sp_ins[i]); +if ((i +1 ) %SP_DUMP_BYTES_PER_LINE ==0 ) { +DPAA2_BUS_DEBUG ("%s" , line); + pos =0 ; + } + } +if (pos) +DPAA2_BUS_DEBUG ("%s" , line); + } + +exit: +if (map_addr) +munmap (map_addr,sizeof (struct dpaa2_parser_ccsr )); +if (fd >=0 ) +close (fd); +} +RTE_EXPORT_INTERNAL_SYMBOL (rte_fslmc_get_device_count) uint32_trte_fslmc_get_device_count (enum rte_dpaa2_dev_type device_type)
@@ -345,6 +433,7 @@ rte_fslmc_scan(void)DPAA2_BUS_ERR ("Unable to open VFIO group directory" ); goto scan_fail; } +fslmc_soft_parser_protocol_supported ();/* Scan the DPRC container object */ ret =scan_one_fslmc_device (group_name);
drivers/net/dpaa2/dpaa2_ethdev.c +2 -0
@@ -3751,6 +3751,8 @@ dpaa2_dev_init(struct rte_eth_dev *eth_dev) } eth_dev->data->mtu =RTE_ETHER_MTU ; + priv->sp_protocol = dpaa2_dev->bus_info->sp_protocol; +DPAA2_PMD_INFO ("%s: netdev created, connected to %s" , eth_dev->data->name, dpaa2_dev->ep_name);
drivers/net/dpaa2/dpaa2_flow.c +32 -97
219 lines not on this page · raw message
drivers/net/dpaa2/dpaa2_rxtx.c +10 -0
@@ -128,6 +128,16 @@ dpaa2_dev_rx_parse_new(struct dpaa2_dev_priv *priv, ext_packet_type |=RTE_PTYPE_INNER_L3_IPV4 ; } } +if (priv->sp_protocol) { +if (frc_parse->fafe2) { + frc_parse->fafe2 =0 ; + ext_packet_type |=RTE_PTYPE_TUNNEL_GENEVE ; + } +if (frc_parse->sum_l.l4.fafe3) { + frc_parse->sum_l.l4.fafe3 =0 ; + ext_packet_type |=RTE_PTYPE_INNER_L3_IPV4 ; + } + }switch (frc) {case DPAA2_PKT_TYPE_IPV4_UDP : m->packet_type = RTE_PTYPE_L2_ETHER |
Signature · 1 line
2.43.0
PATCH 5/10 drivers: assign dpaa2 Rx CGID per traffic class
In reply to Prashant GuptaFrom: Jun Yang <[email protected]>
RXQs in same TC should use same CGID for congestion set.
--- drivers/bus/fslmc/portal/dpaa2_hw_pvt.h | 3 +- drivers/net/dpaa2/dpaa2_ethdev.c | 252 ++++++++++++------------ drivers/net/dpaa2/dpaa2_ethdev.h | 3 +- 3 files changed, 126 insertions(+), 132 deletions(-)
drivers/bus/fslmc/portal/dpaa2_hw_pvt.h +2 -1
@@ -176,7 +176,6 @@ struct __rte_cache_aligned dpaa2_queue {uint32_t fqid;/*!< Unique ID of this queue */ uint16_t flow_id;/*!< To be used by DPAA2 framework */ uint8_t tc_index;/*!< traffic class identifier */ -uint8_t cgid;/*! < Congestion Group id for this queue */ uint64_t rx_pkts;uint64_t tx_pkts;uint64_t err_pkts;
@@ -186,6 +185,8 @@ struct __rte_cache_aligned dpaa2_queue {/**Egress*/ struct qbman_result *cscn; }; +void *cfg; +uint8_t options;struct rte_event ev;dpaa2_queue_cb_dqrr_t *cb;dpaa2_queue_cb_eqresp_free_t *cb_eqresp_free;
drivers/net/dpaa2/dpaa2_ethdev.c +122 -130
408 lines not on this page · raw message
drivers/net/dpaa2/dpaa2_ethdev.h +2 -1
@@ -479,7 +479,8 @@ struct dpaa2_dev_priv {uint8_t en_ordered;uint8_t en_loose_ordered;uint8_t max_cgs; -uint8_t cgid_in_use[MAX_RX_QUEUES ]; +/** RXQs in same TC share same cgid.*/ +uint8_t cgid_in_use[MAX_TCS ];rte_spinlock_t meter_lock;/* Lowest priority FS flow id to receive flow steering miss frames. */ uint16_t default_flow;
Signature · 1 line
2.43.0
PATCH 6/10 drivers: inherit dpaa2 rxq config for event queue
In reply to Prashant GuptaFrom: Jun Yang <[email protected]>
The configuration parameter in event queue attachment should use flc and cgid configured in rxq setup.
--- drivers/bus/fslmc/portal/dpaa2_hw_pvt.h | 2 +- drivers/net/dpaa2/dpaa2_ethdev.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-)
drivers/bus/fslmc/portal/dpaa2_hw_pvt.h +1 -1
@@ -1,7 +1,7 @@/* SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 2016 Freescale Semiconductor, Inc. All rights reserved. -* Copyright 2016-2024 NXP +* Copyright 2016-2025 NXP * */
drivers/net/dpaa2/dpaa2_ethdev.c +2 -1
@@ -2817,11 +2817,12 @@ int dpaa2_eth_eventq_attach(const struct rte_eth_dev *dev,struct dpaa2_dev_priv *eth_priv = dev->data->dev_private;struct fsl_mc_io *dpni = (struct fsl_mc_io *)dev->process_private;struct dpaa2_queue *dpaa2_ethq = eth_priv->rx_vq[eth_rx_queue_id]; -uint8_t flow_id = dpaa2_ethq->flow_id; +uint8_t flow_id;struct dpni_queue *cfg;uint8_t options, priority;int ret; + flow_id = dpaa2_ethq->flow_id; cfg = dpaa2_ethq->cfg;if (queue_conf->ev.sched_type ==RTE_SCHED_TYPE_PARALLEL )
Signature · 1 line
2.43.0
Re: [PATCH v3-S3 06/10] drivers: inherit dpaa2 rxq config for event queue
Quoted 33 lines · Prashant Gupta
From: Jun Yang <[email protected]>
The configuration parameter in event queue attachment should use flc and cgid configured in rxq setup.
Signed-off-by Jun Yang <[email protected]>--- drivers/bus/fslmc/portal/dpaa2_hw_pvt.h | 2 +- drivers/net/dpaa2/dpaa2_ethdev.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-)drivers/bus/fslmc/portal/dpaa2_hw_pvt.h +1
-1@@ -1,7 +1,7 @@/* SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 2016 Freescale Semiconductor, Inc. All rights reserved. -* Copyright 2016-2024 NXP +* Copyright 2016-2025 NXP * */ drivers/net/dpaa2/dpaa2_ethdev.c +0
-0@@ -2817,11 +2817,12 @@ int dpaa2_eth_eventq_attach(const struct rte_eth_dev *dev,struct dpaa2_dev_priv *eth_priv = dev->data->dev_private;struct fsl_mc_io *dpni = (struct fsl_mc_io *)dev->process_private;struct dpaa2_queue *dpaa2_ethq = eth_priv->rx_vq[eth_rx_queue_id];
drivers/net/dpaa2/dpaa2_ethdev.c int dpaa2_eth_eventq_attach(const struct rte_eth_dev *dev, · line 2828
Quoted 10 lines
drivers/net/dpaa2/dpaa2_ethdev.c +2
-1-uint8_t flow_id = dpaa2_ethq->flow_id; +uint8_t flow_id;struct dpni_queue *cfg;uint8_t options, priority;int ret; + flow_id = dpaa2_ethq->flow_id; cfg = dpaa2_ethq->cfg;if (queue_conf->ev.sched_type ==RTE_SCHED_TYPE_PARALLEL )
This patch looks like a noop.
Signature · 1 line
David Marchand
PATCH 7/10 drivers: rework dpaa2 Tx confirmation
In reply to Prashant GuptaFrom: Jun Yang <[email protected]>
Mbufs released by Tx confirmation may come from any mempool, so use the RTE mbuf free API instead of returning the buffers directly to the bman pool. The FD FLC field now carries the Tx mbuf pointer so that the confirmation callback can release it to either the platform pool or an external pool.
Absolute and dynamic Tx confirmation become independent settings, giving three Tx modes:
1) No confirmation (default). Suited to traffic that is mostly sent from the platform pool. For the few packets from other pools the driver allocates a platform buffer, copies the data and frees the original.
2) Absolute confirmation. Suited to traffic mostly sent from non platform pools. Every Tx packet raises a confirmation, configured at queue setup, and the callback frees the packet.
3) Dynamic confirmation. Confirmation is raised only for packets from non platform pools; the driver marks each packet accordingly at runtime. This suits a roughly even mix of platform and non platform buffers.
--- doc/guides/nics/dpaa2.rst | 16 +- drivers/bus/fslmc/portal/dpaa2_hw_pvt.h | 1 + drivers/net/dpaa2/base/dpaa2_hw_dpni.c | 2 +- drivers/net/dpaa2/base/dpaa2_hw_dpni_annot.h | 6 +- drivers/net/dpaa2/dpaa2_ethdev.c | 63 +- drivers/net/dpaa2/dpaa2_ethdev.h | 29 +- drivers/net/dpaa2/dpaa2_ptp.c | 4 +- drivers/net/dpaa2/dpaa2_rxtx.c | 1499 ++++++++---------- 8 files changed, 748 insertions(+), 872 deletions(-)
doc/guides/nics/dpaa2.rst +14 -2
@@ -477,10 +477,22 @@ Refer to the document :doc:`build_and_test` for details. of the packet pull command which is issued in the previous cycle. e.g. ``fslmc:dpni.1,drv_no_prefetch=1`` -* Use dev arg option ``drv_tx_conf=1`` to enable TX confirmation mode. - In this mode tx conf queues need to be polled to free the buffers. +* Use dev arg option ``drv_tx_conf=1`` to enable absolute TX confirmation mode. + In this mode every transmitted buffer is returned on a tx conf queue which + needs to be polled to free the buffers. e.g. ``fslmc:dpni.1,drv_tx_conf=1`` +* Use dev arg option ``drv_tx_dyn_conf=1`` to enable dynamic TX confirmation + mode. In this mode only buffers that cannot be released directly by the + hardware (for example indirect, external or shared buffers) are returned on + a tx conf queue which needs to be polled to free the buffers. + e.g. ``fslmc:dpni.1,drv_tx_dyn_conf=1`` + +* Use dev arg option ``drv_tx_dyn_conf_pre=1`` to prefetch the dynamic TX + confirmation queue before transmit. It is used together with + ``drv_tx_dyn_conf=1``. + e.g. ``fslmc:dpni.1,drv_tx_dyn_conf=1,drv_tx_dyn_conf_pre=1`` + * Use dev arg option ``drv_rx_parse_drop=1`` to configure the system to start dropping the error packets in hardware (parse errors). e.g. ``fslmc:dpni.1,drv_rx_parse_drop=1``
drivers/bus/fslmc/portal/dpaa2_hw_pvt.h +1 -0
@@ -198,6 +198,7 @@ struct __rte_cache_aligned dpaa2_queue {uint16_t tm_sw_td;/*!< TM software taildrop */ uint64_t offloads;uint64_t lpbk_cntx; +int32_t ts_to_cnfd;uint8_t data_stashing_off;/* NAPI rx-interrupt: per-queue DPCON bound to this FQ at dev_start * (DEST_DPCON, static); the polling worker points the channel's CDAN at
drivers/net/dpaa2/base/dpaa2_hw_dpni.c +1 -1
@@ -484,7 +484,7 @@ dpaa2_attach_bp_list(struct dpaa2_dev_priv *priv,*/ /* ... rx buffer layout ... */ -if (priv->flags &DPAA2_TX_DYNAMIC_CONF_ENABLE ) { +if (priv->flags &DPAA2_TX_PREFETCH_DYNAMIC_CONF ) {int out_min_hdr_room, in_min_hdr_room;/** Additional headroom layout for IPSec with TX configure * dynamic enabled.
drivers/net/dpaa2/base/dpaa2_hw_dpni_annot.h +5 -1
@@ -1,7 +1,7 @@/* SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 2016 Freescale Semiconductor, Inc. All rights reserved. -* Copyright 2016,2019,2022,2024 NXP +* Copyright 2016,2019,2022,2024-2026 NXP * */
@@ -281,6 +281,10 @@ struct dpaa2_faead {/*UPD (Update prepended data)*/ #define DPAA2_ANNOT_FAEAD_UPD 0x00000010 +#define DPAA2_TX_CONFIRM_ENABLE \ + (DPAA2_ANNOT_FAEAD_A4V | DPAA2_ANNOT_FAEAD_EBDD | \ + DPAA2_ANNOT_FAEAD_EBDDV) +/* Debug frame, otherwise supposed to be discarded */ #define DPAA2_ETH_FAS_DISC 0x80000000/* MACSEC frame */
drivers/net/dpaa2/dpaa2_ethdev.c +37 -26
141 lines not on this page · raw message
drivers/net/dpaa2/dpaa2_ethdev.h +19 -10
@@ -91,18 +91,14 @@#define DPAA2_TX_DPNI_LOOPBACK_MODE RTE_BIT32(7) -/* Tx confirmation enabled */ -#define DPAA2_TX_CONF_ENABLE RTE_BIT32(8) +#define DPAA2_TX_PREFETCH_DYNAMIC_CONF RTE_BIT32(8) -/* Tx dynamic confirmation enabled, -* only valid with Tx confirmation enabled. -*/ -#define DPAA2_TX_DYNAMIC_CONF_ENABLE RTE_BIT32(9) +#define DPAA2_RX_ERROR_QUEUE_FLAG RTE_BIT32(9)/* Disable data stashing (prefetch of packet data into CPU cache) */ #define DPAA2_RX_DATA_STASHING_OFF_FLAG RTE_BIT32(10) -#define DPAA2_RX_ERROR_QUEUE_FLAG RTE_BIT32(11) +#define DPAA2_RX_SCHED_STRICT_ORDER_FLAG RTE_BIT32(11)#define DPAA2_RX_PRINT_PSR_RESULT_FLAG RTE_BIT32(12)
@@ -452,6 +448,12 @@ struct dpaa2_dev_meter {uint32_t policy_id; }; +enum dpaa2_tx_conf_type { +DPAA2_TX_NO_CONF , +DPAA2_TX_ABSOLUTE_CONF , +DPAA2_TX_DYNAMIC_CONF +}; +struct dpaa2_dev_priv {void *hw;int32_t hw_id;
@@ -467,6 +469,7 @@ struct dpaa2_dev_priv {void *tx_conf_vq[MAX_TX_QUEUES ];void *rx_err_vq;uint32_t flags;/*dpaa2 config flags */ +enum dpaa2_tx_conf_type tx_conf_type;int psr_dynfield_offset;uint8_t max_mac_filters;uint8_t max_vlan_filters;
@@ -511,10 +514,10 @@ struct dpaa2_dev_priv {int rx_ts_offset;uint64_t rx_ts_flag; -/* stores pointer to next tx_conf queue that should be processed, +/* stores next tx queue to be confirmed that should be processed, * it corresponds to last packet transmitted */ -struct dpaa2_queue *next_tx_conf_queue; +struct dpaa2_queue *next_txq_to_cnf;struct rte_eth_dev *eth_dev;/**< Pointer back to holding ethdev */ rte_spinlock_t lpbk_qp_lock;
@@ -647,7 +650,7 @@ uint16_t dpaa2_dev_tx_multi_txq_ordered(void **queue,void dpaa2_dev_free_eqresp_buf (uint16_t eqresp_ci,struct dpaa2_queue *dpaa2_q);void dpaa2_flow_clean (struct rte_eth_dev *dev); -uint16_t dpaa2_dev_tx_conf(void *queue) __rte_unused; +uint16_t dpaa2_dev_tx_conf (void *txq,int drain);int dpaa2_timesync_enable (struct rte_eth_dev *dev);int dpaa2_timesync_disable (struct rte_eth_dev *dev);
@@ -664,6 +667,12 @@ int dpaa2_timesync_read_tx_timestamp(struct rte_eth_dev *dev,int dpaa2_dev_recycle_config (struct rte_eth_dev *eth_dev);int dpaa2_dev_recycle_deconfig (struct rte_eth_dev *eth_dev); + +struct rte_mbuf *__rte_hot +dpaa2_eth_fd_to_mbuf (struct dpaa2_dev_priv *priv,const struct qbman_fd *fd); +struct rte_mbuf *__rte_hot +dpaa2_eth_sg_fd_to_mbuf (struct dpaa2_dev_priv *priv,const struct qbman_fd *fd); +int dpaa2_mtr_ops_get (struct rte_eth_dev *dev,void *ops);int dpaa2_soft_parser_loaded (void );
drivers/net/dpaa2/dpaa2_ptp.c +2 -2
@@ -111,9 +111,9 @@ int dpaa2_timesync_read_tx_timestamp(struct rte_eth_dev *dev, {struct dpaa2_dev_priv *priv = dev->data->dev_private; -if (priv->next_tx_conf_queue) { +if (priv->next_txq_to_cnf) {while (!priv->tx_timestamp) -dpaa2_dev_tx_conf (priv->next_tx_conf_queue); +dpaa2_dev_tx_conf (priv->next_txq_to_cnf, false); }else {return -1 ; }
drivers/net/dpaa2/dpaa2_rxtx.c +669 -830
1,773 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH 8/10 drivers: consume dpaa2 DQRR entries in batches
In reply to Prashant GuptaFrom: Jun Yang <[email protected]>
Each DQRR entry consumed by the software portal costs a write to the cache-invalidate DCAP register. The DCAP register also supports a vector mode where a bitmap of DQRR indices is consumed with a single write, so accumulate the indices and flush the vector once half the ring is pending. A smaller threshold gives little benefit, and a threshold close to the ring size starves WRIOP of DQRR space.
Because entries are now released in batches, a caller that stops polling a portal must flush the pending vector explicitly. Pass a NULL dequeue result to qbman_swp_dqrr_consume() to do that when the eventdev dequeue finds the portal dry, when the net PMD finishes draining a portal, and when a portal is released back to the bus.
--- drivers/bus/fslmc/portal/dpaa2_hw_dpio.c | 4 ++ .../fslmc/qbman/include/fsl_qbman_portal.h | 5 +- drivers/bus/fslmc/qbman/qbman_portal.c | 63 +++++++++++++++++-- drivers/bus/fslmc/qbman/qbman_portal.h | 11 +++- drivers/event/dpaa2/dpaa2_eventdev.c | 4 ++ drivers/net/dpaa2/dpaa2_ethdev.c | 2 + 6 files changed, 81 insertions(+), 8 deletions(-)
drivers/bus/fslmc/portal/dpaa2_hw_dpio.c +4 -0
@@ -305,6 +305,10 @@ dpaa2_configure_stashing(struct dpaa2_dpio_dev *dpio_dev, int cpu_id, bool ethrxstatic void dpaa2_put_qbman_swp (struct dpaa2_dpio_dev *dpio_dev) {if (dpio_dev) { +/* consume indices may still be pending in the portal's DQRR +* consume vector; flush them before the portal is released. +*/ +qbman_swp_dqrr_consume (dpio_dev->sw_portal,NULL );/* rx-queue interrupts (net PMD) can arm a portal without the * event driver; tear it down unconditionally. Safe when never * armed: intr_deinit returns early if intr is not enabled.
drivers/bus/fslmc/qbman/include/fsl_qbman_portal.h +4 -1
@@ -451,7 +451,10 @@ void qbman_swp_prefetch_dqrr_next(struct qbman_swp *s);* qbman_swp_dqrr_consume() - Consume DQRR entries previously returned from * qbman_swp_dqrr_next(). * @s: the software portal object. -* @dq: the DQRR entry to be consumed. +* @dq: the DQRR entry to be consumed, NULL to consume the entries accumulated +* so far. Entries are accumulated and consumed in batches, so a caller which +* stops polling the portal must call this with a NULL dq to release the +* entries it has already processed. */ __rte_internal void qbman_swp_dqrr_consume(struct qbman_swp *s, const struct qbman_result *dq);
drivers/bus/fslmc/qbman/qbman_portal.c +57 -6
103 lines not on this page · raw message
drivers/bus/fslmc/qbman/qbman_portal.h +10 -1
@@ -1,7 +1,7 @@/* SPDX-License-Identifier: BSD-3-Clause * * Copyright (C) 2014-2016 Freescale Semiconductor, Inc. -* Copyright 2018-2020 NXP +* Copyright 2018-2020, 2026 NXP * */
@@ -93,6 +93,15 @@ struct qbman_swp {uint32_t valid_bit;uint8_t dqrr_size;int reset_bug; +/* Consume index vector: instead of writing DCAP once per +* consumed entry, the indices are accumulated in ci_vector +* and written with a single DCAP access once ci_count +* reaches ci_flush_th. +*/ +bool ci_vec_en; +uint8_t ci_count; +uint8_t ci_flush_th; +uint32_t ci_vector; } dqrr;struct {uint32_t pi;
drivers/event/dpaa2/dpaa2_eventdev.c +4 -0
@@ -320,6 +320,10 @@ dpaa2_eventdev_dequeue_burst(void *port, struct rte_event ev[], do { dq = qbman_swp_dqrr_next(swp); if (!dq) { + /* portal is dry: consume whatever is still pending in + * the DQRR consume vector before leaving it idle. + */ + qbman_swp_dqrr_consume(swp, NULL); if (!num_pkts && timeout_ticks) { dpaa2_eventdev_dequeue_wait(timeout_ticks); timeout_ticks = 0;
drivers/net/dpaa2/dpaa2_ethdev.c +2 -0
@@ -3041,6 +3041,8 @@ dpaa2_napi_drain_portal(struct dpaa2_dpio_dev *dpio)while ((dq =qbman_swp_dqrr_next (dpio->sw_portal)))qbman_swp_dqrr_consume (dpio->sw_portal, dq); +/* flush the indices still pending in the DQRR consume vector */ +qbman_swp_dqrr_consume (dpio->sw_portal,NULL );qbman_swp_interrupt_clear_status (dpio->sw_portal,0xffffffff ); }
Signature · 1 line
2.43.0
PATCH 9/10 drivers: resolve dpaa2 endpoint in the net driver
In reply to Prashant GuptaFrom: Jun Yang <[email protected]>
The DPRC object driver walked every device on the bus and, for each DPNI, issued dprc_get_connection() to find the object it is wired to. Two things are wrong with that. The bus keeps the result in struct rte_dpaa2_device even though only the net driver consumes it, and a failure to resolve one DPNI's endpoint aborted the creation of the whole container. The endpoint name was also formatted from endpoint2 outside the DPNI branch, so non-DPNI devices got a name built from uninitialised or stale data.
Move the lookup to dpaa2_dev_init(), which already knows it is dealing with a DPNI and can fail the probe of that one port. This also fills in priv->ep_dev_type, priv->ep_object_id and priv->ep_name, which the net driver reads for MAC-level operations, recycle/loopback configuration and rte_pmd_dpaa2_ep_name(), but which nothing assigned. dpsw endpoints are now recognised, and dpdmux/dpsw names carry the interface index because those endpoints are per-interface.
--- drivers/bus/fslmc/bus_fslmc_driver.h | 3 -- drivers/bus/fslmc/portal/dpaa2_hw_dprc.c | 45 +++--------------- drivers/net/dpaa2/dpaa2_ethdev.c | 59 +++++++++++++++++++++++- drivers/net/dpaa2/dpaa2_recycle.c | 15 +++--- 4 files changed, 71 insertions(+), 51 deletions(-)
drivers/bus/fslmc/bus_fslmc_driver.h +0 -3
@@ -104,10 +104,7 @@ struct rte_dpaa2_device {struct rte_device device;/**< Inherit core device */ enum rte_dpaa2_dev_type dev_type;/**< Device Type */ uint16_t object_id;/**< DPAA2 Object ID */ -enum rte_dpaa2_dev_type ep_dev_type;/**< Endpoint Device Type */ struct dpaa2_dprc_dev *container; -uint16_t ep_object_id;/**< Endpoint DPAA2 Object ID */ -char ep_name[RTE_DEV_NAME_MAX_LEN ];struct rte_intr_handle *intr_handle;/**< Interrupt handle */ char name[FSLMC_OBJECT_MAX_LEN ];/**< DPAA2 Object name*/ struct rte_dma_dev *dmadev;/**< DMA device */
drivers/bus/fslmc/portal/dpaa2_hw_dprc.c +6 -39
58 lines not on this page · raw message
drivers/net/dpaa2/dpaa2_ethdev.c +58 -1
83 lines not on this page · raw message
drivers/net/dpaa2/dpaa2_recycle.c +7 -8
@@ -630,18 +630,18 @@ dpaa2_dev_recycle_config(struct rte_eth_dev *eth_dev)return 0 ; } -if (dpaa2_dev->ep_dev_type ==DPAA2_MAC ) { +if (priv->ep_dev_type ==DPAA2_MAC ) {/** For dpmac-dpni connection, * try setting serdes loopback as recycle device at first. */ if (dpaa2_svr_family ==SVR_LS2088A ) { - ret =ls_serdes_eth_lpbk (dpaa2_dev->ep_object_id,1 ); + ret =ls_serdes_eth_lpbk (priv->ep_object_id,1 );if (!ret) { priv->flags |=DPAA2_TX_SERDES_LOOPBACK_MODE ;return 0 ; } }else if (dpaa2_svr_family ==SVR_LX2160A ) { - ret =lx_serdes_eth_lpbk (dpaa2_dev->ep_object_id,1 ); + ret =lx_serdes_eth_lpbk (priv->ep_object_id,1 );if (!ret) { priv->flags |=DPAA2_TX_SERDES_LOOPBACK_MODE ;return 0 ;
@@ -670,8 +670,8 @@ dpaa2_dev_recycle_config(struct rte_eth_dev *eth_dev)return 0 ; } -if (dpaa2_dev->ep_dev_type ==DPAA2_ETH && - dpaa2_dev->object_id == dpaa2_dev->ep_object_id) { +if (priv->ep_dev_type ==DPAA2_ETH && + dpaa2_dev->object_id == priv->ep_object_id) { priv->flags |=DPAA2_TX_DPNI_LOOPBACK_MODE ;return 0 ;
@@ -684,7 +684,6 @@ int dpaa2_dev_recycle_deconfig(struct rte_eth_dev *eth_dev) {struct dpaa2_dev_priv *priv = eth_dev->data->dev_private; -struct rte_dpaa2_device *dpaa2_dev =RTE_CLASS_TO_BUS_DEVICE (eth_dev, *dpaa2_dev);struct fsl_mc_io *dpni_dev = eth_dev->process_private;struct dpni_port_cfg port_cfg;int ret =0 ;
@@ -694,7 +693,7 @@ dpaa2_dev_recycle_deconfig(struct rte_eth_dev *eth_dev)if (priv->flags &DPAA2_TX_SERDES_LOOPBACK_MODE ) {if (dpaa2_svr_family ==SVR_LS2088A ) { - ret =ls_serdes_eth_lpbk (dpaa2_dev->ep_object_id,0 ); + ret =ls_serdes_eth_lpbk (priv->ep_object_id,0 );if (ret) {DPAA2_PMD_WARN ("Error(%d) to disable Serdes loopback" , ret);
@@ -702,7 +701,7 @@ dpaa2_dev_recycle_deconfig(struct rte_eth_dev *eth_dev) priv->flags &= ~DPAA2_TX_SERDES_LOOPBACK_MODE ; } }else if (dpaa2_svr_family ==SVR_LX2160A ) { - ret =lx_serdes_eth_lpbk (dpaa2_dev->ep_object_id,0 ); + ret =lx_serdes_eth_lpbk (priv->ep_object_id,0 );if (ret) {DPAA2_PMD_WARN ("Error(%d) to disable Serdes loopback" , ret);
Signature · 1 line
2.43.0
PATCH 10/10 drivers: align dpaa2 event port depths with hardware rings
In reply to Prashant GuptaFrom: Jun Yang <[email protected]>
The event port dequeue and enqueue depths were fixed at 8. A dequeue drains the portal DQRR and an enqueue fills the EQCR, so the real limits are the sizes of those two rings, which differ per SoC and are known at run time. Report them instead, adding qbman_swp_portal_dqrr_size() to query the DQRR size (the EQCR size is already available as dpaa2_eqcr_size).
The Tx adapter enqueue helpers sized their on-stack mbuf arrays from the advertised enqueue depth, which no longer bounds the burst the adapter may hand them, so bound the copy by the array itself and transmit in chunks.
--- .../fslmc/qbman/include/fsl_qbman_portal.h | 7 ++ drivers/bus/fslmc/qbman/qbman_portal.c | 15 ++++ drivers/event/dpaa2/dpaa2_eventdev.c | 72 ++++++++++++------- drivers/event/dpaa2/dpaa2_eventdev.h | 4 +- 4 files changed, 69 insertions(+), 29 deletions(-)
drivers/bus/fslmc/qbman/include/fsl_qbman_portal.h +7 -0
@@ -1222,6 +1222,13 @@ __rte_internalint qbman_swp_acquire (struct qbman_swp *s,uint16_t bpid,uint64_t *buffers,unsigned int num_buffers); +/** +* qbman_swp_portal_dqrr_size() - Number of entries in a portal's DQRR. +* @p: the software portal object, NULL to query the SoC's DQRR size. +*/ +__rte_internal +uint32_t qbman_swp_portal_dqrr_size(struct qbman_swp *p); +/*****************/ /* FQ management */ /*****************/
drivers/bus/fslmc/qbman/qbman_portal.c +15 -0
@@ -73,6 +73,11 @@ enum qbman_sdqcr_fc {static struct qbman_swp *portal_idx_map[MAX_QBMAN_PORTALS ];uint32_t qman_version; +/* DQRR size of the portals initialised so far. All portals of a SoC have the +* same size, so this doubles as the SoC's DQRR size for callers that have no +* portal at hand. +*/ +static uint32_t dpaa2_portal_dqrr_size =8 ;/* Internal Function declaration */ static int
@@ -239,6 +244,15 @@ static int (*qbman_swp_release_ptr)(struct qbman_swp *s, const uint64_t *buffers, unsigned int num_buffers) = qbman_swp_release_direct; +RTE_EXPORT_INTERNAL_SYMBOL (qbman_swp_portal_dqrr_size) +uint32_t qbman_swp_portal_dqrr_size(struct qbman_swp *p) +{ +if (p !=NULL ) +return p->dqrr.dqrr_size; + +return dpaa2_portal_dqrr_size; +} +/*********************************/ /* Portal constructor/destructor */ /*********************************/
@@ -298,6 +312,7 @@ struct qbman_swp *qbman_swp_init(const struct qbman_swp_desc *d)*/ p->dqrr.ci_vec_en = p->dqrr.dqrr_size <= (32 -DQRR_DCAP_CI_VEC_OFFSET ); p->dqrr.ci_flush_th = p->dqrr.dqrr_size /2 ; + dpaa2_portal_dqrr_size = p->dqrr.dqrr_size; ret =qbman_swp_sys_init (&p->sys, d, p->dqrr.dqrr_size);if (ret) {
drivers/event/dpaa2/dpaa2_eventdev.c +46 -26
110 lines not on this page · raw message
drivers/event/dpaa2/dpaa2_eventdev.h +1 -3
@@ -1,5 +1,5 @@/* SPDX-License-Identifier: BSD-3-Clause -* Copyright 2017 NXP +* Copyright 2017,2026 NXP */ #ifndef __DPAA2_EVENTDEV_H__
@@ -22,8 +22,6 @@#define DPAA2_EVENT_MAX_QUEUE_FLOWS 2048#define DPAA2_EVENT_MAX_QUEUE_PRIORITY_LEVELS 8#define DPAA2_EVENT_MAX_EVENT_PRIORITY_LEVELS 0 -#define DPAA2_EVENT_MAX_PORT_DEQUEUE_DEPTH 8 -#define DPAA2_EVENT_MAX_PORT_ENQUEUE_DEPTH 8#define DPAA2_EVENT_MAX_NUM_EVENTS (INT32_MAX - 1)#define DPAA2_EVENT_QUEUE_ATOMIC_FLOWS 2048
Signature · 1 line
2.43.0
cover net/dpaa2, event/dpaa2 and fslmc rework
In reply to Prashant GuptaThis is the final DPAA2 upstreaming sub-series, applied on top of v7-S1 ("dpaa2: bus, DMA and mempool base fixes") and v14-S2 ("net/dpaa2 updates").
The series reworks the DPAA2 datapath, flow steering, metering, eventdev integration and fslmc infrastructure. It consolidates device configuration handling, improves queue and portal management, and adds support for additional DPNI, eventdev and datapath capabilities.
Highlights:
- add DMA bypass translation support and table-driven devargs parsing;
- optimize Tx queue, channel and dequeue processing paths;
- centralize MC version, SoC detection and endpoint handling;
- rework RSS, flow steering, QoS and default action programming;
- add rte_mtr support and meter rte_flow actions;
- improve eventdev scheduling, DPCI support and multi-port operation;
- support runtime IEEE1588 timestamping;
- rework xstats collection and MAC statistics handling;
- unify enqueue/dequeue datapaths across net, crypto and eventdev;
- add Tx fast paths and reduce confirmation overhead.
Every commit builds cleanly with arm64 and -Werror and the series remains bisectable.
Breeson Francis (1):
net/dpaa2: rework xstats with page table and MAC support
Hemant Agrawal (1):
net/dpaa2: reject Rx queue deferred start
Jun Yang (63):
net/dpaa2: refactor and optimize Rx parser result decode net/dpaa2: generate devargs table and string from one list crypto/dpaa2_sec: use table-driven devargs parsing dma/dpaa2: use table-driven devargs parsing
net/dpaa2: unify debug dump via log based helpers net/dpaa2: expose Rx L3/L4/L5 offsets via mbuf dynfield net/dpaa2: optimize dpaa2 Tx queue and channel mapping bus/fslmc: split bus-level device walk from VFIO primitives bus/fslmc: centralize MC version and SoC detection in the bus layer net/dpaa2: remove unused soft parser loader
net/dpaa2: cache per-rxq DPNI queue cfg and share CGID per TC The dpaa2 PMD so far supported only two Tx buffer release schemes:
direct release by hardware, and an absolute Tx confirmation mode (drv_tx_conf=1) where every transmitted buffer is returned on a Tx confirmation queue that software must poll to free the buffers. Absolute confirmation adds a confirmation descriptor and a poll cost for all packets, even those the hardware could free on its own.
net/dpaa2: support runtime IEEE1588 timestamping bus/fslmc: consume dpaa2 DQRR entries in batches bus/fslmc: align dpaa2 event port depths with hardware rings net/dpaa2: support multi-DPNI FS redirect and QoS table v3 net/dpaa2: unify xstats layout and add DPMAC counter struct net/dpaa2: reimplement xstats_get() on top of xstats_get_by_id() net/dpaa2: fetch only requested MAC xstats in one MC call net/dpaa2: rework flow with per-table profile and group types net/dpaa2: reimplement RSS distribution via rte_flow net/dpaa2: expand IP address extracts for RSS hashing net/dpaa2: add policer v2 MC command and L2/L3 byte units net/dpaa2: support rte_mtr and METER rte_flow action net/dpaa2: program flow table miss actions via rte_flow net/dpaa2: support DCB Rx mode via rte_flow
bus/fslmc: support DPCI peer and dynamic queues
bus/fslmc: add alloc/free DPIO API for non-affine portals event/dpaa2: rework event port model and DPCI handling event/dpaa2: fix Tx adapter enqueue for mixed destinations event/dpaa2: rework self test for dynamic link and balance check event/dpaa2: add DPCON based standalone Rx scheduler event/dpaa2: add push mode to DPCON Rx scheduler event/dpaa2: drain Rx scheduler queues on destroy event/dpaa2: track and detach attached Rx queues net/dpaa2: add multi-port Tx API
event/dpaa2: limit attached Rx flows per event queue
eventdev: fix port link/unlink callback return documentation event/dpaa2: allow event queue link to multiple ports event/dpaa2: report available DPIO count and fix create cleanup event/dpaa2: use event port DPIO for dequeue wait bus/fslmc: consolidate DPIO interrupt setup and bound coalescing event/dpaa2: honor configured dequeue timeout
bus/fslmc: use EAL API for DPIO interrupt
bus/fslmc: defer DPIO interrupt setup and bind portal to worker core bus/fslmc: move Tx SG mempool to fslmc bus
net/dpaa2: move DPNI endpoint lookup out of the fslmc bus net/dpaa2: add APIs to query device info and set default action net/dpaa2: consolidate dequeue paths and optimize fast path net/dpaa2: bind per-queue DPIO for rx-queue interrupts net/dpaa2: add API to clean Tx confirmation queue event/dpaa2: fix DQRR held buffer accounting on enqueue bus/fslmc: store dequeue dpio in mbuf seq dynfield bus/fslmc: use explicit flags for mbuf seqn encoding net/dpaa2: unify tx burst path for ordered and atomic enqueue crypto/dpaa2_sec: unify enqueue burst path for ordered enqueue bus/fslmc: track atomic DCA context per dequeue dpio bus/fslmc: move enqueue response descriptors to per-queue event/dpaa2: add ordered schedule type support
bus/fslmc: make DPAA2 ORP/ODP ordering per-queue instead of per-device event/dpaa2: support multi-port enqueue in selftest random event
generator
event/dpaa2: do not fail device creation on DPCI errors net/dpaa2: add Tx fast path for no-confirmation case
doc/guides/nics/dpaa2.rst | 29 +- doc/guides/rel_notes/release_26_11.rst | 10 + drivers/bus/fslmc/bus_fslmc_driver.h | 46 +- drivers/bus/fslmc/fslmc_bus.c | 321 +- drivers/bus/fslmc/fslmc_logs.h | 2 + drivers/bus/fslmc/fslmc_vfio.c | 562 +- drivers/bus/fslmc/fslmc_vfio.h | 72 +- drivers/bus/fslmc/mc/dpci.c | 37 +- drivers/bus/fslmc/mc/fsl_dpci.h | 12 +- drivers/bus/fslmc/portal/dpaa2_hw_dpci.c | 304 +- drivers/bus/fslmc/portal/dpaa2_hw_dpcon.c | 25 +- drivers/bus/fslmc/portal/dpaa2_hw_dpio.c | 668 +- drivers/bus/fslmc/portal/dpaa2_hw_dpio.h | 37 +- drivers/bus/fslmc/portal/dpaa2_hw_dprc.c | 52 +- drivers/bus/fslmc/portal/dpaa2_hw_pvt.h | 305 +- drivers/bus/fslmc/private.h | 15 +- .../fslmc/qbman/include/fsl_qbman_portal.h | 24 +- drivers/bus/fslmc/qbman/qbman_portal.c | 100 +- drivers/bus/fslmc/qbman/qbman_portal.h | 11 +- drivers/bus/fslmc/qbman/qbman_sys.h | 4 +- drivers/common/dpaax/dpaax_devarg.h | 69 + drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c | 559 +- drivers/crypto/dpaa2_sec/dpaa2_sec_priv.h | 11 +- drivers/dma/dpaa2/dpaa2_qdma.c | 92 +- drivers/dma/dpaa2/dpaa2_qdma.h | 15 +- drivers/event/dpaa2/dpaa2_eventdev.c | 1266 ++- drivers/event/dpaa2/dpaa2_eventdev.h | 61 +- drivers/event/dpaa2/dpaa2_eventdev_selftest.c | 370 +- drivers/event/dpaa2/dpaa2_scheduler.c | 673 ++ drivers/event/dpaa2/meson.build | 3 +- drivers/net/dpaa2/base/dpaa2_hw_dpni.c | 544 -- drivers/net/dpaa2/base/dpaa2_hw_dpni_annot.h | 6 +- drivers/net/dpaa2/dpaa2_ethdev.c | 3201 ++++--- drivers/net/dpaa2/dpaa2_ethdev.h | 997 +- drivers/net/dpaa2/dpaa2_flow.c | 8426 ++++++++--------- drivers/net/dpaa2/dpaa2_meter.c | 584 ++ drivers/net/dpaa2/dpaa2_parse_dump.h | 707 +- drivers/net/dpaa2/dpaa2_parser_decode.h | 1148 +++ drivers/net/dpaa2/dpaa2_pmd_logs.h | 34 +- drivers/net/dpaa2/dpaa2_ptp.c | 177 +- drivers/net/dpaa2/dpaa2_recycle.c | 18 +- drivers/net/dpaa2/dpaa2_rxtx.c | 2818 +++--- drivers/net/dpaa2/dpaa2_sparser.c | 137 - drivers/net/dpaa2/dpaa2_sparser.h | 202 - drivers/net/dpaa2/mc/dpni.c | 127 +- drivers/net/dpaa2/mc/fsl_dpni.h | 378 +- drivers/net/dpaa2/mc/fsl_dpni_cmd.h | 30 +- drivers/net/dpaa2/mc/fsl_net.h | 4 +- drivers/net/dpaa2/meson.build | 3 +- drivers/net/dpaa2/rte_pmd_dpaa2.h | 238 +- lib/eventdev/eventdev_pmd.h | 9 +- 51 files changed, 14514 insertions(+), 11029 deletions(-) create mode 100644 drivers/common/dpaax/dpaax_devarg.h create mode 100644 drivers/event/dpaa2/dpaa2_scheduler.c delete mode 100644 drivers/net/dpaa2/base/dpaa2_hw_dpni.c create mode 100644 drivers/net/dpaa2/dpaa2_meter.c create mode 100644 drivers/net/dpaa2/dpaa2_parser_decode.h delete mode 100644 drivers/net/dpaa2/dpaa2_sparser.c delete mode 100644 drivers/net/dpaa2/dpaa2_sparser.h
Signature · 1 line
2.43.0
PATCH 1/65 net/dpaa2: refactor and optimize Rx parser result decode
From: Jun Yang <[email protected]>
The hardware annotation (parse result) decode logic was scattered in dpaa2_rxtx.c and dpaa2_parse_dump.h, mixing the fast-path parsing with debug/print helpers and making the code hard to reuse and maintain.
Move the frame annotation and parse-result decode helpers into a new dedicated header, dpaa2_parser_decode.h, and clean up the surrounding Rx path:
- Add dpaa2_parser_decode.h with the annotation/parse-result decode helpers, taking the annotation as a const pointer so callers cannot mutate the hardware annotation area.
- Replace the compile-time/static print path with a runtime devarg "drv_rx_print_parser_result", so the parser result dump can be enabled per device without rebuilding.
- Pass the soft parser protocol (priv->sp_protocol) into the decode helpers so soft parser (SP) and VLAN/checksum handling is correct.
- Use rte_memcpy / rte_cpu_to_be_64 consistently and tidy up the log messages.
Optimize dpaa2_dev_rx_parse_new():
- Precompute the common "ETH + L3 + L4" packet types as DPAA2_FAST_PATH_PTYPE_ETH_IPV4[_UDP/_TCP] / _IPV6[...] macros and use them in the switch, instead of OR-ing RTE_PTYPE_* flags at runtime for every frame.
- Reorder the switch cases so the most common traffic (IPv4/IPv6 UDP/TCP) is matched first, reducing branch cost on the hot path.
- Keep VLAN frames on the fast path: read the FRC parse summary through a union (dpaa2_psr_summary), mask off the VLAN bit, and resolve the packet type via the fast-path switch plus dpaa2_dev_rx_parse_vlan(). Previously a VLAN tag made the frame miss the switch and fall into the slow path (dpaa2_dev_rx_parse_slow) for every packet; now the slow/FRC path is only used for the uncommon default case.
--- doc/guides/nics/dpaa2.rst | 6 +- drivers/net/dpaa2/dpaa2_ethdev.c | 31 +- drivers/net/dpaa2/dpaa2_ethdev.h | 173 ++-- drivers/net/dpaa2/dpaa2_parse_dump.h | 707 +++++++------- drivers/net/dpaa2/dpaa2_parser_decode.h | 1139 +++++++++++++++++++++++ drivers/net/dpaa2/dpaa2_pmd_logs.h | 17 +- drivers/net/dpaa2/dpaa2_rxtx.c | 326 ++++--- drivers/net/dpaa2/rte_pmd_dpaa2.h | 13 +- 8 files changed, 1826 insertions(+), 586 deletions(-) create mode 100644 drivers/net/dpaa2/dpaa2_parser_decode.h
doc/guides/nics/dpaa2.rst +5 -1
@@ -1,5 +1,5 @@ .. SPDX-License-Identifier: BSD-3-Clause - Copyright 2016,2020-2021 NXP + Copyright 2016,2020-2026 NXP DPAA2 Poll Mode Driver
@@ -484,6 +484,10 @@ Refer to the document :doc:`build_and_test` for details. to start dropping the error packets in hardware (parse errors). e.g. ``fslmc:dpni.1,drv_rx_parse_drop=1`` +* Use dev arg option ``drv_rx_print_parser_result=1`` print detailed hardware + parser result of every received packet (debug only, hurts Rx performance). + e.g. ``fslmc:dpni.1,drv_rx_print_parser_result=1`` + * Use dev arg option ``drv_error_queue=1`` to enable Packets in Error queue. DPAA2 hardware drops the error packet in hardware. This option enables the hardware to not drop the error packet and let the driver dump the error
drivers/net/dpaa2/dpaa2_ethdev.c +14 -17
@@ -1,6 +1,6 @@/* SPDX-License-Identifier: BSD-3-Clause * Copyright (c) 2016 Freescale Semiconductor, Inc. All rights reserved. -* Copyright 2016-2025 NXP +* Copyright 2016-2026 NXP */ #include <time.h>
@@ -36,6 +36,7 @@#define DRIVER_NO_PREFETCH_MODE "drv_no_prefetch"#define DRIVER_TX_CONF "drv_tx_conf"#define DRIVER_RX_PARSE_ERR_DROP "drv_rx_parse_drop" +#define DRIVER_RX_PRINT_PARSER_RESULT "drv_rx_print_parser_result"#define DRIVER_ERROR_QUEUE "drv_err_queue"#define DRIVER_NO_TAILDROP "drv_no_taildrop"#define DRIVER_NO_DATA_STASHING "drv_no_data_stashing"
@@ -68,16 +69,13 @@ static uint64_t dev_tx_offloads_sup =RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE ;/* Tx offloads which cannot be disabled */ -static uint64_t dev_tx_offloads_nodis = -RTE_ETH_TX_OFFLOAD_MULTI_SEGS ; +static uint64_t dev_tx_offloads_nodis =RTE_ETH_TX_OFFLOAD_MULTI_SEGS ;/* enable timestamp in mbuf */ bool dpaa2_enable_ts[RTE_MAX_ETHPORTS ];uint64_t dpaa2_timestamp_rx_dynflag;int dpaa2_timestamp_dynfield_offset =-1 ; -bool dpaa2_print_parser_result; -/* Rx descriptor limit when DPNI loads PFDRs in PEB */ #define MAX_NB_RX_DESC_IN_PEB 11264static int total_nb_rx_desc;
@@ -3450,10 +3448,10 @@ dpaa2_dev_init(struct rte_eth_dev *eth_dev)PMD_INIT_FUNC_TRACE (); - dpni_dev =rte_malloc (NULL ,sizeof (struct fsl_mc_io ),0 ); + dpni_dev =rte_zmalloc (NULL ,sizeof (struct fsl_mc_io ),0 );if (!dpni_dev) {DPAA2_PMD_ERR ("Memory allocation failed for dpni device" ); -return -1 ; +return -ENOMEM ; } dpni_dev->regs =dpaa2_get_mcp_ptr (MC_PORTAL_INDEX ); eth_dev->process_private = dpni_dev;
@@ -3502,9 +3500,8 @@ dpaa2_dev_init(struct rte_eth_dev *eth_dev) hw_id = dpaa2_dev->object_id; ret =dpni_open (dpni_dev,CMD_PRI_LOW , hw_id, &priv->token);if (ret) { -DPAA2_PMD_ERR ( -"Failure in opening dpni@%d with err code %d" , - hw_id, ret); +DPAA2_PMD_ERR ("Failure in opening dpni@%d with err code %d" , + hw_id, ret);rte_free (dpni_dev);return ret; }
@@ -3516,20 +3513,19 @@ dpaa2_dev_init(struct rte_eth_dev *eth_dev) ret =dpni_reset (dpni_dev,CMD_PRI_LOW , priv->token);if (ret) {DPAA2_PMD_ERR ("Failure cleaning dpni@%d with err code %d" , - hw_id, ret); + hw_id, ret); goto init_err; } ret =dpni_get_attributes (dpni_dev,CMD_PRI_LOW , priv->token, &attr);if (ret) { -DPAA2_PMD_ERR ( -"Failure in get dpni@%d attribute, err code %d" , - hw_id, ret); +DPAA2_PMD_ERR ("Failure in get dpni@%d attribute, err code %d" , + hw_id, ret); goto init_err; } ret =dpni_get_api_version (dpni_dev,CMD_PRI_LOW , &priv->dpni_ver_major, - &priv->dpni_ver_minor); + &priv->dpni_ver_minor);if (ret) {DPAA2_PMD_ERR ("Failure in get dpni@%d API version, err code %d" , hw_id, ret);
@@ -3590,8 +3586,8 @@ dpaa2_dev_init(struct rte_eth_dev *eth_dev)DPAA2_PMD_INFO ("Drop parse error packets in hw" ); } -if (getenv ("DPAA2_PRINT_RX_PARSER_RESULT" )) - dpaa2_print_parser_result =1 ; +if (dpaa2_get_devargs (dev->devargs,DRIVER_RX_PRINT_PARSER_RESULT )) + priv->flags |=DPAA2_RX_PRINT_PSR_RESULT_FLAG ;/* Allocate memory for hardware structure for queues */ ret =dpaa2_alloc_rx_tx_queues (eth_dev);
@@ -3993,6 +3989,7 @@ RTE_PMD_REGISTER_PARAM_STRING(NET_DPAA2_PMD_DRIVER_NAME,DRIVER_NO_PREFETCH_MODE "=<int>" DRIVER_TX_CONF "=<int>" DRIVER_RX_PARSE_ERR_DROP "=<int>" +DRIVER_RX_PRINT_PARSER_RESULT "=<int>" DRIVER_ERROR_QUEUE "=<int>" DRIVER_NO_TAILDROP "=<int>" DRIVER_NO_DATA_STASHING "=<int>");
drivers/net/dpaa2/dpaa2_ethdev.h +112 -61
241 lines not on this page · raw message
drivers/net/dpaa2/dpaa2_parse_dump.h +370 -337
744 lines not on this page · raw message
drivers/net/dpaa2/dpaa2_parser_decode.h new file +1139 -0
1,139 lines not on this page · raw message
drivers/net/dpaa2/dpaa2_pmd_logs.h +16 -1
@@ -1,10 +1,17 @@/* SPDX-License-Identifier: BSD-3-Clause -* Copyright 2017 NXP +* Copyright 2017-2026 NXP */ #ifndef _DPAA2_PMD_LOGS_H_#define _DPAA2_PMD_LOGS_H_ +#include <stdarg.h> +#include <stdio.h> +#include <string.h> + +#include <rte_common.h> +#include <rte_log.h> +extern int dpaa2_logtype_pmd;#define RTE_LOGTYPE_DPAA2_NET dpaa2_logtype_pmd
@@ -36,4 +43,12 @@ extern int dpaa2_logtype_pmd;#define DPAA2_PMD_DP_WARN (fmt, ...) \ DPAA2_PMD_DP_LOG(WARNING, fmt, ## __VA_ARGS__) +static inline __rte_format_printf(1, 2) void +dpaa2_dump_print(const char *fmt, ...) +{ + va_list ap; +va_start (ap, fmt); +rte_vlog (RTE_LOG_NOTICE ,RTE_LOGTYPE_USER1 , fmt, ap); +va_end (ap); +}#endif /* _DPAA2_PMD_LOGS_H_ */
drivers/net/dpaa2/dpaa2_rxtx.c +158 -168
562 lines not on this page · raw message
drivers/net/dpaa2/rte_pmd_dpaa2.h +12 -1
@@ -1,5 +1,5 @@/* SPDX-License-Identifier: BSD-3-Clause -* Copyright 2018-2024 NXP +* Copyright 2018-2026 NXP */ #ifndef _RTE_PMD_DPAA2_H
@@ -14,6 +14,17 @@#include <rte_compat.h> #include <rte_flow.h> +/** +* LX series support only. +* if (m->ol_flags & RTE_MBUF_F_RX_FDIR) { +* tc = (m->hash.fdir.hi >> RTE_DPAA2_MBUF_F_RX_FDIR_TC_OFFSET); +* flow = m->hash.fdir.hi & RTE_DPAA2_MBUF_F_RX_FDIR_FLOW_MASK; +* } +*/ +#define RTE_DPAA2_MBUF_F_RX_FDIR_TC_OFFSET 16 +#define RTE_DPAA2_MBUF_F_RX_FDIR_FLOW_MASK \ + ((UINT32_C(1) << RTE_DPAA2_MBUF_F_RX_FDIR_TC_OFFSET) - 1) +/** * Create a flow rule to demultiplex ethernet traffic to separate network * interfaces.
Signature · 1 line
2.43.0
PATCH 2/65 net/dpaa2: generate devargs table and string from one list
In reply to Prashant GuptaFrom: Jun Yang <[email protected]>
Add a common dpaax_devarg.h header providing the dpaax_devargs type, the dpaax_get_devargs() parse helper, and two X-macro operators:
DPAAX_DEVARG_TABLE_ENTRY(key, handle, flag) -> {key, handle, flag}, DPAAX_DEVARG_STRING_ENTRY(key, handle, flag) -> key "=<int> "
Convert the dpaa2 net driver to declare its device arguments once via a single DPAA2_DEVARGS(ENTRY) list. The same list now builds both the parse table (s_dpaa2_devargs) and the RTE_PMD_REGISTER_PARAM_STRING valid-args string, so every key is spelled exactly once. The per-arg string defines and the hand-written dpaa2_get_devargs()/ check_devargs_handler() lookups are replaced by a single dpaax_get_devargs() call that sets priv->flags.
--- drivers/common/dpaax/dpaax_devarg.h | 69 ++++++++++++ drivers/net/dpaa2/dpaa2_ethdev.c | 158 +++++++--------------------- 2 files changed, 106 insertions(+), 121 deletions(-) create mode 100644 drivers/common/dpaax/dpaax_devarg.h
drivers/common/dpaax/dpaax_devarg.h new file +69 -0
@@ -0,0 +1,69 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright 2026 NXP +*/ + +#ifndef _DPAAX_DEVARG_H_ +#define _DPAAX_DEVARG_H_ +#include <stdlib.h> +#include <rte_kvargs.h> +#include <ethdev_driver.h> + +struct dpaax_devargs { +const char *arg_key; +void (*handle)(void *vdev,const struct rte_kvargs_pair *pair); +uint64_t flag_bit; +}; + +/* Shared expansions for a driver's devargs X-macro list. +* +* A driver declares its argument list once as a list-macro that takes the +* per-entry operator as a parameter, for example: +* +* #define MY_DEVARGS(ENTRY) \ +* ENTRY("drv_foo", foo_handler, 0) \ +* ENTRY("drv_bar", NULL, MY_BAR_FLAG) +* +* The same list then generates both the parse table and the registered +* valid-args string by passing the matching operator below: +* +* static const struct dpaax_devargs s_my_devargs[] = { +* MY_DEVARGS(DPAAX_DEVARG_TABLE_ENTRY) +* }; +* RTE_PMD_REGISTER_PARAM_STRING(name, MY_DEVARGS(DPAAX_DEVARG_STRING_ENTRY)); +* +* This keeps each key spelled exactly once. +*/ +#define DPAAX_DEVARG_TABLE_ENTRY (key, handle, flag) {key, handle, flag}, +#define DPAAX_DEVARG_STRING_ENTRY (key, handle, flag) key "=<int> " + +#define dpaax_get_devargs (dev_args, dev, flags) \ +({ \ + uint32_t arg_num = RTE_DIM(dev_args), arg_idx, kv_idx;\ + struct rte_device *rdev = dev->device; \ + struct rte_kvargs *kvlist = NULL; \ + struct rte_kvargs_pair *pair; \ + uint32_t flag_bit; \ + \ + if (rdev->devargs) \ + kvlist = rte_kvargs_parse(rdev->devargs->args, NULL); \ + if (kvlist) { \ + for (arg_idx = 0; arg_idx < arg_num; arg_idx++) { \ + for (kv_idx = 0; kv_idx < kvlist->count; kv_idx++) { \ + pair = &kvlist->pairs[kv_idx]; \ + if (strcmp(pair->key, dev_args[arg_idx].arg_key)) \ + continue; \ + if (dev_args[arg_idx].handle) \ + dev_args[arg_idx].handle(dev, pair); \ + flag_bit = dev_args[arg_idx].flag_bit; \ + if (flags && pair->value) { \ + if (atoi(pair->value)) \ + (*((uint32_t *)flags)) |= flag_bit; \ + else \ + (*((uint32_t *)flags)) &= ~flag_bit; \ + } \ + } \ + } \ + rte_kvargs_free(kvlist); \ + } \ +}) +#endif /* _DPAAX_DEVARG_H_ */
drivers/net/dpaa2/dpaa2_ethdev.c +37 -121
214 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH 3/65 crypto/dpaa2_sec: use table-driven devargs parsing
In reply to Prashant GuptaFrom: Jun Yang <[email protected]>
Convert the dpaa2_sec devargs handling to the shared dpaax_devargs table so each argument key is declared once and drives both the parse table and the registered valid-args string.
Replace the custom check_devargs_handler()/dpaa2_sec_get_devargs() pair with the generic dpaax_get_devargs() helper, and attach per-arg callbacks (dpaa2_sec_devarg_dump_set, dpaa2_sec_devarg_order_set) for the value-carrying arguments.
Move the dump level out of the global dpaa2_sec_dp_dump variable into the per-device private data (priv->dump_level) so the dump setting is scoped per device instead of being process-global, and move the dpaa2_sec_dump_levels enum into dpaa2_sec_priv.h.
--- drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c | 133 ++++++++------------ drivers/crypto/dpaa2_sec/dpaa2_sec_priv.h | 10 +- 2 files changed, 61 insertions(+), 82 deletions(-)
drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c +52 -81
@@ -1,7 +1,7 @@/* SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 2016 Freescale Semiconductor, Inc. All rights reserved. -* Copyright 2016-2025 NXP +* Copyright 2016-2026 NXP * */
@@ -31,6 +31,7 @@#include <fsl_dpseci.h> #include <fsl_mc_sys.h> #include <rte_hexdump.h> +#include <dpaax_devarg.h> #include "dpaa2_sec_priv.h" #include "dpaa2_sec_event.h"
@@ -55,18 +56,40 @@#define DPAA2_DEFAULT_NAT_T_PORT 4500#define NO_PREFETCH 0 -#define DRIVER_DUMP_MODE "drv_dump_mode" -#define DRIVER_STRICT_ORDER "drv_strict_order" +static void +dpaa2_sec_devarg_order_set (void *vdev,const struct rte_kvargs_pair *pair) +{ +struct rte_cryptodev *dev = vdev; +struct dpaa2_sec_dev_private *priv = dev->data->dev_private; + + priv->en_loose_ordered =atoi (pair->value) ? false : true; +} + +static void +dpaa2_sec_devarg_dump_set (void *vdev,const struct rte_kvargs_pair *pair) +{ +struct rte_cryptodev *dev = vdev; +struct dpaa2_sec_dev_private *priv = dev->data->dev_private; +enum dpaa2_sec_dump_levels val; + + val =atoi (pair->value); +if (val >DPAA2_SEC_DP_FULL_DUMP ) { +DPAA2_SEC_WARN ("%s: val(%d) > full dump(%d), changing to full dump" , + __func__, val,DPAA2_SEC_DP_FULL_DUMP ); + val =DPAA2_SEC_DP_FULL_DUMP ; + } + priv->dump_level = val; +} + +#define DPAA2_DEVARGS (ENTRY ) \ + ENTRY("drv_dump_mode", dpaa2_sec_devarg_dump_set, 0) \ + ENTRY("drv_strict_order", dpaa2_sec_devarg_order_set, 0) -/* DPAA2_SEC_DP_DUMP levels */ -enum dpaa2_sec_dump_levels { -DPAA2_SEC_DP_NO_DUMP , -DPAA2_SEC_DP_ERR_DUMP , -DPAA2_SEC_DP_FULL_DUMP +static const struct dpaax_devargs s_dpaa2_sec_devargs[] = { +DPAA2_DEVARGS (DPAAX_DEVARG_TABLE_ENTRY ) };uint8_t cryptodev_driver_id; -uint8_t dpaa2_sec_dp_dump =DPAA2_SEC_DP_ERR_DUMP ;static int s_dpaa2_sec_cntx_pos =-1 ;
@@ -1701,10 +1724,9 @@ dpaa2_sec_fd_to_mbuf(const struct qbman_fd *fd,static void dpaa2_sec_dump (struct rte_crypto_op *op,FILE *f) { -int i;dpaa2_sec_session *sess =NULL ;struct ctxt_priv *priv; -uint8_t bufsize; +uint8_t bufsize, i;struct rte_crypto_sym_op *sym_op;if (op->sess_type ==RTE_CRYPTO_OP_WITH_SESSION )
@@ -1717,7 +1739,7 @@ dpaa2_sec_dump(struct rte_crypto_op *op, FILE *f)if (sess ==NULL ) goto mbuf_dump; - priv = (struct ctxt_priv *)sess->ctxt; + priv = sess->ctxt;fprintf (f,"\n****************************************\n" "session params:\n\tContext type:\t%d\n\tDirection:\t%s\n" "\tCipher alg:\t%d\n\tAuth alg:\t%d\n\tAead alg:\t%d\n"
@@ -1746,7 +1768,7 @@ dpaa2_sec_dump(struct rte_crypto_op *op, FILE *f) sess->pdcp.hfn_threshold);#endif - bufsize = (uint8_t )priv->flc_desc[0 ].flc.word1_sdl; + bufsize = priv->flc_desc[0 ].flc.word1_sdl;fprintf (f,"Descriptor Dump:\n" );for (i =0 ; i < bufsize; i++)fprintf (f,"\tDESC[%d]:0x%x\n" , i, priv->flc_desc[0 ].desc[i]);
@@ -1950,10 +1972,10 @@ dpaa2_sec_enqueue_burst_ordered(void *qp, struct rte_crypto_op **ops,static uint16_t dpaa2_sec_dequeue_burst (void *qp,struct rte_crypto_op **ops, -uint16_t nb_ops) +uint16_t nb_ops) {/* Function is responsible to receive frames for a given device and VQ*/ -struct dpaa2_sec_qp *dpaa2_qp = (struct dpaa2_sec_qp *)qp; +struct dpaa2_sec_qp *dpaa2_qp = qp;struct qbman_result *dq_storage;uint32_t fqid = dpaa2_qp->rx_vq.fqid;int ret, num_rx =0 ;
@@ -1961,12 +1983,12 @@ dpaa2_sec_dequeue_burst(void *qp, struct rte_crypto_op **ops,struct qbman_swp *swp;const struct qbman_fd *fd;struct qbman_pull_desc pulldesc; +struct dpaa2_sec_dev_private *priv = dpaa2_qp->rx_vq.crypto_data->dev_private;if (!DPAA2_PER_LCORE_DPIO ) { ret =dpaa2_affine_qbman_swp ();if (ret) { -DPAA2_SEC_ERR ( -"Failed to allocate IO portal, tid: %d" , +DPAA2_SEC_ERR ("Failed to allocate IO portal, tid: %d" ,rte_gettid ());return 0 ; }
@@ -1976,18 +1998,15 @@ dpaa2_sec_dequeue_burst(void *qp, struct rte_crypto_op **ops,qbman_pull_desc_clear (&pulldesc);qbman_pull_desc_set_numframes (&pulldesc, - (nb_ops > dpaa2_dqrr_size) ? - dpaa2_dqrr_size : nb_ops); + (nb_ops > dpaa2_dqrr_size) ? dpaa2_dqrr_size : nb_ops);qbman_pull_desc_set_fq (&pulldesc, fqid);qbman_pull_desc_set_storage (&pulldesc, dq_storage, - (dma_addr_t )DPAA2_VADDR_TO_IOVA (dq_storage), -1 ); + (dma_addr_t )DPAA2_VADDR_TO_IOVA (dq_storage),1 );/*Issue a volatile dequeue command. */ while (1 ) {if (qbman_swp_pull (swp, &pulldesc)) { -DPAA2_SEC_WARN ( -"SEC VDQ command is not issued : QBMAN busy" ); +DPAA2_SEC_WARN ("SEC VDQ command is not issued : QBMAN busy" );/* Portal was busy, try again */ continue ; }
@@ -2017,8 +2036,7 @@ dpaa2_sec_dequeue_burst(void *qp, struct rte_crypto_op **ops, is_last =1 ;/* Check for valid frame. */ status = (uint8_t )qbman_result_DQ_flags (dq_storage); -if (unlikely ( - (status &QBMAN_DQ_STAT_VALIDFRAME ) ==0 )) { +if (unlikely (!(status &QBMAN_DQ_STAT_VALIDFRAME ))) {DPAA2_SEC_DP_DEBUG ("No frame is delivered" );continue ; }
@@ -2029,10 +2047,9 @@ dpaa2_sec_dequeue_burst(void *qp, struct rte_crypto_op **ops,if (unlikely (fd->simple.frc)) {/* TODO Parse SEC errors */ -if (dpaa2_sec_dp_dump >DPAA2_SEC_DP_NO_DUMP ) { -DPAA2_SEC_DP_ERR ("SEC returned Error - %x" , - fd->simple.frc); -if (dpaa2_sec_dp_dump >DPAA2_SEC_DP_ERR_DUMP ) +if (priv->dump_level >DPAA2_SEC_DP_NO_DUMP ) { +DPAA2_SEC_DP_ERR ("SEC returned Error - %x" , fd->simple.frc); +if (priv->dump_level >DPAA2_SEC_DP_ERR_DUMP )dpaa2_sec_dump (ops[num_rx], stdout); }
@@ -2049,7 +2066,7 @@ dpaa2_sec_dequeue_burst(void *qp, struct rte_crypto_op **ops, dpaa2_qp->rx_vq.rx_pkts += num_rx;DPAA2_SEC_DP_DEBUG ("SEC RX pkts %d err pkts %" PRIu64, num_rx, - dpaa2_qp->rx_vq.err_pkts); + dpaa2_qp->rx_vq.err_pkts);/*Return the total number of packets received to DPAA2 app*/ return num_rx; }
@@ -4332,53 +4349,6 @@ dpaa2_sec_uninit(const struct rte_cryptodev *dev)return 0 ; } -static int -check_devargs_handler (const char *key,const char *value, -void *opaque) -{ -struct rte_cryptodev *dev = (struct rte_cryptodev *)opaque; -struct dpaa2_sec_dev_private *priv = dev->data->dev_private; - -if (!strcmp (key,"drv_strict_order" )) { - priv->en_loose_ordered = false; - }else if (!strcmp (key,"drv_dump_mode" )) { - dpaa2_sec_dp_dump =atoi (value); -if (dpaa2_sec_dp_dump >DPAA2_SEC_DP_FULL_DUMP ) { -DPAA2_SEC_WARN ("WARN: DPAA2_SEC_DP_DUMP_LEVEL is not " -"supported, changing to FULL error" -" prints" ); - dpaa2_sec_dp_dump =DPAA2_SEC_DP_FULL_DUMP ; - } - }else -return -1 ; - -return 0 ; -} - -static void -dpaa2_sec_get_devargs (struct rte_cryptodev *cryptodev,const char *key) -{ -struct rte_kvargs *kvlist; -struct rte_devargs *devargs; - - devargs = cryptodev->device->devargs; -if (!devargs) -return ; - - kvlist =rte_kvargs_parse (devargs->args,NULL ); -if (!kvlist) -return ; - -if (!rte_kvargs_count (kvlist, key)) { -rte_kvargs_free (kvlist); -return ; - } - -rte_kvargs_process (kvlist, key, - check_devargs_handler, (void *)cryptodev); -rte_kvargs_free (kvlist); -} -static int dpaa2_sec_dev_init (struct rte_cryptodev *cryptodev) {
@@ -4412,6 +4382,9 @@ dpaa2_sec_dev_init(struct rte_cryptodev *cryptodev) internals = cryptodev->data->dev_private; + internals->dump_level =DPAA2_SEC_DP_ERR_DUMP ; +dpaax_get_devargs (s_dpaa2_sec_devargs, cryptodev,NULL ); +/* * For secondary processes, we don't initialise any further as primary * has already done this work. Only check we don't need a different
@@ -4462,8 +4435,6 @@ dpaa2_sec_dev_init(struct rte_cryptodev *cryptodev) internals->token = token; internals->en_loose_ordered = true; -dpaa2_sec_get_devargs (cryptodev,DRIVER_DUMP_MODE ); -dpaa2_sec_get_devargs (cryptodev,DRIVER_STRICT_ORDER );DPAA2_SEC_INFO ("driver %s: created" , cryptodev->data->name);return 0 ;
@@ -4547,6 +4518,6 @@ RTE_PMD_REGISTER_DPAA2(CRYPTODEV_NAME_DPAA2_SEC_PMD, rte_dpaa2_sec_driver);RTE_PMD_REGISTER_CRYPTO_DRIVER (dpaa2_sec_crypto_drv, rte_dpaa2_sec_driver.driver, cryptodev_driver_id);RTE_PMD_REGISTER_PARAM_STRING (CRYPTODEV_NAME_DPAA2_SEC_PMD , -DRIVER_STRICT_ORDER "=<int>" -DRIVER_DUMP_MODE "=<int>" ); +DPAA2_DEVARGS (DPAAX_DEVARG_STRING_ENTRY ) +);RTE_LOG_REGISTER (dpaa2_logtype_sec, pmd.crypto.dpaa2,NOTICE );
drivers/crypto/dpaa2_sec/dpaa2_sec_priv.h +9 -1
@@ -1,7 +1,7 @@/* SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 2016 Freescale Semiconductor, Inc. All rights reserved. -* Copyright 2016,2020-2024 NXP +* Copyright 2016,2020-2026 NXP * */
@@ -21,6 +21,13 @@ extern uint8_t cryptodev_driver_id;#define FLE_POOL_CACHE_SIZE 512#define FLE_SG_MEM_SIZE (num) (FLE_POOL_BUF_SIZE + ((num) * 32)) +/* DPAA2_SEC_DP_DUMP levels */ +enum dpaa2_sec_dump_levels { +DPAA2_SEC_DP_NO_DUMP , +DPAA2_SEC_DP_ERR_DUMP , +DPAA2_SEC_DP_FULL_DUMP +}; +#define MAX_QUEUES 64#define MAX_DESC_SIZE 64/** private data structure for each DPAA2_SEC device */
@@ -34,6 +41,7 @@ struct dpaa2_sec_dev_private {/**< Max number of queue pairs supported by device */ uint8_t en_ordered;uint8_t en_loose_ordered; +enum dpaa2_sec_dump_levels dump_level; };struct dpaa2_sec_qp {
Signature · 1 line
2.43.0
PATCH 4/65 dma/dpaa2: use table-driven devargs parsing
In reply to Prashant GuptaFrom: Jun Yang <[email protected]>
Convert the dpaa2 qdma devargs handling to the shared dpaax_devargs table so each argument key is declared once and drives both the parse table and the registered valid-args string.
Remove the custom check_devargs_handler()/dpaa2_qdma_get_devargs() helpers and parse the arguments once at device init via dpaax_get_devargs(), storing the results in a single dpdmai_dev->flags bitfield (DPAA2_QDMA_FLE_PRE_POPULATE_FLAG, DPAA2_QDMA_DESC_DEBUG_FLAG, DPAA2_QDMA_SHORT_FD_FLAG).
This drops the per-virtual-queue fle_pre_populate, using_short_fd and flags fields, which only mirrored device-wide devargs, and makes the copy paths read the device flags directly.
--- drivers/dma/dpaa2/dpaa2_qdma.c | 92 +++++++++------------------------- drivers/dma/dpaa2/dpaa2_qdma.h | 15 +++--- 2 files changed, 33 insertions(+), 74 deletions(-)
drivers/dma/dpaa2/dpaa2_qdma.c +25 -67
@@ -1,5 +1,5 @@/* SPDX-License-Identifier: BSD-3-Clause -* Copyright 2018-2024 NXP +* Copyright 2018-2026 NXP */ #include <rte_eal.h>
@@ -11,56 +11,25 @@#include <mc/fsl_dpdmai.h> #include <rte_pmd_dpaax_qdma.h> +#include <dpaax_devarg.h> #include "dpaa2_hw_dpio.h" #include "dpaa2_qdma.h" #include "dpaa2_qdma_logs.h" -#define DPAA2_QDMA_FLE_PRE_POPULATE "fle_pre_populate" -#define DPAA2_QDMA_DESC_DEBUG "desc_debug" -#define DPAA2_QDMA_USING_SHORT_FD "short_fd" +#define DPAA2_DEVARGS (ENTRY ) \ + ENTRY("fle_pre_populate", NULL, DPAA2_QDMA_FLE_PRE_POPULATE_FLAG) \ + ENTRY("desc_debug", NULL, DPAA2_QDMA_DESC_DEBUG_FLAG) \ + ENTRY("short_fd", NULL, DPAA2_QDMA_SHORT_FD_FLAG) + +static const struct dpaax_devargs s_dpaa2_qdma_devargs[] = { +DPAA2_DEVARGS (DPAAX_DEVARG_TABLE_ENTRY ) +};static uint32_t dpaa2_coherent_no_alloc_cache;static uint32_t dpaa2_coherent_alloc_cache;static struct fsl_mc_io s_proc_mc_reg; -static int -check_devargs_handler(__rte_unused const char *key, const char *value, - __rte_unused void *opaque) -{ -if (strcmp (value,"1" )) -return -1 ; - -return 0 ; -} - -static int -dpaa2_qdma_get_devargs (struct rte_devargs *devargs,const char *key) -{ -struct rte_kvargs *kvlist; - -if (!devargs) -return 0 ; - - kvlist =rte_kvargs_parse (devargs->args,NULL ); -if (!kvlist) -return 0 ; - -if (!rte_kvargs_count (kvlist, key)) { -rte_kvargs_free (kvlist); -return 0 ; - } - -if (rte_kvargs_process (kvlist, key, - check_devargs_handler,NULL ) <0 ) { -rte_kvargs_free (kvlist); -return 0 ; - } -rte_kvargs_free (kvlist); - -return 1 ; -} - static inline int qdma_cntx_idx_ring_eq(struct qdma_cntx_idx_ring *ring, const uint16_t *elem, uint16_t nb,
@@ -670,7 +639,7 @@ dpaa2_qdma_copy_sg(void *dev_private,DPAA2_SET_FD_COMPOUND_FMT (fd);DPAA2_SET_FD_FLC (fd, (uint64_t )cntx_sg); -if (qdma_vq->fle_pre_populate) { +if (dpdmai_dev->flags &DPAA2_QDMA_FLE_PRE_POPULATE_FLAG ) {if (unlikely (!fle[DPAA2_QDMA_SRC_FLE ].length)) {fle_sdd_sg_pre_populate (cntx_sg, qdma_vq);if (!qdma_dev->is_silent && cntx_sg && idx_addr) {
@@ -698,7 +667,7 @@ dpaa2_qdma_copy_sg(void *dev_private, QBMAN_FLE_WORD4_FMT_SGE); } -if (unlikely (qdma_vq->flags &DPAA2_QDMA_DESC_DEBUG_FLAG )) +if (unlikely (dpdmai_dev->flags &DPAA2_QDMA_DESC_DEBUG_FLAG ))dpaa2_qdma_long_fmt_dump (cntx_sg->fle_sdd.fle);dpaa2_qdma_fd_save_att (fd,0 ,DPAA2_QDMA_FD_SG );
@@ -844,7 +813,7 @@ dpaa2_qdma_short_copy(struct qdma_virt_queue *qdma_vq,static int dpaa2_qdma_long_copy (struct qdma_virt_queue *qdma_vq,rte_iova_t src,rte_iova_t dst,uint32_t length, -int is_silent,uint64_t flags) +int is_silent,uint64_t flags,uint32_t dev_flags) {int ret =0 , expected;struct qbman_fd *fd = &qdma_vq->fd[qdma_vq->fd_idx];
@@ -872,7 +841,7 @@ dpaa2_qdma_long_copy(struct qdma_virt_queue *qdma_vq,DPAA2_SET_FD_COMPOUND_FMT (fd);DPAA2_SET_FD_FLC (fd, (uint64_t )fle); -if (qdma_vq->fle_pre_populate) { +if (dev_flags &DPAA2_QDMA_FLE_PRE_POPULATE_FLAG ) {if (unlikely (!fle[DPAA2_QDMA_SRC_FLE ].length)) { fle_sdd_pre_populate(fle_sdd, &qdma_vq->rbp,
@@ -888,7 +857,7 @@ dpaa2_qdma_long_copy(struct qdma_virt_queue *qdma_vq, QBMAN_FLE_WORD4_FMT_SBF); } -if (unlikely (qdma_vq->flags &DPAA2_QDMA_DESC_DEBUG_FLAG )) +if (unlikely (dev_flags &DPAA2_QDMA_DESC_DEBUG_FLAG ))dpaa2_qdma_long_fmt_dump (fle); dpaa2_qdma_fd_save_att(fd, DPAA2_QDMA_IDX_FROM_FLAG(flags),
@@ -921,12 +890,14 @@ dpaa2_qdma_copy(void *dev_private, uint16_t vchan,struct qdma_device *qdma_dev = dpdmai_dev->qdma_dev;struct qdma_virt_queue *qdma_vq = &qdma_dev->vqs[vchan]; -if (qdma_vq->using_short_fd) +if (dpdmai_dev->flags &DPAA2_QDMA_SHORT_FD_FLAG ) {return dpaa2_qdma_short_copy (qdma_vq, src, dst, length, qdma_dev->is_silent, flags); -else + }else {return dpaa2_qdma_long_copy (qdma_vq, src, dst, - length, qdma_dev->is_silent, flags); + length, qdma_dev->is_silent, flags, + dpdmai_dev->flags); + } } static inline int
@@ -1379,21 +1350,6 @@ dpaa2_qdma_vchan_setup(struct rte_dma_dev *dev, uint16_t vchan,if (ret)return ret; -if (dpaa2_qdma_get_devargs (dev->device->devargs,DPAA2_QDMA_FLE_PRE_POPULATE )) - qdma_dev->vqs[vchan].fle_pre_populate =1 ; -else - qdma_dev->vqs[vchan].fle_pre_populate =0 ; - -if (dpaa2_qdma_get_devargs (dev->device->devargs,DPAA2_QDMA_DESC_DEBUG )) - qdma_dev->vqs[vchan].flags |=DPAA2_QDMA_DESC_DEBUG_FLAG ; -else - qdma_dev->vqs[vchan].flags &= (~DPAA2_QDMA_DESC_DEBUG_FLAG ); - -if (dpaa2_qdma_get_devargs (dev->device->devargs,DPAA2_QDMA_USING_SHORT_FD )) - qdma_dev->vqs[vchan].using_short_fd =1 ; -else - qdma_dev->vqs[vchan].using_short_fd =0 ; -snprintf (pool_name,sizeof (pool_name),"qdma_fle_pool_dev%d_qid%d" , dpdmai_dev->dpdmai_id, vchan); pool_size =sizeof (struct qdma_cntx_sg );
@@ -1656,6 +1612,9 @@ dpaa2_dpdmai_dev_init(struct rte_dma_dev *dev, uint32_t dpdmai_id)DPAA2_QDMA_FUNC_TRACE (); + dpdmai_dev->flags =0 ; +dpaax_get_devargs (s_dpaa2_qdma_devargs, dev, &dpdmai_dev->flags); +if (!dpaa2_coherent_no_alloc_cache) {if (dpaa2_svr_family ==SVR_LX2160A ) { dpaa2_coherent_no_alloc_cache =
@@ -1801,7 +1760,6 @@ static struct rte_dpaa2_driver rte_dpaa2_qdma_pmd = {RTE_PMD_REGISTER_DPAA2 (dpaa2_qdma, rte_dpaa2_qdma_pmd);RTE_PMD_REGISTER_PARAM_STRING (dpaa2_qdma, -DPAA2_QDMA_FLE_PRE_POPULATE "=<int>" -DPAA2_QDMA_DESC_DEBUG "=<int>" -DPAA2_QDMA_USING_SHORT_FD "=<int>" ); +DPAA2_DEVARGS (DPAAX_DEVARG_STRING_ENTRY ) +);RTE_LOG_REGISTER_DEFAULT (dpaa2_qdma_logtype,INFO );
drivers/dma/dpaa2/dpaa2_qdma.h +8 -7
@@ -1,5 +1,5 @@/* SPDX-License-Identifier: BSD-3-Clause -* Copyright 2018-2024 NXP +* Copyright 2018-2026 NXP */ #ifndef _DPAA2_QDMA_H_
@@ -233,6 +233,12 @@ struct __rte_packed_begin qdma_cntx_sg {#define DPAA2_QDMA_IDX_FROM_FLAG (flag) \ ((flag) >> RTE_DPAAX_QDMA_COPY_IDX_OFFSET) +enum dpaa2_dpdmai_dev_flags { +DPAA2_QDMA_FLE_PRE_POPULATE_FLAG =RTE_BIT32 (0 ), +DPAA2_QDMA_DESC_DEBUG_FLAG =RTE_BIT32 (1 ), +DPAA2_QDMA_SHORT_FD_FLAG =RTE_BIT32 (2 ) +}; +/** Represents a DPDMAI device */ struct dpaa2_dpdmai_dev {/** Pointer to Next device instance */
@@ -247,6 +253,7 @@ struct dpaa2_dpdmai_dev {struct dpaa2_queue rx_queue[DPAA2_DPDMAI_MAX_QUEUES ];/** TX queues */ struct dpaa2_queue tx_queue[DPAA2_DPDMAI_MAX_QUEUES ]; +uint32_t flags;struct qdma_device *qdma_dev; };
@@ -261,8 +268,6 @@ struct qdma_cntx_idx_ring {uint16_t nb_in_ring; }; -#define DPAA2_QDMA_DESC_DEBUG_FLAG (1 << 0) -/** Represents a QDMA virtual queue */ struct qdma_virt_queue {/** Associated hw queue */
@@ -273,8 +278,6 @@ struct qdma_virt_queue {void **fle_elem;/** Route by port */ struct dpaa2_qdma_rbp rbp; -/** States if this vq is in use or not */ -uint8_t fle_pre_populate;/** Number of descriptor for the virtual DMA channel */ uint16_t nb_desc;/* Total number of enqueues on this VQ */
@@ -284,7 +287,6 @@ struct qdma_virt_queue {uint64_t copy_num;uint16_t vq_id; -uint32_t flags;struct qbman_fd fd[DPAA2_QDMA_MAX_DESC ];uint16_t fd_idx;struct qdma_cntx_idx_ring *ring_cntx_idx;
@@ -295,7 +297,6 @@ struct qdma_virt_queue {uint16_t silent_idx;int num_valid_jobs; -int using_short_fd;struct rte_dma_stats stats; };
Signature · 1 line
2.43.0
PATCH 5/65 net/dpaa2: unify debug dump via log based helpers
In reply to Prashant GuptaFrom: Jun Yang <[email protected]>
The dpaa2 PMD printed debug output through several unrelated paths: the flow dump used a raw printf, and the Rx error queue dump used rte_hexdump() straight to stderr with sprintf-built titles. None of these went through the DPDK logging framework, so they could not be filtered and bypassed any configured log stream.
Route all debug dumps through the dpaa2 dump helpers instead. Point DPAA2_FLOW_DUMP at dpaa2_dump_print(), and add a dpaa2_dump_hex_print() helper that emits a buffer as hex using the same path. Convert the Rx error packet dump to use these helpers, rename dump_err_pkts() to dpaa2_dev_rx_err_pkts_dump() for consistency with the other datapath helpers, use rte_pktmbuf_mtod() for the segment payload, and simplify the surrounding code.
--- drivers/net/dpaa2/dpaa2_flow.c | 4 +-- drivers/net/dpaa2/dpaa2_pmd_logs.h | 17 ++++++++++ drivers/net/dpaa2/dpaa2_rxtx.c | 51 +++++++++++++----------------- 3 files changed, 41 insertions(+), 31 deletions(-)
drivers/net/dpaa2/dpaa2_flow.c +2 -2
@@ -1,5 +1,5 @@/* SPDX-License-Identifier: BSD-3-Clause -* Copyright 2018-2022 NXP +* Copyright 2018-2026 NXP */ #include <sys/queue.h>
@@ -196,7 +196,7 @@ static const struct rte_flow_item_pppoe dpaa2_flow_item_pppoe_mask = {#endif -#define DPAA2_FLOW_DUMP printf +#define DPAA2_FLOW_DUMP dpaa2_dump_print static inline void dpaa2_prot_field_string(uint32_t prot, uint32_t field,
drivers/net/dpaa2/dpaa2_pmd_logs.h +17 -0
@@ -51,4 +51,21 @@ dpaa2_dump_print(const char *fmt, ...)rte_vlog (RTE_LOG_NOTICE ,RTE_LOGTYPE_USER1 , fmt, ap); va_end(ap); } + +#define DPAA2_DUMP_HEX_LINE_SIZE 32 + +static inline void +dpaa2_dump_hex_print (const uint8_t *buf,size_t len) +{ +size_t i; + +for (i =0 ; i < len; i++) { +dpaa2_dump_print ("%02x " , buf[i]); + +if (!((i +1 ) %DPAA2_DUMP_HEX_LINE_SIZE )) +dpaa2_dump_print ("\n" ); + } +if (len %DPAA2_DUMP_HEX_LINE_SIZE ) +dpaa2_dump_print ("\n" ); +}#endif /* _DPAA2_PMD_LOGS_H_ */
drivers/net/dpaa2/dpaa2_rxtx.c +22 -29
99 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH 6/65 net/dpaa2: expose Rx L3/L4/L5 offsets via mbuf dynfield
In reply to Prashant GuptaFrom: Jun Yang <[email protected]>
The DPAA2 WRIOP parser already writes the L3, L4 and L5 header offsets of each received frame into the hardware annotation area (FAS word6). Applications that want to work with inner headers (IPsec, tunnel decap, L5 inspection, etc.) currently have to re-parse the packet in software even though the information is a single load away. Expose it through a per-mbuf dynfield so the PMD can hand it to the application without touching generic mbuf fields.
--- drivers/net/dpaa2/dpaa2_ethdev.c | 29 +++++++++- drivers/net/dpaa2/dpaa2_ethdev.h | 12 +++++ drivers/net/dpaa2/dpaa2_rxtx.c | 89 +++++++++++++++++++++++++++++++ drivers/net/dpaa2/rte_pmd_dpaa2.h | 4 ++ 4 files changed, 133 insertions(+), 1 deletion(-)
drivers/net/dpaa2/dpaa2_ethdev.c +28 -1
@@ -33,6 +33,32 @@#include <fsl_qbman_debug.h> #include <dpaax_devarg.h> +static const struct rte_mbuf_dynfield s_dpaa2_rx_protocol_pos_dyn = { + .name ="dpaa2_rx_protocol_pos_dyn" , + .size =sizeof (struct dpaa2_dyn_rx_protocol_pos ), + .align = __alignof__(struct dpaa2_dyn_rx_protocol_pos ), +}; + +static void +dpaa2_dev_args_parser_offset_en (void *vdev, +const struct rte_kvargs_pair *pair) +{ +struct rte_eth_dev *dev = vdev; +struct dpaa2_dev_priv *priv = dev->data->dev_private; +int ret, val =atoi (pair->value); + +if (!val) +return ; + + ret =rte_mbuf_dynfield_register (&s_dpaa2_rx_protocol_pos_dyn); +if (ret <0 ) { +DPAA2_PMD_ERR ("Failed(%d) to register for protocol pos" , ret); +return ; + } +DPAA2_PMD_INFO ("Register mbuf offset(%d) for protocol pos" , ret); + priv->psr_dynfield_offset = ret |DPAA2_PSR_DYNFIELD_OFFSET_EN ; +} +/* Single source of truth for dpaa2 devargs: * ENTRY(key-string, handle, flag-bit) * handle is an optional per-arg callback (NULL if the arg only sets a flag).
@@ -48,7 +74,8 @@ ENTRY("drv_rx_print_parser_result", NULL, DPAA2_RX_PRINT_PSR_RESULT_FLAG) \ ENTRY("drv_err_queue", NULL, DPAA2_RX_ERROR_QUEUE_FLAG) \ ENTRY("drv_no_taildrop", NULL, DPAA2_RX_TAILDROP_OFF) \ - ENTRY("drv_no_data_stashing", NULL, DPAA2_RX_DATA_STASHING_OFF_FLAG) + ENTRY("drv_no_data_stashing", NULL, DPAA2_RX_DATA_STASHING_OFF_FLAG) \ + ENTRY("drv_parse_protocol_offset", dpaa2_dev_args_parser_offset_en, 0)#define CHECK_INTERVAL 100/* 100ms */ #define MAX_REPEAT_TIME 90/* 9s (90 * 100ms) in total */
drivers/net/dpaa2/dpaa2_ethdev.h +12 -0
@@ -58,6 +58,10 @@#define CONG_RETRY_COUNT 18000 +#define DPAA2_PSR_DYNFIELD_OFFSET_EN RTE_BIT32(31) +#define DPAA2_PSR_DYNFIELD_OFFSET_MASK \ + (DPAA2_PSR_DYNFIELD_OFFSET_EN - 1) +/* RX queue tail drop threshold * currently considering 64 KB packets */
@@ -234,6 +238,13 @@ extern const struct rte_flow_ops dpaa2_flow_ops;extern const struct rte_tm_ops dpaa2_tm_ops; +struct dpaa2_dyn_rx_protocol_pos { +uint8_t l3_offset; +uint8_t l4_offset; +uint8_t l5_offset; +uint8_t rsv; +}; +#define DPAA2_FS_FLC_FS_MARK_OFFSET \ (DPAA2_FLC_DATA_STASHING + DPAA2_FLC_STASHING_MAX_BIT_SIZE)
@@ -436,6 +447,7 @@ struct dpaa2_dev_priv {void *tx_conf_vq[MAX_TX_QUEUES *DPAA2_MAX_CHANNELS ];void *rx_err_vq;uint32_t flags;/*dpaa2 config flags */ +uint32_t psr_dynfield_offset;uint8_t max_mac_filters;uint8_t max_vlan_filters;uint8_t num_rx_tc;
drivers/net/dpaa2/dpaa2_rxtx.c +89 -0
125 lines not on this page · raw message
drivers/net/dpaa2/rte_pmd_dpaa2.h +4 -0
@@ -144,6 +144,10 @@ rte_pmd_dpaa2_dev_is_dpaa2(uint32_t eth_id);__rte_experimental const char *rte_pmd_dpaa2_ep_name (uint32_t eth_id); +__rte_experimental +int +rte_pmd_dpaa2_rx_get_offset (uint16_t port_id,struct rte_mbuf *m, +uint8_t *l3_off,uint8_t *l4_off,uint8_t *l5_off);#if defined(RTE_LIBRTE_IEEE1588 ) __rte_experimental
Signature · 1 line
2.43.0
PATCH 7/65 net/dpaa2: optimize dpaa2 Tx queue and channel mapping
In reply to Prashant GuptaFrom: Jun Yang <[email protected]>
Allocate TX queues based on dpni attribute and align the bounds check with the RX queue logic:
- compute nb_tx_queues from num_tx_tcs * num_queues (respecting DPNI_OPT_SINGLE_SENDER) and cap at MAX_TX_QUEUES (128)
- cap nb_rx_queues at MAX_RX_QUEUES (128)
- cap num_channels at DPAA2_MAX_CHANNELS
- assign tc_index/flow_id at queue-allocation time instead of at queue-setup time
- replace the open-coded (channel << 8 | tc) with DPNI_BUILD_PARAM(channel, tc) throughout tx_queue_setup
- initialize fqid to DPAA2_INVALID_FQ_ID and use it as the already-configured guard (replacing DPAA2_INVALID_FLOW_ID)
- add a per-device tx_channels[] array for channel mapping
--- drivers/bus/fslmc/portal/dpaa2_hw_pvt.h | 1 + drivers/net/dpaa2/dpaa2_ethdev.c | 119 +++++++++++++++--------- drivers/net/dpaa2/dpaa2_ethdev.h | 5 +- 3 files changed, 78 insertions(+), 47 deletions(-)
drivers/bus/fslmc/portal/dpaa2_hw_pvt.h +1 -0
@@ -83,6 +83,7 @@#define DPAA2_DPCI_MAX_QUEUES 2#define DPAA2_INVALID_FLOW_ID 0xffff +#define DPAA2_INVALID_FQ_ID ((uint32_t)(-1))#define DPAA2_INVALID_CGID 0xff#define SEC_FLC_DHR_OUTBOUND (-114)
drivers/net/dpaa2/dpaa2_ethdev.c +74 -45
232 lines not on this page · raw message
drivers/net/dpaa2/dpaa2_ethdev.h +3 -2
@@ -30,7 +30,7 @@#define MAX_TCS DPNI_MAX_TC#define MAX_RX_QUEUES 128 -#define MAX_TX_QUEUES 16 +#define MAX_TX_QUEUES 128#define MAX_DPNI 8#define DPAA2_MAX_CHANNELS 16
@@ -438,13 +438,14 @@ struct dpaa2_dev_priv {int32_t hw_id;int32_t qdid;uint16_t token; +uint16_t tx_channels[DPAA2_MAX_CHANNELS ];uint8_t nb_tx_queues;uint8_t nb_rx_queues;uint32_t options;void *rx_vq[MAX_RX_QUEUES ];void *tx_vq[MAX_TX_QUEUES ];struct dpaa2_bp_list *bp_list;/**<Attached buffer pool list */ -void *tx_conf_vq[MAX_TX_QUEUES *DPAA2_MAX_CHANNELS ]; +void *tx_conf_vq[MAX_TX_QUEUES ];void *rx_err_vq;uint32_t flags;/*dpaa2 config flags */ uint32_t psr_dynfield_offset;
Signature · 1 line
2.43.0
PATCH 8/65 bus/fslmc: split bus-level device walk from VFIO primitives
In reply to Prashant GuptaFrom: Jun Yang <[email protected]>
The fslmc bus and its VFIO backend were tangled: VFIO-internal types and DPAA2_MC_*_DEVID constants were exposed in a public header, and the device-iteration / blocklist / primary-secondary policy for probe and close lived inside fslmc_vfio.c (fslmc_vfio_process_group / fslmc_vfio_close_group) even though it is pure bus logic. On top of that, several bus-internal symbols were still declared with public "fslmc_*" names.
--- drivers/bus/fslmc/fslmc_bus.c | 217 ++++++++++++- drivers/bus/fslmc/fslmc_vfio.c | 391 ++++++----------------- drivers/bus/fslmc/fslmc_vfio.h | 48 +-- drivers/bus/fslmc/portal/dpaa2_hw_dprc.c | 3 +- drivers/bus/fslmc/private.h | 14 +- 5 files changed, 326 insertions(+), 347 deletions(-)
drivers/bus/fslmc/fslmc_bus.c +213 -4
@@ -1,6 +1,6 @@/* SPDX-License-Identifier: BSD-3-Clause * -* Copyright 2016,2018-2021 NXP +* Copyright 2016,2018-2021, 2026 NXP * */
@@ -332,7 +332,7 @@ rte_fslmc_scan(void) goto scan_fail; } - ret =fslmc_get_container_group (group_name, &groupid); + ret =fslmc_vfio_get_container_group (group_name, &groupid);if (ret !=0 ) goto scan_fail;
@@ -383,6 +383,175 @@ rte_fslmc_scan(void)return 0 ; } +static int +fslmc_bus_process_iodevices (void ) +{ +int ret; +int found_mportal =0 ; +struct rte_dpaa2_device *dev; +bool is_dpmcp_in_blocklist = false, is_dpio_in_blocklist = false; +int dpmcp_count =0 , dpio_count =0 , current_device; + + RTE_BUS_FOREACH_DEV(dev, &rte_fslmc_bus) { +if (dev->dev_type ==DPAA2_MPORTAL ) { + dpmcp_count++; +if (dev->device.devargs && + dev->device.devargs->policy ==RTE_DEV_BLOCKED ) + is_dpmcp_in_blocklist = true; + } +if (dev->dev_type ==DPAA2_IO ) { + dpio_count++; +if (dev->device.devargs && + dev->device.devargs->policy ==RTE_DEV_BLOCKED ) + is_dpio_in_blocklist = true; + } + } + +/* Search the MCP as that should be initialized first. */ + current_device =0 ; + RTE_BUS_FOREACH_DEV(dev, &rte_fslmc_bus) { +if (dev->dev_type ==DPAA2_MPORTAL ) { + current_device++; +if (dev->device.devargs && + dev->device.devargs->policy ==RTE_DEV_BLOCKED ) { +DPAA2_BUS_DEBUG ("%s Blocked, skipping" , dev->device.name); +rte_bus_remove_device (&rte_fslmc_bus, &dev->device); +continue ; + } + +if (rte_eal_process_type () ==RTE_PROC_SECONDARY && + !is_dpmcp_in_blocklist) { +if (dpmcp_count ==1 || + current_device != dpmcp_count) { +rte_bus_remove_device (&rte_fslmc_bus, &dev->device); +continue ; + } + } + +if (!found_mportal) { + ret =fslmc_vfio_process_mcp (dev); +if (ret) { +DPAA2_BUS_ERR ("Unable to map MC Portal" ); +return ret; + } + found_mportal =1 ; + } + +rte_bus_remove_device (&rte_fslmc_bus, &dev->device); +free (dev); + dev =NULL ; +/* Ideally there is only a single dpmcp, but in case +* multiple exists, looping on remaining devices. +*/ + } + } + +/* Cannot continue if there is not even a single mportal */ +if (!found_mportal) { +DPAA2_BUS_ERR ("No MC Portal device found. Not continuing" ); +return -EIO ; + } + +/* Search for DPRC device next as it updates endpoint of +* other devices. +*/ + current_device =0 ; + RTE_BUS_FOREACH_DEV(dev, &rte_fslmc_bus) { +if (dev->dev_type ==DPAA2_DPRC ) { + ret =fslmc_vfio_process_iodevices (dev); +if (ret) { +DPAA2_BUS_ERR ("Unable to process dprc" ); +return ret; + } +rte_bus_remove_device (&rte_fslmc_bus, &dev->device); + } + } + + current_device =0 ; + RTE_BUS_FOREACH_DEV(dev, &rte_fslmc_bus) { +if (dev->dev_type ==DPAA2_IO ) + current_device++; +if (dev->device.devargs && + dev->device.devargs->policy ==RTE_DEV_BLOCKED ) { +DPAA2_BUS_DEBUG ("%s Blocked, skipping" , dev->device.name); +rte_bus_remove_device (&rte_fslmc_bus, &dev->device); +continue ; + } +if (rte_eal_process_type () ==RTE_PROC_SECONDARY && + dev->dev_type !=DPAA2_ETH && + dev->dev_type !=DPAA2_CRYPTO && + dev->dev_type !=DPAA2_QDMA && + dev->dev_type !=DPAA2_IO ) { +rte_bus_remove_device (&rte_fslmc_bus, &dev->device); +continue ; + } +switch (dev->dev_type) { +case DPAA2_ETH : +case DPAA2_CRYPTO : +case DPAA2_QDMA : + ret =fslmc_vfio_process_iodevices (dev); +if (ret) { +DPAA2_BUS_DEBUG ("Dev (%s) init failed" , dev->device.name); +return ret; + } +break ; +case DPAA2_CON : +case DPAA2_CI : +case DPAA2_BPOOL : +case DPAA2_DPRTC : +case DPAA2_MUX : +/* IN case of secondary processes, all control objects +* like dpbp, dpcon, dpci are not initialized/required +* - all of these are assumed to be initialized and made +* available by primary. +*/ +if (rte_eal_process_type () ==RTE_PROC_SECONDARY ) +continue ; + +/* Call the object creation routine and remove the +* device entry from device list +*/ + ret =fslmc_vfio_process_iodevices (dev); +if (ret) { +DPAA2_BUS_DEBUG ("Dev (%s) init failed" , dev->device.name); +return ret; + } + +break ; +case DPAA2_IO : +if (!is_dpio_in_blocklist && dpio_count >1 ) { +if (rte_eal_process_type () ==RTE_PROC_SECONDARY + && current_device != dpio_count) { +rte_bus_remove_device (&rte_fslmc_bus, &dev->device); +break ; + } +if (rte_eal_process_type () ==RTE_PROC_PRIMARY + && current_device == dpio_count) { +rte_bus_remove_device (&rte_fslmc_bus, &dev->device); +break ; + } + } + + ret =fslmc_vfio_process_iodevices (dev); +if (ret) { +DPAA2_BUS_DEBUG ("Dev (%s) init failed" , dev->device.name); +return ret; + } + +break ; +case DPAA2_UNKNOWN : +default : +/* Unknown - ignore */ +DPAA2_BUS_DEBUG ("Found unknown device (%s)" , dev->device.name); +rte_bus_remove_device (&rte_fslmc_bus, &dev->device); +free (dev); + dev =NULL ; + } + } + +return 0 ; +} +/* Bus initialization needs the DPDK heap and DMA mapping of the memory * segments, which EAL only sets up after the bus scan, so it is done here. */
@@ -424,7 +593,7 @@ rte_fslmc_probe(struct rte_bus *bus) } } - ret =fslmc_vfio_process_group (); + ret =fslmc_bus_process_iodevices ();if (ret) {DPAA2_BUS_ERR ("Unable to setup devices %d" , ret);return ret;
@@ -445,12 +614,52 @@ fslmc_bus_match(const struct rte_driver *drv, const struct rte_device *dev)return false; } +static int +fslmc_bus_close_group (void ) +{ +struct rte_dpaa2_device *dev; + + RTE_BUS_FOREACH_DEV(dev, &rte_fslmc_bus) { +if (dev->device.devargs && + dev->device.devargs->policy ==RTE_DEV_BLOCKED ) { +DPAA2_BUS_DEBUG ("%s Blacklisted, skipping" , dev->device.name); +rte_bus_remove_device (&rte_fslmc_bus, &dev->device); +continue ; + } +switch (dev->dev_type) { +case DPAA2_ETH : +case DPAA2_CRYPTO : +case DPAA2_QDMA : +case DPAA2_IO : +fslmc_vfio_close_iodevices (dev); +break ; +case DPAA2_CON : +case DPAA2_CI : +case DPAA2_BPOOL : +case DPAA2_MUX : +if (rte_eal_process_type () ==RTE_PROC_SECONDARY ) +continue ; + +fslmc_vfio_close_iodevices (dev); +break ; +case DPAA2_DPRTC : +default : +DPAA2_BUS_DEBUG ("Device cannot be closed: Not supported (%s)" , + dev->device.name); + } + } + +fslmc_vfio_clear_group (); + +return 0 ; +} +static int rte_fslmc_close(struct rte_bus *bus __rte_unused) {int ret =0 ; - ret =fslmc_vfio_close_group (); + ret =fslmc_bus_close_group ();if (ret)DPAA2_BUS_INFO ("Unable to close devices %d" , ret);
drivers/bus/fslmc/fslmc_vfio.c +92 -299
545 lines not on this page · raw message
drivers/bus/fslmc/fslmc_vfio.h +7 -41
68 lines not on this page · raw message
drivers/bus/fslmc/portal/dpaa2_hw_dprc.c +2 -1
@@ -1,6 +1,6 @@/* SPDX-License-Identifier: BSD-3-Clause * -* Copyright 2021 NXP +* Copyright 2021, 2026 NXP * */
@@ -17,6 +17,7 @@#include <mc/fsl_dprc.h> #include "portal/dpaa2_hw_pvt.h" +extern struct rte_bus rte_fslmc_bus;TAILQ_HEAD (dprc_dev_list, dpaa2_dprc_dev);static struct dprc_dev_list dprc_dev_list =TAILQ_HEAD_INITIALIZER (dprc_dev_list);/*!< DPRC device list */
drivers/bus/fslmc/private.h +12 -2
@@ -1,5 +1,5 @@/* SPDX-License-Identifier: BSD-3-Clause -* Copyright 2016,2021 NXP +* Copyright 2016, 2021, 2026 NXP */ #ifndef BUS_FSLMC_PRIVATE_H
@@ -9,6 +9,16 @@#include <bus_fslmc_driver.h> -extern struct rte_bus rte_fslmc_bus; +int fslmc_vfio_process_mcp (struct rte_dpaa2_device *dev); +int fslmc_vfio_process_iodevices (struct rte_dpaa2_device *dev); + +void fslmc_vfio_close_iodevices (struct rte_dpaa2_device *dev); + +int fslmc_vfio_setup_group (void ); +void fslmc_vfio_clear_group (void ); + +int fslmc_vfio_get_container_group (const char *group_name,int *gropuid); +int fslmc_vfio_dmamap (void ); +#endif /* BUS_FSLMC_PRIVATE_H */
Signature · 1 line
2.43.0
Re: [PATCH v4-S3 08/65] bus/fslmc: split bus-level device walk from VFIO primitives
Quoted 11 lines · Prashant Gupta
From: Jun Yang <[email protected]>
The fslmc bus and its VFIO backend were tangled: VFIO-internal types and DPAA2_MC_*_DEVID constants were exposed in a public header, and the device-iteration / blocklist / primary-secondary policy for probe and close lived inside
fslmc_vfio.c(fslmc_vfio_process_group/fslmc_vfio_close_group) even though it is pure bus logic. On top of that, several bus-internal symbols were still declared with public "fslmc_*" names.
Quoted 1 line
Signed-off-by Jun Yang <[email protected]>
https://patchwork.dpdk.org/project/dpdk/list/?series=39643
First version posted in July.
https://patchwork.dpdk.org/project/dpdk/patch/[email protected]/
Signature · 1 line
David Marchand
PATCH 9/65 bus/fslmc: centralize MC version and SoC detection in the bus layer
In reply to Prashant GuptaFrom: Jun Yang <[email protected]>
MC-version and SoC-version detection used to be split across several places and done lazily. That meant SoC-dependent globals were only populated after the first DPIO was created (anything running before that saw zero), the MC compatibility check sat in the VFIO mapping function (wrong layer), and the per-SoC table was hard-coded with magic numbers inside dpio.c.
Collect it all once, at MCP map time, and publish it via a per-device rte_fslmc_bus_info handle. Benefits:
- MC version and SoC identity are known as soon as the MCP is mapped, not lazily on first DPIO probe. Code paths that run before DPIO creation (e.g. memory pool / dma map / early dpaa2_svr_family-sensitive logic) now see valid values.
- The MC compatibility check lives at the right layer and runs for both primary and secondary processes through a single code path.
- Per-SoC quirks (cluster base/size, DQRR/EQCR ring sizes) are a single table lookup instead of magic numbers scattered across files; adding a new SoC becomes a one-line change.
- Drivers get MC/SoC info via dpaa2_dev->bus_info and no longer need to call MC commands themselves (dpaa2_fw_version_get() is the first consumer).
--- drivers/bus/fslmc/bus_fslmc_driver.h | 11 +- drivers/bus/fslmc/fslmc_bus.c | 4 +- drivers/bus/fslmc/fslmc_vfio.c | 141 ++++++++++++++++++++++- drivers/bus/fslmc/fslmc_vfio.h | 24 ++++ drivers/bus/fslmc/portal/dpaa2_hw_dpio.c | 79 +------------ drivers/bus/fslmc/portal/dpaa2_hw_dpio.h | 9 +- drivers/bus/fslmc/private.h | 3 +- drivers/net/dpaa2/dpaa2_ethdev.c | 18 ++- drivers/net/dpaa2/dpaa2_ethdev.h | 1 + drivers/net/dpaa2/dpaa2_rxtx.c | 7 +- 10 files changed, 198 insertions(+), 99 deletions(-)
drivers/bus/fslmc/bus_fslmc_driver.h +10 -1
@@ -1,6 +1,6 @@/* SPDX-License-Identifier: BSD-3-Clause * -* Copyright 2016,2021-2023 NXP +* Copyright 2016,2021-2026 NXP * */
@@ -89,6 +89,14 @@ enum rte_dpaa2_dev_type { DPAA2_DEVTYPE_MAX, }; +struct rte_fslmc_bus_info { +void *mem_pool; +int sp_protocol; +uint64_t mc_rev; +uint32_t svr; +uint32_t pvr; +}; +/** * A structure describing a DPAA2 device. */
@@ -102,6 +110,7 @@ struct rte_dpaa2_device {char ep_name[RTE_DEV_NAME_MAX_LEN ];struct rte_intr_handle *intr_handle;/**< Interrupt handle */ char name[FSLMC_OBJECT_MAX_LEN ];/**< DPAA2 Object name*/ +const struct rte_fslmc_bus_info *bus_info; }; typedef int (*rte_dpaa2_obj_create_t)(int vdev_fd,
drivers/bus/fslmc/fslmc_bus.c +3 -1
@@ -29,6 +29,7 @@struct rte_bus rte_fslmc_bus;static int fslmc_bus_device_count[DPAA2_DEVTYPE_MAX ]; +static struct rte_fslmc_bus_info fslmc_bus_info;#define DPAA2_SEQN_DYNFIELD_NAME "dpaa2_seqn_dynfield"RTE_EXPORT_INTERNAL_SYMBOL (dpaa2_seqn_dynfield_offset)
@@ -199,6 +200,7 @@ scan_one_fslmc_device(char *dev_name) goto cleanup; } dev->device.devargs =rte_bus_find_devargs (&rte_fslmc_bus, dev_name); + dev->bus_info = &fslmc_bus_info;/* Update the device found into the device_count table */ fslmc_bus_device_count[dev->dev_type]++;
@@ -429,7 +431,7 @@ fslmc_bus_process_iodevices(void) }if (!found_mportal) { - ret =fslmc_vfio_process_mcp (dev); + ret =fslmc_vfio_process_mcp (dev, &fslmc_bus_info);if (ret) {DPAA2_BUS_ERR ("Unable to map MC Portal" );return ret;
drivers/bus/fslmc/fslmc_vfio.c +140 -1
165 lines not on this page · raw message
drivers/bus/fslmc/fslmc_vfio.h +24 -0
@@ -15,6 +15,30 @@/* Pathname of FSL-MC devices directory. */ #define SYSFS_FSL_MC_DEVICES "/sys/bus/fsl-mc/devices" +extern uint32_t dpaa2_svr_family; +extern uint32_t dpaa2_dqrr_size; +extern uint32_t dpaa2_eqcr_size; +extern uint32_t dpaa2_cluster_base; +extern uint32_t dpaa2_cluster_size; + +#define DPAA2_SVR_MASK 0xffff0000 + +#define SVR_LS1080A 0x87030000 +#define SVR_LS2080A 0x87010000 +#define SVR_LS2088A 0x87090000 +#define SVR_LX2160A 0x87360000 + +#define MC_MAJOR_OFFSET 32 +#define MC_MINOR_OFFSET 16 +#define MC_MINOR_MASK ((((uint64_t)1) << (MC_MAJOR_OFFSET - MC_MINOR_OFFSET)) - 1) +#define MC_REVISION_MASK ((((uint64_t)1) << MC_MINOR_OFFSET) - 1) +#define RTE_FSL_MC_REV (major, minor, revision) \ + ((((uint64_t)(major)) << MC_MAJOR_OFFSET) + \ + (((uint64_t)(minor)) << MC_MINOR_OFFSET) + (revision)) +#define RTE_FSL_MC_REV_MAJOR (rev) ((uint32_t)((rev) >> MC_MAJOR_OFFSET)) +#define RTE_FSL_MC_REV_MINOR (rev) ((uint32_t)(((rev) >> MC_MINOR_OFFSET) & MC_MINOR_MASK)) +#define RTE_FSL_MC_REV_REVISION (rev) ((uint32_t)((rev) & MC_REVISION_MASK)) +__rte_internal int rte_dpaa2_intr_enable(struct rte_intr_handle *intr_handle, int index);
drivers/bus/fslmc/portal/dpaa2_hw_dpio.c +5 -74
119 lines not on this page · raw message
drivers/bus/fslmc/portal/dpaa2_hw_dpio.h +1 -8
@@ -1,7 +1,7 @@/* SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 2016 Freescale Semiconductor, Inc. All rights reserved. -* Copyright 2016-2023 NXP +* Copyright 2016-2023, 2026 NXP * */
@@ -35,13 +35,6 @@ RTE_DECLARE_PER_LCORE(struct dpaa2_io_portal_t, _dpaa2_io);#define DPAA2_PER_LCORE_DQRR_MBUF (i) \ RTE_PER_LCORE(_dpaa2_io).dpio_dev->dpaa2_held_bufs.mbuf[i] -/* Variable to store DPAA2 DQRR size */ -extern uint8_t dpaa2_dqrr_size; -/* Variable to store DPAA2 EQCR size */ -extern uint8_t dpaa2_eqcr_size; - -extern struct dpaa2_io_portal_t dpaa2_io_portal[RTE_MAX_LCORE ]; -/* Affine a DPIO portal to current processing thread */ __rte_internal int dpaa2_affine_qbman_swp(void);
drivers/bus/fslmc/private.h +2 -1
@@ -9,7 +9,8 @@#include <bus_fslmc_driver.h> -int fslmc_vfio_process_mcp (struct rte_dpaa2_device *dev); +int fslmc_vfio_process_mcp (struct rte_dpaa2_device *dev, +struct rte_fslmc_bus_info *bus_info);int fslmc_vfio_process_iodevices (struct rte_dpaa2_device *dev);void fslmc_vfio_close_iodevices (struct rte_dpaa2_device *dev);
drivers/net/dpaa2/dpaa2_ethdev.c +8 -10
@@ -369,24 +369,21 @@ dpaa2_fw_version_get(struct rte_eth_dev *dev, char *fw_version, size_t fw_size) { int ret; +uint32_t major, minor, rev; +struct dpaa2_dev_priv *priv = dev->data->dev_private;struct fsl_mc_io *dpni = dev->process_private;struct mc_soc_version mc_plat_info = {0 }; -struct mc_version mc_ver_info = {0 };PMD_INIT_FUNC_TRACE (); + major =RTE_FSL_MC_REV_MAJOR (priv->mc_rev); + minor =RTE_FSL_MC_REV_MINOR (priv->mc_rev); + rev =RTE_FSL_MC_REV_REVISION (priv->mc_rev);if (mc_get_soc_version (dpni,CMD_PRI_LOW , &mc_plat_info))DPAA2_PMD_WARN ("\tmc_get_soc_version failed" ); -if (mc_get_version (dpni,CMD_PRI_LOW , &mc_ver_info)) -DPAA2_PMD_WARN ("\tmc_get_version failed" ); - - ret =snprintf (fw_version, fw_size, -"%x-%d.%d.%d" , - mc_plat_info.svr, - mc_ver_info.major, - mc_ver_info.minor, - mc_ver_info.revision); + ret =snprintf (fw_version, fw_size,"%x-%d.%d.%d" , + mc_plat_info.svr, major, minor, rev);if (ret <0 )return -EINVAL ;
@@ -3521,6 +3518,7 @@ dpaa2_dev_init(struct rte_eth_dev *eth_dev) goto init_err; } + priv->mc_rev = dpaa2_dev->bus_info->mc_rev; priv->num_rx_tc = attr.num_rx_tcs; priv->num_tx_tc = attr.num_tx_tcs; priv->qos_entries = attr.qos_entries;
drivers/net/dpaa2/dpaa2_ethdev.h +1 -0
@@ -505,6 +505,7 @@ struct dpaa2_dev_priv {uint32_t *cnt_idx_dma_mem;uint64_t *cnt_values_dma_mem;uint64_t cnt_idx_iova, cnt_values_iova; +uint64_t mc_rev;struct dpaa2_dev_flow *curr; LIST_HEAD(, dpaa2_dev_flow) flows;
drivers/net/dpaa2/dpaa2_rxtx.c +4 -3
@@ -1149,7 +1149,8 @@ dpaa2_dev_rx_common(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts,struct dpaa2_queue *dpaa2_q = queue;struct qbman_result *dq_storage;uint32_t fqid = dpaa2_q->fqid; -int ret, num_rx =0 , next_pull = nb_pkts, num_pulled; +uint16_t num_rx =0 , next_pull = nb_pkts, num_pulled; +int ret;uint8_t pending, status;struct qbman_swp *swp;const struct qbman_fd *fd;
@@ -1293,8 +1294,8 @@ uint16_t dpaa2_dev_tx_conf(void *queue)/* Function receive frames for a given device and VQ */ struct dpaa2_queue *dpaa2_q = (struct dpaa2_queue *)queue;struct qbman_result *dq_storage; -uint32_t fqid = dpaa2_q->fqid; -int ret, num_tx_conf =0 , num_pulled; +uint32_t fqid = dpaa2_q->fqid, num_tx_conf =0 , num_pulled; +int ret;uint8_t pending, status;struct qbman_swp *swp;const struct qbman_fd *fd;
Signature · 1 line
2.43.0
PATCH 10/65 net/dpaa2: remove unused soft parser loader
In reply to Prashant GuptaFrom: Jun Yang <[email protected]>
The DPAA2 soft parser (SP) byte code has to be installed by the boot firmware before Linux starts; the WRIOP parser cannot be reprogrammed once the MC is up. Loading an SP image at run time from the PMD therefore never took effect, so the loader and its DPNI_SS_INGRESS plumbing were dead code and are removed, together with dpaa2_sparser.c/.h and the DPAA2_ENABLE_SOFT_PARSER environment hook.
Instead of trying to load an SP image, the presence of a soft parser protocol is now detected once from the WRIOP parser CCSR at bus scan time (fslmc_soft_parser_protocol_supported()) and exposed through priv->sp_protocol. The rte_flow pattern checks that previously relied on the run-time dpaa2_soft_parser_loaded() probe now consume priv->sp_protocol instead.
--- drivers/bus/fslmc/fslmc_bus.c | 89 +++++++++++++ drivers/bus/fslmc/fslmc_logs.h | 2 + drivers/net/dpaa2/dpaa2_ethdev.c | 28 +---- drivers/net/dpaa2/dpaa2_ethdev.h | 1 - drivers/net/dpaa2/dpaa2_flow.c | 114 +++-------------- drivers/net/dpaa2/dpaa2_recycle.c | 3 +- drivers/net/dpaa2/dpaa2_sparser.c | 137 -------------------- drivers/net/dpaa2/dpaa2_sparser.h | 202 ------------------------------ drivers/net/dpaa2/meson.build | 1 - 9 files changed, 107 insertions(+), 470 deletions(-) delete mode 100644 drivers/net/dpaa2/dpaa2_sparser.c delete mode 100644 drivers/net/dpaa2/dpaa2_sparser.h
drivers/bus/fslmc/fslmc_bus.c +89 -0
@@ -8,6 +8,7 @@#include <dirent.h> #include <stdalign.h> #include <stdbool.h> +#include <sys/mman.h> #include <eal_export.h> #include <rte_log.h>
@@ -35,6 +36,93 @@ static struct rte_fslmc_bus_info fslmc_bus_info;RTE_EXPORT_INTERNAL_SYMBOL (dpaa2_seqn_dynfield_offset) int dpaa2_seqn_dynfield_offset = -1; +/** For LX2160A, LS2088A and LS1088A*/ +#define WRIOP_CCSR_BASE 0x8b80000 +#define WRIOP_CCSR_CTLU_OFFSET 0 +#define WRIOP_CCSR_CTLU_PARSER_OFFSET 0 +#define WRIOP_CCSR_CTLU_PARSER_INGRESS_OFFSET 0 + +#define WRIOP_INGRESS_PARSER_PHY \ + (WRIOP_CCSR_BASE + WRIOP_CCSR_CTLU_OFFSET + \ + WRIOP_CCSR_CTLU_PARSER_OFFSET + \ + WRIOP_CCSR_CTLU_PARSER_INGRESS_OFFSET) + +struct __rte_packed_begin dpaa2_parser_ccsr { +uint32_t psr_cfg; +uint32_t psr_idle; +uint32_t psr_pclm; +uint8_t psr_ver_min; +uint8_t psr_ver_maj; +uint8_t psr_id1_l; +uint8_t psr_id1_h; +uint32_t psr_rev2; +uint8_t rsv[0x2c ]; +uint8_t sp_ins[4032 ]; +} __rte_packed_end; + +#define SP_PROTOCOL_MAGIC_DATA 0xabcd +#define SP_PROTOCOL_MAGIC_OFFSET 0x4 + +/** Number of soft parser firmware bytes reported for debugging. */ +#define SP_PRINT_LEN 128 +/** Firmware bytes logged per debug line. */ +#define SP_DUMP_BYTES_PER_LINE 16 + +static void +fslmc_soft_parser_protocol_supported (void ) +{ +int fd, i, pos =0 ; +void *map_addr =NULL ; +const struct dpaa2_parser_ccsr *parser_ccsr =NULL ; +const uint16_t *magic_num; +char line[SP_DUMP_BYTES_PER_LINE *3 +1 ]; + + fd =open ("/dev/mem" ,O_RDWR |O_SYNC ); +if (fd <0 ) { +DPAA2_BUS_ERR ("open \"/dev/mem\" ERROR(%d)" , fd); + goto exit; + } + + map_addr =mmap (NULL ,sizeof (struct dpaa2_parser_ccsr ), +PROT_READ |PROT_WRITE ,MAP_SHARED , fd, +WRIOP_INGRESS_PARSER_PHY ); +if (map_addr ==MAP_FAILED ) { +DPAA2_BUS_ERR ("Map 0x%" PRIx64"(size=0x%zx) failed" , + (uint64_t )WRIOP_INGRESS_PARSER_PHY , +sizeof (struct dpaa2_parser_ccsr )); + map_addr =NULL ; + goto exit; + } + parser_ccsr = map_addr; + +DPAA2_BUS_DEBUG ("Soft ParserID:0x%02x%02x, Rev:maj(%02x), min(%02x)" , + parser_ccsr->psr_id1_h, parser_ccsr->psr_id1_l, + parser_ccsr->psr_ver_maj, parser_ccsr->psr_ver_min); + + magic_num = (const void *)&parser_ccsr->sp_ins[SP_PROTOCOL_MAGIC_OFFSET ]; +if (*magic_num ==SP_PROTOCOL_MAGIC_DATA ) { + fslmc_bus_info.sp_protocol = true; +DPAA2_BUS_NOTICE ("Soft parser protocol support." ); +DPAA2_BUS_NOTICE ("First %d bytes of sp protocol firmware:" ,SP_PRINT_LEN ); +for (i =0 ; i <SP_PRINT_LEN ; i++) { + pos +=snprintf (&line[pos],sizeof (line) - pos, +"%02x " , parser_ccsr->sp_ins[i]); +if ((i +1 ) %SP_DUMP_BYTES_PER_LINE ==0 ) { +DPAA2_BUS_NOTICE ("%s" , line); + pos =0 ; + } + } +if (pos) +DPAA2_BUS_NOTICE ("%s" , line); + } + +exit: +if (map_addr) +munmap (map_addr,sizeof (struct dpaa2_parser_ccsr )); +if (fd >=0 ) +close (fd); +} +RTE_EXPORT_INTERNAL_SYMBOL (rte_fslmc_get_device_count) uint32_trte_fslmc_get_device_count (enum rte_dpaa2_dev_type device_type)
@@ -345,6 +433,7 @@ rte_fslmc_scan(void)DPAA2_BUS_ERR ("Unable to open VFIO group directory" ); goto scan_fail; } +fslmc_soft_parser_protocol_supported ();/* Scan the DPRC container object */ ret =scan_one_fslmc_device (group_name);
drivers/bus/fslmc/fslmc_logs.h +2 -0
@@ -19,6 +19,8 @@ extern int dpaa2_logtype_bus;#define DPAA2_BUS_INFO (fmt, ...) \ DPAA2_BUS_LOG(INFO, fmt, ## __VA_ARGS__) +#define DPAA2_BUS_NOTICE (fmt, ...) \ + DPAA2_BUS_LOG(NOTICE, fmt, ## __VA_ARGS__)#define DPAA2_BUS_ERR (fmt, ...) \ DPAA2_BUS_LOG(ERR, fmt, ## __VA_ARGS__)#define DPAA2_BUS_WARN (fmt, ...) \
drivers/net/dpaa2/dpaa2_ethdev.c +1 -27
@@ -29,7 +29,6 @@#include <mc/fsl_dpmng.h> #include <mc/fsl_dpcon.h> #include "dpaa2_ethdev.h" -#include "dpaa2_sparser.h" #include <fsl_qbman_debug.h> #include <dpaax_devarg.h>
@@ -3688,33 +3687,8 @@ dpaa2_dev_init(struct rte_eth_dev *eth_dev) } eth_dev->data->mtu =RTE_ETHER_MTU ; -/*TODO To enable soft parser support DPAA2 driver needs to integrate -* with external entity to receive byte code for software sequence -* and same will be offload to the H/W using MC interface. -* Currently it is assumed that DPAA2 driver has byte code by some -* mean and same if offloaded to H/W. -*/ -if (getenv ("DPAA2_ENABLE_SOFT_PARSER" )) { -WRIOP_SS_INITIALIZER (priv); - ret =dpaa2_eth_load_wriop_soft_parser (priv,DPNI_SS_INGRESS ); -if (ret <0 ) { -DPAA2_PMD_ERR (" Error(%d) in loading softparser" , - ret); - goto init_err; - } - - ret =dpaa2_eth_enable_wriop_soft_parser (priv, -DPNI_SS_INGRESS ); -if (ret <0 ) { -DPAA2_PMD_ERR (" Error(%d) in enabling softparser" , - ret); - goto init_err; - } - } + priv->sp_protocol = dpaa2_dev->bus_info->sp_protocol; - ret =dpaa2_soft_parser_loaded (); -if (ret >0 ) -DPAA2_PMD_INFO ("soft parser is loaded" );DPAA2_PMD_INFO ("%s: netdev created, connected to %s" , eth_dev->data->name, dpaa2_dev->ep_name);
drivers/net/dpaa2/dpaa2_ethdev.h +0 -1
@@ -637,7 +637,6 @@ int dpaa2_timesync_read_tx_timestamp(struct rte_eth_dev *dev,int dpaa2_dev_recycle_config (struct rte_eth_dev *eth_dev);int dpaa2_dev_recycle_deconfig (struct rte_eth_dev *eth_dev); -int dpaa2_soft_parser_loaded (void );void dpaa2_dev_mac_setup_stats (struct rte_eth_dev *dev);
drivers/net/dpaa2/dpaa2_flow.c +14 -100
187 lines not on this page · raw message
drivers/net/dpaa2/dpaa2_recycle.c +1 -2
@@ -1,5 +1,5 @@/* SPDX-License-Identifier: BSD-3-Clause -* Copyright 2019-2021 NXP +* Copyright 2019-2026 NXP */ #include <time.h>
@@ -23,7 +23,6 @@#include <dpaa2_hw_dpio.h> #include <mc/fsl_dpmng.h> #include "dpaa2_ethdev.h" -#include "dpaa2_sparser.h" #include <fsl_qbman_debug.h> #include <rte_io.h>
drivers/net/dpaa2/dpaa2_sparser.c deleted +0 -137
137 lines not on this page · raw message
drivers/net/dpaa2/dpaa2_sparser.h deleted +0 -202
202 lines not on this page · raw message
drivers/net/dpaa2/meson.build +0 -1
@@ -16,7 +16,6 @@ sources = files( 'dpaa2_flow.c', 'dpaa2_recycle.c', 'dpaa2_rxtx.c', - 'dpaa2_sparser.c', 'dpaa2_ptp.c', 'mc/dprtc.c', 'mc/dpkg.c',
Signature · 1 line
2.43.0
PATCH 11/65 net/dpaa2: cache per-rxq DPNI queue cfg and share CGID per TC
In reply to Prashant GuptaFrom: Jun Yang <[email protected]>
Rework DPAA2 Rx queue setup so the DPNI queue descriptor is allocated once per Rx queue and reused on later reconfiguration (eventq attach / detach, release), and change congestion-group (CGID) allocation from one CGID per Rx queue to one CGID shared by all Rx queues of the same traffic class.
--- drivers/bus/fslmc/portal/dpaa2_hw_pvt.h | 3 +- drivers/net/dpaa2/dpaa2_ethdev.c | 269 ++++++++++++------------ drivers/net/dpaa2/dpaa2_ethdev.h | 3 +- 3 files changed, 134 insertions(+), 141 deletions(-)
drivers/bus/fslmc/portal/dpaa2_hw_pvt.h +2 -1
@@ -177,7 +177,6 @@ struct __rte_cache_aligned dpaa2_queue {uint32_t fqid;/*!< Unique ID of this queue */ uint16_t flow_id;/*!< To be used by DPAA2 framework */ uint8_t tc_index;/*!< traffic class identifier */ -uint8_t cgid;/*! < Congestion Group id for this queue */ uint64_t rx_pkts;uint64_t tx_pkts;uint64_t err_pkts;
@@ -187,6 +186,8 @@ struct __rte_cache_aligned dpaa2_queue {/**Egress*/ struct qbman_result *cscn; }; +void *cfg; +uint8_t options;struct rte_event ev;dpaa2_queue_cb_dqrr_t *cb;dpaa2_queue_cb_eqresp_free_t *cb_eqresp_free;
drivers/net/dpaa2/dpaa2_ethdev.c +130 -139
435 lines not on this page · raw message
drivers/net/dpaa2/dpaa2_ethdev.h +2 -1
@@ -460,7 +460,8 @@ struct dpaa2_dev_priv {uint8_t en_ordered;uint8_t en_loose_ordered;uint8_t max_cgs; -uint8_t cgid_in_use[MAX_RX_QUEUES ]; +/** RXQs in same TC share same cgid.*/ +uint8_t cgid_in_use[MAX_TCS ];/* Current hash distribution size per RX TC, written by * dpaa2_setup_flow_dist_size() and read by reta_query / reta_update.
Signature · 1 line
2.43.0
PATCH 12/65 The dpaa2 PMD so far supported only two Tx buffer release schemes: direct release by hardware, and an absolute Tx confirmation mode (drv_tx_conf=1) where every transmitted buffer is returned on a Tx confirmation queue that software must poll to free the buffers. Absolute confirmation adds a confirmation descriptor and a poll cost for all packets, even those the hardware could free on its own.
In reply to Prashant GuptaFrom: Jun Yang <[email protected]>
Add a dynamic Tx confirmation mode in which only the buffers that the hardware cannot release directly (for example indirect, external or shared buffers) are returned on the Tx confirmation queue, while ordinary buffers from the known hardware pool are still freed by the hardware. This keeps the fast path cheap and limits confirmation polling to the cases that actually need it. The mode is enabled with the new device argument drv_tx_dyn_conf=1.
The Tx path is reworked to build either a simple or a scatter-gather FD with per-buffer confirmation decided at enqueue time (dpaa2_dev_tx_mbuf_to_simple_fd / dpaa2_dev_tx_mbuf_to_sg_fd and the confirm/no-confirm SGE helpers), the FAEAD is programmed accordingly (dpaa2_dev_tx_config_dynamic_confirm), and dpaa2_dev_tx_conf() drains the confirmation queue and frees only the buffers that were handed back. The Rx FD-to-mbuf helpers are exported so the confirmation path can reuse them. Documentation and the device argument string are updated for the new option.
--- doc/guides/nics/dpaa2.rst | 11 +- drivers/net/dpaa2/base/dpaa2_hw_dpni.c | 2 +- drivers/net/dpaa2/base/dpaa2_hw_dpni_annot.h | 6 +- drivers/net/dpaa2/dpaa2_ethdev.c | 67 +- drivers/net/dpaa2/dpaa2_ethdev.h | 27 +- drivers/net/dpaa2/dpaa2_ptp.c | 6 +- drivers/net/dpaa2/dpaa2_rxtx.c | 1436 ++++++++---------- 7 files changed, 683 insertions(+), 872 deletions(-)
doc/guides/nics/dpaa2.rst +9 -2
@@ -476,10 +476,17 @@ Refer to the document :doc:`build_and_test` for details. of the packet pull command which is issued in the previous cycle. e.g. ``fslmc:dpni.1,drv_no_prefetch=1`` -* Use dev arg option ``drv_tx_conf=1`` to enable TX confirmation mode. - In this mode tx conf queues need to be polled to free the buffers. +* Use dev arg option ``drv_tx_conf=1`` to enable absolute TX confirmation mode. + In this mode every transmitted buffer is returned on a tx conf queue which + needs to be polled to free the buffers. e.g. ``fslmc:dpni.1,drv_tx_conf=1`` +* Use dev arg option ``drv_tx_dyn_conf=1`` to enable dynamic TX confirmation + mode. In this mode only buffers that cannot be released directly by the + hardware (for example indirect, external or shared buffers) are returned on + a tx conf queue which needs to be polled to free the buffers. + e.g. ``fslmc:dpni.1,drv_tx_dyn_conf=1`` + * Use dev arg option ``drv_rx_parse_drop=1`` to configure the system to start dropping the error packets in hardware (parse errors). e.g. ``fslmc:dpni.1,drv_rx_parse_drop=1``
drivers/net/dpaa2/base/dpaa2_hw_dpni.c +1 -1
@@ -482,7 +482,7 @@ dpaa2_attach_bp_list(struct dpaa2_dev_priv *priv,*/ /* ... rx buffer layout ... */ -if (priv->flags &DPAA2_TX_DYNAMIC_CONF_ENABLE ) { +if (priv->tx_conf_type ==DPAA2_TX_DYNAMIC_CONF ) {int out_min_hdr_room, in_min_hdr_room;/** Additional headroom layout for IPSec with TX configure * dynamic enabled.
drivers/net/dpaa2/base/dpaa2_hw_dpni_annot.h +5 -1
@@ -1,7 +1,7 @@/* SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 2016 Freescale Semiconductor, Inc. All rights reserved. -* Copyright 2016,2019,2022,2024 NXP +* Copyright 2016,2019,2022,2024-2026 NXP * */
@@ -281,6 +281,10 @@ struct dpaa2_faead {/*UPD (Update prepended data)*/ #define DPAA2_ANNOT_FAEAD_UPD 0x00000010 +#define DPAA2_TX_CONFIRM_ENABLE \ + (DPAA2_ANNOT_FAEAD_A4V | DPAA2_ANNOT_FAEAD_EBDD | \ + DPAA2_ANNOT_FAEAD_EBDDV) +/* Debug frame, otherwise supposed to be discarded */ #define DPAA2_ETH_FAS_DISC 0x80000000/* MACSEC frame */
drivers/net/dpaa2/dpaa2_ethdev.c +43 -24
131 lines not on this page · raw message
drivers/net/dpaa2/dpaa2_ethdev.h +13 -14
@@ -95,20 +95,12 @@#define DPAA2_TX_DPNI_LOOPBACK_MODE RTE_BIT32(7) -/* Tx confirmation enabled */ -#define DPAA2_TX_CONF_ENABLE RTE_BIT32(8) - -/* Tx dynamic confirmation enabled, -* only valid with Tx confirmation enabled. -*/ -#define DPAA2_TX_DYNAMIC_CONF_ENABLE RTE_BIT32(9) -/* Disable data stashing (prefetch of packet data into CPU cache) */ -#define DPAA2_RX_DATA_STASHING_OFF_FLAG RTE_BIT32(10) +#define DPAA2_RX_DATA_STASHING_OFF_FLAG RTE_BIT32(8) -#define DPAA2_RX_ERROR_QUEUE_FLAG RTE_BIT32(11) +#define DPAA2_RX_ERROR_QUEUE_FLAG RTE_BIT32(9) -#define DPAA2_RX_PRINT_PSR_RESULT_FLAG RTE_BIT32(12) +#define DPAA2_RX_PRINT_PSR_RESULT_FLAG RTE_BIT32(10)/* DPDMUX index for DPMAC */ #define DPAA2_DPDMUX_DPMAC_IDX 0
@@ -433,6 +425,12 @@ struct extract_s {uint8_t *tc_extract_param[MAX_TCS ]; }; +enum dpaa2_tx_conf_type { +DPAA2_TX_NO_CONF , +DPAA2_TX_ABSOLUTE_CONF , +DPAA2_TX_DYNAMIC_CONF +}; +struct dpaa2_dev_priv {void *hw;int32_t hw_id;
@@ -448,6 +446,7 @@ struct dpaa2_dev_priv {void *tx_conf_vq[MAX_TX_QUEUES ];void *rx_err_vq;uint32_t flags;/*dpaa2 config flags */ +enum dpaa2_tx_conf_type tx_conf_type;uint32_t psr_dynfield_offset;uint8_t max_mac_filters;uint8_t max_vlan_filters;
@@ -487,10 +486,10 @@ struct dpaa2_dev_priv {/*stores timestamp of last received tx confirmation packet on dev*/ uint64_t tx_timestamp; -/* stores pointer to next tx_conf queue that should be processed, +/* stores next tx queue to be confirmed that should be processed, * it corresponds to last packet transmitted */ -struct dpaa2_queue *next_tx_conf_queue; +struct dpaa2_queue *next_txq_to_cnf;struct rte_eth_dev *eth_dev;/**< Pointer back to holding ethdev */ rte_spinlock_t lpbk_qp_lock;
@@ -621,7 +620,7 @@ uint16_t dpaa2_dev_tx_multi_txq_ordered(void **queue,void dpaa2_dev_free_eqresp_buf (uint16_t eqresp_ci,struct dpaa2_queue *dpaa2_q);void dpaa2_flow_clean (struct rte_eth_dev *dev); -uint16_t dpaa2_dev_tx_conf(void *queue) __rte_unused; +uint16_t dpaa2_dev_tx_conf (void *txq,int drain);int dpaa2_timesync_enable (struct rte_eth_dev *dev);int dpaa2_timesync_disable (struct rte_eth_dev *dev);
drivers/net/dpaa2/dpaa2_ptp.c +3 -3
@@ -1,5 +1,5 @@/* SPDX-License-Identifier: BSD-3-Clause -* Copyright 2019, 2023 NXP +* Copyright 2019, 2023-2026 NXP */ #include <sys/queue.h>
@@ -111,9 +111,9 @@ int dpaa2_timesync_read_tx_timestamp(struct rte_eth_dev *dev, {struct dpaa2_dev_priv *priv = dev->data->dev_private; -if (priv->next_tx_conf_queue) { +if (priv->next_txq_to_cnf) {while (!priv->tx_timestamp) -dpaa2_dev_tx_conf (priv->next_tx_conf_queue); +dpaa2_dev_tx_conf (priv->next_txq_to_cnf, false); }else {return -1 ; }
drivers/net/dpaa2/dpaa2_rxtx.c +609 -827
1,688 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH 13/65 net/dpaa2: support runtime IEEE1588 timestamping
In reply to Prashant GuptaFrom: Jun Yang <[email protected]>
IEEE1588 timestamping in the dpaa2 PMD was only available when the whole DPDK build was compiled with RTE_LIBRTE_IEEE1588. The timesync ops, the Tx confirmation timestamp read and the one-step PTP setup were all guarded by that build-time macro, and the Rx timestamp relied on the global dpaa2_enable_ts[] / dpaa2_timestamp_dynfield_offset state. This made PTP a compile-time decision shared by all ports and prevented enabling it per device at runtime.
Rework the timestamping path to be controlled at runtime:
- Drop the RTE_LIBRTE_IEEE1588 guards around the timesync ops and the dprtc object registration, and remove the global dpaa2_enable_ts[], dpaa2_timestamp_rx_dynflag and dpaa2_timestamp_dynfield_offset variables. Rx/Tx timestamping is now tracked per device through priv->flags (DPAA2_IEEE1588_RX_TS_FLAG / DPAA2_IEEE1588_TX_TS_FLAG) and the per-device rx_ts_offset / rx_ts_flag dynfield registration.
- Enable Tx one-step PTP at timesync_enable() time and update the correction offset at runtime from the actual PTP header of each transmitted frame (dpaa2_dev_tx_ptp_one_step_runtime), using the shared dpaax_ptp helpers to parse the header. The Tx path marks timestamp requests, forces dynamic confirmation for those frames, and the Tx confirmation handler records the egress timestamp.
- Make the shared PTP state SMP-safe by converting rx_timestamp, tx_timestamp, next_txq_to_cnf and the per-queue ts_to_cnfd pending counter to C11 atomics, and read the Tx timestamp by draining the confirmation queue until the pending count reaches zero.
- Add an optional debug trace (DPAA2_IEEE1588_DEBUG_FLAG, enabled when the PMD log level is DEBUG) for the timesync operations.
Since one-step PTP is now configured internally, remove the experimental APIs rte_pmd_dpaa2_set_one_step_ts() and rte_pmd_dpaa2_get_one_step_ts() and document their removal in the 26.11 release notes.
--- doc/guides/rel_notes/release_26_11.rst | 2 + drivers/bus/fslmc/portal/dpaa2_hw_pvt.h | 1 + drivers/net/dpaa2/dpaa2_ethdev.c | 89 +---------- drivers/net/dpaa2/dpaa2_ethdev.h | 38 ++++- drivers/net/dpaa2/dpaa2_ptp.c | 175 ++++++++++++++++++---- drivers/net/dpaa2/dpaa2_rxtx.c | 190 +++++++++++++++++++----- drivers/net/dpaa2/rte_pmd_dpaa2.h | 10 -- 7 files changed, 335 insertions(+), 170 deletions(-)
doc/guides/rel_notes/release_26_11.rst +2 -0
@@ -163,6 +163,8 @@ Removed Items This section is a comment. Do not overwrite or remove it. Also, make sure to start the actual text at the margin. ======================================================= +* net/dpaa2: Removed the experimental one-step PTP APIs + ``rte_pmd_dpaa2_set_one_step_ts()`` and ``rte_pmd_dpaa2_get_one_step_ts()``. * Removed deprecated symbols:
drivers/bus/fslmc/portal/dpaa2_hw_pvt.h +1 -0
@@ -199,6 +199,7 @@ struct __rte_cache_aligned dpaa2_queue {uint16_t tm_sw_td;/*!< TM software taildrop */ uint64_t offloads;uint64_t lpbk_cntx; +RTE_ATOMIC (int32_t ) ts_to_cnfd;uint8_t data_stashing_off;/* NAPI rx-interrupt: per-queue DPCON bound to this FQ at dev_start * (DEST_DPCON, static); the polling worker points the channel's CDAN at
drivers/net/dpaa2/dpaa2_ethdev.c +5 -84
135 lines not on this page · raw message
drivers/net/dpaa2/dpaa2_ethdev.h +30 -8
@@ -8,6 +8,7 @@#ifndef _DPAA2_ETHDEV_H#define _DPAA2_ETHDEV_H +#include <rte_time.h> #include <rte_compat.h> #include <rte_event_eth_rx_adapter.h> #include <rte_pmd_dpaa2.h>
@@ -102,6 +103,12 @@#define DPAA2_RX_PRINT_PSR_RESULT_FLAG RTE_BIT32(10) +#define DPAA2_IEEE1588_DEBUG_FLAG RTE_BIT32(11) + +#define DPAA2_IEEE1588_TX_TS_FLAG RTE_BIT32(12) + +#define DPAA2_IEEE1588_RX_TS_FLAG RTE_BIT32(13) +/* DPDMUX index for DPMAC */ #define DPAA2_DPDMUX_DPMAC_IDX 0
@@ -220,11 +227,6 @@ struct sw_buf_free {struct rte_mbuf *seg; }; -/* enable timestamp in mbuf*/ -extern bool dpaa2_enable_ts[]; -extern uint64_t dpaa2_timestamp_rx_dynflag; -extern int dpaa2_timestamp_dynfield_offset; -/* Externally defined */ extern const struct rte_flow_ops dpaa2_flow_ops;
@@ -482,14 +484,16 @@ struct dpaa2_dev_priv {uint64_t ss_iova;uint64_t ss_param_iova;/*stores timestamp of last received packet on dev*/ -uint64_t rx_timestamp; +RTE_ATOMIC (uint64_t ) rx_timestamp;/*stores timestamp of last received tx confirmation packet on dev*/ -uint64_t tx_timestamp; +RTE_ATOMIC (uint64_t ) tx_timestamp; +int rx_ts_offset; +uint64_t rx_ts_flag;/* stores next tx queue to be confirmed that should be processed, * it corresponds to last packet transmitted */ -struct dpaa2_queue *next_txq_to_cnf; +RTE_ATOMIC (struct dpaa2_queue *) next_txq_to_cnf;struct rte_eth_dev *eth_dev;/**< Pointer back to holding ethdev */ rte_spinlock_t lpbk_qp_lock;
@@ -560,6 +564,21 @@ dpaa2_dev_rx_print_parser_result(struct dpaa2_dev_priv *priv, } } +static inline void +dpaa2_timestamp_debug (struct dpaa2_dev_priv *priv, +const char *prefix,uint64_t timestamp) +{ +struct timespec ts; + +if (likely (!(priv->flags &DPAA2_IEEE1588_DEBUG_FLAG ))) +return ; + + ts =rte_ns_to_timespec (timestamp); +dpaa2_dump_print ("DPAA2 TS DBG: %s: ns(%" PRIu64")->%" PRId64 +" seconds/%" PRId64" nanoseconds" , + prefix, timestamp, (int64_t )ts.tv_sec, (int64_t )ts.tv_nsec); +} +int dpaa2_distset_to_dpkg_profile_cfg (uint64_t req_dist_set,struct dpkg_profile_cfg *kg_cfg);
@@ -622,6 +641,9 @@ void dpaa2_dev_free_eqresp_buf(uint16_t eqresp_ci, struct dpaa2_queue *dpaa2_q);void dpaa2_flow_clean (struct rte_eth_dev *dev);uint16_t dpaa2_dev_tx_conf (void *txq,int drain); +void +dpaa2_dev_tx_ptp_one_step_runtime (struct rte_eth_dev *dev, +struct rte_mbuf *buf,int *tstamp,int *set);int dpaa2_timesync_enable (struct rte_eth_dev *dev);int dpaa2_timesync_disable (struct rte_eth_dev *dev); int dpaa2_timesync_read_time(struct rte_eth_dev *dev,
drivers/net/dpaa2/dpaa2_ptp.c +145 -30
289 lines not on this page · raw message
drivers/net/dpaa2/dpaa2_rxtx.c +152 -38
396 lines not on this page · raw message
drivers/net/dpaa2/rte_pmd_dpaa2.h +0 -10
@@ -148,14 +148,4 @@ __rte_experimentalint rte_pmd_dpaa2_rx_get_offset (uint16_t port_id,struct rte_mbuf *m,uint8_t *l3_off,uint8_t *l4_off,uint8_t *l5_off); - -#if defined(RTE_LIBRTE_IEEE1588 ) -__rte_experimental -int -rte_pmd_dpaa2_set_one_step_ts (uint16_t port_id,uint16_t offset,uint8_t ch_update); - -__rte_experimental -int -rte_pmd_dpaa2_get_one_step_ts (uint16_t port_id,bool mc_query); -#endif #endif /* _RTE_PMD_DPAA2_H */
Signature · 1 line
2.43.0
PATCH 14/65 bus/fslmc: consume dpaa2 DQRR entries in batches
In reply to Prashant GuptaFrom: Jun Yang <[email protected]>
Each DQRR entry consumed by the software portal costs a write to the cache-invalidate DCAP register. The DCAP register also supports a vector mode where a bitmap of DQRR indices is consumed with a single write, so accumulate the indices and flush the vector once half the ring is pending. A smaller threshold gives little benefit, and a threshold close to the ring size starves WRIOP of DQRR space.
Because entries are now released in batches, a caller that stops polling a portal must flush the pending vector explicitly. Pass a NULL dequeue result to qbman_swp_dqrr_consume() to do that when the eventdev dequeue finds the portal dry, when the net PMD finishes draining a portal, and when a portal is released back to the bus.
--- drivers/bus/fslmc/portal/dpaa2_hw_dpio.c | 4 ++ .../fslmc/qbman/include/fsl_qbman_portal.h | 5 +- drivers/bus/fslmc/qbman/qbman_portal.c | 63 +++++++++++++++++-- drivers/bus/fslmc/qbman/qbman_portal.h | 11 +++- drivers/event/dpaa2/dpaa2_eventdev.c | 4 ++ drivers/net/dpaa2/dpaa2_ethdev.c | 2 + 6 files changed, 81 insertions(+), 8 deletions(-)
drivers/bus/fslmc/portal/dpaa2_hw_dpio.c +4 -0
@@ -305,6 +305,10 @@ dpaa2_configure_stashing(struct dpaa2_dpio_dev *dpio_dev, int cpu_id, bool ethrxstatic void dpaa2_put_qbman_swp (struct dpaa2_dpio_dev *dpio_dev) {if (dpio_dev) { +/* consume indices may still be pending in the portal's DQRR +* consume vector; flush them before the portal is released. +*/ +qbman_swp_dqrr_consume (dpio_dev->sw_portal,NULL );/* rx-queue interrupts (net PMD) can arm a portal without the * event driver; tear it down unconditionally. Safe when never * armed: intr_deinit returns early if intr is not enabled.
drivers/bus/fslmc/qbman/include/fsl_qbman_portal.h +4 -1
@@ -451,7 +451,10 @@ void qbman_swp_prefetch_dqrr_next(struct qbman_swp *s);* qbman_swp_dqrr_consume() - Consume DQRR entries previously returned from * qbman_swp_dqrr_next(). * @s: the software portal object. -* @dq: the DQRR entry to be consumed. +* @dq: the DQRR entry to be consumed, NULL to consume the entries accumulated +* so far. Entries are accumulated and consumed in batches, so a caller which +* stops polling the portal must call this with a NULL dq to release the +* entries it has already processed. */ __rte_internal void qbman_swp_dqrr_consume(struct qbman_swp *s, const struct qbman_result *dq);
drivers/bus/fslmc/qbman/qbman_portal.c +57 -6
103 lines not on this page · raw message
drivers/bus/fslmc/qbman/qbman_portal.h +10 -1
@@ -1,7 +1,7 @@/* SPDX-License-Identifier: BSD-3-Clause * * Copyright (C) 2014-2016 Freescale Semiconductor, Inc. -* Copyright 2018-2020 NXP +* Copyright 2018-2020, 2026 NXP * */
@@ -93,6 +93,15 @@ struct qbman_swp {uint32_t valid_bit;uint8_t dqrr_size;int reset_bug; +/* Consume index vector: instead of writing DCAP once per +* consumed entry, the indices are accumulated in ci_vector +* and written with a single DCAP access once ci_count +* reaches ci_flush_th. +*/ +bool ci_vec_en; +uint8_t ci_count; +uint8_t ci_flush_th; +uint32_t ci_vector; } dqrr;struct {uint32_t pi;
drivers/event/dpaa2/dpaa2_eventdev.c +4 -0
@@ -320,6 +320,10 @@ dpaa2_eventdev_dequeue_burst(void *port, struct rte_event ev[], do { dq = qbman_swp_dqrr_next(swp); if (!dq) { + /* portal is dry: consume whatever is still pending in + * the DQRR consume vector before leaving it idle. + */ + qbman_swp_dqrr_consume(swp, NULL); if (!num_pkts && timeout_ticks) { dpaa2_eventdev_dequeue_wait(timeout_ticks); timeout_ticks = 0;
drivers/net/dpaa2/dpaa2_ethdev.c +2 -0
@@ -3083,6 +3083,8 @@ dpaa2_napi_drain_portal(struct dpaa2_dpio_dev *dpio)while ((dq =qbman_swp_dqrr_next (dpio->sw_portal)))qbman_swp_dqrr_consume (dpio->sw_portal, dq); +/* flush the indices still pending in the DQRR consume vector */ +qbman_swp_dqrr_consume (dpio->sw_portal,NULL );qbman_swp_interrupt_clear_status (dpio->sw_portal,0xffffffff ); }
Signature · 1 line
2.43.0
PATCH 15/65 bus/fslmc: align dpaa2 event port depths with hardware rings
In reply to Prashant GuptaFrom: Jun Yang <[email protected]>
The event port dequeue and enqueue depths were fixed at 8. A dequeue drains the portal DQRR and an enqueue fills the EQCR, so the real limits are the sizes of those two rings, which differ per SoC and are known at run time. Report them instead, adding qbman_swp_portal_dqrr_size() to query the DQRR size (the EQCR size is already available as dpaa2_eqcr_size).
The Tx adapter enqueue helpers sized their on-stack mbuf arrays from the advertised enqueue depth, which no longer bounds the burst the adapter may hand them, so bound the copy by the array itself and transmit in chunks.
--- .../fslmc/qbman/include/fsl_qbman_portal.h | 7 ++ drivers/bus/fslmc/qbman/qbman_portal.c | 15 ++++ drivers/event/dpaa2/dpaa2_eventdev.c | 72 ++++++++++++------- drivers/event/dpaa2/dpaa2_eventdev.h | 4 +- 4 files changed, 69 insertions(+), 29 deletions(-)
drivers/bus/fslmc/qbman/include/fsl_qbman_portal.h +7 -0
@@ -1222,6 +1222,13 @@ __rte_internalint qbman_swp_acquire (struct qbman_swp *s,uint16_t bpid,uint64_t *buffers,unsigned int num_buffers); +/** +* qbman_swp_portal_dqrr_size() - Number of entries in a portal's DQRR. +* @p: the software portal object, NULL to query the SoC's DQRR size. +*/ +__rte_internal +uint32_t qbman_swp_portal_dqrr_size(struct qbman_swp *p); +/*****************/ /* FQ management */ /*****************/
drivers/bus/fslmc/qbman/qbman_portal.c +15 -0
@@ -73,6 +73,11 @@ enum qbman_sdqcr_fc {static struct qbman_swp *portal_idx_map[MAX_QBMAN_PORTALS ];uint32_t qman_version; +/* DQRR size of the portals initialised so far. All portals of a SoC have the +* same size, so this doubles as the SoC's DQRR size for callers that have no +* portal at hand. +*/ +static uint32_t dpaa2_portal_dqrr_size =8 ;/* Internal Function declaration */ static int
@@ -239,6 +244,15 @@ static int (*qbman_swp_release_ptr)(struct qbman_swp *s, const uint64_t *buffers, unsigned int num_buffers) = qbman_swp_release_direct; +RTE_EXPORT_INTERNAL_SYMBOL (qbman_swp_portal_dqrr_size) +uint32_t qbman_swp_portal_dqrr_size(struct qbman_swp *p) +{ +if (p !=NULL ) +return p->dqrr.dqrr_size; + +return dpaa2_portal_dqrr_size; +} +/*********************************/ /* Portal constructor/destructor */ /*********************************/
@@ -298,6 +312,7 @@ struct qbman_swp *qbman_swp_init(const struct qbman_swp_desc *d)*/ p->dqrr.ci_vec_en = p->dqrr.dqrr_size <= (32 -DQRR_DCAP_CI_VEC_OFFSET ); p->dqrr.ci_flush_th = p->dqrr.dqrr_size /2 ; + dpaa2_portal_dqrr_size = p->dqrr.dqrr_size; ret =qbman_swp_sys_init (&p->sys, d, p->dqrr.dqrr_size);if (ret) {
drivers/event/dpaa2/dpaa2_eventdev.c +46 -26
110 lines not on this page · raw message
drivers/event/dpaa2/dpaa2_eventdev.h +1 -3
@@ -1,5 +1,5 @@/* SPDX-License-Identifier: BSD-3-Clause -* Copyright 2017 NXP +* Copyright 2017,2026 NXP */ #ifndef __DPAA2_EVENTDEV_H__
@@ -22,8 +22,6 @@#define DPAA2_EVENT_MAX_QUEUE_FLOWS 2048#define DPAA2_EVENT_MAX_QUEUE_PRIORITY_LEVELS 8#define DPAA2_EVENT_MAX_EVENT_PRIORITY_LEVELS 0 -#define DPAA2_EVENT_MAX_PORT_DEQUEUE_DEPTH 8 -#define DPAA2_EVENT_MAX_PORT_ENQUEUE_DEPTH 8#define DPAA2_EVENT_MAX_NUM_EVENTS (INT32_MAX - 1)#define DPAA2_EVENT_QUEUE_ATOMIC_FLOWS 2048
Signature · 1 line
2.43.0
PATCH 16/65 net/dpaa2: support multi-DPNI FS redirect and QoS table v3
In reply to Prashant GuptaFrom: Jun Yang <[email protected]>
Pick up the newer MC command versions for the DPNI flow-steering and QoS table APIs, and expose the multi-DPNI redirect feature they add, while keeping the driver working against older MC firmwares.
--- drivers/net/dpaa2/dpaa2_ethdev.h | 3 + drivers/net/dpaa2/dpaa2_flow.c | 27 +++++--- drivers/net/dpaa2/mc/dpni.c | 73 +++++++++++++++++----- drivers/net/dpaa2/mc/fsl_dpni.h | 95 +++++++++++++++++++++++++++-- drivers/net/dpaa2/mc/fsl_dpni_cmd.h | 30 +++++---- 5 files changed, 189 insertions(+), 39 deletions(-)
drivers/net/dpaa2/dpaa2_ethdev.h +3 -0
@@ -204,6 +204,9 @@#define DPAA2_PKT_TYPE_VLAN \ (DPAA2_PKT_TYPE_VLAN_1 | DPAA2_PKT_TYPE_VLAN_2) +#define DPAA2_FLOW_FRM_REPLICATION_ACTION_MC_REV RTE_FSL_MC_REV(10, 39, 106) +#define DPAA2_QOS_FLOW_TABLE_SET_V3_MC_REV RTE_FSL_MC_REV(10, 39, 109) +/* mac counters */ #define DPAA2_MAC_NUM_STATS (DPMAC_CNT_EGR_CONTROL_FRAME + 1)#define DPAA2_MAC_STATS_INDEX_DMA_SIZE (DPAA2_MAC_NUM_STATS * sizeof(uint32_t))
drivers/net/dpaa2/dpaa2_flow.c +19 -8
@@ -539,10 +539,17 @@ dpaa2_flow_add_fs_rule(struct dpaa2_dev_priv *priv,dpaa2_flow_fs_entry_log ("Start add" , flow); - ret =dpni_add_fs_entry (dpni,CMD_PRI_LOW , - priv->token, flow->tc_id, - flow->tc_index, &flow->fs_rule, - &flow->fs_action_cfg); +if (priv->mc_rev >=DPAA2_FLOW_FRM_REPLICATION_ACTION_MC_REV ) { + ret =dpni_add_fs_entry (dpni,CMD_PRI_LOW , + priv->token, flow->tc_id, + flow->tc_index, &flow->fs_rule, + &flow->fs_action_cfg); + }else { + ret =dpni_add_fs_entry_legacy (dpni,CMD_PRI_LOW , + priv->token, flow->tc_id, + flow->tc_index, &flow->fs_rule, + &flow->fs_action_cfg); + }if (ret <0 ) {DPAA2_PMD_ERR ("Add rule(%d) to FS table(%d) failed" , flow->tc_index, flow->tc_id);
@@ -4424,8 +4431,8 @@ dpaa2_configure_flow_fs_action(struct dpaa2_dev_priv *priv, dest_q = dest_priv->tx_vq[0 ]; flow->fs_action_cfg.options =DPNI_FS_OPT_REDIRECT_TO_DPNI_TX ; - flow->fs_action_cfg.redirect_obj_token = - dest_priv->token; + flow->fs_action_cfg.num_tokens =1 ; + flow->fs_action_cfg.redir_tokens[0 ] = dest_priv->token; flow->fs_action_cfg.flow_id = dest_q->flow_id; }else if (flow->action_type ==RTE_FLOW_ACTION_TYPE_DROP ) { flow->fs_action_cfg.options =DPNI_FS_OPT_DISCARD ;
@@ -4626,8 +4633,12 @@ dpaa2_configure_qos_table(struct dpaa2_dev_priv *priv, qos_cfg.default_tc =0 ; } - ret =dpni_set_qos_table (dpni,CMD_PRI_LOW , - priv->token, &qos_cfg); +if (priv->mc_rev <DPAA2_QOS_FLOW_TABLE_SET_V3_MC_REV ) + ret =dpni_set_qos_table_v2 (dpni,CMD_PRI_LOW , + priv->token, &qos_cfg); +else + ret =dpni_set_qos_table (dpni,CMD_PRI_LOW , + priv->token, &qos_cfg);if (ret <0 ) {DPAA2_PMD_ERR ("QoS table set failed" );return ret;
drivers/net/dpaa2/mc/dpni.c +57 -16
109 lines not on this page · raw message
drivers/net/dpaa2/mc/fsl_dpni.h +91 -4
166 lines not on this page · raw message
drivers/net/dpaa2/mc/fsl_dpni_cmd.h +19 -11
@@ -1,7 +1,7 @@/* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 * * Copyright 2013-2016 Freescale Semiconductor Inc. -* Copyright 2016-2025 NXP +* Copyright 2016-2026 NXP * */ #ifndef _FSL_DPNI_CMD_H
@@ -20,6 +20,7 @@#define DPNI_CMD_VERSION_7 7#define DPNI_CMD_ID_OFFSET 4 +#define DPNI_CMD_VER (cmd_id) ((cmd_id) & ((1 << DPNI_CMD_ID_OFFSET) - 1))#define DPNI_CMD (id) (((id) << DPNI_CMD_ID_OFFSET) | DPNI_CMD_BASE_VERSION)#define DPNI_CMD_V2 (id) (((id) << DPNI_CMD_ID_OFFSET) | DPNI_CMD_VERSION_2)#define DPNI_CMD_V3 (id) (((id) << DPNI_CMD_ID_OFFSET) | DPNI_CMD_VERSION_3)
@@ -77,13 +78,16 @@#define DPNI_CMDID_SET_RX_TC_DIST DPNI_CMD_V4(0x235) -#define DPNI_CMDID_SET_RX_TC_POLICING DPNI_CMD(0x23E) +#define DPNI_CMDID_SET_RX_TC_POLICING_V1 DPNI_CMD(0x23E) +#define DPNI_CMDID_SET_RX_TC_POLICING DPNI_CMD_V2(0x23E) -#define DPNI_CMDID_SET_QOS_TBL DPNI_CMD_V2(0x240) +#define DPNI_CMDID_SET_QOS_TBL DPNI_CMD_V3(0x240) +#define DPNI_CMDID_SET_QOS_TBL_V2 DPNI_CMD_V2(0x240)#define DPNI_CMDID_ADD_QOS_ENT DPNI_CMD_V2(0x241)#define DPNI_CMDID_REMOVE_QOS_ENT DPNI_CMD(0x242)#define DPNI_CMDID_CLR_QOS_TBL DPNI_CMD(0x243) -#define DPNI_CMDID_ADD_FS_ENT DPNI_CMD_V2(0x244) +#define DPNI_CMDID_ADD_FS_ENT_LEGACY DPNI_CMD_V2(0x244) +#define DPNI_CMDID_ADD_FS_ENT DPNI_CMD_V3(0x244)#define DPNI_CMDID_REMOVE_FS_ENT DPNI_CMD(0x245)#define DPNI_CMDID_CLR_FS_ENT DPNI_CMD(0x246)
@@ -584,19 +588,18 @@ struct dpni_cmd_set_queue {#define DPNI_DISCARD_ON_MISS_SIZE 1#define DPNI_KEEP_QOS_ENTRIES_SHIFT 1#define DPNI_KEEP_QOS_ENTRIES_SIZE 1 +#define DPNI_SET_DEFAULT_FLOW_ID_SHIFT 2 +#define DPNI_SET_DEFAULT_FLOW_ID_SIZE 1struct dpni_cmd_set_qos_table { -uint32_t pad; +uint16_t pad; +uint16_t default_flow_id;uint8_t default_tc; -/* only the LSB */ -uint8_t discard_on_miss; +uint8_t flags;uint16_t pad1[21 ];uint64_t key_cfg_iova; }; -#define DPNI_QOS_OPT_SET_TC_ONLY 0x0 -#define DPNI_QOS_OPT_SET_FLOW_ID 0x1 -struct dpni_cmd_add_qos_entry {uint8_t flags;uint8_t flow_id;
@@ -616,6 +619,10 @@ struct dpni_cmd_remove_qos_entry {uint64_t mask_iova; }; +#ifndef DPNI_FS_REDIR_MAX_NUM +#define DPNI_FS_REDIR_MAX_NUM 8 +#endif +struct dpni_cmd_add_fs_entry {uint16_t options;uint8_t tc_id;
@@ -625,7 +632,8 @@ struct dpni_cmd_add_fs_entry {uint64_t key_iova;uint64_t mask_iova;uint64_t flc; -uint16_t redir_token; +uint16_t redir_tokens[DPNI_FS_REDIR_MAX_NUM ]; +uint8_t token_num; };struct dpni_cmd_remove_fs_entry {
Signature · 1 line
2.43.0
PATCH 17/65 net/dpaa2: rework xstats with page table and MAC support
In reply to Prashant GuptaFrom: Breeson Francis <[email protected]>
Reshape DPAA2 xstats so that counter identity is derived from the DPNI statistics page layout itself instead of a hand-maintained parallel table, extend coverage to all DPNI pages (0..6, including CEETM and tx-pending), expose per-MAC counters when the endpoint is a DPMAC on MC firmware that supports it, and make xstats_get_by_id() actually cheap when a caller asks for a subset of IDs.
--- drivers/net/dpaa2/dpaa2_ethdev.c | 1004 +++++++++++++++++++----------- drivers/net/dpaa2/dpaa2_ethdev.h | 11 +- drivers/net/dpaa2/mc/fsl_dpni.h | 116 ++-- 3 files changed, 708 insertions(+), 423 deletions(-)
drivers/net/dpaa2/dpaa2_ethdev.c +631 -373
@@ -169,116 +169,290 @@ dpaa2_dist_size_is_supported(uint16_t n)int dpaa2_valid_dev;struct rte_mempool *dpaa2_tx_sg_pool; -struct rte_dpaa2_xstats_name_off { +struct dpaa2_dpni_xstats_pg_seq { +struct dpni_statistics_page_0 pg0; +struct dpni_statistics_page_1 pg1; +struct dpni_statistics_page_2 pg2; +struct dpni_statistics_page_3 pg3; +struct dpni_statistics_page_4 pg4; +struct dpni_statistics_page_5 pg5[MAX_TCS ]; +struct dpni_statistics_page_6 pg6; +}; + +#define DPAA2_DPNI_XSTAT_MAX_NUM \ + (sizeof(struct dpaa2_dpni_xstats_pg_seq) / sizeof(uint64_t)) + +struct dpaa2_dpni_xstats_pg { +uint64_t page_offset; +enum dpni_statistics_page_id page_id; +uint16_t param; +uint16_t size; +}; + +static const struct dpaa2_dpni_xstats_pg s_dpaa2_dpni_xstats_pgs[] = { + { + offsetof(struct dpaa2_dpni_xstats_pg_seq , pg0), +DPNI_INGRESS_STATISTICS_PAGE_ID ,0 , +sizeof (struct dpni_statistics_page_0 ) + }, + { + offsetof(struct dpaa2_dpni_xstats_pg_seq , pg1), +DPNI_EGRESS_STATISTICS_PAGE_ID ,0 , +sizeof (struct dpni_statistics_page_1 ) + }, + { + offsetof(struct dpaa2_dpni_xstats_pg_seq , pg2), +DPNI_ERR_STATISTICS_PAGE_ID ,0 , +sizeof (struct dpni_statistics_page_2 ) + }, + { + offsetof(struct dpaa2_dpni_xstats_pg_seq , pg3), +DPNI_CEETM_STATISTICS_PAGE_ID ,0 , +sizeof (struct dpni_statistics_page_3 ) + }, + { + offsetof(struct dpaa2_dpni_xstats_pg_seq , pg4), +DPNI_CGR_STATISTICS_PAGE_ID ,0 , +sizeof (struct dpni_statistics_page_4 ) + }, + { + offsetof(struct dpaa2_dpni_xstats_pg_seq, pg5[0]), +DPNI_POLICER_STATISTICS_PAGE_ID ,0 , +sizeof (struct dpni_statistics_page_5 ) + }, + { + offsetof(struct dpaa2_dpni_xstats_pg_seq, pg5[1]), +DPNI_POLICER_STATISTICS_PAGE_ID ,1 , +sizeof (struct dpni_statistics_page_5 ) + }, + { + offsetof(struct dpaa2_dpni_xstats_pg_seq, pg5[2]), +DPNI_POLICER_STATISTICS_PAGE_ID ,2 , +sizeof (struct dpni_statistics_page_5 ) + }, + { + offsetof(struct dpaa2_dpni_xstats_pg_seq, pg5[3]), +DPNI_POLICER_STATISTICS_PAGE_ID ,3 , +sizeof (struct dpni_statistics_page_5 ) + }, + { + offsetof(struct dpaa2_dpni_xstats_pg_seq, pg5[4]), +DPNI_POLICER_STATISTICS_PAGE_ID ,4 , +sizeof (struct dpni_statistics_page_5 ) + }, + { + offsetof(struct dpaa2_dpni_xstats_pg_seq, pg5[5]), +DPNI_POLICER_STATISTICS_PAGE_ID ,5 , +sizeof (struct dpni_statistics_page_5 ) + }, + { + offsetof(struct dpaa2_dpni_xstats_pg_seq, pg5[6]), +DPNI_POLICER_STATISTICS_PAGE_ID ,6 , +sizeof (struct dpni_statistics_page_5 ) + }, + { + offsetof(struct dpaa2_dpni_xstats_pg_seq, pg5[7]), +DPNI_POLICER_STATISTICS_PAGE_ID ,7 , +sizeof (struct dpni_statistics_page_5 ) + }, + { + offsetof(struct dpaa2_dpni_xstats_pg_seq , pg6), +DPNI_TX_PENDING_STATISTICS_PAGE_ID ,0 , +sizeof (struct dpni_statistics_page_6 ) + }, + { +sizeof (struct dpaa2_dpni_xstats_pg_seq ), +0 ,0 ,0 + } +}; + +static inline int +dpaa2_xstats_id_parse (uint32_t id,uint8_t *page, +uint8_t *stat_id,uint16_t *param,uint16_t *size) +{ +int found =0 ; +uint8_t _page =0 , _stat_id =0 ; +uint16_t _param =0 , _size =0 ; +uint64_t offset = id *sizeof (uint64_t ), page_offset =0 , i; + +for (i =1 ; i <RTE_DIM (s_dpaa2_dpni_xstats_pgs); i++) { +if (offset < s_dpaa2_dpni_xstats_pgs[i].page_offset) { + page_offset = s_dpaa2_dpni_xstats_pgs[i -1 ].page_offset; + _page = s_dpaa2_dpni_xstats_pgs[i -1 ].page_id; + _stat_id = (offset - page_offset) /sizeof (uint64_t ); + _param = s_dpaa2_dpni_xstats_pgs[i -1 ].param; + _size = s_dpaa2_dpni_xstats_pgs[i -1 ].size /sizeof (uint64_t ); + found =1 ; +break ; + } + } + +if (!found) +return -EINVAL ; + +if (page) + *page = _page; +if (stat_id) + *stat_id = _stat_id; +if (param) + *param = _param; +if (size) + *size = _size; + +return 0 ; +} + +struct dpaa2_stats_name_off {char name[RTE_ETH_XSTATS_NAME_SIZE ]; -uint8_t page_id;/* dpni statistics page id */ -uint8_t stats_id;/* stats id in the given page */ +uint64_t offset; +}; + +#define DPAA2_STATS_IPACKETS_STR "ingress_all_frames" +#define DPAA2_STATS_OPACKETS_STR "egress_all_frames" +#define DPAA2_STATS_IBYTES_STR "ingress_all_bytes" +#define DPAA2_STATS_OBYTES_STR "egress_all_bytes" +#define DPAA2_STATS_IERRORS_STR "ingress_discarded_frames" +#define DPAA2_STATS_OERRORS_STR "egress_discarded_frames" +#define DPAA2_STATS_RX_NOMBUF_STR "ingress_nobuffer_discards" +#define DPAA2_STATS_FILTERED_STR "ingress_filtered_frames" + +static const struct dpaa2_stats_name_off dpaa2_stats_strings[] = { + { +DPAA2_STATS_IPACKETS_STR , + offsetof(struct rte_eth_stats , ipackets) + }, + { +DPAA2_STATS_OPACKETS_STR , + offsetof(struct rte_eth_stats , opackets) + }, + { +DPAA2_STATS_IBYTES_STR , + offsetof(struct rte_eth_stats , ibytes) + }, + { +DPAA2_STATS_OBYTES_STR , + offsetof(struct rte_eth_stats , obytes) + }, + { +DPAA2_STATS_FILTERED_STR , +sizeof (struct rte_eth_stats ) + }, + { +DPAA2_STATS_IERRORS_STR , + offsetof(struct rte_eth_stats , ierrors) + }, + { +DPAA2_STATS_OERRORS_STR , + offsetof(struct rte_eth_stats , oerrors) + }, + { +DPAA2_STATS_RX_NOMBUF_STR , + offsetof(struct rte_eth_stats , rx_nombuf) + } }; -static const struct rte_dpaa2_xstats_name_off dpaa2_xstats_strings[] = { - {"ingress_multicast_frames" ,0 ,2 }, - {"ingress_multicast_bytes" ,0 ,3 }, - {"ingress_broadcast_frames" ,0 ,4 }, - {"ingress_broadcast_bytes" ,0 ,5 }, - {"egress_multicast_frames" ,1 ,2 }, - {"egress_multicast_bytes" ,1 ,3 }, - {"egress_broadcast_frames" ,1 ,4 }, - {"egress_broadcast_bytes" ,1 ,5 }, - {"ingress_filtered_frames" ,2 ,0 }, - {"ingress_discarded_frames" ,2 ,1 }, - {"ingress_nobuffer_discards" ,2 ,2 }, - {"egress_discarded_frames" ,2 ,3 }, - {"egress_confirmed_frames" ,2 ,4 }, - {"cgr_reject_frames" ,4 ,0 }, - {"cgr_reject_bytes" ,4 ,1 }, - {"TC_0_policer_cnt_red" ,5 ,0 }, - {"TC_0_policer_cnt_yellow" ,5 ,1 }, - {"TC_0_policer_cnt_green" ,5 ,2 }, - {"TC_0_policer_cnt_re_red" ,5 ,3 }, - {"TC_0_policer_cnt_re_yellow" ,5 ,4 }, - {"TC_1_policer_cnt_red" ,6 ,0 }, - {"TC_1_policer_cnt_yellow" ,6 ,1 }, - {"TC_1_policer_cnt_green" ,6 ,2 }, - {"TC_1_policer_cnt_re_red" ,6 ,3 }, - {"TC_1_policer_cnt_re_yellow" ,6 ,4 }, - {"TC_2_policer_cnt_red" ,7 ,0 }, - {"TC_2_policer_cnt_yellow" ,7 ,1 }, - {"TC_2_policer_cnt_green" ,7 ,2 }, - {"TC_2_policer_cnt_re_red" ,7 ,3 }, - {"TC_2_policer_cnt_re_yellow" ,7 ,4 }, - {"TC_3_policer_cnt_red" ,8 ,0 }, - {"TC_3_policer_cnt_yellow" ,8 ,1 }, - {"TC_3_policer_cnt_green" ,8 ,2 }, - {"TC_3_policer_cnt_re_red" ,8 ,3 }, - {"TC_3_policer_cnt_re_yellow" ,8 ,4 }, - {"TC_4_policer_cnt_red" ,9 ,0 }, - {"TC_4_policer_cnt_yellow" ,9 ,1 }, - {"TC_4_policer_cnt_green" ,9 ,2 }, - {"TC_4_policer_cnt_re_red" ,9 ,3 }, - {"TC_4_policer_cnt_re_yellow" ,9 ,4 }, - {"TC_5_policer_cnt_red" ,10 ,0 }, - {"TC_5_policer_cnt_yellow" ,10 ,1 }, - {"TC_5_policer_cnt_green" ,10 ,2 }, - {"TC_5_policer_cnt_re_red" ,10 ,3 }, - {"TC_5_policer_cnt_re_yellow" ,10 ,4 }, - {"TC_6_policer_cnt_red" ,11 ,0 }, - {"TC_6_policer_cnt_yellow" ,11 ,1 }, - {"TC_6_policer_cnt_green" ,11 ,2 }, - {"TC_6_policer_cnt_re_red" ,11 ,3 }, - {"TC_6_policer_cnt_re_yellow" ,11 ,4 }, - {"TC_7_policer_cnt_red" ,12 ,0 }, - {"TC_7_policer_cnt_yellow" ,12 ,1 }, - {"TC_7_policer_cnt_green" ,12 ,2 }, - {"TC_7_policer_cnt_re_red" ,12 ,3 }, - {"TC_7_policer_cnt_re_yellow" ,12 ,4 }, - {"mac_rx_64 bytes" ,0 ,0 }, - {"mac_rx_65-127 bytes" ,0 ,0 }, - {"mac_rx_128-255 bytes" ,0 ,0 }, - {"mac_rx_256-511 bytes" ,0 ,0 }, - {"mac_rx_512-1023 bytes" ,0 ,0 }, - {"mac_rx_1024-1518 bytes" ,0 ,0 }, - {"mac_rx_1519-max bytes" ,0 ,0 }, - {"mac_rx_frags" ,0 ,0 }, - {"mac_rx_jabber" ,0 ,0 }, - {"mac_rx_frame discards" ,0 ,0 }, - {"mac_rx_align errors" ,0 ,0 }, - {"mac_tx_undersized" ,0 ,0 }, - {"mac_rx_oversized" ,0 ,0 }, - {"mac_rx_pause" ,0 ,0 }, - {"mac_tx_b-pause" ,0 ,0 }, - {"mac_rx_bytes" ,0 ,0 }, - {"mac_rx_m-cast" ,0 ,0 }, - {"mac_rx_b-cast" ,0 ,0 }, - {"mac_rx_all frames" ,0 ,0 }, - {"mac_rx_u-cast" ,0 ,0 }, - {"mac_rx_frame errors" ,0 ,0 }, - {"mac_tx_bytes" ,0 ,0 }, - {"mac_tx_m-cast" ,0 ,0 }, - {"mac_tx_b-cast" ,0 ,0 }, - {"mac_tx_u-cast" ,0 ,0 }, - {"mac_tx_frame errors" ,0 ,0 }, - {"mac_rx_frames ok" ,0 ,0 }, - {"mac_tx_frames ok" ,0 ,0 }, - {"mac_tx_64 bytes" ,0 ,0 }, - {"mac_tx_65-127 bytes" ,0 ,0 }, - {"mac_tx_128-255 bytes" ,0 ,0 }, - {"mac_tx_256-511 bytes" ,0 ,0 }, - {"mac_tx_512-1023 bytes" ,0 ,0 }, - {"mac_tx_1024-1518 bytes" ,0 ,0 }, - {"mac_tx_1519-max bytes" ,0 ,0 }, - {"mac_rx_all_bytes" ,0 ,0 }, - {"mac_rx_fcs_err" ,0 ,0 }, - {"mac_rx_vlan_frame" ,0 ,0 }, - {"mac_rx_undersized" ,0 ,0 }, - {"mac_rx_control_frame" ,0 ,0 }, - {"mac_rx_frame_discard_not_trunc" ,0 ,0 }, - {"mac_tx_all_bytes" ,0 ,0 }, - {"mac_tx_fcs_err" ,0 ,0 }, - {"mac_tx_vlan_frame" ,0 ,0 }, - {"mac_tx_all_frame" ,0 ,0 }, - {"mac_tx_control_frame" ,0 ,0 }, +#define DPAA2_STATS_SET_BY_OFFSET (p_stats, offset, val) \ + (*((uint64_t *)((uint8_t *)(p_stats) + (offset))) = (val)) + +#define DPAA2_TC_COLOR (tc) \ + "TC_"#tc"_policer_cnt_red", \ + "TC_"#tc"_policer_cnt_yellow", \ + "TC_"#tc"_policer_cnt_green", \ + "TC_"#tc"_policer_cnt_re_red", \ + "TC_"#tc"_policer_cnt_re_yellow" \ + +static const char *const dpaa2_dpni_xstats_strings[] = { +DPAA2_STATS_IPACKETS_STR , +DPAA2_STATS_IBYTES_STR , +"ingress_multicast_frames" , +"ingress_multicast_bytes" , +"ingress_broadcast_frames" , +"ingress_broadcast_bytes" , + +DPAA2_STATS_OPACKETS_STR , +DPAA2_STATS_OBYTES_STR , +"egress_multicast_frames" , +"egress_multicast_bytes" , +"egress_broadcast_frames" , +"egress_broadcast_bytes" , + +DPAA2_STATS_FILTERED_STR , +DPAA2_STATS_IERRORS_STR , +DPAA2_STATS_RX_NOMBUF_STR , +DPAA2_STATS_OERRORS_STR , +"egress_confirmed_frames" , + +"cgr_reject_frames" , +"cgr_reject_bytes" , + +"ceetm_dequeue_bytes" , +"ceetm_dequeue_frames" , +"ceetm_reject_bytes" , +"ceetm_reject_frames" , +DPAA2_TC_COLOR (0 ), +DPAA2_TC_COLOR (1 ), +DPAA2_TC_COLOR (2 ), +DPAA2_TC_COLOR (3 ), +DPAA2_TC_COLOR (4 ), +DPAA2_TC_COLOR (5 ), +DPAA2_TC_COLOR (6 ), +DPAA2_TC_COLOR (7 ), + +"tx_pending_frames_cnt" }; +static const char *const dpaa2_mac_xstats_strings[] = { +"mac_rx_64 bytes" , +"mac_rx_65-127 bytes" , +"mac_rx_128-255 bytes" , +"mac_rx_256-511 bytes" , +"mac_rx_512-1023 bytes" , +"mac_rx_1024-1518 bytes" , +"mac_rx_1519-max bytes" , +"mac_rx_frags" , +"mac_rx_jabber" , +"mac_rx_frame discards" , +"mac_rx_align errors" , +"mac_tx_undersized" , +"mac_rx_oversized" , +"mac_rx_pause" , +"mac_tx_b-pause" , +"mac_rx_bytes" , +"mac_rx_m-cast" , +"mac_rx_b-cast" , +"mac_rx_all frames" , +"mac_rx_u-cast" , +"mac_rx_frame errors" , +"mac_tx_bytes" , +"mac_tx_m-cast" , +"mac_tx_b-cast" , +"mac_tx_u-cast" , +"mac_tx_frame errors" , +"mac_rx_frames ok" , +"mac_tx_frames ok" , +"mac_tx_64 bytes" , +"mac_tx_65-127 bytes" , +"mac_tx_128-255 bytes" , +"mac_tx_256-511 bytes" , +"mac_tx_512-1023 bytes" , +"mac_tx_1024-1518 bytes" , +"mac_tx_1519-max bytes" , +"mac_rx_all_bytes" , +"mac_rx_fcs_err" , +"mac_rx_vlan_frame" , +"mac_rx_undersized" , +"mac_rx_control_frame" , +"mac_rx_frame_discard_not_trunc" , +"mac_tx_all_bytes" , +"mac_tx_fcs_err" , +"mac_tx_vlan_frame" , +"mac_tx_all_frame" , +"mac_tx_control_frame" +}; + +#define DPAA2_MAC_XSTATS_START_ID \ + (sizeof(struct dpaa2_dpni_xstats_pg_seq) / sizeof(uint64_t)) +static struct rte_dpaa2_driver rte_dpaa2_pmd;static int dpaa2_dev_link_update (struct rte_eth_dev *dev,int wait_to_complete);
@@ -1958,132 +2132,97 @@ dpaa2_dev_set_mac_addr(struct rte_eth_dev *dev, }static int -dpaa2_dev_stats_get (struct rte_eth_dev *dev, -struct rte_eth_stats *stats,struct eth_queue_stats *qstats) +dpaa2_dev_xstat_mac_setup_mem (struct rte_eth_dev *dev) {struct dpaa2_dev_priv *priv = dev->data->dev_private; -struct fsl_mc_io *dpni = dev->process_private; -int32_t retcode; -uint8_t page0 =0 , page1 =1 , page2 =2 ; -union dpni_statistics value; -int i; -struct dpaa2_queue *dpaa2_rxq, *dpaa2_txq; - -memset (&value,0 ,sizeof (union dpni_statistics )); - -PMD_INIT_FUNC_TRACE (); +uint32_t *cnt_idx, i; +int ret =0 ; -if (!dpni) { -DPAA2_PMD_ERR ("dpni is NULL" ); -return -EINVAL ; - } +if (!priv->cnt_idx_dma_mem) { + priv->cnt_idx_dma_mem =rte_zmalloc (NULL , +DPAA2_MAC_STATS_INDEX_DMA_SIZE ,RTE_CACHE_LINE_SIZE ); +if (!priv->cnt_idx_dma_mem) { + ret = -ENOMEM ; +DPAA2_PMD_ERR ("Failure to allocate memory for mac index" ); + goto out; + } -if (!stats) { -DPAA2_PMD_ERR ("stats is NULL" ); -return -EINVAL ; + priv->cnt_idx_iova =rte_mem_virt2iova (priv->cnt_idx_dma_mem); +if (priv->cnt_idx_iova ==RTE_BAD_IOVA ) { + ret = -ENOBUFS ; +DPAA2_PMD_ERR ("%s: No IOMMU map for count index dma mem(%p)" , + __func__, priv->cnt_idx_dma_mem); + goto err_dma_map; + } + cnt_idx = priv->cnt_idx_dma_mem; +for (i =0 ; i <DPAA2_MAC_NUM_STATS ; i++) + cnt_idx[i] =rte_cpu_to_le_32 (i); } -/*Get Counters from page_0*/ - retcode =dpni_get_statistics (dpni,CMD_PRI_LOW , priv->token, - page0,0 , &value); -if (retcode) - goto err; - - stats->ipackets = value.page_0.ingress_all_frames; - stats->ibytes = value.page_0.ingress_all_bytes; - -/*Get Counters from page_1*/ - retcode =dpni_get_statistics (dpni,CMD_PRI_LOW , priv->token, - page1,0 , &value); -if (retcode) - goto err; - - stats->opackets = value.page_1.egress_all_frames; - stats->obytes = value.page_1.egress_all_bytes; - -/*Get Counters from page_2*/ - retcode =dpni_get_statistics (dpni,CMD_PRI_LOW , priv->token, - page2,0 , &value); -if (retcode) - goto err; - -/* Ingress drop frame count due to configured rules */ - stats->ierrors = value.page_2.ingress_filtered_frames; -/* Ingress drop frame count due to error */ - stats->ierrors += value.page_2.ingress_discarded_frames; - - stats->oerrors = value.page_2.egress_discarded_frames; - stats->imissed = value.page_2.ingress_nobuffer_discards; - -/* Fill in per queue stats. Byte counting is not implemented. */ -if (qstats !=NULL ) { -for (i =0 ; i < dev->data->nb_rx_queues; ++i) { - dpaa2_rxq = priv->rx_vq[i]; -if (dpaa2_rxq) - qstats[i].q_ipackets = dpaa2_rxq->rx_pkts; +if (!priv->cnt_values_dma_mem) { + priv->cnt_values_dma_mem =rte_zmalloc (NULL , +DPAA2_MAC_STATS_VALUE_DMA_SIZE ,RTE_CACHE_LINE_SIZE ); +if (!priv->cnt_values_dma_mem) { + ret = -ENOMEM ; +DPAA2_PMD_ERR ("Failure to allocate memory for mac values" ); + goto err_alloc_values; } -for (i =0 ; i < dev->data->nb_tx_queues; ++i) { - dpaa2_txq = priv->tx_vq[i]; -if (dpaa2_txq) - qstats[i].q_opackets = dpaa2_txq->tx_pkts; + priv->cnt_values_iova =rte_mem_virt2iova (priv->cnt_values_dma_mem); +if (priv->cnt_values_iova ==RTE_BAD_IOVA ) { + ret = -ENOBUFS ; +DPAA2_PMD_ERR ("%s: No IOMMU map for count values dma mem(%p)" , + __func__, priv->cnt_values_dma_mem); + goto err_dma_map; } }return 0 ; -err: -DPAA2_PMD_ERR ("Operation not completed:Error Code = %d" , retcode); -return retcode; -}; +err_dma_map: +rte_free (priv->cnt_values_dma_mem); +err_alloc_values: +rte_free (priv->cnt_idx_dma_mem); +out: + priv->cnt_idx_dma_mem =NULL ; + priv->cnt_values_dma_mem =NULL ; -void -dpaa2_dev_mac_setup_stats (struct rte_eth_dev *dev) +return ret; +} + +static int +dpaa2_dev_mac_xstats_avail (struct rte_eth_dev *dev) {struct dpaa2_dev_priv *priv = dev->data->dev_private; -uint32_t *cnt_idx; -int i; - - priv->cnt_idx_dma_mem =rte_malloc (NULL ,DPAA2_MAC_STATS_INDEX_DMA_SIZE , -RTE_CACHE_LINE_SIZE ); -if (!priv->cnt_idx_dma_mem) { -DPAA2_PMD_ERR ("Failure to allocate memory for mac index" ); - goto out; - } - priv->cnt_values_dma_mem =rte_malloc (NULL ,DPAA2_MAC_STATS_VALUE_DMA_SIZE , -RTE_CACHE_LINE_SIZE ); -if (!priv->cnt_values_dma_mem) { -DPAA2_PMD_ERR ("Failure to allocate memory for mac values" ); - goto err_alloc_values; - } +if (priv->ep_dev_type !=DPAA2_MAC ) +return false; +if (priv->mc_rev <DPAA2_MAC_XSTATS_MC_REV ) +return false; - cnt_idx = priv->cnt_idx_dma_mem; -for (i =0 ; i <DPAA2_MAC_NUM_STATS ; i++) - *cnt_idx++ =rte_cpu_to_le_32 ((uint32_t )i); +return true; +} - priv->cnt_idx_iova =rte_mem_virt2iova (priv->cnt_idx_dma_mem); -if (priv->cnt_idx_iova ==RTE_BAD_IOVA ) { -DPAA2_PMD_ERR ("%s: No IOMMU map for count index dma mem(%p)" , - __func__, priv->cnt_idx_dma_mem); - goto err_dma_map; - } +static int +dpaa2_dev_dpni_xstats_avail (struct rte_eth_dev *dev, +uint8_t page_id,uint16_t param) +{ +struct dpaa2_dev_priv *priv = dev->data->dev_private; +uint8_t tc, i; - priv->cnt_values_iova =rte_mem_virt2iova (priv->cnt_values_dma_mem); -if (priv->cnt_values_iova ==RTE_BAD_IOVA ) { -DPAA2_PMD_ERR ("%s: No IOMMU map for count values dma mem(%p)" , - __func__, priv->cnt_values_dma_mem); - goto err_dma_map; +if (page_id ==DPNI_CGR_STATISTICS_PAGE_ID ) { +for (i =0 ; i < priv->max_cgs; i++) { +if (priv->cgid_in_use[i]) +return true; + } + }else if (page_id ==DPNI_POLICER_STATISTICS_PAGE_ID ) { + tc = param; +if (tc <MAX_TCS ) +return true; + }else { +return true; } -return ; - -err_dma_map: -rte_free (priv->cnt_values_dma_mem); -err_alloc_values: -rte_free (priv->cnt_idx_dma_mem); -out: - priv->cnt_idx_dma_mem =NULL ; - priv->cnt_values_dma_mem =NULL ; +return false; }/*
@@ -2093,213 +2232,343 @@ dpaa2_dev_mac_setup_stats(struct rte_eth_dev *dev)*/ static int dpaa2_dev_xstats_get (struct rte_eth_dev *dev, -struct rte_eth_xstat *xstats,unsigned int n) +struct rte_eth_xstat *xstats,uint32_t n) { -struct fsl_mc_io *dpni = (struct fsl_mc_io *)dev->process_private; -unsigned int i =0 , j =0 , num =RTE_DIM (dpaa2_xstats_strings); +struct fsl_mc_io *dpni = dev->process_private; +uint16_t i, j, param, stat_cnt, size;struct dpaa2_dev_priv *priv = dev->data->dev_private; -union dpni_statistics value[13 ] = {}; -struct dpni_rx_tc_policing_cfg cfg; -uint8_t page_id, stats_id; +union dpni_statistics values; +uint8_t page_id, stat_id;uint64_t *cnt_values; -int32_t retcode; -int16_t tc; +int retcode; + + stat_cnt =DPAA2_DPNI_XSTAT_MAX_NUM ; +if (priv->ep_dev_type ==DPAA2_MAC ) + stat_cnt +=DPAA2_MAC_NUM_STATS ; -if (n < num) -return num; +if (n > stat_cnt) { +DPAA2_PMD_ERR ("%s: Expected number(%d) > max number(%d)" , + __func__, n, stat_cnt); +return -EINVAL ; + }if (!xstats)return 0 ; -/* Get Counters from page_0*/ - retcode =dpni_get_statistics (dpni,CMD_PRI_LOW , priv->token, -0 ,0 , &value[0 ]); -if (retcode) - goto err; - -/* Get Counters from page_1*/ - retcode =dpni_get_statistics (dpni,CMD_PRI_LOW , priv->token, -1 ,0 , &value[1 ]); -if (retcode) - goto err; - -/* Get Counters from page_2*/ - retcode =dpni_get_statistics (dpni,CMD_PRI_LOW , priv->token, -2 ,0 , &value[2 ]); -if (retcode) - goto err; - -for (j =0 ; j < priv->max_cgs; j++) { -if (!priv->cgid_in_use[j]) { -/* Get Counters from page_4*/ - retcode =dpni_get_statistics (dpni,CMD_PRI_LOW , - priv->token, -4 ,0 , &value[4 ]); -if (retcode) - goto err; -break ; + i =0 ; +while (i < n) { +if (i >=DPAA2_MAC_XSTATS_START_ID ) { +if (!dpaa2_dev_mac_xstats_avail (dev)) { +for (j = i; j < n; j++) { + xstats[j].id = j; + xstats[j].value =0 ; + } + i = n; +break ; + } + goto dpmac_get_xstat; } - } -for (tc =0 ; tc < priv->num_rx_tc; tc++) { - retcode =dpni_get_rx_tc_policing (dpni,CMD_PRI_LOW , - priv->token, tc, - &cfg); + page_id =0 ; + stat_id =0 ; + param =0 ; + retcode =dpaa2_xstats_id_parse (i, &page_id, &stat_id, ¶m, &size); +if (retcode) +return retcode; +if (!dpaa2_dev_dpni_xstats_avail (dev, page_id, param)) { + xstats[i].id = i; + xstats[i].value =0 ; + i++; +continue ; + } + retcode =dpni_get_statistics (dpni,CMD_PRI_LOW , + priv->token, page_id, param, &values);if (retcode) { -DPAA2_PMD_ERR ("Error to get the policer rule: %d" , retcode); - goto err; +DPAA2_PMD_ERR ("%s: Failed(%d) to get %s's statistcis of page%d!" , + __func__, retcode, dev->data->name, page_id); +return retcode; } - -/* get policer stats if policer is enabled */ -if (cfg.mode !=0 ) { -/* Get Counters from page_5*/ - retcode =dpni_get_statistics (dpni,CMD_PRI_LOW , - priv->token,5 , tc, - &value[(tc +5 )]); -if (retcode) - goto err; + cnt_values = (void *)&values; + j = stat_id; +while (i < n && j < size) { + xstats[i].id = i; + xstats[i].value = cnt_values[j]; + i++; + j++; } - } +continue ; -while (i < (num -DPAA2_MAC_NUM_STATS )) { - xstats[i].id = i; - page_id = dpaa2_xstats_strings[i].page_id; - stats_id = dpaa2_xstats_strings[i].stats_id; - xstats[i].value = value[page_id].raw.counter[stats_id]; - i++; - } - -if (priv->cnt_idx_dma_mem && - !dpni_get_mac_statistics (dpni,CMD_PRI_LOW , priv->token, - priv->cnt_idx_iova, - priv->cnt_values_iova, -DPAA2_MAC_NUM_STATS )) { +dpmac_get_xstat: + retcode =dpaa2_dev_xstat_mac_setup_mem (dev); +if (retcode) { +DPAA2_PMD_ERR ("%s: Failed(%d) to setup %s MAC statistics!" , + __func__, retcode, dev->data->name); +return retcode; + } + retcode =dpni_get_mac_statistics (dpni,CMD_PRI_LOW , + priv->token, priv->cnt_idx_iova, + priv->cnt_values_iova,DPAA2_MAC_NUM_STATS ); +if (retcode) { +DPAA2_PMD_ERR ("%s: Failed(%d) to get %s's MAC statistics!" , + __func__, retcode, dev->data->name); +return retcode; + } cnt_values = priv->cnt_values_dma_mem; -while (i >= (num -DPAA2_MAC_NUM_STATS ) && i < num) { + + j = i -DPAA2_MAC_XSTATS_START_ID ; +while (i < n && j <DPAA2_MAC_NUM_STATS ) { xstats[i].id = i; - xstats[i].value =rte_le_to_cpu_64 (*cnt_values++); + xstats[i].value = cnt_values[j]; i++; + j++; } -return i; - } - -while (i >= (num -DPAA2_MAC_NUM_STATS ) && i < num) { - xstats[i].id = i; - xstats[i].value =0 ; - i++; }return i; -err: -DPAA2_PMD_ERR ("Error in obtaining extended stats (%d)" , retcode); -return retcode; }static int -dpaa2_xstats_get_names(__rte_unused struct rte_eth_dev *dev, -struct rte_eth_xstat_name *xstats_names, -unsigned int limit) +dpaa2_dev_xstats_get_names (struct rte_eth_dev *dev, +struct rte_eth_xstat_name *xstats_names,uint32_t limit) { -unsigned int i, stat_cnt =RTE_DIM (dpaa2_xstats_strings); +struct dpaa2_dev_priv *priv = dev->data->dev_private; +uint16_t i, stat_cnt; + + stat_cnt =DPAA2_DPNI_XSTAT_MAX_NUM ; +if (priv->ep_dev_type ==DPAA2_MAC ) + stat_cnt +=DPAA2_MAC_NUM_STATS ; + +if (!limit) +return stat_cnt;if (limit < stat_cnt) + stat_cnt = limit; + +if (!xstats_names)return stat_cnt; -if (xstats_names !=NULL ) -for (i =0 ; i < stat_cnt; i++) -strlcpy (xstats_names[i].name, - dpaa2_xstats_strings[i].name, -sizeof (xstats_names[i].name)); +for (i =0 ; i < stat_cnt; i++) { +if (i <DPAA2_DPNI_XSTAT_MAX_NUM ) { +rte_strscpy (xstats_names[i].name, dpaa2_dpni_xstats_strings[i], +RTE_ETH_XSTATS_NAME_SIZE ); + }else { +rte_strscpy (xstats_names[i].name, + dpaa2_mac_xstats_strings[i -DPAA2_DPNI_XSTAT_MAX_NUM ], +RTE_ETH_XSTATS_NAME_SIZE ); + } + }return stat_cnt; }static int -dpaa2_xstats_get_by_id (struct rte_eth_dev *dev,const uint64_t *ids, -uint64_t *values,unsigned int n) +dpaa2_dev_xstats_get_by_id (struct rte_eth_dev *dev,const uint64_t *ids, +uint64_t *values,uint32_t n) { -unsigned int i, stat_cnt =RTE_DIM (dpaa2_xstats_strings); -uint64_t values_copy[stat_cnt]; -uint8_t page_id, stats_id; - -if (!ids) { -struct dpaa2_dev_priv *priv = dev->data->dev_private; -struct fsl_mc_io *dpni = dev->process_private; -int32_t retcode; -union dpni_statistics value[5 ] = {}; +uint16_t i, id, stat_cnt; +uint8_t page_id, stat_id; +uint16_t param; +struct dpaa2_dev_priv *priv = dev->data->dev_private; +struct fsl_mc_io *dpni = dev->process_private; +bool page_fetched[DPNI_MAX_STATISTICS_PAGE_ID ][DPNI_STAT_MAX_PARAM ]; +/* Fetch all MAC counters in a single MC command on first MAC xstat. */ +bool mac_fetched = false; +int retcode; +uint64_t *cnt_values; -if (n < stat_cnt) -return stat_cnt; + stat_cnt =DPAA2_DPNI_XSTAT_MAX_NUM ; +if (priv->ep_dev_type ==DPAA2_MAC ) + stat_cnt +=DPAA2_MAC_NUM_STATS ; -if (!values) -return 0 ; +memset (page_fetched,0 ,sizeof (page_fetched)); -/* Get Counters from page_0*/ - retcode =dpni_get_statistics (dpni,CMD_PRI_LOW , priv->token, -0 ,0 , &value[0 ]); +for (i =0 ; i < n; i++) { +if (ids && ids[i] >= stat_cnt) { +DPAA2_PMD_ERR ("xstats id value isn't valid" ); +return -EINVAL ; + } + id = ids ? ids[i] : i; +if (id >=DPAA2_MAC_XSTATS_START_ID ) { +if (!dpaa2_dev_mac_xstats_avail (dev)) { + values[i] =0 ; +continue ; + } +if (mac_fetched) { + cnt_values = priv->cnt_values_dma_mem; + values[i] = cnt_values[id -DPAA2_MAC_XSTATS_START_ID ]; +continue ; + } + goto dpmac_get_xstat; + } + page_id =0 ; + stat_id =0 ; + param =0 ; + retcode =dpaa2_xstats_id_parse (id, &page_id, &stat_id, ¶m,NULL );if (retcode) -return 0 ; +return retcode; +if (!dpaa2_dev_dpni_xstats_avail (dev, page_id, param)) { + values[i] =0 ; +continue ; + } +if (!page_fetched[page_id][param]) + goto dpni_get_xstat; + values[i] = priv->pg_xstats[page_id][param].raw.counter[stat_id]; +continue ; + +dpmac_get_xstat: +/* Single MC call fetches all MAC counters at once; +* reuse the result for every subsequent MAC xstat. +*/ + retcode =dpaa2_dev_xstat_mac_setup_mem (dev); +if (retcode) { +DPAA2_PMD_ERR ("%s: Failed(%d) to setup %s's MAC statistics!" , + __func__, retcode, dev->data->name); +return retcode; + } + retcode =dpni_get_mac_statistics (dpni,CMD_PRI_LOW , + priv->token, priv->cnt_idx_iova, + priv->cnt_values_iova,DPAA2_MAC_NUM_STATS ); +if (retcode) { +DPAA2_PMD_ERR ("%s: Failed(%d) to get %s's MAC statistics!" , + __func__, retcode, dev->data->name); +return retcode; + } + mac_fetched = true; + cnt_values = priv->cnt_values_dma_mem; + values[i] = cnt_values[id -DPAA2_MAC_XSTATS_START_ID ]; +continue ; -/* Get Counters from page_1*/ - retcode =dpni_get_statistics (dpni,CMD_PRI_LOW , priv->token, -1 ,0 , &value[1 ]); -if (retcode) -return 0 ; +dpni_get_xstat: +/* Cache dpni page results: multiple xstats can share +* the same (page_id, param), so only fetch each pair once. +*/ + retcode =dpni_get_statistics (dpni,CMD_PRI_LOW , + priv->token, page_id, param, + &priv->pg_xstats[page_id][param]); +if (retcode) { +DPAA2_PMD_ERR ("%s: Failed(%d) to get %s's statistcis of page%d!" , + __func__, retcode, dev->data->name, page_id); +return retcode; + } + page_fetched[page_id][param] = true; + values[i] = priv->pg_xstats[page_id][param].raw.counter[stat_id]; + } -/* Get Counters from page_2*/ - retcode =dpni_get_statistics (dpni,CMD_PRI_LOW , priv->token, -2 ,0 , &value[2 ]); -if (retcode) -return 0 ; +return n; +} -/* Get Counters from page_4*/ - retcode =dpni_get_statistics (dpni,CMD_PRI_LOW , priv->token, -4 ,0 , &value[4 ]); -if (retcode) -return 0 ; +static int +dpaa2_dev_xstats_get_names_by_id (struct rte_eth_dev *dev, +const uint64_t *ids,struct rte_eth_xstat_name *xstats_names, +uint32_t limit) +{ +struct dpaa2_dev_priv *priv = dev->data->dev_private; +uint16_t i, stat_cnt; -for (i =0 ; i < stat_cnt; i++) { - page_id = dpaa2_xstats_strings[i].page_id; - stats_id = dpaa2_xstats_strings[i].stats_id; - values[i] = value[page_id].raw.counter[stats_id]; - } -return stat_cnt; - } + stat_cnt =DPAA2_DPNI_XSTAT_MAX_NUM ; +if (priv->ep_dev_type ==DPAA2_MAC ) + stat_cnt +=DPAA2_MAC_NUM_STATS ; -dpaa2_xstats_get_by_id (dev,NULL , values_copy, stat_cnt); +if (!ids) +return dpaa2_dev_xstats_get_names (dev, xstats_names, limit); -for (i =0 ; i < n; i++) { +for (i =0 ; i < limit; i++) {if (ids[i] >= stat_cnt) { -DPAA2_PMD_ERR ("xstats id value isn't valid" ); +DPAA2_PMD_ERR ("xstats id[%d] value(%" PRIu64") >= max count(%d)" , + i, ids[i], stat_cnt);return -EINVAL ; } - values[i] = values_copy[ids[i]]; +if (ids[i] <DPAA2_DPNI_XSTAT_MAX_NUM ) { +rte_strscpy (xstats_names[i].name, dpaa2_dpni_xstats_strings[ids[i]], +RTE_ETH_XSTATS_NAME_SIZE ); + }else { +rte_strscpy (xstats_names[i].name, + dpaa2_mac_xstats_strings[ids[i] -DPAA2_DPNI_XSTAT_MAX_NUM ], +RTE_ETH_XSTATS_NAME_SIZE ); + } } -return n; +return limit; }static int -dpaa2_xstats_get_names_by_id (struct rte_eth_dev *dev, -const uint64_t *ids, -struct rte_eth_xstat_name *xstats_names, -unsigned int limit) +dpaa2_dev_stats_get (struct rte_eth_dev *dev, +struct rte_eth_stats *stats,struct eth_queue_stats *qstats) { -unsigned int i, stat_cnt =RTE_DIM (dpaa2_xstats_strings); -struct rte_eth_xstat_name xstats_names_copy[stat_cnt]; +struct dpaa2_dev_priv *priv = dev->data->dev_private; +int32_t retcode; +uint16_t stats_len =RTE_DIM (dpaa2_stats_strings), i, j, xstats_len; +struct dpaa2_queue *dpaa2_q; +uint64_t ids[stats_len]; +uint64_t counts[stats_len]; +uint64_t ifiltered =0 ; +const char **dpni_nms = (const char **)&dpaa2_dpni_xstats_strings; -if (!ids) -return dpaa2_xstats_get_names (dev, xstats_names, limit); +PMD_INIT_FUNC_TRACE (); -dpaa2_xstats_get_names (dev, xstats_names_copy, limit); + xstats_len =DPAA2_DPNI_XSTAT_MAX_NUM ; +if (priv->ep_dev_type ==DPAA2_MAC ) + xstats_len +=DPAA2_MAC_NUM_STATS ; -for (i =0 ; i < limit; i++) { -if (ids[i] >= stat_cnt) { -DPAA2_PMD_ERR ("xstats id value isn't valid" ); -return -1 ; +if (!stats) { +DPAA2_PMD_ERR ("stats is NULL" ); +return -EINVAL ; + } + +memset (stats,0 ,sizeof (struct rte_eth_stats )); + +for (i =0 ; i < stats_len; i++) { +for (j =0 ; j < xstats_len; j++) { +if (j <DPAA2_DPNI_XSTAT_MAX_NUM ) { + retcode =strcmp (dpaa2_stats_strings[i].name, dpni_nms[j]); + }else { + retcode =strcmp (dpaa2_stats_strings[i].name, + dpaa2_mac_xstats_strings[j -DPAA2_DPNI_XSTAT_MAX_NUM ]); + } +if (!retcode) { + ids[i] = j; +break ; + } + } +if (j == xstats_len) { +DPAA2_PMD_ERR ("%s: stat(%s) not found in xstat!" , + __func__, dpaa2_stats_strings[i].name); +return -EINVAL ; } -strcpy (xstats_names[i].name, xstats_names_copy[ids[i]].name); } -return limit; + + retcode =dpaa2_dev_xstats_get_by_id (dev, ids, counts, stats_len); +if (retcode != stats_len) { +DPAA2_PMD_ERR ("%s: Failed to get xstats (%d)counters by %d IDs" , + __func__, retcode, stats_len); +if (retcode >=0 ) + retcode = -EINVAL ; +return retcode; + } + +for (i =0 ; i < stats_len; i++) { +if (dpaa2_stats_strings[i].offset <sizeof (struct rte_eth_stats )) { +DPAA2_STATS_SET_BY_OFFSET (stats, + dpaa2_stats_strings[i].offset, counts[i]); + }else { + ifiltered = counts[i]; + } + } + stats->imissed = stats->ierrors + stats->rx_nombuf + ifiltered; + +if (qstats) { +for (i =0 ; i < dev->data->nb_rx_queues; i++) { + dpaa2_q = priv->rx_vq[i]; +if (dpaa2_q) + qstats[i].q_ipackets = dpaa2_q->rx_pkts; + } +for (i =0 ; i < dev->data->nb_tx_queues; i++) { + dpaa2_q = priv->tx_vq[i]; +if (dpaa2_q) + qstats[i].q_opackets = dpaa2_q->tx_pkts; + } + } + +return 0 ; } static int
@@ -3326,9 +3595,9 @@ static struct eth_dev_ops dpaa2_ethdev_ops = { .link_update = dpaa2_dev_link_update, .stats_get = dpaa2_dev_stats_get, .xstats_get = dpaa2_dev_xstats_get, - .xstats_get_by_id = dpaa2_xstats_get_by_id, - .xstats_get_names_by_id = dpaa2_xstats_get_names_by_id, - .xstats_get_names = dpaa2_xstats_get_names, + .xstats_get_by_id = dpaa2_dev_xstats_get_by_id, + .xstats_get_names_by_id = dpaa2_dev_xstats_get_names_by_id, + .xstats_get_names = dpaa2_dev_xstats_get_names, .stats_reset = dpaa2_dev_stats_reset, .xstats_reset = dpaa2_dev_stats_reset, .fw_version_get = dpaa2_fw_version_get,
@@ -3682,17 +3951,6 @@ dpaa2_dev_init(struct rte_eth_dev *eth_dev) priv->speed_capa =dpaa2_dev_get_speed_capability (eth_dev); -/* mac_statistics supported on MC version > 10.39.0 */ - { -struct mc_version mc_ver_info = {0 }; - -if (!mc_get_version (dpni_dev,CMD_PRI_LOW , &mc_ver_info) && - mc_ver_info.major >=MC_VER_MAJOR && - mc_ver_info.minor >=MC_VER_MINOR && - mc_ver_info.revision >0 ) -dpaa2_dev_mac_setup_stats (eth_dev); - } -return 0 ; init_err:dpaa2_dev_close (eth_dev);
drivers/net/dpaa2/dpaa2_ethdev.h +7 -4
@@ -206,6 +206,7 @@#define DPAA2_FLOW_FRM_REPLICATION_ACTION_MC_REV RTE_FSL_MC_REV(10, 39, 106)#define DPAA2_QOS_FLOW_TABLE_SET_V3_MC_REV RTE_FSL_MC_REV(10, 39, 109) +#define DPAA2_MAC_XSTATS_MC_REV RTE_FSL_MC_REV(10, 39, 109)/* mac counters */ #define DPAA2_MAC_NUM_STATS (DPMAC_CNT_EGR_CONTROL_FRAME + 1)
@@ -514,6 +515,12 @@ struct dpaa2_dev_priv {uint64_t cnt_idx_iova, cnt_values_iova;uint64_t mc_rev; +/* Cache one dpni_statistics result per (page_id, param) pair to avoid +* redundant MC commands when multiple xstats share the same page. +* Put it in heap to avoid allocating multi-KB stack in runtime. +*/ +union dpni_statistics pg_xstats[DPNI_MAX_STATISTICS_PAGE_ID ][DPNI_STAT_MAX_PARAM ]; +struct dpaa2_dev_flow *curr; LIST_HEAD(, dpaa2_dev_flow) flows; LIST_HEAD(nodes, dpaa2_tm_node) nodes;
@@ -662,8 +669,4 @@ int dpaa2_timesync_read_tx_timestamp(struct rte_eth_dev *dev,int dpaa2_dev_recycle_config (struct rte_eth_dev *eth_dev);int dpaa2_dev_recycle_deconfig (struct rte_eth_dev *eth_dev); - -void -dpaa2_dev_mac_setup_stats (struct rte_eth_dev *dev); -#endif /* _DPAA2_ETHDEV_H */
drivers/net/dpaa2/mc/fsl_dpni.h +70 -46
129 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH 18/65 net/dpaa2: unify xstats layout and add DPMAC counter struct
In reply to Prashant GuptaFrom: Jun Yang <[email protected]>
The DPNI page counters and the DPMAC counters were described by three loosely coupled artifacts: a struct dpaa2_dpni_xstats_pg_seq covering only the DPNI pages, a parallel s_dpaa2_dpni_xstats_pgs[] descriptor table carrying (page_offset, page_id, param, size), and two separate name arrays (dpaa2_dpni_xstats_strings[] and dpaa2_mac_xstats_strings[]). Keeping those three in sync was manual and error prone, and dpaa2_dev_stats_get() further depended on a fourth table (dpaa2_stats_strings[]) plus a string-match loop to translate rte_eth_stats fields into xstat ids.
Collapse all of this to a single source of truth driven by the C struct layout.
Behavior is unchanged apart from the per-TC policer name format; the refactor removes ~200 lines of duplicated metadata and makes adding a new counter a one-line struct change.
--- drivers/net/dpaa2/dpaa2_ethdev.c | 549 +++++++++++++------------------ drivers/net/dpaa2/dpaa2_ethdev.h | 3 +- drivers/net/dpaa2/mc/fsl_dpni.h | 146 ++++++++ 3 files changed, 378 insertions(+), 320 deletions(-)
drivers/net/dpaa2/dpaa2_ethdev.c +230 -319
@@ -169,7 +169,7 @@ dpaa2_dist_size_is_supported(uint16_t n)int dpaa2_valid_dev;struct rte_mempool *dpaa2_tx_sg_pool; -struct dpaa2_dpni_xstats_pg_seq { +struct dpaa2_xstats_seq {struct dpni_statistics_page_0 pg0;struct dpni_statistics_page_1 pg1;struct dpni_statistics_page_2 pg2;
@@ -177,119 +177,81 @@ struct dpaa2_dpni_xstats_pg_seq {struct dpni_statistics_page_4 pg4;struct dpni_statistics_page_5 pg5[MAX_TCS ];struct dpni_statistics_page_6 pg6; +struct dpni_dpmac_counters mac_cnt; };#define DPAA2_DPNI_XSTAT_MAX_NUM \ - (sizeof(struct dpaa2_dpni_xstats_pg_seq) / sizeof(uint64_t)) - -struct dpaa2_dpni_xstats_pg { -uint64_t page_offset; -enum dpni_statistics_page_id page_id; -uint16_t param; -uint16_t size; -}; - -static const struct dpaa2_dpni_xstats_pg s_dpaa2_dpni_xstats_pgs[] = { - { - offsetof(struct dpaa2_dpni_xstats_pg_seq , pg0), -DPNI_INGRESS_STATISTICS_PAGE_ID ,0 , -sizeof (struct dpni_statistics_page_0 ) - }, - { - offsetof(struct dpaa2_dpni_xstats_pg_seq , pg1), -DPNI_EGRESS_STATISTICS_PAGE_ID ,0 , -sizeof (struct dpni_statistics_page_1 ) - }, - { - offsetof(struct dpaa2_dpni_xstats_pg_seq , pg2), -DPNI_ERR_STATISTICS_PAGE_ID ,0 , -sizeof (struct dpni_statistics_page_2 ) - }, - { - offsetof(struct dpaa2_dpni_xstats_pg_seq , pg3), -DPNI_CEETM_STATISTICS_PAGE_ID ,0 , -sizeof (struct dpni_statistics_page_3 ) - }, - { - offsetof(struct dpaa2_dpni_xstats_pg_seq , pg4), -DPNI_CGR_STATISTICS_PAGE_ID ,0 , -sizeof (struct dpni_statistics_page_4 ) - }, - { - offsetof(struct dpaa2_dpni_xstats_pg_seq, pg5[0]), -DPNI_POLICER_STATISTICS_PAGE_ID ,0 , -sizeof (struct dpni_statistics_page_5 ) - }, - { - offsetof(struct dpaa2_dpni_xstats_pg_seq, pg5[1]), -DPNI_POLICER_STATISTICS_PAGE_ID ,1 , -sizeof (struct dpni_statistics_page_5 ) - }, - { - offsetof(struct dpaa2_dpni_xstats_pg_seq, pg5[2]), -DPNI_POLICER_STATISTICS_PAGE_ID ,2 , -sizeof (struct dpni_statistics_page_5 ) - }, - { - offsetof(struct dpaa2_dpni_xstats_pg_seq, pg5[3]), -DPNI_POLICER_STATISTICS_PAGE_ID ,3 , -sizeof (struct dpni_statistics_page_5 ) - }, - { - offsetof(struct dpaa2_dpni_xstats_pg_seq, pg5[4]), -DPNI_POLICER_STATISTICS_PAGE_ID ,4 , -sizeof (struct dpni_statistics_page_5 ) - }, - { - offsetof(struct dpaa2_dpni_xstats_pg_seq, pg5[5]), -DPNI_POLICER_STATISTICS_PAGE_ID ,5 , -sizeof (struct dpni_statistics_page_5 ) - }, - { - offsetof(struct dpaa2_dpni_xstats_pg_seq, pg5[6]), -DPNI_POLICER_STATISTICS_PAGE_ID ,6 , -sizeof (struct dpni_statistics_page_5 ) - }, - { - offsetof(struct dpaa2_dpni_xstats_pg_seq, pg5[7]), -DPNI_POLICER_STATISTICS_PAGE_ID ,7 , -sizeof (struct dpni_statistics_page_5 ) - }, - { - offsetof(struct dpaa2_dpni_xstats_pg_seq , pg6), -DPNI_TX_PENDING_STATISTICS_PAGE_ID ,0 , -sizeof (struct dpni_statistics_page_6 ) - }, - { -sizeof (struct dpaa2_dpni_xstats_pg_seq ), -0 ,0 ,0 - } -}; + (offsetof(struct dpaa2_xstats_seq, mac_cnt) / sizeof(uint64_t)) + +#define DPAA2_DPNI_STAT_SET_PAGE_PARAM (param) \ +({ \ + int ret = false; \ + \ + if ((id) >= this_offset && (id) < (this_offset + pg_size)) { \ + _stat_id = (id) - this_offset; \ + _param = param; \ + _size = pg_size; \ + ret = true; \ + } \ + ret; \ +}) + +#define DPAA2_DPNI_STAT_PAGE_PARAM (pid) \ +({ \ + uint64_t this_offset = offsetof(struct dpaa2_xstats_seq, pg##pid) / sizeof(uint64_t); \ + uint64_t pg_size = sizeof(struct dpni_statistics_page_##pid) / sizeof(uint64_t); \ + int ret; \ + \ + ret = DPAA2_DPNI_STAT_SET_PAGE_PARAM(0); \ + if (!ret) \ + _page++; \ + ret; \ +}) + +#define DPAA2_DPNI_STAT_POLICER_PAGE_PARAM () \ +({ \ + int ret = false; \ + uint8_t tc_id; \ + uint64_t this_offset; \ + uint64_t pg_size = sizeof(struct dpni_statistics_page_5) / sizeof(uint64_t); \ + \ + for (tc_id = 0; tc_id < MAX_TCS; tc_id++) { \ + this_offset = offsetof(struct dpaa2_xstats_seq, pg5[tc_id]) / sizeof(uint64_t); \ + ret = DPAA2_DPNI_STAT_SET_PAGE_PARAM(tc_id); \ + if (ret) \ + break; \ + } \ + if (!ret) \ + _page++; \ + ret; \ +})static inline int dpaa2_xstats_id_parse (uint32_t id,uint8_t *page,uint8_t *stat_id,uint16_t *param,uint16_t *size) { -int found =0 ; -uint8_t _page =0 , _stat_id =0 ; +uint8_t _page =DPNI_INGRESS_STATISTICS_PAGE_ID , _stat_id =0 ;uint16_t _param =0 , _size =0 ; -uint64_t offset = id *sizeof (uint64_t ), page_offset =0 , i; - -for (i =1 ; i <RTE_DIM (s_dpaa2_dpni_xstats_pgs); i++) { -if (offset < s_dpaa2_dpni_xstats_pgs[i].page_offset) { - page_offset = s_dpaa2_dpni_xstats_pgs[i -1 ].page_offset; - _page = s_dpaa2_dpni_xstats_pgs[i -1 ].page_id; - _stat_id = (offset - page_offset) /sizeof (uint64_t ); - _param = s_dpaa2_dpni_xstats_pgs[i -1 ].param; - _size = s_dpaa2_dpni_xstats_pgs[i -1 ].size /sizeof (uint64_t ); - found =1 ; -break ; - } - } - -if (!found) -return -EINVAL ; +if (DPAA2_DPNI_STAT_PAGE_PARAM (0 )) + goto found_id; +if (DPAA2_DPNI_STAT_PAGE_PARAM (1 )) + goto found_id; +if (DPAA2_DPNI_STAT_PAGE_PARAM (2 )) + goto found_id; +if (DPAA2_DPNI_STAT_PAGE_PARAM (3 )) + goto found_id; +if (DPAA2_DPNI_STAT_PAGE_PARAM (4 )) + goto found_id; +if (DPAA2_DPNI_STAT_POLICER_PAGE_PARAM ()) + goto found_id; +if (DPAA2_DPNI_STAT_PAGE_PARAM (6 )) + goto found_id; + +DPAA2_PMD_ERR ("ID(%d) was not found in DPNI page statistics" , id); +return -EINVAL ; + +found_id:if (page) *page = _page;if (stat_id)
@@ -302,156 +264,155 @@ dpaa2_xstats_id_parse(uint32_t id, uint8_t *page,return 0 ; } -struct dpaa2_stats_name_off { -char name[RTE_ETH_XSTATS_NAME_SIZE ]; -uint64_t offset; +#define DPAA2_XSTAT_STR_SET (pg, field) \ + .pg.field = (uint64_t)RTE_STR(field) + +#define DPAA2_XSTAT_TC_STR_SET (pg, tc, field) \ + .pg[tc].field = (uint64_t)("TC" RTE_STR(tc)"_" RTE_STR(field)) + +#define DPAA2_XSTAT_TC_COLOR_STR_SET (pg, tc) \ + DPAA2_XSTAT_TC_STR_SET(pg, tc, policer_cnt_red), \ + DPAA2_XSTAT_TC_STR_SET(pg, tc, policer_cnt_yellow), \ + DPAA2_XSTAT_TC_STR_SET(pg, tc, policer_cnt_green), \ + DPAA2_XSTAT_TC_STR_SET(pg, tc, policer_cnt_re_red), \ + DPAA2_XSTAT_TC_STR_SET(pg, tc, policer_cnt_re_yellow) + +#define MAC_STR (name) ("mac_" #name) +#define MAC_STR_ADDR (name) ((size_t)MAC_STR(name)) + +static const struct dpaa2_xstats_seq dpaa2_xstats_strings = { +DPAA2_XSTAT_STR_SET (pg0, ingress_all_frames), +DPAA2_XSTAT_STR_SET (pg0, ingress_all_bytes), +DPAA2_XSTAT_STR_SET (pg0, ingress_multicast_frames), +DPAA2_XSTAT_STR_SET (pg0, ingress_multicast_bytes), +DPAA2_XSTAT_STR_SET (pg0, ingress_broadcast_frames), +DPAA2_XSTAT_STR_SET (pg0, ingress_broadcast_bytes), + +DPAA2_XSTAT_STR_SET (pg1, egress_all_frames), +DPAA2_XSTAT_STR_SET (pg1, egress_all_bytes), +DPAA2_XSTAT_STR_SET (pg1, egress_multicast_frames), +DPAA2_XSTAT_STR_SET (pg1, egress_multicast_bytes), +DPAA2_XSTAT_STR_SET (pg1, egress_broadcast_frames), +DPAA2_XSTAT_STR_SET (pg1, egress_broadcast_bytes), + +DPAA2_XSTAT_STR_SET (pg2, ingress_filtered_frames), +DPAA2_XSTAT_STR_SET (pg2, ingress_discarded_frames), +DPAA2_XSTAT_STR_SET (pg2, ingress_nobuffer_discards), +DPAA2_XSTAT_STR_SET (pg2, egress_discarded_frames), +DPAA2_XSTAT_STR_SET (pg2, egress_confirmed_frames), + +DPAA2_XSTAT_STR_SET (pg3, ceetm_dequeue_bytes), +DPAA2_XSTAT_STR_SET (pg3, ceetm_dequeue_frames), +DPAA2_XSTAT_STR_SET (pg3, ceetm_reject_bytes), +DPAA2_XSTAT_STR_SET (pg3, ceetm_reject_frames), + +DPAA2_XSTAT_STR_SET (pg4, cgr_reject_frames), +DPAA2_XSTAT_STR_SET (pg4, cgr_reject_bytes), + +DPAA2_XSTAT_TC_COLOR_STR_SET (pg5,0 ), +DPAA2_XSTAT_TC_COLOR_STR_SET (pg5,1 ), +DPAA2_XSTAT_TC_COLOR_STR_SET (pg5,2 ), +DPAA2_XSTAT_TC_COLOR_STR_SET (pg5,3 ), +DPAA2_XSTAT_TC_COLOR_STR_SET (pg5,4 ), +DPAA2_XSTAT_TC_COLOR_STR_SET (pg5,5 ), +DPAA2_XSTAT_TC_COLOR_STR_SET (pg5,6 ), +DPAA2_XSTAT_TC_COLOR_STR_SET (pg5,7 ), + +DPAA2_XSTAT_STR_SET (pg6, tx_pending_frames_cnt), + + .mac_cnt.rx_64_bytes =MAC_STR_ADDR (rx_64_bytes), + .mac_cnt.rx_65_127_bytes =MAC_STR_ADDR (rx_65_127_bytes), + .mac_cnt.rx_128_255_bytes =MAC_STR_ADDR (rx_128_255_bytes), + .mac_cnt.rx_256_511_bytes =MAC_STR_ADDR (rx_256_511_bytes), + .mac_cnt.rx_512_1023_bytes =MAC_STR_ADDR (rx_512_1023_bytes), + .mac_cnt.rx_1024_1518_bytes =MAC_STR_ADDR (rx_1024_1518_bytes), + .mac_cnt.rx_1519_max_bytes =MAC_STR_ADDR (rx_1519_max_bytes), + + .mac_cnt.rx_fragments =MAC_STR_ADDR (rx_fragments), + .mac_cnt.rx_jabber =MAC_STR_ADDR (rx_jabber), + .mac_cnt.rx_drop_fifo =MAC_STR_ADDR (rx_drop_fifo), + .mac_cnt.rx_alignment_error =MAC_STR_ADDR (rx_alignment_error), + + .mac_cnt.tx_undersize_good =MAC_STR_ADDR (tx_undersize_good), + .mac_cnt.rx_oversize_good =MAC_STR_ADDR (rx_oversize_good), + + .mac_cnt.rx_pause =MAC_STR_ADDR (rx_pause), + .mac_cnt.tx_pause =MAC_STR_ADDR (tx_pause), + + .mac_cnt.rx_good_bytes =MAC_STR_ADDR (rx_good_bytes), + .mac_cnt.rx_multicast =MAC_STR_ADDR (rx_multicast), + .mac_cnt.rx_broadcast =MAC_STR_ADDR (rx_broadcast), + .mac_cnt.rx_all_frames =MAC_STR_ADDR (rx_all_frames), + .mac_cnt.rx_unicast =MAC_STR_ADDR (rx_unicast), + .mac_cnt.rx_error =MAC_STR_ADDR (rx_error), + + .mac_cnt.tx_good_bytes =MAC_STR_ADDR (tx_good_bytes), + .mac_cnt.tx_multicast =MAC_STR_ADDR (tx_multicast), + .mac_cnt.tx_broadcast =MAC_STR_ADDR (tx_broadcast), + .mac_cnt.tx_unicast =MAC_STR_ADDR (tx_unicast), + .mac_cnt.tx_error =MAC_STR_ADDR (tx_error), + + .mac_cnt.rx_valid_frames =MAC_STR_ADDR (rx_valid_frames), + .mac_cnt.tx_valid_frames =MAC_STR_ADDR (tx_valid_frames), + + .mac_cnt.tx_64_bytes =MAC_STR_ADDR (tx_64_bytes), + .mac_cnt.tx_65_127_bytes =MAC_STR_ADDR (tx_65_127_bytes), + .mac_cnt.tx_128_255_bytes =MAC_STR_ADDR (tx_128_255_bytes), + .mac_cnt.tx_256_511_bytes =MAC_STR_ADDR (tx_256_511_bytes), + .mac_cnt.tx_512_1023_bytes =MAC_STR_ADDR (tx_512_1023_bytes), + .mac_cnt.tx_1024_1518_bytes =MAC_STR_ADDR (tx_1024_1518_bytes), + .mac_cnt.tx_1519_max_bytes =MAC_STR_ADDR (tx_1519_max_bytes), + + .mac_cnt.rx_bytes_all =MAC_STR_ADDR (rx_bytes_all), + .mac_cnt.rx_crc_error =MAC_STR_ADDR (rx_crc_error), + .mac_cnt.rx_vlan =MAC_STR_ADDR (rx_vlan), + .mac_cnt.rx_undersize_good =MAC_STR_ADDR (rx_undersize_good), + .mac_cnt.rx_ctrl_non_pause =MAC_STR_ADDR (rx_ctrl_non_pause), + .mac_cnt.rx_drop_full =MAC_STR_ADDR (rx_drop_full), + + .mac_cnt.tx_bytes_all =MAC_STR_ADDR (tx_bytes_all), + .mac_cnt.tx_crc_error =MAC_STR_ADDR (tx_crc_error), + .mac_cnt.tx_vlan =MAC_STR_ADDR (tx_vlan), + .mac_cnt.tx_all_frames =MAC_STR_ADDR (tx_all_frames), + .mac_cnt.tx_ctrl_non_pause =MAC_STR_ADDR (tx_ctrl_non_pause), + + .mac_cnt.rx_pfc_class[0 ] =MAC_STR_ADDR (rx_pfc_class_0), + .mac_cnt.rx_pfc_class[1 ] =MAC_STR_ADDR (rx_pfc_class_1), + .mac_cnt.rx_pfc_class[2 ] =MAC_STR_ADDR (rx_pfc_class_2), + .mac_cnt.rx_pfc_class[3 ] =MAC_STR_ADDR (rx_pfc_class_3), + .mac_cnt.rx_pfc_class[4 ] =MAC_STR_ADDR (rx_pfc_class_4), + .mac_cnt.rx_pfc_class[5 ] =MAC_STR_ADDR (rx_pfc_class_5), + .mac_cnt.rx_pfc_class[6 ] =MAC_STR_ADDR (rx_pfc_class_6), + .mac_cnt.rx_pfc_class[7 ] =MAC_STR_ADDR (rx_pfc_class_7), + + .mac_cnt.tx_pfc_class[0 ] =MAC_STR_ADDR (tx_pfc_class_0), + .mac_cnt.tx_pfc_class[1 ] =MAC_STR_ADDR (tx_pfc_class_1), + .mac_cnt.tx_pfc_class[2 ] =MAC_STR_ADDR (tx_pfc_class_2), + .mac_cnt.tx_pfc_class[3 ] =MAC_STR_ADDR (tx_pfc_class_3), + .mac_cnt.tx_pfc_class[4 ] =MAC_STR_ADDR (tx_pfc_class_4), + .mac_cnt.tx_pfc_class[5 ] =MAC_STR_ADDR (tx_pfc_class_5), + .mac_cnt.tx_pfc_class[6 ] =MAC_STR_ADDR (tx_pfc_class_6), + .mac_cnt.tx_pfc_class[7 ] =MAC_STR_ADDR (tx_pfc_class_7) }; -#define DPAA2_STATS_IPACKETS_STR "ingress_all_frames" -#define DPAA2_STATS_OPACKETS_STR "egress_all_frames" -#define DPAA2_STATS_IBYTES_STR "ingress_all_bytes" -#define DPAA2_STATS_OBYTES_STR "egress_all_bytes" -#define DPAA2_STATS_IERRORS_STR "ingress_discarded_frames" -#define DPAA2_STATS_OERRORS_STR "egress_discarded_frames" -#define DPAA2_STATS_RX_NOMBUF_STR "ingress_nobuffer_discards" -#define DPAA2_STATS_FILTERED_STR "ingress_filtered_frames" - -static const struct dpaa2_stats_name_off dpaa2_stats_strings[] = { - { -DPAA2_STATS_IPACKETS_STR , - offsetof(struct rte_eth_stats , ipackets) - }, - { -DPAA2_STATS_OPACKETS_STR , - offsetof(struct rte_eth_stats , opackets) - }, - { -DPAA2_STATS_IBYTES_STR , - offsetof(struct rte_eth_stats , ibytes) - }, - { -DPAA2_STATS_OBYTES_STR , - offsetof(struct rte_eth_stats , obytes) - }, - { -DPAA2_STATS_FILTERED_STR , -sizeof (struct rte_eth_stats ) - }, - { -DPAA2_STATS_IERRORS_STR , - offsetof(struct rte_eth_stats , ierrors) - }, - { -DPAA2_STATS_OERRORS_STR , - offsetof(struct rte_eth_stats , oerrors) - }, - { -DPAA2_STATS_RX_NOMBUF_STR , - offsetof(struct rte_eth_stats , rx_nombuf) - } +#define DPAA2_DPNI_XSTAT_FIELD_ID (field) \ + (offsetof(struct dpaa2_xstats_seq, field) / sizeof(uint64_t)) + +static const struct rte_eth_stats dpaa2_stats_xstat_ids = { + .ipackets =DPAA2_DPNI_XSTAT_FIELD_ID (pg0.ingress_all_frames), + .opackets =DPAA2_DPNI_XSTAT_FIELD_ID (pg1.egress_all_frames), + .ibytes =DPAA2_DPNI_XSTAT_FIELD_ID (pg0.ingress_all_bytes), + .obytes =DPAA2_DPNI_XSTAT_FIELD_ID (pg1.egress_all_bytes), + .imissed =DPAA2_DPNI_XSTAT_FIELD_ID (pg2.ingress_filtered_frames), + .ierrors =DPAA2_DPNI_XSTAT_FIELD_ID (pg2.ingress_discarded_frames), + .oerrors =DPAA2_DPNI_XSTAT_FIELD_ID (pg2.egress_discarded_frames), + .rx_nombuf =DPAA2_DPNI_XSTAT_FIELD_ID (pg2.ingress_nobuffer_discards) }; -#define DPAA2_STATS_SET_BY_OFFSET (p_stats, offset, val) \ - (*((uint64_t *)((uint8_t *)(p_stats) + (offset))) = (val)) - -#define DPAA2_TC_COLOR (tc) \ - "TC_"#tc"_policer_cnt_red", \ - "TC_"#tc"_policer_cnt_yellow", \ - "TC_"#tc"_policer_cnt_green", \ - "TC_"#tc"_policer_cnt_re_red", \ - "TC_"#tc"_policer_cnt_re_yellow" \ - -static const char *const dpaa2_dpni_xstats_strings[] = { -DPAA2_STATS_IPACKETS_STR , -DPAA2_STATS_IBYTES_STR , -"ingress_multicast_frames" , -"ingress_multicast_bytes" , -"ingress_broadcast_frames" , -"ingress_broadcast_bytes" , - -DPAA2_STATS_OPACKETS_STR , -DPAA2_STATS_OBYTES_STR , -"egress_multicast_frames" , -"egress_multicast_bytes" , -"egress_broadcast_frames" , -"egress_broadcast_bytes" , - -DPAA2_STATS_FILTERED_STR , -DPAA2_STATS_IERRORS_STR , -DPAA2_STATS_RX_NOMBUF_STR , -DPAA2_STATS_OERRORS_STR , -"egress_confirmed_frames" , - -"cgr_reject_frames" , -"cgr_reject_bytes" , - -"ceetm_dequeue_bytes" , -"ceetm_dequeue_frames" , -"ceetm_reject_bytes" , -"ceetm_reject_frames" , -DPAA2_TC_COLOR (0 ), -DPAA2_TC_COLOR (1 ), -DPAA2_TC_COLOR (2 ), -DPAA2_TC_COLOR (3 ), -DPAA2_TC_COLOR (4 ), -DPAA2_TC_COLOR (5 ), -DPAA2_TC_COLOR (6 ), -DPAA2_TC_COLOR (7 ), - -"tx_pending_frames_cnt" -}; +#define DPAA2_STATS_XSTATS_NUM \ + (sizeof(dpaa2_stats_xstat_ids) / sizeof(uint64_t)) -static const char *const dpaa2_mac_xstats_strings[] = { -"mac_rx_64 bytes" , -"mac_rx_65-127 bytes" , -"mac_rx_128-255 bytes" , -"mac_rx_256-511 bytes" , -"mac_rx_512-1023 bytes" , -"mac_rx_1024-1518 bytes" , -"mac_rx_1519-max bytes" , -"mac_rx_frags" , -"mac_rx_jabber" , -"mac_rx_frame discards" , -"mac_rx_align errors" , -"mac_tx_undersized" , -"mac_rx_oversized" , -"mac_rx_pause" , -"mac_tx_b-pause" , -"mac_rx_bytes" , -"mac_rx_m-cast" , -"mac_rx_b-cast" , -"mac_rx_all frames" , -"mac_rx_u-cast" , -"mac_rx_frame errors" , -"mac_tx_bytes" , -"mac_tx_m-cast" , -"mac_tx_b-cast" , -"mac_tx_u-cast" , -"mac_tx_frame errors" , -"mac_rx_frames ok" , -"mac_tx_frames ok" , -"mac_tx_64 bytes" , -"mac_tx_65-127 bytes" , -"mac_tx_128-255 bytes" , -"mac_tx_256-511 bytes" , -"mac_tx_512-1023 bytes" , -"mac_tx_1024-1518 bytes" , -"mac_tx_1519-max bytes" , -"mac_rx_all_bytes" , -"mac_rx_fcs_err" , -"mac_rx_vlan_frame" , -"mac_rx_undersized" , -"mac_rx_control_frame" , -"mac_rx_frame_discard_not_trunc" , -"mac_tx_all_bytes" , -"mac_tx_fcs_err" , -"mac_tx_vlan_frame" , -"mac_tx_all_frame" , -"mac_tx_control_frame" -}; - -#define DPAA2_MAC_XSTATS_START_ID \ - (sizeof(struct dpaa2_dpni_xstats_pg_seq) / sizeof(uint64_t)) +#define DPAA2_MAC_XSTATS_START_ID DPAA2_DPNI_XSTAT_MAX_NUMstatic struct rte_dpaa2_driver rte_dpaa2_pmd; static int dpaa2_dev_link_update(struct rte_eth_dev *dev,
@@ -2333,6 +2294,7 @@ dpaa2_dev_xstats_get_names(struct rte_eth_dev *dev, {struct dpaa2_dev_priv *priv = dev->data->dev_private;uint16_t i, stat_cnt; +uint64_t xstat_str[sizeof (struct dpaa2_xstats_seq ) /sizeof (uint64_t )]; stat_cnt =DPAA2_DPNI_XSTAT_MAX_NUM ;if (priv->ep_dev_type ==DPAA2_MAC )
@@ -2347,16 +2309,10 @@ dpaa2_dev_xstats_get_names(struct rte_eth_dev *dev,if (!xstats_names)return stat_cnt; -for (i =0 ; i < stat_cnt; i++) { -if (i <DPAA2_DPNI_XSTAT_MAX_NUM ) { -rte_strscpy (xstats_names[i].name, dpaa2_dpni_xstats_strings[i], -RTE_ETH_XSTATS_NAME_SIZE ); - }else { -rte_strscpy (xstats_names[i].name, - dpaa2_mac_xstats_strings[i -DPAA2_DPNI_XSTAT_MAX_NUM ], -RTE_ETH_XSTATS_NAME_SIZE ); - } - } +rte_memcpy (xstat_str, &dpaa2_xstats_strings,sizeof (xstat_str)); + +for (i =0 ; i < stat_cnt; i++) +rte_strscpy (xstats_names[i].name, (char *)xstat_str[i],RTE_ETH_XSTATS_NAME_SIZE );return stat_cnt; }
@@ -2464,6 +2420,7 @@ dpaa2_dev_xstats_get_names_by_id(struct rte_eth_dev *dev, {struct dpaa2_dev_priv *priv = dev->data->dev_private;uint16_t i, stat_cnt; +uint64_t xstat_str[sizeof (struct dpaa2_xstats_seq ) /sizeof (uint64_t )]; stat_cnt =DPAA2_DPNI_XSTAT_MAX_NUM ;if (priv->ep_dev_type ==DPAA2_MAC )
@@ -2472,20 +2429,15 @@ dpaa2_dev_xstats_get_names_by_id(struct rte_eth_dev *dev,if (!ids)return dpaa2_dev_xstats_get_names (dev, xstats_names, limit); +rte_memcpy (xstat_str, &dpaa2_xstats_strings,sizeof (xstat_str)); +for (i =0 ; i < limit; i++) {if (ids[i] >= stat_cnt) {DPAA2_PMD_ERR ("xstats id[%d] value(%" PRIu64") >= max count(%d)" , i, ids[i], stat_cnt);return -EINVAL ; } -if (ids[i] <DPAA2_DPNI_XSTAT_MAX_NUM ) { -rte_strscpy (xstats_names[i].name, dpaa2_dpni_xstats_strings[ids[i]], -RTE_ETH_XSTATS_NAME_SIZE ); - }else { -rte_strscpy (xstats_names[i].name, - dpaa2_mac_xstats_strings[ids[i] -DPAA2_DPNI_XSTAT_MAX_NUM ], -RTE_ETH_XSTATS_NAME_SIZE ); - } +rte_strscpy (xstats_names[i].name, (char *)xstat_str[ids[i]],RTE_ETH_XSTATS_NAME_SIZE ); }return limit; }
@@ -2496,64 +2448,24 @@ dpaa2_dev_stats_get(struct rte_eth_dev *dev, {struct dpaa2_dev_priv *priv = dev->data->dev_private;int32_t retcode; -uint16_t stats_len =RTE_DIM (dpaa2_stats_strings), i, j, xstats_len; +uint16_t i; +uint64_t ids[DPAA2_STATS_XSTATS_NUM ], counts[DPAA2_STATS_XSTATS_NUM ] = {0 };struct dpaa2_queue *dpaa2_q; -uint64_t ids[stats_len]; -uint64_t counts[stats_len]; -uint64_t ifiltered =0 ; -const char **dpni_nms = (const char **)&dpaa2_dpni_xstats_strings;PMD_INIT_FUNC_TRACE (); - xstats_len =DPAA2_DPNI_XSTAT_MAX_NUM ; -if (priv->ep_dev_type ==DPAA2_MAC ) - xstats_len +=DPAA2_MAC_NUM_STATS ; - -if (!stats) { -DPAA2_PMD_ERR ("stats is NULL" ); -return -EINVAL ; - } - -memset (stats,0 ,sizeof (struct rte_eth_stats )); - -for (i =0 ; i < stats_len; i++) { -for (j =0 ; j < xstats_len; j++) { -if (j <DPAA2_DPNI_XSTAT_MAX_NUM ) { - retcode =strcmp (dpaa2_stats_strings[i].name, dpni_nms[j]); - }else { - retcode =strcmp (dpaa2_stats_strings[i].name, - dpaa2_mac_xstats_strings[j -DPAA2_DPNI_XSTAT_MAX_NUM ]); - } -if (!retcode) { - ids[i] = j; -break ; - } - } -if (j == xstats_len) { -DPAA2_PMD_ERR ("%s: stat(%s) not found in xstat!" , - __func__, dpaa2_stats_strings[i].name); -return -EINVAL ; - } - } - - retcode =dpaa2_dev_xstats_get_by_id (dev, ids, counts, stats_len); -if (retcode != stats_len) { -DPAA2_PMD_ERR ("%s: Failed to get xstats (%d)counters by %d IDs" , - __func__, retcode, stats_len); +rte_memcpy (ids, &dpaa2_stats_xstat_ids,sizeof (dpaa2_stats_xstat_ids)); + retcode =dpaa2_dev_xstats_get_by_id (dev, ids, counts,DPAA2_STATS_XSTATS_NUM ); +if (retcode !=RTE_DIM (ids)) { +DPAA2_PMD_ERR ("%s: Failed to get xstats (%d)counters by %ld IDs" , + __func__, retcode,DPAA2_STATS_XSTATS_NUM );if (retcode >=0 ) retcode = -EINVAL ;return retcode; } -for (i =0 ; i < stats_len; i++) { -if (dpaa2_stats_strings[i].offset <sizeof (struct rte_eth_stats )) { -DPAA2_STATS_SET_BY_OFFSET (stats, - dpaa2_stats_strings[i].offset, counts[i]); - }else { - ifiltered = counts[i]; - } - } - stats->imissed = stats->ierrors + stats->rx_nombuf + ifiltered; +rte_memcpy (stats, counts,sizeof (struct rte_eth_stats )); + stats->imissed += stats->ierrors + stats->rx_nombuf;if (qstats) {for (i =0 ; i < dev->data->nb_rx_queues; i++) {
@@ -2576,8 +2488,7 @@ dpaa2_dev_stats_reset(struct rte_eth_dev *dev) {struct dpaa2_dev_priv *priv = dev->data->dev_private;struct fsl_mc_io *dpni = dev->process_private; -int retcode; -int i; +int retcode, i;struct dpaa2_queue *dpaa2_q;PMD_INIT_FUNC_TRACE ();
@@ -2587,7 +2498,7 @@ dpaa2_dev_stats_reset(struct rte_eth_dev *dev)return -EINVAL ; } - retcode =dpni_reset_statistics (dpni,CMD_PRI_LOW , priv->token); + retcode =dpni_reset_statistics (dpni,CMD_PRI_LOW , priv->token);if (retcode) goto error;
drivers/net/dpaa2/dpaa2_ethdev.h +2 -1
@@ -209,7 +209,8 @@#define DPAA2_MAC_XSTATS_MC_REV RTE_FSL_MC_REV(10, 39, 109)/* mac counters */ -#define DPAA2_MAC_NUM_STATS (DPMAC_CNT_EGR_CONTROL_FRAME + 1) +#define DPAA2_MAC_NUM_STATS \ + (sizeof(struct dpni_dpmac_counters) / sizeof(uint64_t))#define DPAA2_MAC_STATS_INDEX_DMA_SIZE (DPAA2_MAC_NUM_STATS * sizeof(uint32_t))#define DPAA2_MAC_STATS_VALUE_DMA_SIZE (DPAA2_MAC_NUM_STATS * sizeof(uint64_t))
drivers/net/dpaa2/mc/fsl_dpni.h +146 -0
152 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH 19/65 net/dpaa2: reimplement xstats_get() on top of xstats_get_by_id()
In reply to Prashant GuptaFrom: Jun Yang <[email protected]>
dpaa2_dev_xstats_get() duplicated almost all of the logic already present in dpaa2_dev_xstats_get_by_id(): it walked the DPNI pages one by one with dpaa2_xstats_id_parse(), called dpni_get_statistics() per page, special-cased the DPMAC counter range with its own dpni_get_mac_statistics() path, handled per-page/per-MAC availability with inline zero-fill loops, etc. All of that behavior is already provided by dpaa2_dev_xstats_get_by_id(), so the standalone implementation was just a second place to keep in sync.
Rewrite dpaa2_dev_xstats_get() as a thin wrapper:
- Clamp the requested count to DPAA2_XSTAT_MAX_NUM (new helper defined as sizeof(struct dpaa2_xstats_seq) / sizeof(uint64_t)) with a warning when the caller asks for more.
- Build a trivial [0..n) id array, pre-zero the xstats[] entries, and call dpaa2_dev_xstats_get_by_id() once.
- Copy the returned values into xstats[].value and return the number of entries dpaa2_dev_xstats_get_by_id() produced.
Also reuse DPAA2_XSTAT_MAX_NUM in dpaa2_dev_xstats_get_names() and dpaa2_dev_xstats_get_names_by_id() in place of the open-coded sizeof(struct dpaa2_xstats_seq) / sizeof(uint64_t) local array sizes, and move dpaa2_dev_xstats_get() below the _by_id variants to reflect the new dependency direction.
No functional change: availability gating (DPNI page / DPMAC MC version), per-page dpni_get_statistics() batching and the DPMAC dpni_get_mac_statistics() path are all still performed, now solely inside dpaa2_dev_xstats_get_by_id().
--- drivers/net/dpaa2/dpaa2_ethdev.c | 146 +++++++++---------------------- 1 file changed, 42 insertions(+), 104 deletions(-)
drivers/net/dpaa2/dpaa2_ethdev.c +42 -104
@@ -180,6 +180,9 @@ struct dpaa2_xstats_seq {struct dpni_dpmac_counters mac_cnt; }; +#define DPAA2_XSTAT_MAX_NUM \ + (sizeof(struct dpaa2_xstats_seq) / sizeof(uint64_t)) +#define DPAA2_DPNI_XSTAT_MAX_NUM \ (offsetof(struct dpaa2_xstats_seq, mac_cnt) / sizeof(uint64_t))
@@ -2186,115 +2189,13 @@ dpaa2_dev_dpni_xstats_avail(struct rte_eth_dev *dev,return false; } -/* -* dpaa2_dev_xstats_get(): Get counters of dpni and dpmac. -* MAC (mac_*) counters are supported on MC version > 10.39.0 -* TC_x_policer_* counters are supported only when Policer is enable. -*/ -static int -dpaa2_dev_xstats_get (struct rte_eth_dev *dev, -struct rte_eth_xstat *xstats,uint32_t n) -{ -struct fsl_mc_io *dpni = dev->process_private; -uint16_t i, j, param, stat_cnt, size; -struct dpaa2_dev_priv *priv = dev->data->dev_private; -union dpni_statistics values; -uint8_t page_id, stat_id; -uint64_t *cnt_values; -int retcode; - - stat_cnt =DPAA2_DPNI_XSTAT_MAX_NUM ; -if (priv->ep_dev_type ==DPAA2_MAC ) - stat_cnt +=DPAA2_MAC_NUM_STATS ; - -if (n > stat_cnt) { -DPAA2_PMD_ERR ("%s: Expected number(%d) > max number(%d)" , - __func__, n, stat_cnt); -return -EINVAL ; - } - -if (!xstats) -return 0 ; - - i =0 ; -while (i < n) { -if (i >=DPAA2_MAC_XSTATS_START_ID ) { -if (!dpaa2_dev_mac_xstats_avail (dev)) { -for (j = i; j < n; j++) { - xstats[j].id = j; - xstats[j].value =0 ; - } - i = n; -break ; - } - goto dpmac_get_xstat; - } - - page_id =0 ; - stat_id =0 ; - param =0 ; - retcode =dpaa2_xstats_id_parse (i, &page_id, &stat_id, ¶m, &size); -if (retcode) -return retcode; -if (!dpaa2_dev_dpni_xstats_avail (dev, page_id, param)) { - xstats[i].id = i; - xstats[i].value =0 ; - i++; -continue ; - } - retcode =dpni_get_statistics (dpni,CMD_PRI_LOW , - priv->token, page_id, param, &values); -if (retcode) { -DPAA2_PMD_ERR ("%s: Failed(%d) to get %s's statistcis of page%d!" , - __func__, retcode, dev->data->name, page_id); -return retcode; - } - cnt_values = (void *)&values; - j = stat_id; -while (i < n && j < size) { - xstats[i].id = i; - xstats[i].value = cnt_values[j]; - i++; - j++; - } -continue ; - -dpmac_get_xstat: - retcode =dpaa2_dev_xstat_mac_setup_mem (dev); -if (retcode) { -DPAA2_PMD_ERR ("%s: Failed(%d) to setup %s MAC statistics!" , - __func__, retcode, dev->data->name); -return retcode; - } - retcode =dpni_get_mac_statistics (dpni,CMD_PRI_LOW , - priv->token, priv->cnt_idx_iova, - priv->cnt_values_iova,DPAA2_MAC_NUM_STATS ); -if (retcode) { -DPAA2_PMD_ERR ("%s: Failed(%d) to get %s's MAC statistics!" , - __func__, retcode, dev->data->name); -return retcode; - } - cnt_values = priv->cnt_values_dma_mem; - - j = i -DPAA2_MAC_XSTATS_START_ID ; -while (i < n && j <DPAA2_MAC_NUM_STATS ) { - xstats[i].id = i; - xstats[i].value = cnt_values[j]; - i++; - j++; - } - } - -return i; -} -static int dpaa2_dev_xstats_get_names (struct rte_eth_dev *dev,struct rte_eth_xstat_name *xstats_names,uint32_t limit) {struct dpaa2_dev_priv *priv = dev->data->dev_private;uint16_t i, stat_cnt; -uint64_t xstat_str[sizeof (struct dpaa2_xstats_seq ) /sizeof (uint64_t )]; +uint64_t xstat_str[DPAA2_XSTAT_MAX_NUM ]; stat_cnt =DPAA2_DPNI_XSTAT_MAX_NUM ;if (priv->ep_dev_type ==DPAA2_MAC )
@@ -2420,7 +2321,7 @@ dpaa2_dev_xstats_get_names_by_id(struct rte_eth_dev *dev, {struct dpaa2_dev_priv *priv = dev->data->dev_private;uint16_t i, stat_cnt; -uint64_t xstat_str[sizeof (struct dpaa2_xstats_seq ) /sizeof (uint64_t )]; +uint64_t xstat_str[DPAA2_XSTAT_MAX_NUM ]; stat_cnt =DPAA2_DPNI_XSTAT_MAX_NUM ;if (priv->ep_dev_type ==DPAA2_MAC )
@@ -2442,6 +2343,43 @@ dpaa2_dev_xstats_get_names_by_id(struct rte_eth_dev *dev,return limit; } +/* +* dpaa2_dev_xstats_get(): Get counters of dpni and dpmac. +* MAC (mac_*) counters are supported on MC version > 10.39.0 +* TC_x_policer_* counters are supported only when Policer is enable. +*/ +static int +dpaa2_dev_xstats_get (struct rte_eth_dev *dev, +struct rte_eth_xstat *xstats,uint32_t n) +{ +int retcode; +uint32_t i; +uint64_t ids[DPAA2_XSTAT_MAX_NUM ], vals[DPAA2_XSTAT_MAX_NUM ]; + +if (!xstats || !n) +return 0 ; + +if (n >DPAA2_XSTAT_MAX_NUM ) { +DPAA2_PMD_WARN ("%s: Expected xstat number(%d) > max(%ld)" , + __func__, n,DPAA2_XSTAT_MAX_NUM ); + n =DPAA2_XSTAT_MAX_NUM ; + } +for (i =0 ; i < n; i++) { + ids[i] = i; + xstats[i].id = i; + xstats[i].value =0 ; + } + + retcode =dpaa2_dev_xstats_get_by_id (dev, ids, vals, n); +if (retcode <0 ) +return retcode; + +for (i =0 ; i < (uint32_t )retcode; i++) + xstats[i].value = vals[i]; + +return retcode; +} +static int dpaa2_dev_stats_get (struct rte_eth_dev *dev,struct rte_eth_stats *stats,struct eth_queue_stats *qstats)
Signature · 1 line
2.43.0
PATCH 20/65 net/dpaa2: fetch only requested MAC xstats in one MC call
In reply to Prashant GuptaFrom: Jun Yang <[email protected]>
dpaa2_dev_xstats_get_by_id() previously handled MAC counters by issuing dpni_get_mac_statistics() for all DPAA2_MAC_NUM_STATS counters on the first MAC id seen, caching the full result in priv->cnt_values_dma_mem, and indexing into it for the remaining MAC ids in the same call. That had two drawbacks:
- Every caller that asked for even a single MAC counter paid for a full-block MC fetch.
- The cnt_idx_dma_mem table was pre-populated at setup time with a fixed 0..N-1 index list, so the MC command was effectively locked to "read all counters in order".
Rework the MAC path to build the index list on the fly from the ids the caller actually requested:
- Drop the one-shot cnt_idx_dma_mem initialisation in dpaa2_dev_xstat_mac_setup_mem(); it now only allocates and maps the DMA buffers.
- Call dpaa2_dev_xstat_mac_setup_mem() once at the top of dpaa2_dev_xstats_get_by_id() so the DMA memory is always ready.
- While walking ids[], for every id in the MAC range populate mac_idx[mac_num] with the MAC counter index and remember the destination slot in mac_val[mac_num]; zero values[i] up front so unavailable MAC counters stay zero.
- After the DPNI loop, if mac_num > 0 issue a single dpni_get_mac_statistics() for exactly mac_num entries and scatter the results back through mac_val[]. Removes the mac_fetched flag and the dpmac_get_xstat / dpni_get_xstat gotos.
Also replace the open-coded priv->ep_dev_type == DPAA2_MAC checks in dpaa2_dev_xstats_get_names(), dpaa2_dev_xstats_get_names_by_id() and _get_by_id() with the existing dpaa2_dev_mac_xstats_avail() helper, so MAC xstats are only exposed when both the endpoint is DPAA2_MAC and the MC version supports them.
Introduce DPAA2_MAC_XSTAT_MAX_NUM (= DPAA2_MAC_NUM_STATS) and a static_assert thatDPAA2_DPNI_XSTAT_MAX_NUM + DPAA2_MAC_XSTAT_MAX_NUM equals DPAA2_XSTAT_MAX_NUM, so the DPNI+MAC id space stays consistent with struct dpaa2_xstats_seq.
--- drivers/net/dpaa2/dpaa2_ethdev.c | 97 +++++++++++++++----------------- 1 file changed, 44 insertions(+), 53 deletions(-)
drivers/net/dpaa2/dpaa2_ethdev.c +44 -53
@@ -186,6 +186,10 @@ struct dpaa2_xstats_seq {#define DPAA2_DPNI_XSTAT_MAX_NUM \ (offsetof(struct dpaa2_xstats_seq, mac_cnt) / sizeof(uint64_t)) +#define DPAA2_MAC_XSTAT_MAX_NUM DPAA2_MAC_NUM_STATS + +static_assert ((DPAA2_DPNI_XSTAT_MAX_NUM +DPAA2_MAC_XSTAT_MAX_NUM ) ==DPAA2_XSTAT_MAX_NUM ); +#define DPAA2_DPNI_STAT_SET_PAGE_PARAM (param) \ ({ \ int ret = false; \
@@ -2099,7 +2103,6 @@ static int dpaa2_dev_xstat_mac_setup_mem(struct rte_eth_dev *dev) {struct dpaa2_dev_priv *priv = dev->data->dev_private; -uint32_t *cnt_idx, i;int ret =0 ;if (!priv->cnt_idx_dma_mem) {
@@ -2118,9 +2121,6 @@ dpaa2_dev_xstat_mac_setup_mem(struct rte_eth_dev *dev) __func__, priv->cnt_idx_dma_mem); goto err_dma_map; } - cnt_idx = priv->cnt_idx_dma_mem; -for (i =0 ; i <DPAA2_MAC_NUM_STATS ; i++) - cnt_idx[i] =rte_cpu_to_le_32 (i); }if (!priv->cnt_values_dma_mem) {
@@ -2193,13 +2193,12 @@ static int dpaa2_dev_xstats_get_names(struct rte_eth_dev *dev, struct rte_eth_xstat_name *xstats_names, uint32_t limit) { - struct dpaa2_dev_priv *priv = dev->data->dev_private; uint16_t i, stat_cnt;uint64_t xstat_str[DPAA2_XSTAT_MAX_NUM ]; stat_cnt =DPAA2_DPNI_XSTAT_MAX_NUM ; -if (priv->ep_dev_type ==DPAA2_MAC ) - stat_cnt +=DPAA2_MAC_NUM_STATS ; +if (dpaa2_dev_mac_xstats_avail (dev)) + stat_cnt +=DPAA2_MAC_XSTAT_MAX_NUM ;if (!limit)return stat_cnt;
@@ -2222,20 +2221,28 @@ static int dpaa2_dev_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids, uint64_t *values, uint32_t n) { - uint16_t i, id, stat_cnt; + uint16_t i, id, stat_cnt, mac_num = 0;uint8_t page_id, stat_id;uint16_t param;struct dpaa2_dev_priv *priv = dev->data->dev_private;struct fsl_mc_io *dpni = dev->process_private;bool page_fetched[DPNI_MAX_STATISTICS_PAGE_ID ][DPNI_STAT_MAX_PARAM ]; -/* Fetch all MAC counters in a single MC command on first MAC xstat. */ -bool mac_fetched = false; +/* Fetch required MAC counters in a single MC command. */ int retcode; -uint64_t *cnt_values; +uint32_t *mac_idx; +uint64_t *mac_val[DPAA2_MAC_XSTAT_MAX_NUM ]; + + retcode =dpaa2_dev_xstat_mac_setup_mem (dev); +if (retcode) { +DPAA2_PMD_ERR ("%s: Failed(%d) to setup %s's MAC statistics!" , + __func__, retcode, dev->data->name); +return retcode; + } + mac_idx = priv->cnt_idx_dma_mem; stat_cnt =DPAA2_DPNI_XSTAT_MAX_NUM ; -if (priv->ep_dev_type ==DPAA2_MAC ) - stat_cnt +=DPAA2_MAC_NUM_STATS ; +if (dpaa2_dev_mac_xstats_avail (dev)) + stat_cnt +=DPAA2_MAC_XSTAT_MAX_NUM ;memset (page_fetched,0 ,sizeof (page_fetched));
@@ -2246,16 +2253,13 @@ dpaa2_dev_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids, } id = ids ? ids[i] : i;if (id >=DPAA2_MAC_XSTATS_START_ID ) { -if (!dpaa2_dev_mac_xstats_avail (dev)) { - values[i] =0 ; -continue ; - } -if (mac_fetched) { - cnt_values = priv->cnt_values_dma_mem; - values[i] = cnt_values[id -DPAA2_MAC_XSTATS_START_ID ]; -continue ; + values[i] =0 ; +if (dpaa2_dev_mac_xstats_avail (dev)) { + mac_idx[mac_num] =rte_cpu_to_le_32 (id -DPAA2_MAC_XSTATS_START_ID ); + mac_val[mac_num] = &values[i]; + mac_num++; } - goto dpmac_get_xstat; +continue ; } page_id =0 ; stat_id =0 ;
@@ -2267,35 +2271,10 @@ dpaa2_dev_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids, values[i] =0 ;continue ; } -if (!page_fetched[page_id][param]) - goto dpni_get_xstat; - values[i] = priv->pg_xstats[page_id][param].raw.counter[stat_id]; -continue ; - -dpmac_get_xstat: -/* Single MC call fetches all MAC counters at once; -* reuse the result for every subsequent MAC xstat. -*/ - retcode =dpaa2_dev_xstat_mac_setup_mem (dev); -if (retcode) { -DPAA2_PMD_ERR ("%s: Failed(%d) to setup %s's MAC statistics!" , - __func__, retcode, dev->data->name); -return retcode; - } - retcode =dpni_get_mac_statistics (dpni,CMD_PRI_LOW , - priv->token, priv->cnt_idx_iova, - priv->cnt_values_iova,DPAA2_MAC_NUM_STATS ); -if (retcode) { -DPAA2_PMD_ERR ("%s: Failed(%d) to get %s's MAC statistics!" , - __func__, retcode, dev->data->name); -return retcode; +if (page_fetched[page_id][param]) { + values[i] = priv->pg_xstats[page_id][param].raw.counter[stat_id]; +continue ; } - mac_fetched = true; - cnt_values = priv->cnt_values_dma_mem; - values[i] = cnt_values[id -DPAA2_MAC_XSTATS_START_ID ]; -continue ; - -dpni_get_xstat:/* Cache dpni page results: multiple xstats can share * the same (page_id, param), so only fetch each pair once. */
@@ -2311,6 +2290,19 @@ dpaa2_dev_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids, values[i] = priv->pg_xstats[page_id][param].raw.counter[stat_id]; } +if (mac_num >0 ) { + retcode =dpni_get_mac_statistics (dpni,CMD_PRI_LOW , + priv->token, priv->cnt_idx_iova, + priv->cnt_values_iova, mac_num); +if (retcode) { +DPAA2_PMD_ERR ("%s: Failed(%d) to get %s's %d MAC statistics!" , + __func__, retcode, dev->data->name, mac_num); +return retcode; + } +for (i =0 ; i < mac_num; i++) + *mac_val[i] = priv->cnt_values_dma_mem[i]; + } +return n; }
@@ -2319,13 +2311,12 @@ dpaa2_dev_xstats_get_names_by_id(struct rte_eth_dev *dev, const uint64_t *ids, struct rte_eth_xstat_name *xstats_names, uint32_t limit) { - struct dpaa2_dev_priv *priv = dev->data->dev_private; uint16_t i, stat_cnt;uint64_t xstat_str[DPAA2_XSTAT_MAX_NUM ]; stat_cnt =DPAA2_DPNI_XSTAT_MAX_NUM ; -if (priv->ep_dev_type ==DPAA2_MAC ) - stat_cnt +=DPAA2_MAC_NUM_STATS ; +if (dpaa2_dev_mac_xstats_avail (dev)) + stat_cnt +=DPAA2_MAC_XSTAT_MAX_NUM ;if (!ids)return dpaa2_dev_xstats_get_names (dev, xstats_names, limit);
Signature · 1 line
2.43.0
PATCH 21/65 net/dpaa2: rework flow with per-table profile and group types
In reply to Prashant GuptaFrom: Jun Yang <[email protected]>
The dpaa2 PMD flow engine was built around a device-wide extract_s blob (qos_key_extract + tc_key_extract[MAX_TCS]) and a single dpaa2_dev_flow object that carried QoS and FS state side by side (qos_rule / fs_rule, qos_key_addr / fs_key_addr, ...). Growing new features onto that layout had become painful:
- There was no clean way to express a "QoS only", "FS only" or "RSS" flow; everything flowed through the same code path.
- IP src/dst and L4 src/dst extracts were open-coded with ip_addr_type / ip_addr_extract_pos / l4_src_port_pos state that was easy to desync when rules were added or removed.
- There was no bookkeeping of which hardware entries were in use, no runtime "clean invalid extract" step, and no way to update the action on an existing rule or set per-group miss actions.
- Protocol parsers were a long series of dpaa2_configure_flow_<proto>() clones that each had their own tunnel/raw/soft-parser branches and FAF handling.
- QoS and FS table setup, default action programming and entry/update/remove were all duplicated.
Reimplement the flow engine around a per-table profile and a per-type generic flow:
Core data model (dpaa2_ethdev.h):
- Replace struct extract_s and the two parallel dpaa2_key_extract arrays with struct dpaa2_flow_profile, which holds a dpaa2_flow_tbl_profile for the single QoS table and one per TC for FS/RSS. Each tbl_profile owns its dpkg extract param DMA buffer, dpni_qos_tbl_cfg / dpni_rx_dist_cfg config, default action (default_drop / default_jump / default_queue), rss_flow pointer, and an entry_map bitmap tracking used indices.
- Replace the open-coded IP/L4 extract state with struct dpaa2_ip_addr_extract ip_addr[2] and
struct dpaa2_l4_port_extract l4_port[DPAA2_L4_PORT_NUM], plus a key_profile that is just dpkg + prot_field[] with (type, prot, key_field, key_offset, key_size) per extract.
- Delete the old DPAA2_FAFE_PSR_OFFSET / enum dpaa2_rx_faf_offset
constants: FAF/PSR bit offsets are now obtained from the parser decode helpers (dpaa2_protocol_psr_bit_offset).
Add new DPAA2_QOS_FLOW_TABLE_MISS_FLOW_ACTION_MC_REV (10.39.109) gating for QoS miss-flow-id action, and DPAA2_QOS_ONLY_FLOW_STEER_FLAG to force a device into QoS-only mode.
Flow object model (dpaa2_flow.c):
- Introduce struct dpaa2_generic_flow carrying one steering flow:
type (QOS/FS/RSS), rule_cfg, key_addr/mask_addr, rule_size, entry_index, ip_key/ip_src/ip_dst, tc_id, action_type and an embedded dpaa2_dev_fs_action (dpni_fs_action_cfg + per-redir dst_name[]). A dpaa2_dev_flow now just references up to three dpaa2_generic_flow objects (qos_flow / fs_flow / rss_flow), allowing a user flow to be any combination.
- Add generic flow lifecycle helpers (init / deinit / add rule / remove rule / verify entry) plus entry_map get/set so that conflicting entries are detected before HW programming.
Extract/rule insertion helpers:
- Centralize all extract-set operations into:
dpaa2_profile_insert_ipaddr_extract(), dpaa2_profile_insert_no_ipaddr_extract(), dpaa2_dpkg_insert_extract(), dpaa2_flow_rule_insert_hole() / _dpaa2_flow_rule_insert_hole().
These are the only places that touch key_offset / key_size and move trailing extracts when a new field is inserted.
- Build dpaa2_flow_extract_add_hdr / _add_soft_psr / _add_faf_psr / _add_raw on top of them, and corresponding dpaa2_flow_add_hdr_extract_rule / _add_ipaddr_extract_rule / _add_soft_psr_extract_rule / _faf_add_rule to attach actual key/mask bytes.
Protocol handling:
- Replace the per-protocol dpaa2_configure_flow_<proto>() set with a single dispatch table s_dpaa2_flow_proto_handle[] indexed by rte_flow_item_type. Each entry declares the item's mask, fields[], field_offset[], field_size[], its parser protocol id, tunnel protocol id and the two callbacks (normal and tunnel). New callbacks cover eth, vlan, ipv4, ipv6, icmp, udp, tcp, esp, ah, sctp, gre, gtp, vxlan, ecpri, geneve and raw with shared logic in dpaa2_flow_general_extract_rule_set() and the _tunnel_* variants; eCPRI uses the parser decode helpers.
- IPv4 fragment is matched by setting the IP-frag FAF rather than the open-coded fragment_offset extract.
Table and action handling:
- dpaa2_flow_qos_table_config() / dpaa2_flow_tc_table_config() (re)program dpkg, set/clear RSS, write default (drop / jump / queue) action, and re-add existing rules via dpaa2_flow_add_all_steering_rule(). Default actions are gated on MC rev via DPAA2_QOS_FLOW_TABLE_SET_V3_MC_REV and DPAA2_QOS_FLOW_TABLE_MISS_FLOW_ACTION_MC_REV.
- dpaa2_flow_add_steering_rule() handles add vs update (DPNI_FS_OPT_UPDATE_IF_EXISTS / DPNI_QOS_OPT_UPDATE_IF_EXISTS) and uses dpni_add_fs_entry_legacy for MC revs before DPAA2_FLOW_FRM_REPLICATION_ACTION_MC_REV.
- Actions are converted uniformly in dpaa2_flow_action_rxq_convert() (QUEUE), dpaa2_flow_action_tx_port_convert() (PORT_ID / REPRESENTED_PORT, with multi-redirect via DPNI_FS_OPT_REDIRECT_TO_MULTIPLE_DPNI_TX gated on DPNI_OPT_V8_HAS_REPLICATION), DROP (DPNI_FS_OPT_DISCARD) and JUMP (sets flow->tc_id). FS actions carry a dst_name[] array for logging.
New flow APIs and group types:
- Add RTE_DPAA2_FLAT_GROUP_FLOW / RTE_DPAA2_QOS_GROUP_FLOW / RTE_DPAA2_FS_GROUP_FLOW and the macros RTE_DPAA2_FLOW_GROUP_TYPE_SET / RTE_DPAA2_FLOW_GROUP_TYPE_GET / RTE_DPAA2_FLOW_GROUP_ID_GET so that callers can request a QoS-only or FS-only rule inside the standard rte_flow API by encoding the type in the high bits of attr->group.
- Expose rte_dpaa2_flow_create() wrapper and rte_dpaa2_flow_group_set_miss_actions() so apps can set per-group default (drop / jump / queue) actions via rte_flow_group_set_miss_actions().
Expose rte_dpaa2_flow_validate() wrapper for apps to validate before calling rte_dpaa2_flow_create().
- dpaa2_flow_create() now:
- RSS-only when actions[0]==RSS,
- QoS-only when the port is QoS-only or group type is RTE_DPAA2_QOS_GROUP_FLOW or the action is JUMP,
- otherwise programs a QoS entry (synthesized JUMP to the FS TC) plus an FS entry, so one user flow transparently covers QoS->FS redirection on multi-TC devices.
- Implement flow actions_update by walking the three sub-flows and calling dpaa2_flow_steering_flow_action_update() / dpaa2_flow_rss_action_update() as appropriate.
- Implement group_set_miss_actions() backed by dpaa2_flow_qos_table_set_default() / dpaa2_flow_fs_table_set_default() with full validation of the (drop / jump / queue) combination.
- Replace the stub dpaa2_flow_query() with a dpni_dump_table() based implementation that locates the user flow's QoS and FS entries by matching key/mask against the HW dump.
- Add rte_pmd_dpaa2_flow_table_query() experimental API that dumps every QoS and FS entry currently programmed in HW and cross-checks it against the PMD's software flow list.
- dpaa2_flow_clean() now takes (tc_id, type) and selectively removes QoS-only, FS-only or RSS-only rules of a given TC, so that creating an FS rule in a TC automatically evicts a stale RSS rule in the same TC and vice versa.
Dynamic reconfiguration and validation:
- dpaa2_flow_remove_invalid_extract() walks the current extract set, drops extracts no longer referenced by any rule (including the IP-address pair and L4 port pair), shrinks each rule's key/mask buffer accordingly, recomputes key_max_size and ip_addr sizes based on each rule's ip_key (IPv4 vs IPv6), and triggers a table re-program via dpaa2_flow_table_update(). This runs on every flow destroy so the HW table stays as small as possible.
- dpaa2_flow_verify_patterns(), dpaa2_flow_verify_flow_action(), dpaa2_flow_verify_steering_attr() and dpaa2_flow_check_actions_support() are reorganized around the split dpaa2_supported_fs_action_type / dpaa2_supported_qos_action_type arrays (FS now explicitly adds DROP; QoS adds JUMP) and the new group-type encoding.
Debug/log:
- Add DPAA2_FLOW_DUMP() going to stderr (independent of rte_log so multi-line dumps are not interleaved), controlled by env DPAA2_FLOW_CONTROL_LOG. Replace the old dpaa2_flow_qos_extracts_log / dpaa2_flow_fs_extracts_log / dpaa2_flow_qos_entry_log / dpaa2_flow_fs_entry_log quartet with a shared dpaa2_flow_extracts_log(), dpaa2_flow_steering_entry_log() and dpaa2_dump_extract_map() that work for QoS and FS uniformly and also decode the chosen action (receive to flow / redirect to port(s) / drop / jump).
- Replace the hand-rolled dpaa2_prot_field_string() if/else chain with a static descriptor table dpaa2_hw_prot_field_support[] covering eth, vlan, ip, tcp, udp, sctp, icmp, gre, gtp, esp and ah, and add dpaa2_dump_dpkg() for human-readable extract dumps.
Init / close (dpaa2_ethdev.c):
- dpaa2_dev_init() now allocates extract_param and entry_map for every tbl_profile (QoS + MAX_TCS FS tables), stamps the default drop/jump/queue destinations, and primes tc_cfg.dist_size / key_cfg_iova per TC.
- dpaa2_dev_close() frees the per-table extract_param and entry_map and calls dpaa2_flow_clean(dev, MAX_TCS, DPAA2_FLOW_ALL_TYPE) to tear down all flows.
Parser decode (dpaa2_parser_decode.h):
- Add DPAA2_PARSER_NULL_ID so dispatch-table slots for items that have no corresponding FAF (eCPRI/VXLAN inner, raw) can be tagged explicitly instead of leaving a magic 0.
--- doc/guides/nics/dpaa2.rst | 8 + drivers/net/dpaa2/dpaa2_ethdev.c | 96 +- drivers/net/dpaa2/dpaa2_ethdev.h | 583 +- drivers/net/dpaa2/dpaa2_flow.c | 8107 ++++++++++------------- drivers/net/dpaa2/dpaa2_parser_decode.h | 9 + drivers/net/dpaa2/rte_pmd_dpaa2.h | 59 + 6 files changed, 4209 insertions(+), 4653 deletions(-)
doc/guides/nics/dpaa2.rst +8 -0
@@ -495,6 +495,14 @@ Refer to the document :doc:`build_and_test` for details. parser result of every received packet (debug only, hurts Rx performance). e.g. ``fslmc:dpni.1,drv_rx_print_parser_result=1`` +* Use dev arg option ``drv_qos_flow_only_steer=1`` to steer ingress traffic + using the QoS table only. + e.g. ``fslmc:dpni.1,drv_qos_flow_only_steer=1`` + +* Use dev arg option ``drv_flow_api_debug=1`` to enable debug logs for the flow + create, destroy and update operations. + e.g. ``fslmc:dpni.1,drv_flow_api_debug=1`` + * Use dev arg option ``drv_error_queue=1`` to enable Packets in Error queue. DPAA2 hardware drops the error packet in hardware. This option enables the hardware to not drop the error packet and let the driver dump the error
drivers/net/dpaa2/dpaa2_ethdev.c +69 -27
155 lines not on this page · raw message
drivers/net/dpaa2/dpaa2_ethdev.h +435 -148
651 lines not on this page · raw message
drivers/net/dpaa2/dpaa2_flow.c +3629 -4478
2,180 lines not on this page · raw message
drivers/net/dpaa2/dpaa2_parser_decode.h +9 -0
Lines of this file are not shown. View the raw message.
drivers/net/dpaa2/rte_pmd_dpaa2.h +59 -0
59 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.43.0
Part of the diff is not shown here. View the raw message.
PATCH 22/65 net/dpaa2: reimplement RSS distribution via rte_flow
In reply to Prashant GuptaFrom: Jun Yang <[email protected]>
Prefer the stable rte_flow API over driver-private, experimental entry points for RSS setup, and retire the private helpers that duplicated what rte_flow already does. The goal is that user code configures DPAA2 RSS the same way it configures any other PMD, with no reliance on experimental or vendor-specific interfaces.
Delete drivers/net/dpaa2/base/dpaa2_hw_dpni.c and drop it from meson.build. The helpers it hosted (dpaa2_setup_flow_dist, dpaa2_setup_flow_dist_size, dpaa2_remove_flow_dist, dpaa2_distset_to_dpkg_profile_cfg, dpaa2_attach_bp_list, rte_pmd_dpaa2_set_custom_hash) are either reimplemented in dpaa2_ethdev.c or fully superseded by rte_flow.
--- doc/guides/rel_notes/release_26_11.rst | 8 + drivers/net/dpaa2/base/dpaa2_hw_dpni.c | 544 ------------------------- drivers/net/dpaa2/dpaa2_ethdev.c | 297 +++++++++++--- drivers/net/dpaa2/dpaa2_ethdev.h | 21 - drivers/net/dpaa2/meson.build | 1 - drivers/net/dpaa2/rte_pmd_dpaa2.h | 84 ++-- 6 files changed, 311 insertions(+), 644 deletions(-) delete mode 100644 drivers/net/dpaa2/base/dpaa2_hw_dpni.c
doc/guides/rel_notes/release_26_11.rst +8 -0
@@ -228,6 +228,14 @@ API Changes Also, make sure to start the actual text at the margin. ======================================================= +* net/dpaa2: The exported function ``rte_pmd_dpaa2_set_custom_hash()`` is no + longer provided as a stable ABI symbol. A ``static inline`` helper of the + same name is still available in the DPAA2 public header, but it is now + implemented purely on top of the standard ``rte_flow`` API and no longer + depends on any DPAA2-specific internals. The inline helper is provided only + as a reference for users; applications should prefer calling the + ``rte_flow`` API directly. + * eal: Improved pointer arithmetic macros. * ``RTE_PTR_ADD``, ``RTE_PTR_SUB``, ``RTE_PTR_ALIGN``, ``RTE_PTR_ALIGN_CEIL``,
drivers/net/dpaa2/base/dpaa2_hw_dpni.c deleted +0 -544
544 lines not on this page · raw message
drivers/net/dpaa2/dpaa2_ethdev.c +243 -54
434 lines not on this page · raw message
drivers/net/dpaa2/dpaa2_ethdev.h +0 -21
@@ -395,12 +395,6 @@ struct dpaa2_dev_priv {/** RXQs in same TC share same cgid.*/ uint8_t cgid_in_use[MAX_TCS ]; -/* Current hash distribution size per RX TC, written by -* dpaa2_setup_flow_dist_size() and read by reta_query / reta_update. -* Zero means "use default" (= nb_rx_queues clamped to dist_queues). -*/ -uint16_t dist_size_cur[MAX_TCS ]; -uint16_t dpni_ver_major;uint16_t dpni_ver_minor;uint32_t speed_capa;
@@ -876,21 +870,6 @@ dpaa2_dpkg_insert_extract(struct dpkg_profile_cfg *kg_cfg, kg_cfg->num_extracts++; } -int dpaa2_distset_to_dpkg_profile_cfg (uint64_t req_dist_set, -struct dpkg_profile_cfg *kg_cfg); - -int dpaa2_setup_flow_dist (struct rte_eth_dev *eth_dev, -uint64_t req_dist_set,int tc_index); - -int dpaa2_setup_flow_dist_size (struct rte_eth_dev *eth_dev, -uint64_t req_dist_set,int tc_index,uint16_t dist_size); - -int dpaa2_remove_flow_dist (struct rte_eth_dev *eth_dev, -uint8_t tc_index); - -int dpaa2_attach_bp_list (struct dpaa2_dev_priv *priv, -struct fsl_mc_io *dpni,void *blist); - __rte_internal int dpaa2_eth_eventq_attach(const struct rte_eth_dev *dev, int eth_rx_queue_id,
drivers/net/dpaa2/meson.build +0 -1
@@ -8,7 +8,6 @@ endif deps += ['mempool_dpaa2'] sources = files( - 'base/dpaa2_hw_dpni.c', 'base/dpaa2_tlu_hash.c', 'dpaa2_tm.c', 'dpaa2_mux.c',
drivers/net/dpaa2/rte_pmd_dpaa2.h +60 -24
100 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH 23/65 net/dpaa2: expand IP address extracts for RSS hashing
In reply to Prashant GuptaFrom: Jun Yang <[email protected]>
When RSS distribution is enabled, hashing on an IP source or destination address should cover both the outermost and the innermost (last) IP header so that tunnelled and multi-layer IP traffic is spread correctly. The key configuration only described a single header index, so only one IP layer contributed to the hash.
Add dpaa2_flow_dpkg_ip_addr_hdr_expand(), which copies the existing key extracts and, for every IP source/destination address extract, inserts a second extract with hdr_index set to LAST_HDR_INDEX. The TC table configuration now uses this expanded key configuration on the RSS distribution path, while the exact-match path keeps the original key.
Move dpaa2_flow_is_ip_addr_extract() earlier so the new helper can use it, and change it to return a boolean since only the match result is needed.
Also fix LAST_HDR_INDEX, which was defined as 0xFFFFFFFF but is written into the 8-bit hdr_index field of the MC key extract; use 0xFF so the "last header" marker is programmed correctly.
--- drivers/net/dpaa2/dpaa2_flow.c | 68 ++++++++++++++++++++++++++-------- drivers/net/dpaa2/mc/fsl_net.h | 4 +- 2 files changed, 55 insertions(+), 17 deletions(-)
drivers/net/dpaa2/dpaa2_flow.c +53 -15
@@ -2613,6 +2613,48 @@ dpaa2_flow_fs_table_set_default(struct dpaa2_dev_priv *priv,return 0 ; } +static int +dpaa2_flow_is_ip_addr_extract (const struct dpkg_extract *extract) +{ +enum dpkg_extract_type type = extract->type; +enum net_prot prot = extract->extract.from_hdr.prot; +uint32_t field = extract->extract.from_hdr.field; + +if (type ==DPKG_EXTRACT_FROM_HDR && prot ==NET_PROT_IP && + (field ==NH_FLD_IP_SRC || field ==NH_FLD_IP_DST )) +return true; + +return false; +} + +static int +dpaa2_flow_dpkg_ip_addr_hdr_expand (const struct dpkg_profile_cfg *dpkg, +struct dpkg_profile_cfg *rss_dpkg) +{ +uint8_t i; + +memset (rss_dpkg,0 ,sizeof (struct dpkg_profile_cfg )); +for (i =0 ; i < dpkg->num_extracts; i++) { +if ((rss_dpkg->num_extracts +1 ) >DPKG_MAX_NUM_OF_EXTRACTS ) +return -ENOSPC ; +rte_memcpy (&rss_dpkg->extracts[rss_dpkg->num_extracts], + &dpkg->extracts[i],sizeof (struct dpkg_extract )); + rss_dpkg->extracts[rss_dpkg->num_extracts].extract.from_hdr.hdr_index =0 ; + rss_dpkg->num_extracts++; +if (!dpaa2_flow_is_ip_addr_extract (&dpkg->extracts[i])) +continue ; +if ((rss_dpkg->num_extracts +1 ) >DPKG_MAX_NUM_OF_EXTRACTS ) +return -ENOSPC ; +rte_memcpy (&rss_dpkg->extracts[rss_dpkg->num_extracts], &dpkg->extracts[i], +sizeof (struct dpkg_extract )); + rss_dpkg->extracts[rss_dpkg->num_extracts].extract.from_hdr.hdr_index = +LAST_HDR_INDEX ; + rss_dpkg->num_extracts++; + } + +return 0 ; +} +static int dpaa2_flow_tc_table_config (struct dpaa2_dev_priv *priv,uint8_t tc_id,int rss_dist,int enable)
@@ -2624,6 +2666,8 @@ dpaa2_flow_tc_table_config(struct dpaa2_dev_priv *priv,struct fsl_mc_io *dpni = priv->hw;uint16_t entry_size;struct dpaa2_queue *queue; +const struct dpkg_profile_cfg *cfg; +struct dpkg_profile_cfg rss_extract; tbl_profile = &priv->flow_profile.tc_profile[tc_id];if (tbl_profile->entry_num) {
@@ -2645,7 +2689,15 @@ dpaa2_flow_tc_table_config(struct dpaa2_dev_priv *priv, }dpaa2_flow_extracts_log (priv,"Configure" , tc_id); - ret =dpkg_prepare_key_cfg (&key_profile->dpkg, tbl_profile->extract_param); +if (rss_dist) { + ret =dpaa2_flow_dpkg_ip_addr_hdr_expand (&key_profile->dpkg, &rss_extract); +if (ret) +return ret; + cfg = &rss_extract; + }else { + cfg = &key_profile->dpkg; + } + ret =dpkg_prepare_key_cfg (cfg, tbl_profile->extract_param);if (ret <0 ) {DPAA2_PMD_ERR ("TC[%d] prepare key failed" , tc_id);return ret;
@@ -3251,20 +3303,6 @@ dpaa2_flow_validate(struct rte_eth_dev *dev,return ret; } -static uint32_t -dpaa2_flow_is_ip_addr_extract (const struct dpkg_extract *extract) -{ -enum dpkg_extract_type type = extract->type; -enum net_prot prot = extract->extract.from_hdr.prot; -uint32_t field = extract->extract.from_hdr.field; - -if (type ==DPKG_EXTRACT_FROM_HDR && prot ==NET_PROT_IP && - (field ==NH_FLD_IP_SRC || field ==NH_FLD_IP_DST )) -return field; - -return 0 ; -} -static void dpaa2_flow_key_offset_size (struct dpaa2_key_profile *key_profile,uint8_t idx,uint8_t *offset,uint8_t *size)
drivers/net/dpaa2/mc/fsl_net.h +2 -2
@@ -1,14 +1,14 @@/* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 * * Copyright 2013-2015 Freescale Semiconductor Inc. -* Copyright 2018-2019 NXP +* Copyright 2018-2019, 2026 NXP * */ #ifndef __FSL_NET_H#define __FSL_NET_H -#define LAST_HDR_INDEX 0xFFFFFFFF +#define LAST_HDR_INDEX 0xFF/*****************************************************************************/ /* Protocol fields */
Signature · 1 line
2.43.0
PATCH 24/65 net/dpaa2: add policer v2 MC command and L2/L3 byte units
In reply to Prashant GuptaFrom: Jun Yang <[email protected]>
Pick up the v2 version of the DPNI SET_RX_TC_POLICING MC command and expose the new policer features it brings, while keeping support for older MC firmwares that only speak the v1 command.
--- drivers/net/dpaa2/mc/dpni.c | 54 +++++++++++++++++++++------------ drivers/net/dpaa2/mc/fsl_dpni.h | 23 +++++++++++--- 2 files changed, 53 insertions(+), 24 deletions(-)
drivers/net/dpaa2/mc/dpni.c +34 -20
@@ -2210,30 +2210,16 @@ int dpni_clear_fs_entries(struct fsl_mc_io *mc_io,return mc_send_command (mc_io, &cmd); } -/** -* dpni_set_rx_tc_policing() - Set Rx traffic class policing configuration -* @mc_io: Pointer to MC portal's I/O object -* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' -* @token: Token of DPNI object -* @tc_id: Traffic class selection (0-7) -* @cfg: Traffic class policing configuration -* -* Return: '0' on Success; error code otherwise. -*/ -int dpni_set_rx_tc_policing (struct fsl_mc_io *mc_io, -uint32_t cmd_flags, -uint16_t token, -uint8_t tc_id, -const struct dpni_rx_tc_policing_cfg *cfg) +static int +_dpni_set_rx_tc_policing (struct fsl_mc_io *mc_io, +uint32_t cmd_flags,uint16_t token,uint8_t tc_id, +const struct dpni_rx_tc_policing_cfg *cfg,uint16_t cmd_id) {struct dpni_cmd_set_rx_tc_policing *cmd_params;struct mc_command cmd = {0 }; -/* prepare command */ - cmd.header =mc_encode_cmd_header (DPNI_CMDID_SET_RX_TC_POLICING , - cmd_flags, - token); - cmd_params = (struct dpni_cmd_set_rx_tc_policing *)cmd.params; + cmd.header =mc_encode_cmd_header (cmd_id, cmd_flags, token); + cmd_params = (void *)cmd.params;dpni_set_field (cmd_params->mode_color,COLOR , cfg->default_color);dpni_set_field (cmd_params->mode_color,MODE , cfg->mode);dpni_set_field (cmd_params->units,UNITS , cfg->units);
@@ -2248,6 +2234,34 @@ int dpni_set_rx_tc_policing(struct fsl_mc_io *mc_io,return mc_send_command (mc_io, &cmd); } +/** +* dpni_set_rx_tc_policing() - Set Rx traffic class policing configuration +* @mc_io: Pointer to MC portal's I/O object +* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' +* @token: Token of DPNI object +* @tc_id: Traffic class selection (0-7) +* @cfg: Traffic class policing configuration +* +* Return: '0' on Success; error code otherwise. +*/ +int +dpni_set_rx_tc_policing (struct fsl_mc_io *mc_io, +uint32_t cmd_flags,uint16_t token,uint8_t tc_id, +const struct dpni_rx_tc_policing_cfg *cfg) +{ +return _dpni_set_rx_tc_policing (mc_io, cmd_flags, token, tc_id, cfg, +DPNI_CMDID_SET_RX_TC_POLICING ); +} + +int +dpni_set_rx_tc_policing_v1 (struct fsl_mc_io *mc_io, +uint32_t cmd_flags,uint16_t token,uint8_t tc_id, +const struct dpni_rx_tc_policing_cfg *cfg) +{ +return _dpni_set_rx_tc_policing (mc_io, cmd_flags, token, tc_id, cfg, +DPNI_CMDID_SET_RX_TC_POLICING_V1 ); +} +/** * dpni_get_rx_tc_policing() - Get Rx traffic class policing configuration * @mc_io: Pointer to MC portal's I/O object
drivers/net/dpaa2/mc/fsl_dpni.h +19 -4
@@ -1141,6 +1141,11 @@ int dpni_set_rx_tc_dist(struct fsl_mc_io *mc_io,*/ #define DPNI_POLICER_OPT_DISCARD_RED 0x00000002 +/** +* Do NOT reset counters generally for policer update +*/ +#define DPNI_POLICER_OPT_DO_NOT_RESET_COUNTERS 0x00000004 +/** * enum dpni_policer_mode - selecting the policer mode * @DPNI_POLICER_MODE_NONE: Policer is disabled
@@ -1157,12 +1162,17 @@ enum dpni_policer_mode {/** * enum dpni_policer_unit - DPNI policer units -* @DPNI_POLICER_UNIT_BYTES: bytes units +* @DPNI_POLICER_UNIT_BYTES_L3: bytes units (for each frame takes into account +* FD length - L3 offset) * @DPNI_POLICER_UNIT_FRAMES: frames units +* @DPNI_POLICER_UNIT_BYTES_L2_WITHOUT_FCS: bytes units (for each frame takes +* into account FD length - L2 offset, which means L2 size without the 4 bytes +* for the FCS) */ enum dpni_policer_unit { -DPNI_POLICER_UNIT_BYTES =0 , -DPNI_POLICER_UNIT_FRAMES +DPNI_POLICER_UNIT_BYTES_L3 =0 , +DPNI_POLICER_UNIT_FRAMES , +DPNI_POLICER_UNIT_BYTES_L2_WITHOUT_FCS , };/**
@@ -1203,13 +1213,18 @@ struct dpni_rx_tc_policing_cfg {uint32_t ebs; }; -int dpni_set_rx_tc_policing (struct fsl_mc_io *mc_io,uint32_t cmd_flags,uint16_t token,uint8_t tc_id,const struct dpni_rx_tc_policing_cfg *cfg); +int dpni_set_rx_tc_policing_v1 (struct fsl_mc_io *mc_io, +uint32_t cmd_flags, +uint16_t token, +uint8_t tc_id, +const struct dpni_rx_tc_policing_cfg *cfg); + int dpni_get_rx_tc_policing(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token,
Signature · 1 line
2.43.0
PATCH 25/65 net/dpaa2: support rte_mtr and METER rte_flow action
In reply to Prashant GuptaFrom: Jun Yang <[email protected]>
Add a traffic metering/policing path to the DPAA2 PMD that is driven entirely through the standard DPDK APIs: rte_mtr for profile/policy /meter object management and rte_flow METER / METER_MARK actions for binding a meter to a per-TC ingress flow. No DPAA2-specific or experimental entry points are introduced.
- Add drivers/net/dpaa2/dpaa2_meter.c implementing struct rte_mtr_ops (capabilities_get, meter_profile_add/get/delete, meter_policy_add/get/delete, create, destroy, meter_profile_update, meter_policy_update) on top of the DPNI policer. Supported algorithms are RTE_MTR_NONE, RTE_MTR_TRTCM_RFC2698 and RTE_MTR_TRTCM_RFC4115, in both byte and packet mode, color-aware or blind.
- Hook dpaa2_mtr_ops_get() into dpaa2_ethdev_ops.mtr_ops_get so applications reach the implementation via rte_mtr_ops_get() / rte_mtr_*(). Register the file in drivers/net/dpaa2/meson.build.
- Extend struct dpaa2_dev_priv with LIST_HEADs for meter profiles, policies and meter objects, and a meter_lock spinlock to serialize concurrent rte_mtr calls. Add helper structs dpaa2_dev_meter_profile / _policy / _meter.
- Extend struct dpaa2_flow_profile with per-TC meter bookkeeping (tc_mtr_profile[], mtr_flow[]) and add DPAA2_FLOW_METER_TYPE to enum dpaa2_flow_dist_type so the flow cleaner can tear meter flows down together with QoS/FS/RSS flows.
- Wire the METER and METER_MARK rte_flow actions into dpaa2_flow.c:
dpaa2_flow_validate() recognizes them, dpaa2_flow_create() routes such rules into a new dpaa2_flow_create_meter_flow() path, and dpaa2_flow_actions_update() updates the policer in place via dpaa2_flow_meter_action_update(). dpaa2_flow_destroy() / dpaa2_flow_clean() tear down meter flows and reset the TC policer to DPNI_POLICER_MODE_NONE.
- dpaa2_flow_set_police_action() programs the HW policer via dpni_set_rx_tc_policing(), honoring the profile's mode/units/ CIR/CBS/PIR/PBS, the policy's RED action (drop vs. passthrough), and color_mode. Picks the v1 or v2 MC command based on the DPNI firmware revision, and preserves counters on update when the firmware supports DPNI_POLICER_OPT_DO_NOT_RESET_COUNTERS.
- Add MC-rev gates DPAA2_POLICER_SET_V2_MC_REV and DPAA2_POLICER_NOT_RESET_COUNTER_MC_REV so the driver falls back to dpni_set_rx_tc_policing_v1() on older firmware.
--- drivers/net/dpaa2/dpaa2_ethdev.c | 1 + drivers/net/dpaa2/dpaa2_ethdev.h | 39 ++- drivers/net/dpaa2/dpaa2_flow.c | 327 ++++++++++++++++- drivers/net/dpaa2/dpaa2_meter.c | 584 +++++++++++++++++++++++++++++++ drivers/net/dpaa2/meson.build | 1 + 5 files changed, 948 insertions(+), 4 deletions(-) create mode 100644 drivers/net/dpaa2/dpaa2_meter.c
drivers/net/dpaa2/dpaa2_ethdev.c +1 -0
@@ -3678,6 +3678,7 @@ static struct eth_dev_ops dpaa2_ethdev_ops = { .rxq_info_get = dpaa2_rxq_info_get, .txq_info_get = dpaa2_txq_info_get, .tm_ops_get = dpaa2_tm_ops_get, + .mtr_ops_get = dpaa2_mtr_ops_get, .timesync_enable = dpaa2_timesync_enable, .timesync_disable = dpaa2_timesync_disable, .timesync_read_time = dpaa2_timesync_read_time,
drivers/net/dpaa2/dpaa2_ethdev.h +38 -1
@@ -213,6 +213,8 @@#define DPAA2_FLOW_FRM_REPLICATION_ACTION_MC_REV RTE_FSL_MC_REV(10, 39, 106)#define DPAA2_QOS_FLOW_TABLE_SET_V3_MC_REV RTE_FSL_MC_REV(10, 39, 109)#define DPAA2_QOS_FLOW_TABLE_MISS_FLOW_ACTION_MC_REV RTE_FSL_MC_REV(10, 39, 109) +#define DPAA2_POLICER_SET_V2_MC_REV RTE_FSL_MC_REV(10, 39, 109) +#define DPAA2_POLICER_NOT_RESET_COUNTER_MC_REV DPAA2_POLICER_SET_V2_MC_REV#define DPAA2_MAC_XSTATS_MC_REV RTE_FSL_MC_REV(10, 39, 109)/* mac counters */
@@ -270,8 +272,9 @@ enum dpaa2_flow_dist_type {DPAA2_FLOW_QOS_TYPE =1 <<0 ,DPAA2_FLOW_FS_TYPE =1 <<1 ,DPAA2_FLOW_RSS_TYPE =1 <<2 , +DPAA2_FLOW_METER_TYPE =1 <<3 ,DPAA2_FLOW_ALL_TYPE = (DPAA2_FLOW_QOS_TYPE |DPAA2_FLOW_FS_TYPE | -DPAA2_FLOW_RSS_TYPE ) +DPAA2_FLOW_RSS_TYPE |DPAA2_FLOW_METER_TYPE ) }; enum key_prot_type {
@@ -340,6 +343,9 @@ struct dpaa2_flow_tbl_profile {struct dpaa2_flow_profile {struct dpaa2_flow_tbl_profile qos_profile;struct dpaa2_flow_tbl_profile tc_profile[MAX_TCS ]; +/** Meter per TC.*/ +struct dpaa2_dev_meter_profile *tc_mtr_profile[MAX_TCS ]; +void *mtr_flow[MAX_TCS ];void *mempool[MAX_TCS ];uint8_t bp_idx[MAX_TCS ]; };
@@ -350,6 +356,30 @@ enum dpaa2_tx_conf_type {DPAA2_TX_DYNAMIC_CONF }; +struct dpaa2_dev_meter_profile { +LIST_ENTRY (dpaa2_dev_meter_profile) next; +uint32_t profile_id; +uint64_t cir; +uint64_t cbs; +uint64_t pir; +uint64_t pbs; +enum dpni_policer_mode mode; +enum dpni_policer_unit policer_unit; +}; + +struct dpaa2_dev_meter_policy { +LIST_ENTRY (dpaa2_dev_meter_policy) next; +uint32_t policy_id; +int red_drop; +}; + +struct dpaa2_dev_meter { +LIST_ENTRY (dpaa2_dev_meter) next; +uint32_t meter_id; +uint32_t profile_id; +uint32_t policy_id; +}; +struct dpaa2_dev_priv {void *hw;int32_t hw_id;
@@ -395,6 +425,8 @@ struct dpaa2_dev_priv {/** RXQs in same TC share same cgid.*/ uint8_t cgid_in_use[MAX_TCS ]; +rte_spinlock_t meter_lock; +uint16_t dpni_ver_major;uint16_t dpni_ver_minor;uint32_t speed_capa;
@@ -443,6 +475,9 @@ struct dpaa2_dev_priv {union dpni_statistics pg_xstats[DPNI_MAX_STATISTICS_PAGE_ID ][DPNI_STAT_MAX_PARAM ]; LIST_HEAD(, dpaa2_dev_flow) flows; + LIST_HEAD(, dpaa2_dev_meter_profile) profiles; + LIST_HEAD(, dpaa2_dev_meter_policy) policies; + LIST_HEAD(, dpaa2_dev_meter) meters; LIST_HEAD(nodes, dpaa2_tm_node) nodes; LIST_HEAD(shaper_profiles, dpaa2_tm_shaper_profile) shaper_profiles; };
@@ -936,4 +971,6 @@ int dpaa2_timesync_read_tx_timestamp(struct rte_eth_dev *dev,int dpaa2_dev_recycle_config (struct rte_eth_dev *eth_dev);int dpaa2_dev_recycle_deconfig (struct rte_eth_dev *eth_dev); + +int dpaa2_mtr_ops_get (struct rte_eth_dev *dev,void *ops);#endif /* _DPAA2_ETHDEV_H */
drivers/net/dpaa2/dpaa2_flow.c +324 -3
430 lines not on this page · raw message
drivers/net/dpaa2/dpaa2_meter.c new file +584 -0
584 lines not on this page · raw message
drivers/net/dpaa2/meson.build +1 -0
@@ -16,6 +16,7 @@ sources = files( 'dpaa2_recycle.c', 'dpaa2_rxtx.c', 'dpaa2_ptp.c', + 'dpaa2_meter.c', 'mc/dprtc.c', 'mc/dpkg.c', 'mc/dpdmux.c',
Signature · 1 line
2.43.0
PATCH 26/65 net/dpaa2: program flow table miss actions via rte_flow
In reply to Prashant GuptaFrom: Jun Yang <[email protected]>
Push the per-table "miss" behavior for the DPAA2 QoS and FS tables through the standard rte_flow_group_set_miss_actions() API instead of leaving it implicit, and tidy up the surrounding dev-ops code.
--- drivers/net/dpaa2/dpaa2_ethdev.c | 440 +++++++++++++++++-------------- 1 file changed, 243 insertions(+), 197 deletions(-)
drivers/net/dpaa2/dpaa2_ethdev.c +243 -197
@@ -459,11 +459,52 @@ static const struct rte_eth_stats dpaa2_stats_xstat_ids = {#define DPAA2_MAC_XSTATS_START_ID DPAA2_DPNI_XSTAT_MAX_NUMstatic struct rte_dpaa2_driver rte_dpaa2_pmd; -static int dpaa2_dev_link_update (struct rte_eth_dev *dev, -int wait_to_complete); -static int dpaa2_dev_set_link_up (struct rte_eth_dev *dev); -static int dpaa2_dev_set_link_down (struct rte_eth_dev *dev); -static int dpaa2_dev_mtu_set (struct rte_eth_dev *dev,uint16_t mtu); + +static int +dpaa2_setup_table_miss_action (struct rte_eth_dev *eth_dev, +uint8_t tc_index) +{ +struct dpaa2_dev_priv *priv = eth_dev->data->dev_private; +struct rte_flow_group_attr attr; +struct rte_flow_action actions[2 ]; +struct dpaa2_flow_tbl_profile *tbl_profile; + +memset (&attr,0 ,sizeof (attr)); + attr.ingress =1 ; +if (tc_index < priv->num_rx_tc) { + tbl_profile = &priv->flow_profile.tc_profile[tc_index]; +if (tbl_profile->default_drop) { + actions[0 ].type =RTE_FLOW_ACTION_TYPE_DROP ; + }else if (tbl_profile->default_queue.index >= eth_dev->data->nb_rx_queues) { +DPAA2_PMD_DEBUG ("%s-tc%d-default-rxq(%d) >= max rxq(%d), Force to drop." , + eth_dev->data->name, tc_index, tbl_profile->default_queue.index, + eth_dev->data->nb_rx_queues); + tbl_profile->default_drop = true; + actions[0 ].type =RTE_FLOW_ACTION_TYPE_DROP ; + }else { + actions[0 ].type =RTE_FLOW_ACTION_TYPE_QUEUE ; + actions[0 ].conf = &tbl_profile->default_queue; + } + }else { + tbl_profile = &priv->flow_profile.qos_profile; +if (tbl_profile->default_drop) { + actions[0 ].type =RTE_FLOW_ACTION_TYPE_DROP ; + }else if (tbl_profile->default_jump.group >= priv->num_rx_tc) { +DPAA2_PMD_DEBUG ("%s-default-tc(%d) >= max tc(%d), Force to drop." , + eth_dev->data->name, tbl_profile->default_jump.group, + priv->num_rx_tc); + tbl_profile->default_drop = true; + actions[0 ].type =RTE_FLOW_ACTION_TYPE_DROP ; + }else { + actions[0 ].type =RTE_FLOW_ACTION_TYPE_JUMP ; + actions[0 ].conf = &tbl_profile->default_jump; + } + } + actions[1 ].type =RTE_FLOW_ACTION_TYPE_END ; + +return rte_flow_group_set_miss_actions (eth_dev->data->port_id, + tc_index, &attr, actions,NULL ); +} static int dpaa2_setup_flow_dist(struct rte_eth_dev *eth_dev,
@@ -1162,18 +1203,14 @@ dpaa2_eth_dev_configure(struct rte_eth_dev *dev)/* Rx offloads which are enabled by default */ if (dev_rx_offloads_nodis & ~rx_offloads) { -DPAA2_PMD_INFO ( -"Some of rx offloads enabled by default - requested 0x%" PRIx64 -" fixed are 0x%" PRIx64, - rx_offloads, dev_rx_offloads_nodis); +DPAA2_PMD_INFO ("RX offloads requested/fixed: 0x%" PRIx64"/0x%" PRIx64, + rx_offloads, dev_rx_offloads_nodis); }/* Tx offloads which are enabled by default */ if (dev_tx_offloads_nodis & ~tx_offloads) { -DPAA2_PMD_INFO ( -"Some of tx offloads enabled by default - requested 0x%" PRIx64 -" fixed are 0x%" PRIx64, - tx_offloads, dev_tx_offloads_nodis); +DPAA2_PMD_INFO ("TX offloads requested/fixed: 0x%" PRIx64"/0x%" PRIx64, + tx_offloads, dev_tx_offloads_nodis); } max_rx_pktlen = eth_conf->rxmode.mtu + RTE_ETHER_HDR_LEN +
@@ -1181,16 +1218,31 @@ dpaa2_eth_dev_configure(struct rte_eth_dev *dev)if (max_rx_pktlen <=DPAA2_MAX_RX_PKT_LEN ) { ret =dpni_set_max_frame_length (dpni,CMD_PRI_LOW , priv->token, max_rx_pktlen -RTE_ETHER_CRC_LEN ); -if (ret !=0 ) { +if (ret) {DPAA2_PMD_ERR ("Unable to set mtu. check config" );return ret; }DPAA2_PMD_DEBUG ("MTU configured for the device: %d" , dev->data->mtu); }else { -DPAA2_PMD_ERR ("Configured mtu %d and calculated max-pkt-len is %d which should be <= %d" , - eth_conf->rxmode.mtu, max_rx_pktlen,DPAA2_MAX_RX_PKT_LEN ); -return -1 ; +DPAA2_PMD_ERR ("MAX MTU(%d) to configure > %d" , + max_rx_pktlen,DPAA2_MAX_RX_PKT_LEN ); +return -ENOTSUP ; + } + +if (priv->fs_entries) { +for (tc_index =0 ; tc_index < priv->num_rx_tc; tc_index++) { + ret =dpaa2_setup_table_miss_action (dev, tc_index); +if (ret) { +DPAA2_PMD_ERR ("Error(%d) to set miss action of %s-tc%d table" , + ret, dev->data->name, tc_index); + } + } + } + ret =dpaa2_setup_table_miss_action (dev, priv->num_rx_tc); +if (ret) { +DPAA2_PMD_ERR ("Error(%d) to set miss action of %s-QoS table" , + ret, dev->data->name); }if (eth_conf->rxmode.mq_mode ==RTE_ETH_MQ_RX_RSS ) {
@@ -1784,6 +1836,171 @@ dpaa2_supported_ptypes_get(struct rte_eth_dev *dev, size_t *no_of_elements)return NULL ; } +/* return 0 means link status changed, -1 means not changed */ +static int +dpaa2_dev_link_update (struct rte_eth_dev *dev, +int wait_to_complete) +{ +int ret; +struct dpaa2_dev_priv *priv = dev->data->dev_private; +struct fsl_mc_io *dpni = dev->process_private; +struct rte_eth_link link; +struct dpni_link_state state = {0 }; +uint8_t count; + +if (!dpni) { +DPAA2_PMD_ERR ("dpni is NULL" ); +return 0 ; + } + +for (count =0 ; count <=MAX_REPEAT_TIME ; count++) { + ret =dpni_get_link_state (dpni,CMD_PRI_LOW , priv->token, &state); +if (ret <0 ) { +DPAA2_PMD_DEBUG ("error: dpni_get_link_state %d" , ret); +return ret; + } +if (state.up ==RTE_ETH_LINK_DOWN && + wait_to_complete) +rte_delay_ms (CHECK_INTERVAL ); +else +break ; + } + +memset (&link,0 ,sizeof (struct rte_eth_link )); + link.link_status = state.up; + link.link_speed = state.rate; + +if (state.options &DPNI_LINK_OPT_HALF_DUPLEX ) + link.link_duplex =RTE_ETH_LINK_HALF_DUPLEX ; +else + link.link_duplex =RTE_ETH_LINK_FULL_DUPLEX ; + + ret =rte_eth_linkstatus_set (dev, &link); +if (ret <0 ) { +DPAA2_PMD_DEBUG ("No change in status" ); + }else { +DPAA2_PMD_INFO ("Port %d Link is %s" , dev->data->port_id, + link.link_status ?"Up" :"Down" ); + } + +return ret; +} + +/** +* Toggle the DPNI to enable, if not already enabled. +* This is not strictly PHY up/down - it is more of logical toggling. +*/ +static int +dpaa2_dev_set_link_up (struct rte_eth_dev *dev) +{ +int ret, en =0 ; +struct dpaa2_dev_priv *priv; +struct fsl_mc_io *dpni; +struct dpni_link_state state = {0 }; + + priv = dev->data->dev_private; + dpni = dev->process_private; + +if (!dpni) { +DPAA2_PMD_ERR ("dpni is NULL" ); +return -ENODEV ; + } + +/* Check if DPNI is currently enabled */ + ret =dpni_is_enabled (dpni,CMD_PRI_LOW , priv->token, &en); +if (ret) { +/* Unable to obtain dpni status; Not continuing */ +DPAA2_PMD_ERR ("Interface Link UP failed (%d)" , ret); +return ret; + } + +/* Enable link if not already enabled */ +if (!en) { + ret =dpni_enable (dpni,CMD_PRI_LOW , priv->token); +if (ret) { +DPAA2_PMD_ERR ("Interface Link UP failed (%d)" , ret); +return ret; + } + } + ret =dpni_get_link_state (dpni,CMD_PRI_LOW , priv->token, &state); +if (ret <0 ) { +DPAA2_PMD_DEBUG ("Unable to get link state (%d)" , ret); +return ret; + } + +/* changing tx burst function to start enqueues */ + dev->tx_pkt_burst = dpaa2_dev_tx; + dev->data->dev_link.link_status = state.up; + dev->data->dev_link.link_speed = state.rate; + +if (state.options &DPNI_LINK_OPT_HALF_DUPLEX ) + dev->data->dev_link.link_duplex =RTE_ETH_LINK_HALF_DUPLEX ; +else + dev->data->dev_link.link_duplex =RTE_ETH_LINK_FULL_DUPLEX ; + +if (state.up) +DPAA2_PMD_DEBUG ("Port %d Link is Up" , dev->data->port_id); +else +DPAA2_PMD_DEBUG ("Port %d Link is Down" , dev->data->port_id); +return ret; +} + +/** +* Toggle the DPNI to disable, if not already disabled. +* This is not strictly PHY up/down - it is more of logical toggling. +*/ +static int +dpaa2_dev_set_link_down (struct rte_eth_dev *dev) +{ +int ret, dpni_enabled =0 , retries =10 ; +struct dpaa2_dev_priv *priv; +struct fsl_mc_io *dpni; + +PMD_INIT_FUNC_TRACE (); + + priv = dev->data->dev_private; + dpni = dev->process_private; + +if (!dpni) { +DPAA2_PMD_ERR ("Device has not yet been configured" ); +return -ENODEV ; + } + +/*changing tx burst function to avoid any more enqueues */ + dev->tx_pkt_burst = rte_eth_pkt_burst_dummy; + +/* Loop while dpni_disable() attempts to drain the egress FQs +* and confirm them back to us. +*/ +do { + ret =dpni_disable (dpni,0 , priv->token); +if (ret) { +DPAA2_PMD_ERR ("dpni disable failed (%d)" , ret); +return ret; + } + ret =dpni_is_enabled (dpni,0 , priv->token, &dpni_enabled); +if (ret) { +DPAA2_PMD_ERR ("dpni enable check failed (%d)" , ret); +return ret; + } +if (dpni_enabled) +/* Allow the MC some slack */ +rte_delay_ms (CHECK_INTERVAL ); + }while (dpni_enabled && --retries); + +if (!retries) { +DPAA2_PMD_WARN ("Retry count exceeded disabling dpni" ); +/* todo- we may have to manually cleanup queues. +*/ + }else { +DPAA2_PMD_INFO ("Port %d Link DOWN successful" , dev->data->port_id); + } + + dev->data->dev_link.link_status =0 ; + +return ret; +} +/** * Dpaa2 link Interrupt handler *
@@ -1842,19 +2059,18 @@ dpaa2_eth_setup_irqs(struct rte_eth_dev *dev, int enable)PMD_INIT_FUNC_TRACE (); - err =dpni_set_irq_mask (dpni,CMD_PRI_LOW , priv->token, - irq_index, mask); + err =dpni_set_irq_mask (dpni,CMD_PRI_LOW , priv->token, irq_index, mask);if (err <0 ) {DPAA2_PMD_ERR ("Error: dpni_set_irq_mask():%d (%s)" , err, -strerror (-err)); +strerror (-err));return err; } - err =dpni_set_irq_enable (dpni,CMD_PRI_LOW , priv->token, - irq_index, enable); -if (err <0 ) + err =dpni_set_irq_enable (dpni,CMD_PRI_LOW , priv->token, irq_index, enable); +if (err <0 ) {DPAA2_PMD_ERR ("Error: dpni_set_irq_enable():%d (%s)" , err, -strerror (-err)); +strerror (-err)); + }return err; }
@@ -2021,8 +2237,7 @@ dpaa2_dev_stop(struct rte_eth_dev *dev)/* Unregistering LSC interrupt handler */ rte_intr_callback_unregister (intr_handle, - dpaa2_interrupt_handler, - (void *)dev); + dpaa2_interrupt_handler, (void *)dev); }dpaa2_dev_set_link_down (dev);
@@ -2233,14 +2448,14 @@ dpaa2_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)if (!dpni) {DPAA2_PMD_ERR ("dpni is NULL" ); -return -EINVAL ; +return -ENODEV ; }/* Set the Max Rx frame length as 'mtu' + * Maximum Ethernet header length */ ret =dpni_set_max_frame_length (dpni,CMD_PRI_LOW , priv->token, - frame_size -RTE_ETHER_CRC_LEN ); + frame_size -RTE_ETHER_CRC_LEN );if (ret) {DPAA2_PMD_ERR ("Setting the max frame length failed" );return ret;
@@ -2676,175 +2891,6 @@ dpaa2_dev_stats_reset(struct rte_eth_dev *dev)return retcode; }; -/* return 0 means link status changed, -1 means not changed */ -static int -dpaa2_dev_link_update (struct rte_eth_dev *dev, -int wait_to_complete) -{ -int ret; -struct dpaa2_dev_priv *priv = dev->data->dev_private; -struct fsl_mc_io *dpni = dev->process_private; -struct rte_eth_link link; -struct dpni_link_state state = {0 }; -uint8_t count; - -if (!dpni) { -DPAA2_PMD_ERR ("dpni is NULL" ); -return 0 ; - } - -for (count =0 ; count <=MAX_REPEAT_TIME ; count++) { - ret =dpni_get_link_state (dpni,CMD_PRI_LOW , priv->token, - &state); -if (ret <0 ) { -DPAA2_PMD_DEBUG ("error: dpni_get_link_state %d" , ret); -return ret; - } -if (state.up ==RTE_ETH_LINK_DOWN && - wait_to_complete) -rte_delay_ms (CHECK_INTERVAL ); -else -break ; - } - -memset (&link,0 ,sizeof (struct rte_eth_link )); - link.link_status = state.up; - link.link_speed = state.rate; - -if (state.options &DPNI_LINK_OPT_HALF_DUPLEX ) - link.link_duplex =RTE_ETH_LINK_HALF_DUPLEX ; -else - link.link_duplex =RTE_ETH_LINK_FULL_DUPLEX ; - - ret =rte_eth_linkstatus_set (dev, &link); -if (ret <0 ) -DPAA2_PMD_DEBUG ("No change in status" ); -else -DPAA2_PMD_INFO ("Port %d Link is %s" , dev->data->port_id, - link.link_status ?"Up" :"Down" ); - -return ret; -} - -/** -* Toggle the DPNI to enable, if not already enabled. -* This is not strictly PHY up/down - it is more of logical toggling. -*/ -static int -dpaa2_dev_set_link_up (struct rte_eth_dev *dev) -{ -int ret = -EINVAL ; -struct dpaa2_dev_priv *priv; -struct fsl_mc_io *dpni; -int en =0 ; -struct dpni_link_state state = {0 }; - - priv = dev->data->dev_private; - dpni = dev->process_private; - -if (!dpni) { -DPAA2_PMD_ERR ("dpni is NULL" ); -return ret; - } - -/* Check if DPNI is currently enabled */ - ret =dpni_is_enabled (dpni,CMD_PRI_LOW , priv->token, &en); -if (ret) { -/* Unable to obtain dpni status; Not continuing */ -DPAA2_PMD_ERR ("Interface Link UP failed (%d)" , ret); -return ret; - } - -/* Enable link if not already enabled */ -if (!en) { - ret =dpni_enable (dpni,CMD_PRI_LOW , priv->token); -if (ret) { -DPAA2_PMD_ERR ("Interface Link UP failed (%d)" , ret); -return ret; - } - } - ret =dpni_get_link_state (dpni,CMD_PRI_LOW , priv->token, &state); -if (ret <0 ) { -DPAA2_PMD_DEBUG ("Unable to get link state (%d)" , ret); -return ret; - } - -/* changing tx burst function to start enqueues */ - dev->tx_pkt_burst = dpaa2_dev_tx; - dev->data->dev_link.link_status = state.up; - dev->data->dev_link.link_speed = state.rate; - -if (state.options &DPNI_LINK_OPT_HALF_DUPLEX ) - dev->data->dev_link.link_duplex =RTE_ETH_LINK_HALF_DUPLEX ; -else - dev->data->dev_link.link_duplex =RTE_ETH_LINK_FULL_DUPLEX ; - -if (state.up) -DPAA2_PMD_DEBUG ("Port %d Link is Up" , dev->data->port_id); -else -DPAA2_PMD_DEBUG ("Port %d Link is Down" , dev->data->port_id); -return ret; -} - -/** -* Toggle the DPNI to disable, if not already disabled. -* This is not strictly PHY up/down - it is more of logical toggling. -*/ -static int -dpaa2_dev_set_link_down (struct rte_eth_dev *dev) -{ -int ret = -EINVAL ; -struct dpaa2_dev_priv *priv; -struct fsl_mc_io *dpni; -int dpni_enabled =0 ; -int retries =10 ; - -PMD_INIT_FUNC_TRACE (); - - priv = dev->data->dev_private; - dpni = dev->process_private; - -if (!dpni) { -DPAA2_PMD_ERR ("Device has not yet been configured" ); -return ret; - } - -/*changing tx burst function to avoid any more enqueues */ - dev->tx_pkt_burst = rte_eth_pkt_burst_dummy; - -/* Loop while dpni_disable() attempts to drain the egress FQs -* and confirm them back to us. -*/ -do { - ret =dpni_disable (dpni,0 , priv->token); -if (ret) { -DPAA2_PMD_ERR ("dpni disable failed (%d)" , ret); -return ret; - } - ret =dpni_is_enabled (dpni,0 , priv->token, &dpni_enabled); -if (ret) { -DPAA2_PMD_ERR ("dpni enable check failed (%d)" , ret); -return ret; - } -if (dpni_enabled) -/* Allow the MC some slack */ -rte_delay_ms (CHECK_INTERVAL ); - }while (dpni_enabled && --retries); - -if (!retries) { -DPAA2_PMD_WARN ("Retry count exceeded disabling dpni" ); -/* todo- we may have to manually cleanup queues. -*/ - }else { -DPAA2_PMD_INFO ("Port %d Link DOWN successful" , - dev->data->port_id); - } - - dev->data->dev_link.link_status =0 ; - -return ret; -} -static int dpaa2_flow_ctrl_get (struct rte_eth_dev *dev,struct rte_eth_fc_conf *fc_conf) {
Signature · 1 line
2.43.0
PATCH 27/65 net/dpaa2: support DCB Rx mode via rte_flow
In reply to Prashant GuptaFrom: Jun Yang <[email protected]>
Add DCB (Data Center Bridging) support to the DPAA2 PMD so that applications requesting RTE_ETH_MQ_RX_DCB map VLAN PCP priorities to receive TCs, and expose the per-port mapping through the standard rte_eth_dev_get_dcb_info() API.
Reject QoS entries whose index collides with an already-installed DCB flow slot with -ENODATA, so user-added QoS rules cannot silently overwrite the DCB-generated ones.
--- drivers/net/dpaa2/dpaa2_ethdev.c | 107 ++++++++++++++++++++++++++++--- drivers/net/dpaa2/dpaa2_ethdev.h | 3 + drivers/net/dpaa2/dpaa2_flow.c | 5 ++ 3 files changed, 105 insertions(+), 10 deletions(-)
drivers/net/dpaa2/dpaa2_ethdev.c +97 -10
@@ -507,7 +507,7 @@ dpaa2_setup_table_miss_action(struct rte_eth_dev *eth_dev, }static int -dpaa2_setup_flow_dist (struct rte_eth_dev *eth_dev, +dpaa2_setup_flow_rss_dist (struct rte_eth_dev *eth_dev,uint64_t req_dist_set,int tc_index) {struct dpaa2_dev_priv *priv = eth_dev->data->dev_private;
@@ -555,6 +555,49 @@ dpaa2_setup_flow_dist(struct rte_eth_dev *eth_dev,return 0 ; } +static int +dpaa2_setup_flow_dcb_dist (struct rte_eth_dev *eth_dev, +uint8_t prio,uint8_t tc) +{ +struct dpaa2_dev_priv *priv = eth_dev->data->dev_private; +struct rte_flow_attr attr; +struct rte_flow_action actions[2 ]; +struct rte_flow_item_vlan vlan_item; +struct rte_flow_item_vlan vlan_mask; +struct rte_flow_item items[2 ]; +struct rte_flow_action_jump action_jump; +struct rte_flow *qos_flow; + +memset (&attr,0 ,sizeof (struct rte_flow_attr )); + attr.ingress =1 ; + + attr.group = priv->num_rx_tc; + attr.priority = prio; +memset (&vlan_item,0 ,sizeof (struct rte_flow_item_vlan )); +memset (&vlan_mask,0 ,sizeof (struct rte_flow_item_vlan )); + vlan_item.hdr.vlan_tci =rte_cpu_to_be_16 (RTE_VLAN_TCI_MAKE (0 , prio,0 )); + vlan_mask.hdr.vlan_tci =rte_cpu_to_be_16 (RTE_VLAN_PRI_MASK ); + items[0 ].spec = &vlan_item; + items[0 ].mask = &vlan_mask; + items[0 ].type =RTE_FLOW_ITEM_TYPE_VLAN ; + items[1 ].type =RTE_FLOW_ITEM_TYPE_END ; + + actions[0 ].type =RTE_FLOW_ACTION_TYPE_JUMP ; + action_jump.group = tc; + actions[0 ].conf = &action_jump; + actions[1 ].type =RTE_FLOW_ACTION_TYPE_END ; + + qos_flow =rte_flow_create (eth_dev->data->port_id, + &attr, items, actions,NULL ); +if (!qos_flow) { +DPAA2_PMD_WARN ("Failed to direct vlan with prio(%d) to tc%d" , prio, tc); +return -EIO ; + } + priv->dcb_flow[prio] = qos_flow; + +return 0 ; +} +static int dpaa2_remove_flow_rss_dist (struct rte_eth_dev *eth_dev,uint8_t tc_index)
@@ -1175,6 +1218,28 @@ dpaa2_free_rx_tx_queues(struct rte_eth_dev *dev) } } +static int +dpaa2_dev_dcb_info (struct rte_eth_dev *dev, +struct rte_eth_dcb_info *dcb_info) +{ +struct dpaa2_dev_priv *priv = dev->data->dev_private; +int i; + +if (!priv->nb_dcb_tcs) +return -ENOTSUP ; + +memset (dcb_info,0 ,sizeof (struct rte_eth_dcb_info )); + dcb_info->nb_tcs = priv->nb_dcb_tcs; +rte_memcpy (dcb_info->prio_tc, priv->prio_dcb_tc, +sizeof (uint8_t ) *RTE_ETH_DCB_NUM_USER_PRIORITIES ); +for (i =0 ; i < dcb_info->nb_tcs; i++) { + dcb_info->tc_queue.tc_rxq[0 ][i].base = priv->dist_queues * i; + dcb_info->tc_queue.tc_rxq[0 ][i].nb_queue = priv->dist_queues; + } + +return 0 ; +} +static int dpaa2_eth_dev_configure (struct rte_eth_dev *dev) {
@@ -1187,7 +1252,7 @@ dpaa2_eth_dev_configure(struct rte_eth_dev *dev)int rx_l4_csum_offload = false;int tx_l3_csum_offload = false;int tx_l4_csum_offload = false; -int ret, tc_index; +int ret, tc_index, nb_tcs;uint32_t max_rx_pktlen;PMD_INIT_FUNC_TRACE ();
@@ -1245,15 +1310,26 @@ dpaa2_eth_dev_configure(struct rte_eth_dev *dev) ret, dev->data->name); } -if (eth_conf->rxmode.mq_mode ==RTE_ETH_MQ_RX_RSS ) { +if (eth_conf->rxmode.mq_mode &RTE_ETH_MQ_RX_RSS ) {for (tc_index =0 ; tc_index < priv->num_rx_tc; tc_index++) { - ret =dpaa2_setup_flow_dist (dev, - eth_conf->rx_adv_conf.rss_conf.rss_hf, - tc_index); + ret =dpaa2_setup_flow_rss_dist (dev, + eth_conf->rx_adv_conf.rss_conf.rss_hf, tc_index);if (ret) { -DPAA2_PMD_ERR ( -"Unable to set flow distribution on tc%d." -"Check queue config" , tc_index); +DPAA2_PMD_ERR ("RSS dist on tc%d err(%d)" , tc_index, ret); +return ret; + } + } + } + +if ((eth_conf->rxmode.mq_mode &RTE_ETH_MQ_RX_DCB ) && priv->qos_entries) { + nb_tcs = eth_conf->rx_adv_conf.dcb_rx_conf.nb_tcs; +for (tc_index =0 ; tc_index < nb_tcs; tc_index++) { +if (tc_index >= priv->num_rx_tc) +break ; + ret =dpaa2_setup_flow_dcb_dist (dev, + eth_conf->rx_adv_conf.dcb_rx_conf.dcb_tc[tc_index], tc_index); +if (ret) { +DPAA2_PMD_ERR ("DCB direct to tc%d err(%d)" , tc_index, ret);return ret; } }
@@ -1320,7 +1396,7 @@ dpaa2_eth_dev_configure(struct rte_eth_dev *dev)*/ if (dpaa2_svr_family ==SVR_LX2160A ) { ret =dpni_set_offload (dpni,CMD_PRI_LOW , priv->token, -DPNI_FLCTYPE_HASH , true); +DPNI_FLCTYPE_HASH , true);if (ret) {DPAA2_PMD_ERR ("Error setting FLCTYPE: Err = %d" , ret);return ret;
@@ -2282,6 +2358,8 @@ dpaa2_dev_close(struct rte_eth_dev *dev)dpaa2_tm_deinit (dev);dpaa2_flow_clean (dev,MAX_TCS ,DPAA2_FLOW_ALL_TYPE ); +/** No matter dcb flows are created or not, they are destroyed in flow clean.*/ +memset (priv->dcb_flow,0 ,sizeof (void *) *RTE_ETH_DCB_NUM_USER_PRIORITIES );/* Clean the device first */ ret =dpni_reset (dpni,CMD_PRI_LOW , priv->token);if (ret) {
@@ -3725,6 +3803,7 @@ static struct eth_dev_ops dpaa2_ethdev_ops = { .txq_info_get = dpaa2_txq_info_get, .tm_ops_get = dpaa2_tm_ops_get, .mtr_ops_get = dpaa2_mtr_ops_get, + .get_dcb_info = dpaa2_dev_dcb_info, .timesync_enable = dpaa2_timesync_enable, .timesync_disable = dpaa2_timesync_disable, .timesync_read_time = dpaa2_timesync_read_time,
@@ -4054,6 +4133,14 @@ dpaa2_dev_init(struct rte_eth_dev *eth_dev) tbl_profile->entry_map_size = entry_num /8 +1 ; } +for (i =0 ; i < priv->num_rx_tc; i++) { +if (i >=RTE_ETH_DCB_NUM_USER_PRIORITIES ) +break ; +if (i >= priv->qos_entries) +break ; + priv->prio_dcb_tc[i] = i; + } + priv->nb_dcb_tcs = i; ret =dpni_set_max_frame_length (dpni_dev,CMD_PRI_LOW , priv->token,RTE_ETHER_MAX_LEN -RTE_ETHER_CRC_LEN +VLAN_TAG_SIZE );if (ret) {
drivers/net/dpaa2/dpaa2_ethdev.h +3 -0
@@ -436,6 +436,9 @@ struct dpaa2_dev_priv {char ep_name[RTE_DEV_NAME_MAX_LEN ];struct dpaa2_flow_profile flow_profile; +uint8_t nb_dcb_tcs; +uint8_t prio_dcb_tc[RTE_ETH_DCB_NUM_USER_PRIORITIES ]; +void *dcb_flow[RTE_ETH_DCB_NUM_USER_PRIORITIES ];uint16_t ss_offset;uint64_t ss_iova;
drivers/net/dpaa2/dpaa2_flow.c +5 -0
@@ -3228,6 +3228,11 @@ dpaa2_flow_get_flow_index(struct dpaa2_dev_priv *priv,DPAA2_PMD_ERR ("QoS flow index(%d) >= max(%d)" , idx, priv->qos_entries);return -ENOSPC ; } + +if (idx <RTE_ETH_DCB_NUM_USER_PRIORITIES && priv->dcb_flow[idx]) { +DPAA2_PMD_ERR ("QoS flow[%d] added conflicts with dcb flow" , idx); +return -ENODATA ; + } }else {if (attr->priority >= priv->fs_entries) { DPAA2_PMD_ERR("FS[%d].entry(%d) >= max(%d)",
Signature · 1 line
2.43.0
PATCH 28/65 net/dpaa2: reject Rx queue deferred start
In reply to Prashant GuptaFrom: Hemant Agrawal <[email protected]>
The driver has no way to hold an Rx queue down while the port is started, and dpaa2_rxq_info_get() already reports rx_deferred_start as 0. The Tx side rejects the request; do the same for Rx instead of silently accepting a configuration that will not be honoured.
--- drivers/net/dpaa2/dpaa2_ethdev.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/net/dpaa2/dpaa2_ethdev.c +7 -0
@@ -1483,6 +1483,13 @@ dpaa2_dev_rx_queue_setup(struct rte_eth_dev *dev,DPAA2_PMD_DEBUG ("dev =%p, queue =%d, pool = %p, conf =%p" , dev, rx_queue_id, mb_pool, rx_conf); +/* Rx deferred start is not supported */ +if (rx_conf->rx_deferred_start) { +DPAA2_PMD_ERR ("%s: Rx deferred start not supported" , + dev->data->name); +return -EINVAL ; + } + total_nb_rx_desc += nb_rx_desc;if (total_nb_rx_desc >MAX_NB_RX_DESC_IN_PEB && (priv->options &DPNI_OPT_V1_PFDR_IN_PEB )) {
Signature · 1 line
2.43.0
PATCH 29/65 bus/fslmc: support DPCI peer and dynamic queues
In reply to Prashant GuptaFrom: Jun Yang <[email protected]>
Add dpci_get_peer_attributes() to query the DPCI object a given DPCI is connected to, and use it to fix the DPCI Tx fqid. A DPCI's Tx fqid only equals its Rx fqid when the DPCI is self-connected; when it has a real peer, the Tx fqids must come from dpci_get_tx_queue().
Rework DPCI device creation accordingly:
- Replace the fixed DPAA2_DPCI_MAX_QUEUES arrays with dynamically allocated rx_queue/tx_queue arrays sized from the object's own num_of_priorities and the peer's num_of_priorities.
- Determine the peer via dpci_get_peer_attributes(); fall back to self-connection when no peer is present.
- Use rte_zmalloc for the node, zero the attribute structs, and replace the single err label with staged open_err/queue_err/ enable_err cleanup that closes/disables and frees only what was allocated.
- Rename the internal create/close callbacks to the dpaa2_ prefix.
Add rte_dpaa2_dpci_link_attach() so a consumer can bind a free DPCI Rx queue to a destination (e.g. a DPCON), install its dequeue callback and obtain the matching peer Tx queue. The event PMD uses this in place of its private dpaa2_eventdev_setup_dpci(): each event queue now tracks a per-sched-type Tx queue array (dpci_txqs[]) and the owning event port, and the enqueue path selects the Tx fqid by event->queue_id and sched_type while validating port ownership.
--- drivers/bus/fslmc/mc/dpci.c | 37 +++- drivers/bus/fslmc/mc/fsl_dpci.h | 12 +- drivers/bus/fslmc/portal/dpaa2_hw_dpci.c | 225 ++++++++++++++++------- drivers/bus/fslmc/portal/dpaa2_hw_pvt.h | 16 +- drivers/event/dpaa2/dpaa2_eventdev.c | 122 ++++++------ drivers/event/dpaa2/dpaa2_eventdev.h | 8 +- 6 files changed, 282 insertions(+), 138 deletions(-)
drivers/bus/fslmc/mc/dpci.c +36 -1
@@ -1,7 +1,7 @@/* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 * * Copyright 2013-2016 Freescale Semiconductor Inc. -* Copyright 2017-2019 NXP +* Copyright 2017-2019, 2026 NXP * */ #include <fsl_mc_sys.h>
@@ -304,6 +304,41 @@ int dpci_get_attributes(struct fsl_mc_io *mc_io,return 0 ; } +/** +* dpci_get_peer_attributes() - Retrieve DPCI peer attributes. +* @mc_io: Pointer to MC portal's I/O object +* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' +* @token: Token of DPCI object +* @attr: Returned DPCI peer's attributes +* +* Return: '0' on Success; Error code otherwise. +*/ +int dpci_get_peer_attributes (struct fsl_mc_io *mc_io, +uint32_t cmd_flags, +uint16_t token, +struct dpci_peer_attr *attr) +{ +struct dpci_rsp_get_attr *rsp_params; +struct mc_command cmd = {0 }; +int err; + +/* prepare command */ + cmd.header =mc_encode_cmd_header (DPCI_CMDID_GET_PEER_ATTR , + cmd_flags, token); + +/* send command to mc*/ + err =mc_send_command (mc_io, &cmd); +if (err) +return err; + +/* retrieve response parameters */ + rsp_params = (struct dpci_rsp_get_attr *)cmd.params; + attr->peer_id =le32_to_cpu (rsp_params->id); + attr->num_of_priorities = rsp_params->num_of_priorities; + +return 0 ; +} +/** * dpci_set_rx_queue() - Set Rx queue configuration * @mc_io: Pointer to MC portal's I/O object
drivers/bus/fslmc/mc/fsl_dpci.h +11 -1
@@ -1,7 +1,7 @@/* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 * * Copyright 2013-2016 Freescale Semiconductor Inc. -* Copyright 2017-2019 NXP +* Copyright 2017-2019, 2026 NXP * */ #ifndef __FSL_DPCI_H
@@ -111,6 +111,16 @@ int dpci_get_attributes(struct fsl_mc_io *mc_io,uint16_t token, struct dpci_attr *attr); +struct dpci_peer_attr { +int peer_id; +uint8_t num_of_priorities; +}; + +int dpci_get_peer_attributes (struct fsl_mc_io *mc_io, +uint32_t cmd_flags, +uint16_t token, +struct dpci_peer_attr *attr); +/** * enum dpci_dest - DPCI destination types * @DPCI_DEST_NONE: Unassigned destination; The queue is set in parked mode
drivers/bus/fslmc/portal/dpaa2_hw_dpci.c +158 -67
318 lines not on this page · raw message
drivers/bus/fslmc/portal/dpaa2_hw_pvt.h +12 -4
@@ -14,6 +14,7 @@#include <dpaax_iova_table.h> #include <mc/fsl_mc_sys.h> +#include <mc/fsl_dpci.h> #include <fsl_qbman_portal.h> #include <bus_fslmc_driver.h>
@@ -81,7 +82,6 @@#define DPAA2_HW_BUF_RESERVE 0#define DPAA2_PACKET_LAYOUT_ALIGN 64/*changing from 256 */ -#define DPAA2_DPCI_MAX_QUEUES 2#define DPAA2_INVALID_FLOW_ID 0xffff#define DPAA2_INVALID_FQ_ID ((uint32_t)(-1))#define DPAA2_INVALID_CGID 0xff
@@ -267,13 +267,16 @@ struct dpaa2_dprc_dev {struct dpaa2_dpci_dev {TAILQ_ENTRY (dpaa2_dpci_dev) next; -/**< Pointer to Next device instance */ +/**< Pointer to Next device instance */ struct fsl_mc_io dpci;/** handle to DPCI portal object */ uint16_t token;RTE_ATOMIC (uint16_t ) in_use;uint32_t dpci_id;/*HW ID for DPCI object */ -struct dpaa2_queue rx_queue[DPAA2_DPCI_MAX_QUEUES ]; -struct dpaa2_queue tx_queue[DPAA2_DPCI_MAX_QUEUES ]; +uint32_t peer_id; +uint16_t rx_queue_num; +uint16_t tx_queue_num; +struct dpaa2_queue *rx_queue; +struct dpaa2_queue *tx_queue; };struct dpaa2_dpcon_dev {
@@ -577,6 +580,11 @@ struct dpaa2_dpci_dev *rte_dpaa2_alloc_dpci_dev(void);__rte_internal void rte_dpaa2_free_dpci_dev(struct dpaa2_dpci_dev *dpci); +__rte_internal +int rte_dpaa2_dpci_link_attach(struct dpaa2_dpci_dev *dpci_dev, +enum dpci_dest dest_type,uint32_t dest_id,uint8_t priority, +dpaa2_queue_cb_dqrr_t *rx_cb,struct dpaa2_queue **txq); +/* Global MCP pointer */ __rte_internal void *dpaa2_get_mcp_ptr(int portal_idx);
drivers/event/dpaa2/dpaa2_eventdev.c +59 -63
209 lines not on this page · raw message
drivers/event/dpaa2/dpaa2_eventdev.h +6 -2
@@ -51,20 +51,24 @@ enum {* the ethdev to eventdev with DPAA2 devices. */ +#define DPAA2_EVENTQ_LINK_CONF_MAX 4/** Max schedule type + 1.*/ struct dpaa2_eventq { +int valid; +void *event_port;/* DPcon device */ struct dpaa2_dpcon_dev *dpcon;/* Attached DPCI device */ struct dpaa2_dpci_dev *dpci; -/* Mapped event port */ -struct dpaa2_io_portal_t *event_port;/* Configuration provided by the user */ uint32_t event_queue_cfg;uint32_t event_queue_id; +struct dpaa2_queue *dpci_txqs[DPAA2_EVENTQ_LINK_CONF_MAX ]; };struct dpaa2_port { +struct rte_eventdev *eventdev;struct dpaa2_eventq evq_info[DPAA2_EVENT_MAX_QUEUES ]; +uint8_t port_id;uint8_t num_linked_evq;uint8_t is_port_linked;uint64_t timeout_us;
Signature · 1 line
2.43.0
PATCH 30/65 bus/fslmc: add alloc/free DPIO API for non-affine portals
In reply to Prashant GuptaFrom: Jun Yang <[email protected]>
Add rte_dpaa2_alloc_dpio_device() and rte_dpaa2_free_dpio_device() to grab and release a DPIO software portal that is not tied to a specific CPU affinity. The allocator reserves a free portal from the DPIO list, sets up the DQRI interrupt when the event driver is built in, and the release helper returns the portal via dpaa2_put_qbman_swp().
This lets consumers that manage their own threading (rather than the per-lcore affine portals) obtain a dedicated portal handle.
--- drivers/bus/fslmc/portal/dpaa2_hw_dpio.c | 40 ++++++++++++++++++++++++ drivers/bus/fslmc/portal/dpaa2_hw_dpio.h | 8 +++++ 2 files changed, 48 insertions(+)
drivers/bus/fslmc/portal/dpaa2_hw_dpio.c +40 -0
@@ -422,6 +422,46 @@ static void dpaa2_portal_finish(void *arg)pthread_setspecific (dpaa2_portal_key,NULL ); } +RTE_EXPORT_INTERNAL_SYMBOL (rte_dpaa2_alloc_dpio_device) +struct dpaa2_dpio_dev * +rte_dpaa2_alloc_dpio_device (void ) +{ +struct dpaa2_dpio_dev *dpio_dev =NULL ; +uint16_t expected =0 ; + +/* Get DPIO dev handle from list using index */ + TAILQ_FOREACH(dpio_dev, &dpio_dev_list, next) { +if (dpio_dev && +rte_atomic_compare_exchange_strong_explicit (&dpio_dev->ref_count, + &expected,1 , rte_memory_order_acquire, rte_memory_order_relaxed)) +break ; + } +if (!dpio_dev) { +DPAA2_BUS_ERR ("No software portal resource left" ); +return NULL ; + } + +DPAA2_BUS_DEBUG ("New Portal %p (%d) affined thread - %u" , + dpio_dev, dpio_dev->index,rte_gettid ()); + +#ifdef RTE_EVENT_DPAA2 +if (dpaa2_dpio_intr_init (dpio_dev,1 ,0 , false)) { +DPAA2_BUS_ERR ("Interrupt registration failed for dpio" ); +rte_atomic_store_explicit (&dpio_dev->ref_count,0 , + rte_memory_order_release); +return NULL ; + } +#endif + +return dpio_dev; +} + +RTE_EXPORT_INTERNAL_SYMBOL (rte_dpaa2_free_dpio_device) +void rte_dpaa2_free_dpio_device(struct dpaa2_dpio_dev *dpio_dev) +{ +dpaa2_put_qbman_swp (dpio_dev); +} +static void dpaa2_close_dpio_device (int object_id) {
drivers/bus/fslmc/portal/dpaa2_hw_dpio.h +8 -0
@@ -70,4 +70,12 @@ __rte_internaluint32_t dpaa2_free_eq_descriptors (void ); +__rte_internal +struct dpaa2_dpio_dev * +rte_dpaa2_alloc_dpio_device (void ); + +__rte_internal +void +rte_dpaa2_free_dpio_device (struct dpaa2_dpio_dev *dpio_dev); +#endif /* _DPAA2_HW_DPIO_H_ */
Signature · 1 line
2.43.0
PATCH 31/65 event/dpaa2: rework event port model and DPCI handling
In reply to Prashant GuptaFrom: Jun Yang <[email protected]>
Rework the DPAA2 eventdev port model so that each event port owns a dedicated DPIO/software portal instead of relying on the per-lcore DPIO of whatever thread happens to call enqueue/dequeue. This removes the lazy link-on-first-burst logic and its error-unwind paths, and makes port behaviour independent of the calling lcore.
Main changes:
- Dedicated portal per event port:
rte_dpaa2_alloc_dpio_device() is called at port setup and stored in struct dpaa2_port. enqueue/dequeue use portal->dpio_dev directly and reject calls on a port that was never set up or has no linked queue. An optional atomic port mode (RTE_DPAA2_EVENT_PORT_CFG_ATOMIC) takes a per-port spinlock so several lcores can share one port; otherwise the port records its affine lcore and warns on cross-lcore use.
- Dynamic link and unlink:
port_link now attaches DPCON static dequeue channels at link time (unlinking any previous queues first), validates queue ownership, and unwinds cleanly on failure. port_unlink removes the channels, compacts the evq_info array, and is used by port_release so a port is properly torn down. The redundant *_queue_del_all() and per-error detach unwind paths are removed.
- Per-DPIO held-buffer tracking:
The per-lcore DQRR bookkeeping globals (DPAA2_PER_LCORE_DQRR_*) are replaced by a dpaa2_held_bufs structure in struct dpaa2_dpio_dev, so atomic-queue DQRR state follows the portal that owns it. All dqrr callbacks now take struct dpaa2_dpio_dev * instead of struct qbman_swp *; the dpaa2_sec and net/dpaa2 callbacks are updated to match.
- Event object allocation from a mempool:
Each DPCI Rx queue gets an env_pool mempool of rte_event objects. enqueue takes an event from the peer queue's pool and the process callbacks return it, replacing the per-event rte_malloc/rte_free on the hot path.
- Flush on stop:
dpaa2_eventdev_stop() now drains each linked port and calls the registered dev_stop_flush callback for every leftover event.
--- drivers/bus/fslmc/portal/dpaa2_hw_dpci.c | 26 +- drivers/bus/fslmc/portal/dpaa2_hw_dpio.c | 5 +- drivers/bus/fslmc/portal/dpaa2_hw_dpio.h | 2 +- drivers/bus/fslmc/portal/dpaa2_hw_pvt.h | 4 +- drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c | 32 +- drivers/event/dpaa2/dpaa2_eventdev.c | 712 ++++++++++---------- drivers/event/dpaa2/dpaa2_eventdev.h | 13 +- drivers/net/dpaa2/dpaa2_ethdev.c | 22 +- drivers/net/dpaa2/dpaa2_ethdev.h | 26 +- drivers/net/dpaa2/dpaa2_rxtx.c | 69 +- drivers/net/dpaa2/rte_pmd_dpaa2.h | 2 + 11 files changed, 464 insertions(+), 449 deletions(-)
drivers/bus/fslmc/portal/dpaa2_hw_dpci.c +25 -1
@@ -56,6 +56,8 @@ dpaa2_create_dpci_device(int vdev_fd __rte_unused,struct dpci_rx_queue_attr rx_attr;struct dpci_tx_queue_attr tx_attr;int ret, i, dpci_id = obj->object_id; +char pool_name[64 ]; +uint64_t pool_size;memset (&attr,0 ,sizeof (struct dpci_attr ));memset (&peer_attr,0 ,sizeof (struct dpci_peer_attr ));
@@ -118,6 +120,17 @@ dpaa2_create_dpci_device(int vdev_fd __rte_unused, goto queue_err; } dpci_node->rx_queue[i].fqid = rx_attr.fqid; +snprintf (pool_name,sizeof (pool_name),"dpci%d_qid%d_env" , dpci_id, i); + pool_size =RTE_ALIGN (sizeof (struct rte_event ),RTE_CACHE_LINE_SIZE ); + dpci_node->rx_queue[i].env_pool =rte_mempool_create (pool_name, +1024 , pool_size,512 ,0 ,NULL ,NULL ,NULL ,NULL , +SOCKET_ID_ANY ,0 ); +if (!dpci_node->rx_queue[i].env_pool) { +DPAA2_BUS_ERR ("Rx queue event pool create(%s) failed" , + pool_name); + ret = -ENOMEM ; + goto queue_err; + } }/* Enable the device */
@@ -177,8 +190,13 @@ dpaa2_create_dpci_device(int vdev_fd __rte_unused,rte_free (dpci_node->tx_queue);dpci_disable (&dpci_node->dpci,CMD_PRI_LOW , dpci_node->token); queue_err: -if (dpci_node->rx_queue) +if (dpci_node->rx_queue) { +for (i =0 ; i < dpci_node->rx_queue_num; i++) { +if (dpci_node->rx_queue[i].env_pool) +rte_mempool_free (dpci_node->rx_queue[i].env_pool); + }rte_free (dpci_node->rx_queue); + } open_err:dpci_close (&dpci_node->dpci,CMD_PRI_LOW , dpci_node->token);
@@ -223,11 +241,16 @@ static void dpaa2_close_dpci_device(int object_id) {struct dpaa2_dpci_dev *dpci_dev =NULL ; +int i; dpci_dev =get_dpci_from_id ((uint32_t )object_id);if (dpci_dev) {dpci_disable (&dpci_dev->dpci,CMD_PRI_LOW , dpci_dev->token); +for (i =0 ; i < dpci_dev->rx_queue_num; i++) { +if (dpci_dev->rx_queue[i].env_pool) +rte_mempool_free (dpci_dev->rx_queue[i].env_pool); + }rte_free (dpci_dev->rx_queue);rte_free (dpci_dev->tx_queue);dpci_close (&dpci_dev->dpci,CMD_PRI_LOW , dpci_dev->token);
@@ -285,6 +308,7 @@ rte_dpaa2_dpci_link_attach(struct dpaa2_dpci_dev *dpci_dev,return ret; } dpci_dev->rx_queue[i].cb = rx_cb; + dpci_dev->tx_queue[i].env_pool = peer_dpci->rx_queue[i].env_pool;if (txq) *txq = &dpci_dev->tx_queue[i];
drivers/bus/fslmc/portal/dpaa2_hw_dpio.c +4 -1
@@ -314,6 +314,7 @@ static void dpaa2_put_qbman_swp(struct dpaa2_dpio_dev *dpio_dev)* armed: intr_deinit returns early if intr is not enabled. */ dpaa2_dpio_intr_deinit (dpio_dev); + dpio_dev->cpu_affine =-1 ;rte_atomic_store_explicit (&dpio_dev->ref_count,0 , rte_memory_order_release); }
@@ -357,6 +358,7 @@ static struct dpaa2_dpio_dev *dpaa2_get_qbman_swp(bool ethrx)return NULL ; } } + dpio_dev->cpu_affine = cpu_id; ret =pthread_setspecific (dpaa2_portal_key, (void *)dpio_dev);if (ret) {
@@ -424,7 +426,7 @@ static void dpaa2_portal_finish(void *arg)RTE_EXPORT_INTERNAL_SYMBOL (rte_dpaa2_alloc_dpio_device) struct dpaa2_dpio_dev * -rte_dpaa2_alloc_dpio_device (void ) +rte_dpaa2_alloc_dpio_device (int32_t cpu_affine) {struct dpaa2_dpio_dev *dpio_dev =NULL ;uint16_t expected =0 ;
@@ -452,6 +454,7 @@ rte_dpaa2_alloc_dpio_device(void) return NULL; }#endif + dpio_dev->cpu_affine = cpu_affine;return dpio_dev; }
drivers/bus/fslmc/portal/dpaa2_hw_dpio.h +1 -1
@@ -72,7 +72,7 @@ dpaa2_free_eq_descriptors(void);__rte_internal struct dpaa2_dpio_dev * -rte_dpaa2_alloc_dpio_device (void ); +rte_dpaa2_alloc_dpio_device (int32_t cpu_affine);__rte_internal void
drivers/bus/fslmc/portal/dpaa2_hw_pvt.h +3 -1
@@ -136,6 +136,7 @@ struct dpaa2_dpio_dev {int32_t epoll_fd;/**< File descriptor created for interrupt polling */ int32_t hw_id;/**< An unique ID of this DPIO device instance */ uint8_t intr_enabled;/**< DQRI portal interrupt already set up */ +int32_t cpu_affine;uint16_t ethrx_intr_refcnt;/**< rx queues currently armed on this portal */ struct dpaa2_portal_dqrr dpaa2_held_bufs; };
@@ -159,7 +160,7 @@ struct queue_storage_info_t {struct dpaa2_queue ; -typedef void (dpaa2_queue_cb_dqrr_t)(struct qbman_swp *swp, +typedef void (dpaa2_queue_cb_dqrr_t)(struct dpaa2_dpio_dev *dpio_dev, const struct qbman_fd *fd, const struct qbman_result *dq, struct dpaa2_queue *rxq,
@@ -189,6 +190,7 @@ struct __rte_cache_aligned dpaa2_queue {void *cfg;uint8_t options;struct rte_event ev; +struct rte_mempool *env_pool;dpaa2_queue_cb_dqrr_t *cb;dpaa2_queue_cb_eqresp_free_t *cb_eqresp_free;struct dpaa2_bp_info *bp_array;
drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c +14 -18
@@ -4098,13 +4098,12 @@ void dpaa2_sec_stats_reset(struct rte_cryptodev *dev) } static void __rte_hot -dpaa2_sec_process_parallel_event (struct qbman_swp *swp, -const struct qbman_fd *fd, -const struct qbman_result *dq, -struct dpaa2_queue *rxq, -struct rte_event *ev) +dpaa2_sec_process_parallel_event (struct dpaa2_dpio_dev *dpio_dev, +const struct qbman_fd *fd,const struct qbman_result *dq, +struct dpaa2_queue *rxq,struct rte_event *ev) {struct dpaa2_sec_qp *qp; +struct qbman_swp *swp = dpio_dev->sw_portal; qp = container_of(rxq, struct dpaa2_sec_qp, rx_vq); ev->flow_id = rxq->ev.flow_id;
@@ -4120,11 +4119,9 @@ dpaa2_sec_process_parallel_event(struct qbman_swp *swp, }static void -dpaa2_sec_process_atomic_event(struct qbman_swp *swp __rte_unused, -const struct qbman_fd *fd, -const struct qbman_result *dq, -struct dpaa2_queue *rxq, -struct rte_event *ev) +dpaa2_sec_process_atomic_event (struct dpaa2_dpio_dev *dpio_dev, +const struct qbman_fd *fd,const struct qbman_result *dq, +struct dpaa2_queue *rxq,struct rte_event *ev) {uint8_t dqrr_index;struct dpaa2_sec_qp *qp;
@@ -4142,21 +4139,20 @@ dpaa2_sec_process_atomic_event(struct qbman_swp *swp __rte_unused, crypto_op =dpaa2_sec_fd_to_mbuf (fd, qp); dqrr_index =qbman_get_dqrr_idx (dq); *dpaa2_seqn (crypto_op->sym->m_src) =QBMAN_ENQUEUE_FLAG_DCA | dqrr_index; -DPAA2_PER_LCORE_DQRR_SIZE ++; -DPAA2_PER_LCORE_DQRR_HELD |=UINT64_C (1 ) << dqrr_index; -DPAA2_PER_LCORE_DQRR_MBUF (dqrr_index) = crypto_op->sym->m_src; + dpio_dev->dpaa2_held_bufs.dqrr_size++; + dpio_dev->dpaa2_held_bufs.dqrr_held |=UINT64_C (1 ) << dqrr_index; + dpio_dev->dpaa2_held_bufs.mbuf[dqrr_index] = crypto_op->sym->m_src; ev->event_ptr = crypto_op; } static void __rte_hot -dpaa2_sec_process_ordered_event (struct qbman_swp *swp, -const struct qbman_fd *fd, -const struct qbman_result *dq, -struct dpaa2_queue *rxq, -struct rte_event *ev) +dpaa2_sec_process_ordered_event (struct dpaa2_dpio_dev *dpio_dev, +const struct qbman_fd *fd,const struct qbman_result *dq, +struct dpaa2_queue *rxq,struct rte_event *ev) {struct rte_crypto_op *crypto_op;struct dpaa2_sec_qp *qp; +struct qbman_swp *swp = dpio_dev->sw_portal; qp = container_of(rxq, struct dpaa2_sec_qp, rx_vq); ev->flow_id = rxq->ev.flow_id;
drivers/event/dpaa2/dpaa2_eventdev.c +357 -355
1,000 lines not on this page · raw message
drivers/event/dpaa2/dpaa2_eventdev.h +11 -2
@@ -67,10 +67,19 @@ struct dpaa2_eventq {struct dpaa2_port {struct rte_eventdev *eventdev; -struct dpaa2_eventq evq_info[DPAA2_EVENT_MAX_QUEUES ]; +struct dpaa2_dpio_dev *dpio_dev; +int port_atomic; +rte_spinlock_t port_lock; +/* +* Set by the control thread while draining this port in the stop +* path. Read on the data path to suppress the cross-lcore warning +* without mutating cpu_affine (which would race with the data path). +*/ +RTE_ATOMIC (uint32_t ) flushing; + +struct dpaa2_eventq *evq_info[DPAA2_EVENT_MAX_QUEUES ];uint8_t port_id;uint8_t num_linked_evq; -uint8_t is_port_linked;uint64_t timeout_us; };
drivers/net/dpaa2/dpaa2_ethdev.c +13 -9
@@ -3315,11 +3315,10 @@ int dpaa2_eth_eventq_attach(const struct rte_eth_dev *dev, const struct rte_event_eth_rx_adapter_queue_conf *queue_conf) {struct dpaa2_dev_priv *eth_priv = dev->data->dev_private; -struct fsl_mc_io *dpni = (struct fsl_mc_io *)dev->process_private; +struct fsl_mc_io *dpni = dev->process_private;struct dpaa2_queue *dpaa2_ethq = eth_priv->rx_vq[eth_rx_queue_id]; -uint8_t flow_id = dpaa2_ethq->flow_id; +uint8_t flow_id = dpaa2_ethq->flow_id, options, priority;struct dpni_queue *cfg; -uint8_t options, priority;int ret; cfg = dpaa2_ethq->cfg;
@@ -3352,7 +3351,7 @@ int dpaa2_eth_eventq_attach(const struct rte_eth_dev *dev, }if (queue_conf->ev.sched_type ==RTE_SCHED_TYPE_ORDERED && - !eth_priv->en_ordered) { + !eth_priv->en_ordered) {struct opr_cfg ocfg;/* Restoration window size = 256 frames */
@@ -3376,10 +3375,10 @@ int dpaa2_eth_eventq_attach(const struct rte_eth_dev *dev, } ret =dpni_set_opr (dpni,CMD_PRI_LOW , eth_priv->token, - dpaa2_ethq->tc_index, flow_id, -OPR_OPT_CREATE , &ocfg,0 ); + dpaa2_ethq->tc_index, flow_id,OPR_OPT_CREATE , &ocfg,0 );if (ret) { -DPAA2_PMD_ERR ("Error setting opr: ret: %d" , ret); +DPAA2_PMD_ERR ("Failed(%d) to set opr of TC%d.flow.%d" , + ret, dpaa2_ethq->tc_index, flow_id);return ret; }
@@ -3390,13 +3389,18 @@ int dpaa2_eth_eventq_attach(const struct rte_eth_dev *dev, cfg->user_context = (size_t )(dpaa2_ethq); ret =dpni_set_queue (dpni,CMD_PRI_LOW , eth_priv->token,DPNI_QUEUE_RX , - dpaa2_ethq->tc_index, flow_id, options, cfg); + dpaa2_ethq->tc_index, flow_id, options, cfg);if (ret) { -DPAA2_PMD_ERR ("Error in dpni_set_queue: ret: %d" , ret); +DPAA2_PMD_ERR ("Failed(%d) to set queue of TC%d.flow.%d" , + ret, dpaa2_ethq->tc_index, flow_id);return ret; }rte_memcpy (&dpaa2_ethq->ev, &queue_conf->ev,sizeof (struct rte_event )); + dpaa2_ethq->ev.flow_id = flow_id; + dpaa2_ethq->ev.event_type =RTE_EVENT_TYPE_ETHDEV ; + dpaa2_ethq->ev.op =RTE_EVENT_OP_NEW ; + dpaa2_ethq->ev.queue_id = eth_rx_queue_id;return 0 ; }
drivers/net/dpaa2/dpaa2_ethdev.h +11 -15
@@ -929,21 +929,17 @@ uint16_t dpaa2_dev_prefetch_rx_channel(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts);uint16_t dpaa2_dev_rx_channel (void *queue,struct rte_mbuf **bufs,uint16_t nb_pkts); -void dpaa2_dev_process_parallel_event (struct qbman_swp *swp, -const struct qbman_fd *fd, -const struct qbman_result *dq, -struct dpaa2_queue *rxq, -struct rte_event *ev); -void dpaa2_dev_process_atomic_event (struct qbman_swp *swp, -const struct qbman_fd *fd, -const struct qbman_result *dq, -struct dpaa2_queue *rxq, -struct rte_event *ev); -void dpaa2_dev_process_ordered_event (struct qbman_swp *swp, -const struct qbman_fd *fd, -const struct qbman_result *dq, -struct dpaa2_queue *rxq, -struct rte_event *ev); + +void dpaa2_dev_process_parallel_event (struct dpaa2_dpio_dev *dpio_dev, +const struct qbman_fd *fd,const struct qbman_result *dq, +struct dpaa2_queue *rxq,struct rte_event *ev); +void dpaa2_dev_process_atomic_event (struct dpaa2_dpio_dev *dpio_dev, +const struct qbman_fd *fd,const struct qbman_result *dq, +struct dpaa2_queue *rxq,struct rte_event *ev); +void dpaa2_dev_process_ordered_event (struct dpaa2_dpio_dev *dpio_dev, +const struct qbman_fd *fd,const struct qbman_result *dq, +struct dpaa2_queue *rxq,struct rte_event *ev); +uint16_t dpaa2_dev_tx (void *queue,struct rte_mbuf **bufs,uint16_t nb_pkts);uint16_t dpaa2_dev_tx_ordered (void *queue,struct rte_mbuf **bufs,uint16_t nb_pkts);
drivers/net/dpaa2/dpaa2_rxtx.c +23 -46
100 lines not on this page · raw message
drivers/net/dpaa2/rte_pmd_dpaa2.h +2 -0
@@ -129,6 +129,8 @@ int rte_pmd_dpaa2_rx_get_offset(uint16_t port_id, struct rte_mbuf *m, uint8_t *l3_off, uint8_t *l4_off, uint8_t *l5_off); +#define RTE_DPAA2_EVENT_PORT_CFG_ATOMIC RTE_BIT32(31) +/** RTE_DPAA2_MIX_GROUP_FLOW has same behavio as RTE_DPAA2_FLAT_GROUP_FLOW*/ enum rte_dpaa2_flow_type {RTE_DPAA2_FLAT_GROUP_FLOW ,
Signature · 1 line
2.43.0
PATCH 32/65 event/dpaa2: fix Tx adapter enqueue for mixed destinations
In reply to Prashant GuptaFrom: Jun Yang <[email protected]>
The "same destination" Tx adapter enqueue path assumed every event in a burst targeted the same ethdev port and Tx queue, reading the port and queue id only from the first mbuf (ev[0]) and pushing the whole burst with rte_eth_tx_burst() to that single destination.
This assumption does not always hold: an event burst may carry mbufs bound for different ports or queues. In that case, packets destined for other ports/queues were sent to the destination of the first mbuf, causing misdirected transmission.
Make the generic enqueue handler, which resolves the port and Tx queue per mbuf and transmits through dpaa2_dev_tx_multi_txq_ordered(), the sole implementation. The same-destination variant now simply forwards to it, so both callbacks handle mixed destinations correctly.
--- drivers/event/dpaa2/dpaa2_eventdev.c | 45 ++++++++-------------------- 1 file changed, 12 insertions(+), 33 deletions(-)
drivers/event/dpaa2/dpaa2_eventdev.c +12 -33
@@ -983,28 +983,28 @@ dpaa2_eventdev_tx_adapter_caps(const struct rte_eventdev *dev, }static uint16_t -dpaa2_eventdev_txa_enqueue_same_dest (void *port, +dpaa2_eventdev_txa_enqueue (void *port,struct rte_event ev[],uint16_t nb_events) { -struct rte_mbuf *m[MAX_TX_RING_SLOTS ], *m0; -uint16_t sent =0 , burst, i, port_id; -uint8_t qid; +void *txq[MAX_TX_RING_SLOTS ]; +struct rte_mbuf *m[MAX_TX_RING_SLOTS ]; +uint16_t sent =0 , burst, i, port_id, qid;RTE_SET_USED (port); - m0 = ev[0 ].mbuf; - qid =rte_event_eth_tx_adapter_txq_get (m0); - port_id = m0->port; -/* The advertised enqueue depth is the EQCR size, which may exceed the * on-stack burst array, so transmit in ring-sized chunks. */ while (sent < nb_events) { burst =RTE_MIN (nb_events - sent, (uint16_t )RTE_DIM (m)); -for (i =0 ; i < burst; i++) +for (i =0 ; i < burst; i++) { m[i] = ev[sent + i].mbuf; + port_id = m[i]->port; + qid =rte_event_eth_tx_adapter_txq_get (m[i]); + txq[i] = rte_eth_devices[port_id].data->tx_queues[qid]; + } - i =rte_eth_tx_burst (port_id, qid, m, burst); + i =dpaa2_dev_tx_multi_txq_ordered (txq, m, burst); sent += i;if (i < burst)break ;
@@ -1014,31 +1014,10 @@ dpaa2_eventdev_txa_enqueue_same_dest(void *port, }static uint16_t -dpaa2_eventdev_txa_enqueue (void *port, +dpaa2_eventdev_txa_enqueue_same_dest (void *port,struct rte_event ev[],uint16_t nb_events) { -void *txq[MAX_TX_RING_SLOTS ]; -struct rte_mbuf *m[MAX_TX_RING_SLOTS ]; -uint16_t sent =0 , burst, i; -uint8_t qid; - -RTE_SET_USED (port); - -while (sent < nb_events) { - burst =RTE_MIN (nb_events - sent, (uint16_t )RTE_DIM (m)); -for (i =0 ; i < burst; i++) { - m[i] = ev[sent + i].mbuf; - qid =rte_event_eth_tx_adapter_txq_get (m[i]); - txq[i] = rte_eth_devices[m[i]->port].data->tx_queues[qid]; - } - - i =dpaa2_dev_tx_multi_txq_ordered (txq, m, burst); - sent += i; -if (i < burst) -break ; - } - -return sent; +return dpaa2_eventdev_txa_enqueue (port, ev, nb_events); }static struct eventdev_ops dpaa2_eventdev_ops = {
Signature · 1 line
2.43.0
PATCH 33/65 event/dpaa2: rework self test for dynamic link and balance check
In reply to Prashant GuptaFrom: Jun Yang <[email protected]>
The eventdev self test linked every queue to every port during device setup, which prevented individual test cases from exercising their own queue-to-port topologies and made enqueue/dequeue accounting unreliable.
Rework the self test as follows:
- Move queue-to-port linking out of _eventdev_setup() into each test case, so every test establishes the link topology it needs.
- Convert the test mode selector to a bitmask and add an atomic port setup path (RTE_DPAA2_EVENT_PORT_CFG_ATOMIC), used by the multi-queue/multi-port dequeue test.
- Return the number of dequeued events from consume_events() and assert that the dequeued count matches the injected count, verifying balance between ingress and egress.
- Retry enqueue until the event is accepted so injection no longer silently drops events.
- Propagate meaningful error codes (-ENOMEM, -EINVAL, -ETIMEDOUT, -ENODEV, and the underlying ret) instead of a bare -1.
--- drivers/event/dpaa2/dpaa2_eventdev_selftest.c | 336 ++++++++++-------- 1 file changed, 197 insertions(+), 139 deletions(-)
drivers/event/dpaa2/dpaa2_eventdev_selftest.c +197 -139
@@ -1,5 +1,5 @@/* SPDX-License-Identifier: BSD-3-Clause -* Copyright 2018-2019 NXP +* Copyright 2018-2019, 2026 NXP */ #include <rte_stdatomic.h>
@@ -20,6 +20,7 @@#include <bus_vdev_driver.h> #include <rte_test.h> #include <bus_fslmc_driver.h> +#include <rte_pmd_dpaa2.h> #include "dpaa2_eventdev.h" #include "dpaa2_eventdev_logs.h"
@@ -105,63 +106,64 @@ devconf_set_default_sane_values(struct rte_event_dev_config *dev_conf, }enum { -TEST_EVENTDEV_SETUP_DEFAULT , -TEST_EVENTDEV_SETUP_PRIORITY , -TEST_EVENTDEV_SETUP_DEQUEUE_TIMEOUT , +TEST_EVENTDEV_SETUP_DEFAULT = (1 <<0 ), +TEST_EVENTDEV_SETUP_PRIORITY = (1 <<1 ), +TEST_EVENTDEV_SETUP_DEQUEUE_TIMEOUT = (1 <<2 ), +TEST_EVENTDEV_SETUP_ATOMIC = (1 <<3 ) };static int _eventdev_setup (int mode) { -int i, ret; +int ret;struct rte_event_dev_config dev_conf;struct rte_event_dev_info info;const char *pool_name ="evdev_dpaa2_test_pool" ; +uint32_t queue_count, port_count, i; +uint8_t step; +struct rte_event_port_conf port_conf, *pport_conf;/* Create and destroy pool for each test case to make it standalone */ eventdev_test_mempool =rte_pktmbuf_pool_create (pool_name, -MAX_EVENTS , +1024 /*TOTAL_EVENTS*/ ,0 /*MBUF_CACHE_SIZE*/ ,0 , -512 ,/* Use very small mbufs */ +2048 +256 /*512*/ ,/* Use very small mbufs */ rte_socket_id ());if (!eventdev_test_mempool) {dpaa2_evdev_err ("ERROR creating mempool" ); -return -1 ; +return -ENOMEM ; } ret =rte_event_dev_info_get (evdev, &info);RTE_TEST_ASSERT_SUCCESS (ret,"Failed to get event dev info" );RTE_TEST_ASSERT (info.max_num_events >= (int32_t )MAX_EVENTS ,"ERROR max_num_events=%d < max_events=%d" , - info.max_num_events,MAX_EVENTS ); + info.max_num_events,MAX_EVENTS );devconf_set_default_sane_values (&dev_conf, &info); -if (mode ==TEST_EVENTDEV_SETUP_DEQUEUE_TIMEOUT ) +if (mode &TEST_EVENTDEV_SETUP_DEQUEUE_TIMEOUT ) dev_conf.event_dev_cfg |=RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT ; ret =rte_event_dev_configure (evdev, &dev_conf);RTE_TEST_ASSERT_SUCCESS (ret,"Failed to configure eventdev" ); -uint32_t queue_count;RTE_TEST_ASSERT_SUCCESS (rte_event_dev_attr_get (evdev, -RTE_EVENT_DEV_ATTR_QUEUE_COUNT , - &queue_count),"Queue count get failed" ); - -if (mode ==TEST_EVENTDEV_SETUP_PRIORITY ) { -if (queue_count >8 ) { -dpaa2_evdev_err ( -"test expects the unique priority per queue" ); -return -ENOTSUP ; +RTE_EVENT_DEV_ATTR_QUEUE_COUNT , &queue_count), +"Queue count get failed" ); + +if (mode &TEST_EVENTDEV_SETUP_PRIORITY ) { +if (!queue_count) { +dpaa2_evdev_err ("No queue available" ); +return -EINVAL ; }/* Configure event queues(0 to n) with * RTE_EVENT_DEV_PRIORITY_HIGHEST to * RTE_EVENT_DEV_PRIORITY_LOWEST */ -uint8_t step = (RTE_EVENT_DEV_PRIORITY_LOWEST +1 ) / - queue_count; -for (i =0 ; i < (int )queue_count; i++) { + step = (RTE_EVENT_DEV_PRIORITY_LOWEST +1 ) / queue_count; +for (i =0 ; i < queue_count; i++) {struct rte_event_queue_conf queue_conf; ret = rte_event_queue_default_conf_get(evdev, i,
@@ -170,29 +172,33 @@ _eventdev_setup(int mode) i); queue_conf.priority = i * step; ret =rte_event_queue_setup (evdev, i, &queue_conf); -RTE_TEST_ASSERT_SUCCESS (ret,"Failed to setup queue=%d" , - i); +RTE_TEST_ASSERT_SUCCESS (ret,"Failed to setup queue=%d" , i); } - }else {/* Configure event queues with default priority */ -for (i =0 ; i < (int )queue_count; i++) { +for (i =0 ; i < queue_count; i++) { ret =rte_event_queue_setup (evdev, i,NULL ); -RTE_TEST_ASSERT_SUCCESS (ret,"Failed to setup queue=%d" , - i); +RTE_TEST_ASSERT_SUCCESS (ret,"Failed to setup queue=%d" , i); } } +/* Configure event ports */ -uint32_t port_count;RTE_TEST_ASSERT_SUCCESS (rte_event_dev_attr_get (evdev, -RTE_EVENT_DEV_ATTR_PORT_COUNT , - &port_count),"Port count get failed" ); -for (i =0 ; i < (int )port_count; i++) { - ret =rte_event_port_setup (evdev, i,NULL ); +RTE_EVENT_DEV_ATTR_PORT_COUNT , &port_count), +"Port count get failed" ); +for (i =0 ; i < port_count; i++) { +if (mode &TEST_EVENTDEV_SETUP_ATOMIC ) { + pport_conf = &port_conf; +memset (pport_conf,0 ,sizeof (struct rte_event_port_conf )); + ret =rte_event_port_default_conf_get (evdev, i, pport_conf); +RTE_TEST_ASSERT_SUCCESS (ret, +"Failed to get default conf of port=%d" , i); + pport_conf->event_port_cfg =RTE_DPAA2_EVENT_PORT_CFG_ATOMIC ; + }else { + pport_conf =NULL ; + } + ret =rte_event_port_setup (evdev, i, pport_conf);RTE_TEST_ASSERT_SUCCESS (ret,"Failed to setup port=%d" , i); - ret =rte_event_port_link (evdev, i,NULL ,NULL ,0 ); -RTE_TEST_ASSERT (ret >=0 ,"Failed to link all queues port=%d" , - i); } ret =rte_event_dev_start (evdev);
@@ -207,6 +213,13 @@ eventdev_setup(void)return _eventdev_setup (TEST_EVENTDEV_SETUP_DEFAULT ); } +static int +eventdev_atomic_port_setup (void ) +{ +return _eventdev_setup (TEST_EVENTDEV_SETUP_DEFAULT | +TEST_EVENTDEV_SETUP_ATOMIC ); +} +static void eventdev_teardown (void ) {
@@ -216,9 +229,9 @@ eventdev_teardown(void)static void update_event_and_validation_attr (struct rte_mbuf *m,struct rte_event *ev, -uint32_t flow_id,uint8_t event_type, -uint8_t sub_event_type,uint8_t sched_type, -uint8_t queue,uint8_t port,uint8_t seq) +uint32_t flow_id,uint8_t event_type, +uint8_t sub_event_type,uint8_t sched_type, +uint8_t queue,uint8_t port,uint8_t seq) {struct event_attr *attr;
@@ -249,6 +262,7 @@ inject_events(uint32_t flow_id, uint8_t event_type, uint8_t sub_event_type, {struct rte_mbuf *m;unsigned int i; +uint16_t eq, err_count;for (i =0 ; i < events; i++) {struct rte_event ev = {.event =0 , .u64 =0 };
@@ -258,7 +272,16 @@ inject_events(uint32_t flow_id, uint8_t event_type, uint8_t sub_event_type,update_event_and_validation_attr (m, &ev, flow_id, event_type, sub_event_type, sched_type, queue, port, i); -rte_event_enqueue_burst (evdev, port, &ev,1 ); + err_count =0 ; +eq_again: + eq =rte_event_enqueue_burst (evdev, port, &ev,1 ); +if (eq !=1 ) { +dpaa2_evdev_err ("Failed, eq(%d) != 1" , eq); +if (err_count >10 ) +return -EBUSY ; + err_count++; + goto eq_again; + } }return 0 ; }
@@ -271,7 +294,7 @@ check_excess_events(uint8_t port)struct rte_event ev;/* Check for excess events, try for a few times and exit */ -for (i =0 ; i <32 ; i++) { +for (i =0 ; i <4 ; i++) { valid_event =rte_event_dequeue_burst (evdev, port, &ev,1 ,0 ); RTE_TEST_ASSERT_SUCCESS(valid_event,
@@ -285,27 +308,35 @@ static int generate_random_events(const unsigned int total_events) {struct rte_event_dev_info info; -unsigned int i; +uint32_t queue_count, i; +uint8_t queues[RTE_EVENT_MAX_QUEUES_PER_DEV ];int ret; -uint32_t queue_count;RTE_TEST_ASSERT_SUCCESS (rte_event_dev_attr_get (evdev, -RTE_EVENT_DEV_ATTR_QUEUE_COUNT , - &queue_count),"Queue count get failed" ); +RTE_EVENT_DEV_ATTR_QUEUE_COUNT , &queue_count), +"Queue count get failed" ); +if (queue_count >RTE_EVENT_MAX_QUEUES_PER_DEV ) + queue_count =RTE_EVENT_MAX_QUEUES_PER_DEV ; +for (i =0 ; i < queue_count; i++) + queues[i] = i; + + ret =rte_event_port_link (evdev,0 , queues,NULL , + queue_count); +RTE_TEST_ASSERT (ret >=0 ,"Failed to link %d queues port0" , + queue_count); ret =rte_event_dev_info_get (evdev, &info);RTE_TEST_ASSERT_SUCCESS (ret,"Failed to get event dev info" );for (i =0 ; i < total_events; i++) { - ret =inject_events ( -rte_rand () % info.max_event_queue_flows/*flow_id */ , + ret =inject_events (rte_rand () % info.max_event_queue_flows/*flow_id */ ,RTE_EVENT_TYPE_CPU /* event_type */ ,rte_rand () %256 /* sub_event_type */ ,rte_rand () % (RTE_SCHED_TYPE_PARALLEL +1 ), -rte_rand () % queue_count/* queue */ , +rte_rand () % queue_count,0 /* port */ ,1 /* events */ );if (ret) -return -1 ; +return ret; }return ret; }
@@ -339,7 +370,8 @@ typedef int (*validate_event_cb)(uint32_t index, uint8_t port, struct rte_event *ev);static int -consume_events (uint8_t port,const uint32_t total_events,validate_event_cb fn) +consume_events (uint8_t port,const uint32_t total_events, +uint32_t *dq_events,validate_event_cb fn) {int ret;uint16_t valid_event;
@@ -349,7 +381,7 @@ consume_events(uint8_t port, const uint32_t total_events, validate_event_cb fn)while (1 ) {if (++forward_progress_cnt >UINT16_MAX ) {dpaa2_evdev_err ("Detected deadlock" ); -return -1 ; +return -ETIMEDOUT ; } valid_event =rte_event_dequeue_burst (evdev, port, &ev,1 ,0 );
@@ -359,9 +391,9 @@ consume_events(uint8_t port, const uint32_t total_events, validate_event_cb fn) forward_progress_cnt =0 ; ret =validate_event (&ev);if (ret) -return -1 ; +return ret; -if (fn !=NULL ) { +if (fn) { ret =fn (index, port, &ev);RTE_TEST_ASSERT_SUCCESS (ret,"Failed to validate test specific event" );
@@ -374,6 +406,9 @@ consume_events(uint8_t port, const uint32_t total_events, validate_event_cb fn)break ; } +if (dq_events) + *dq_events = events; +return check_excess_events (port); }
@@ -394,18 +429,28 @@ static int test_simple_enqdeq(uint8_t sched_type) {int ret; +uint8_t queue =0 ; +uint32_t total_dq =0 ; + + ret =rte_event_port_link (evdev,0 , &queue,NULL ,1 ); +RTE_TEST_ASSERT (ret >=0 ,"Failed to link 1 queues port0" ); ret =inject_events (0 /*flow_id */ , -RTE_EVENT_TYPE_CPU /* event_type */ , -0 /* sub_event_type */ , - sched_type, -0 /* queue */ , -0 /* port */ , -MAX_EVENTS ); +RTE_EVENT_TYPE_CPU /* event_type */ , +0 /* sub_event_type */ , + sched_type, +0 /* queue */ , +0 /* port */ , +MAX_EVENTS );if (ret) -return -1 ; +return ret; -return consume_events (0 /* port */ ,MAX_EVENTS , validate_simple_enqdeq); + ret =consume_events (0 /* port */ ,MAX_EVENTS , &total_dq, validate_simple_enqdeq); +RTE_TEST_ASSERT (!ret,"Failed to consume event from port0" ); +RTE_TEST_ASSERT (total_dq ==MAX_EVENTS , +"total_dq(%d) != MAX_EVENTS(8)" , total_dq); + +return ret; } static int
@@ -429,12 +474,18 @@ static inttest_multi_queue_enq_single_port_deq (void) {int ret; +uint32_t dq_events; ret =generate_random_events (MAX_EVENTS );if (ret) -return -1 ; +return ret; + + ret =consume_events (0 /* port */ ,MAX_EVENTS , &dq_events,NULL ); +RTE_TEST_ASSERT (!ret,"Failed to consume event from port0" ); +RTE_TEST_ASSERT (dq_events ==MAX_EVENTS , +"dq_events(%d) != MAX_EVENTS(8)" , dq_events); -return consume_events (0 /* port */ ,MAX_EVENTS ,NULL ); +return ret; } static int
@@ -479,8 +530,7 @@ wait_workers_to_join(int lcore, const __rte_atomic uint32_t *count) print_cycles = new_cycles; }if (new_cycles - cycles >rte_get_timer_hz () *10 ) { -dpaa2_evdev_info ( -"%s: No schedules for seconds, deadlock (%u)" , +dpaa2_evdev_info ("%s: No schedules for seconds, deadlock (%d)" , __func__,rte_atomic_load_explicit (count, rte_memory_order_relaxed));rte_event_dev_dump (evdev, stdout);
@@ -495,8 +545,8 @@ wait_workers_to_join(int lcore, const __rte_atomic uint32_t *count)static int launch_workers_and_wait (int (*main_worker)(void *), -int (*workers)(void *),uint32_t total_events, -uint8_t nb_workers,uint8_t sched_type) +int (*workers)(void *),uint32_t total_events, +uint8_t nb_workers,uint8_t sched_type) {uint8_t port =0 ;int w_lcore;
@@ -513,13 +563,13 @@ launch_workers_and_wait(int (*main_worker)(void *), param =malloc (sizeof (struct test_core_param ) * nb_workers);if (!param) -return -1 ; +return -ENOMEM ; ret =rte_event_dequeue_timeout_ticks (evdev,rte_rand () %10000000 /* 10ms */ , &dequeue_tmo_ticks);if (ret) {free (param); -return -1 ; +return ret; } param[0 ].total_events = &atomic_total_events;
@@ -563,22 +613,22 @@ test_multi_queue_enq_multi_port_deq(void) ret =generate_random_events (total_events);if (ret) -return -1 ; +return ret;RTE_TEST_ASSERT_SUCCESS (rte_event_dev_attr_get (evdev, -RTE_EVENT_DEV_ATTR_PORT_COUNT , - &nr_ports),"Port count get failed" ); +RTE_EVENT_DEV_ATTR_PORT_COUNT , &nr_ports), +"Port count get failed" ); nr_ports =RTE_MIN (nr_ports,rte_lcore_count () -1 );if (!nr_ports) {dpaa2_evdev_err ("%s: Not enough ports=%d or workers=%d" , - __func__, nr_ports,rte_lcore_count () -1 ); -return 0 ; + __func__, nr_ports,rte_lcore_count () -1 ); +return -EINVAL ; }return launch_workers_and_wait (worker_multi_port_fn, - worker_multi_port_fn, total_events, - nr_ports,0xff /* invalid */ ); + worker_multi_port_fn, total_events, + nr_ports,0xff /* invalid */ ); } static
@@ -589,7 +639,6 @@ void flush(uint8_t dev_id, struct rte_event event, void *arg)RTE_SET_USED (dev_id);if (event.event_type ==RTE_EVENT_TYPE_CPU ) *count = *count +1 ; - } static int
@@ -610,8 +659,8 @@ test_dev_stop_flush(void)if (ret)return -3 ;RTE_TEST_ASSERT_EQUAL (total_events, count, -"count mismatch total_events=%d count=%d" , - total_events, count); +"count mismatch total_events=%d count=%d" , + total_events, count);return 0 ; }
@@ -621,8 +670,8 @@ validate_queue_to_port_single_link(uint32_t index, uint8_t port, {RTE_SET_USED (index);RTE_TEST_ASSERT_EQUAL (port, ev->queue_id, -"queue mismatch enq=%d deq =%d" , - port, ev->queue_id); +"queue mismatch enq=%d deq =%d" , + port, ev->queue_id);return 0 ; }
@@ -633,39 +682,32 @@ validate_queue_to_port_single_link(uint32_t index, uint8_t port,static int test_queue_to_port_single_link (void ) { -int i, nr_links, ret; - -uint32_t port_count; +int ret; +uint8_t queue; +uint32_t port_count, queue_count, nr_links, total_events, i; +uint32_t dq_events =0 , total_dqs =0 ;RTE_TEST_ASSERT_SUCCESS (rte_event_dev_attr_get (evdev, -RTE_EVENT_DEV_ATTR_PORT_COUNT , - &port_count),"Port count get failed" ); - -/* Unlink all connections that created in eventdev_setup */ -for (i =0 ; i < (int )port_count; i++) { - ret =rte_event_port_unlink (evdev, i,NULL ,0 ); -RTE_TEST_ASSERT (ret >=0 , -"Failed to unlink all queues port=%d" , i); - } - -uint32_t queue_count; +RTE_EVENT_DEV_ATTR_PORT_COUNT , &port_count), +"Port count get failed" );RTE_TEST_ASSERT_SUCCESS (rte_event_dev_attr_get (evdev, -RTE_EVENT_DEV_ATTR_QUEUE_COUNT , - &queue_count),"Queue count get failed" ); +RTE_EVENT_DEV_ATTR_QUEUE_COUNT , &queue_count), +"Queue count get failed" ); nr_links =RTE_MIN (port_count, queue_count); -const unsigned int total_events =MAX_EVENTS / nr_links; + total_events =MAX_EVENTS / nr_links; -/* Link queue x to port x and inject events to queue x through port x */ for (i =0 ; i < nr_links; i++) { -uint8_t queue = (uint8_t )i; - + queue = i; ret =rte_event_port_link (evdev, i, &queue,NULL ,1 );RTE_TEST_ASSERT (ret ==1 ,"Failed to link queue to port %d" , i); + } - ret = inject_events( - 0x100 /*flow_id */, +/* Link queue x to port x and inject events to queue x through port x */ +for (i =0 ; i < nr_links; i++) { + queue = i; + ret = inject_events(0x100 /*flow_id */, RTE_EVENT_TYPE_CPU /* event_type */, rte_rand() % 256 /* sub_event_type */, rte_rand() % (RTE_SCHED_TYPE_PARALLEL + 1),
@@ -673,16 +715,21 @@ test_queue_to_port_single_link(void) i/* port */ , total_events /* events */);if (ret) -return -1 ; +return ret; }/* Verify the events generated from correct queue */ for (i =0 ; i < nr_links; i++) { ret =consume_events (i/* port */ , total_events, + &dq_events, validate_queue_to_port_single_link);if (ret) -return -1 ; +return ret; + total_dqs += dq_events; } +RTE_TEST_ASSERT (total_dqs == total_events * nr_links, +"total_dqs(%d) != total_events(%d) * nr_links(%d)" , + total_dqs, total_events, nr_links);return 0 ; }
@@ -693,8 +740,8 @@ validate_queue_to_port_multi_link(uint32_t index, uint8_t port, {RTE_SET_USED (index);RTE_TEST_ASSERT_EQUAL (port, (ev->queue_id &0x1 ), -"queue mismatch enq=%d deq =%d" , - port, ev->queue_id); +"queue mismatch enq=%d deq =%d" , + port, ev->queue_id);return 0 ; }
@@ -705,46 +752,48 @@ validate_queue_to_port_multi_link(uint32_t index, uint8_t port,static int test_queue_to_port_multi_link (void ) { -int ret, port0_events =0 , port1_events =0 ; +int ret;uint8_t queue, port; -uint32_t nr_queues =0 ; -uint32_t nr_ports =0 ; +uint32_t nr_queues =0 , total_events, even_idx =0 , odd_idx =0 ; +uint32_t nr_ports =0 , dq_events, port0_events =0 , port1_events =0 ; +uint8_t even_queues[RTE_EVENT_MAX_QUEUES_PER_DEV ]; +uint8_t odd_queues[RTE_EVENT_MAX_QUEUES_PER_DEV ];RTE_TEST_ASSERT_SUCCESS (rte_event_dev_attr_get (evdev, -RTE_EVENT_DEV_ATTR_QUEUE_COUNT , - &nr_queues),"Queue count get failed" ); - +RTE_EVENT_DEV_ATTR_QUEUE_COUNT , &nr_queues), +"Queue count get failed" );RTE_TEST_ASSERT_SUCCESS (rte_event_dev_attr_get (evdev, -RTE_EVENT_DEV_ATTR_QUEUE_COUNT , - &nr_queues),"Queue count get failed" ); -RTE_TEST_ASSERT_SUCCESS (rte_event_dev_attr_get (evdev, -RTE_EVENT_DEV_ATTR_PORT_COUNT , - &nr_ports),"Port count get failed" ); +RTE_EVENT_DEV_ATTR_PORT_COUNT , &nr_ports), +"Port count get failed" );if (nr_ports <2 ) {dpaa2_evdev_err ("%s: Not enough ports to test ports=%d" , - __func__, nr_ports); -return 0 ; + __func__, nr_ports); +return -ENODEV ; } -/* Unlink all connections that created in eventdev_setup */ -for (port =0 ; port < nr_ports; port++) { - ret =rte_event_port_unlink (evdev, port,NULL ,0 ); -RTE_TEST_ASSERT (ret >=0 ,"Failed to unlink all queues port=%d" , - port); +for (queue =0 ; queue < nr_queues; queue++) { +if (queue &0x1 ) { + odd_queues[odd_idx] = queue; + odd_idx++; + }else { + even_queues[even_idx] = queue; + even_idx++; + } } -const unsigned int total_events =MAX_EVENTS / nr_queues; + ret =rte_event_port_link (evdev,0 , even_queues,NULL , even_idx); +RTE_TEST_ASSERT (ret >=0 ,"Failed to link queues port0" ); + ret =rte_event_port_link (evdev,1 , odd_queues,NULL , odd_idx); +RTE_TEST_ASSERT (ret >=0 ,"Failed to link queues port1" ); + + total_events =MAX_EVENTS / nr_queues;/* Link all even number of queues to port0 and odd numbers to port 1*/ for (queue =0 ; queue < nr_queues; queue++) { port = queue &0x1 ; - ret =rte_event_port_link (evdev, port, &queue,NULL ,1 ); -RTE_TEST_ASSERT (ret ==1 ,"Failed to link queue=%d to port=%d" , - queue, port); - ret = inject_events( - 0x100 /*flow_id */, + ret = inject_events(0x100 /*flow_id */, RTE_EVENT_TYPE_CPU /* event_type */, rte_rand() % 256 /* sub_event_type */, rte_rand() % (RTE_SCHED_TYPE_PARALLEL + 1),
@@ -752,7 +801,7 @@ test_queue_to_port_multi_link(void) port/* port */ , total_events /* events */);if (ret) -return -1 ; +return ret;if (port ==0 ) port0_events += total_events;
@@ -760,14 +809,23 @@ test_queue_to_port_multi_link(void) port1_events += total_events; } - ret =consume_events (0 /* port */ , port0_events, - validate_queue_to_port_multi_link); + dq_events =0 ; + ret =consume_events (0 /* port */ , port0_events, &dq_events, + validate_queue_to_port_multi_link);if (ret) -return -1 ; - ret =consume_events (1 /* port */ , port1_events, - validate_queue_to_port_multi_link); +return ret; +RTE_TEST_ASSERT (dq_events == port0_events, +"dq_events(%d) != port0_events(%d)" , + dq_events, port0_events); + + dq_events =0 ; + ret =consume_events (1 /* port */ , port1_events, &dq_events, + validate_queue_to_port_multi_link);if (ret) -return -1 ; +return ret; +RTE_TEST_ASSERT (dq_events == port1_events, +"dq_events(%d) != port1_events(%d)" , + dq_events, port0_events);return 0 ; }
@@ -805,7 +863,7 @@ test_eventdev_dpaa2(void) test_multi_queue_enq_single_port_deq);DPAA2_TEST_RUN (eventdev_setup, eventdev_teardown, test_dev_stop_flush); -DPAA2_TEST_RUN (eventdev_setup, eventdev_teardown, +DPAA2_TEST_RUN (eventdev_atomic_port_setup, eventdev_teardown, test_multi_queue_enq_multi_port_deq);DPAA2_TEST_RUN (eventdev_setup, eventdev_teardown, test_queue_to_port_single_link);
Signature · 1 line
2.43.0
PATCH 34/65 event/dpaa2: add DPCON based standalone Rx scheduler
In reply to Prashant GuptaFrom: Jun Yang <[email protected]>
Add a standalone DPCON-based Rx scheduler API that lets applications aggregate multiple ethdev Rx queues onto a single DPCON channel and receive packets directly, without going through the eventdev framework.
The new API is exposed as experimental in rte_pmd_dpaa2.h:
- rte_dpaa2_scheduler_init(): allocate a DPCON device and select the
receive path (plain or prefetch, chosen by the DPAA2_SCHEDULE_RX_PREFETCH env).
- rte_dpaa2_scheduler_add(): attach an ethdev Rx queue to the DPCON
channel with a given priority.
- rte_dpaa2_scheduler_start(): enable the DPCON channel. - rte_dpaa2_scheduler_rx(): dequeue packets from the channel. - rte_dpaa2_scheduler_destroy(): disable the DPCON channel.
- rte_dpaa2_scheduler_max_prio(): Get the maximum supported priority. The priority specified in rte_dpaa2_scheduler_add() must not exceed this value.
Two receive implementations are provided: a plain single-buffer pull (dpaa2_scheduler_recv) and a double-buffered prefetch variant (dpaa2_scheduler_prefetch_recv) that overlaps the next pull with mbuf extraction.
To support this, the fslmc bus exposes internal helpers rte_dpaa2_dpcon_start()/stop() to enable/disable a DPCON, extends struct dpaa2_dpcon_dev with per-lcore dequeue storage and an rx_schedule callback, and caches the dequeue storage IOVA in
struct queue_storage_info_t to avoid repeated address translation on the receive path.
--- drivers/bus/fslmc/portal/dpaa2_hw_dpcon.c | 25 +- drivers/bus/fslmc/portal/dpaa2_hw_dpio.c | 2 + drivers/bus/fslmc/portal/dpaa2_hw_pvt.h | 5 + drivers/event/dpaa2/dpaa2_scheduler.c | 458 ++++++++++++++++++++++ drivers/event/dpaa2/meson.build | 3 +- drivers/net/dpaa2/dpaa2_ethdev.c | 4 +- drivers/net/dpaa2/dpaa2_ethdev.h | 38 ++ drivers/net/dpaa2/dpaa2_rxtx.c | 21 + drivers/net/dpaa2/rte_pmd_dpaa2.h | 28 ++ 9 files changed, 579 insertions(+), 5 deletions(-) create mode 100644 drivers/event/dpaa2/dpaa2_scheduler.c
drivers/bus/fslmc/portal/dpaa2_hw_dpcon.c +24 -1
@@ -1,6 +1,6 @@/* SPDX-License-Identifier: BSD-3-Clause * -* Copyright 2017, 2020, 2023 NXP +* Copyright 2017, 2020, 2023, 2026 NXP * */
@@ -121,6 +121,29 @@ void rte_dpaa2_free_dpcon_dev(struct dpaa2_dpcon_dev *dpcon) } } +RTE_EXPORT_INTERNAL_SYMBOL (rte_dpaa2_dpcon_start) +int32_t rte_dpaa2_dpcon_start(struct dpaa2_dpcon_dev *dpcon_dev) +{ +int32_t ret; + + ret =dpcon_enable (&dpcon_dev->dpcon,CMD_PRI_LOW , dpcon_dev->token); +if (ret) +DPAA2_BUS_ERR ("Failed(%d) to enable dpcon.%d" , ret, dpcon_dev->dpcon_id); + +return ret; +} + +RTE_EXPORT_INTERNAL_SYMBOL (rte_dpaa2_dpcon_stop) +int32_t rte_dpaa2_dpcon_stop(struct dpaa2_dpcon_dev *dpcon_dev) +{ +int32_t ret; + + ret =dpcon_disable (&dpcon_dev->dpcon,CMD_PRI_LOW , dpcon_dev->token); +if (ret) +DPAA2_BUS_ERR ("Failed(%d) to disable dpcon.%d" , ret, dpcon_dev->dpcon_id); + +return ret; +}static void rte_dpaa2_close_dpcon_device (int object_id)
drivers/bus/fslmc/portal/dpaa2_hw_dpio.c +2 -0
@@ -692,6 +692,8 @@ dpaa2_alloc_dq_storage(struct queue_storage_info_t *q_storage) RTE_CACHE_LINE_SIZE);if (!q_storage->dq_storage[i]) goto fail; + q_storage->iova_dq_storage[i] = +DPAA2_VADDR_TO_IOVA (q_storage->dq_storage[i]); }return 0 ; fail:
drivers/bus/fslmc/portal/dpaa2_hw_pvt.h +5 -0
@@ -152,6 +152,7 @@ struct dpaa2_dpbp_dev {struct queue_storage_info_t {struct qbman_result *dq_storage[NUM_DQS_PER_QUEUE ]; +uint64_t iova_dq_storage[NUM_DQS_PER_QUEUE ];struct qbman_result *active_dqs;uint8_t active_dpio_id;uint8_t toggle;
@@ -297,6 +298,10 @@ __rte_internalstruct dpaa2_dpcon_dev *rte_dpaa2_alloc_dpcon_dev (void );__rte_internal void rte_dpaa2_free_dpcon_dev(struct dpaa2_dpcon_dev *dpcon); +__rte_internal +int32_t rte_dpaa2_dpcon_start(struct dpaa2_dpcon_dev *dpcon_dev); +__rte_internal +int32_t rte_dpaa2_dpcon_stop(struct dpaa2_dpcon_dev *dpcon_dev);/* Refer to Table 7-3 in SEC BG */ #define QBMAN_FLE_WORD4_FMT_SBF 0x0/* Single buffer frame */
drivers/event/dpaa2/dpaa2_scheduler.c new file +458 -0
458 lines not on this page · raw message
drivers/event/dpaa2/meson.build +2 -1
@@ -1,5 +1,5 @@ # SPDX-License-Identifier: BSD-3-Clause -# Copyright 2018 NXP +# Copyright 2018, 2026 NXP if not is_linux build = false
@@ -9,6 +9,7 @@ deps += ['bus_vdev', 'net_dpaa2', 'crypto_dpaa2_sec'] sources = files( 'dpaa2_eventdev.c', 'dpaa2_eventdev_selftest.c', + 'dpaa2_scheduler.c' ) includes += include_directories('../../crypto/dpaa2_sec/')
drivers/net/dpaa2/dpaa2_ethdev.c +1 -3
@@ -3332,14 +3332,12 @@ int dpaa2_eth_eventq_attach(const struct rte_eth_dev *dev,else return -EINVAL ; - priority = (RTE_EVENT_DEV_PRIORITY_LOWEST / queue_conf->ev.priority) * - (dpcon->num_priorities -1 ); -if (!cfg) {DPAA2_PMD_ERR ("%s: %s-rxq%d was not setup yet!" , __func__, dev->data->name, eth_rx_queue_id);return -EINVAL ; } + priority =dpaa2_eth_eventq_prio_ev_to_dpcon (dpcon, queue_conf); options =DPNI_QUEUE_OPT_DEST ; cfg->destination.type =DPNI_DEST_DPCON ; cfg->destination.id = dpcon->dpcon_id;
drivers/net/dpaa2/dpaa2_ethdev.h +38 -0
@@ -908,6 +908,33 @@ dpaa2_dpkg_insert_extract(struct dpkg_profile_cfg *kg_cfg, kg_cfg->num_extracts++; } +static inline void +dpaa2_eth_eventq_prio_dpcon_to_ev (uint8_t priority, +struct dpaa2_dpcon_dev *dpcon, +struct rte_event_eth_rx_adapter_queue_conf *queue_conf) +{ +uint8_t priority_step; +uint32_t priority_ev; + + priority_step = (RTE_EVENT_DEV_PRIORITY_LOWEST +1 - +RTE_EVENT_DEV_PRIORITY_HIGHEST ) / dpcon->num_priorities; + priority_ev = priority * priority_step; +if (priority_ev >RTE_EVENT_DEV_PRIORITY_LOWEST ) + priority_ev =RTE_EVENT_DEV_PRIORITY_LOWEST ; + queue_conf->ev.priority = priority_ev; +} + +static inline uint8_t +dpaa2_eth_eventq_prio_ev_to_dpcon (struct dpaa2_dpcon_dev *dpcon, +const struct rte_event_eth_rx_adapter_queue_conf *queue_conf) +{ +uint8_t priority_step; + + priority_step = (RTE_EVENT_DEV_PRIORITY_LOWEST +1 - +RTE_EVENT_DEV_PRIORITY_HIGHEST ) / dpcon->num_priorities; +return queue_conf->ev.priority / priority_step; +} + __rte_internal int dpaa2_eth_eventq_attach(const struct rte_eth_dev *dev, int eth_rx_queue_id,
@@ -971,5 +998,16 @@ int dpaa2_timesync_read_tx_timestamp(struct rte_eth_dev *dev,int dpaa2_dev_recycle_config (struct rte_eth_dev *eth_dev);int dpaa2_dev_recycle_deconfig (struct rte_eth_dev *eth_dev); +__rte_internal +struct rte_mbuf * +dpaa2_eth_fd_to_mbuf_export (struct dpaa2_dev_priv *priv,const struct qbman_fd *fd); +__rte_internal +struct rte_mbuf * +dpaa2_eth_sg_fd_to_mbuf_export (struct dpaa2_dev_priv *priv,const struct qbman_fd *fd); +__rte_internal +void +dpaa2_dev_rx_mbuf_flc_offload_export (struct rte_mbuf *m, +const struct qbman_fd *fd); +int dpaa2_mtr_ops_get (struct rte_eth_dev *dev,void *ops);#endif /* _DPAA2_ETHDEV_H */
drivers/net/dpaa2/dpaa2_rxtx.c +21 -0
@@ -165,6 +165,13 @@ dpaa2_dev_rx_mbuf_flc_offload(struct rte_mbuf *m, } } +RTE_EXPORT_INTERNAL_SYMBOL (dpaa2_dev_rx_mbuf_flc_offload_export) +void dpaa2_dev_rx_mbuf_flc_offload_export(struct rte_mbuf *m, +const struct qbman_fd *fd) +{ +dpaa2_dev_rx_mbuf_flc_offload (m, fd); +} +static inline void dpaa2_dev_rx_read_timestamp (struct dpaa2_dev_priv *priv,struct rte_mbuf *m)
@@ -479,6 +486,13 @@ dpaa2_eth_sg_fd_to_mbuf(struct dpaa2_dev_priv *priv, const struct qbman_fd *fd)return (void *)first_seg; } +RTE_EXPORT_INTERNAL_SYMBOL (dpaa2_eth_sg_fd_to_mbuf_export) +struct rte_mbuf * +dpaa2_eth_sg_fd_to_mbuf_export (struct dpaa2_dev_priv *priv,const struct qbman_fd *fd) +{ +return dpaa2_eth_sg_fd_to_mbuf (priv, fd); +} + static inline struct rte_mbuf *__rte_hotdpaa2_eth_fd_to_mbuf (struct dpaa2_dev_priv *priv,const struct qbman_fd *fd) {
@@ -534,6 +548,13 @@ dpaa2_eth_fd_to_mbuf(struct dpaa2_dev_priv *priv, const struct qbman_fd *fd)return mbuf; } +RTE_EXPORT_INTERNAL_SYMBOL (dpaa2_eth_fd_to_mbuf_export) +struct rte_mbuf * +dpaa2_eth_fd_to_mbuf_export (struct dpaa2_dev_priv *priv,const struct qbman_fd *fd) +{ +return dpaa2_eth_fd_to_mbuf (priv, fd); +} +static void dpaa2_dev_tx_enable_tstamp (struct qbman_fd *fd) {struct dpaa2_faead *fd_faead;
drivers/net/dpaa2/rte_pmd_dpaa2.h +28 -0
@@ -129,6 +129,34 @@ int rte_pmd_dpaa2_rx_get_offset(uint16_t port_id, struct rte_mbuf *m, uint8_t *l3_off, uint8_t *l4_off, uint8_t *l5_off); +__rte_experimental +void * +rte_dpaa2_scheduler_init (void ); +__rte_experimental +int +rte_dpaa2_scheduler_start (void *scheduler_handle); +__rte_experimental +int +rte_dpaa2_scheduler_destroy (void *scheduler_handle); +__rte_experimental +uint16_t +rte_dpaa2_scheduler_max_prio (void *scheduler_handle); +__rte_experimental +int +rte_dpaa2_scheduler_add (void *scheduler_handle, +uint16_t port_id,uint16_t rxq_id,uint8_t priority); + +/* rte_dpaa2_scheduler_rx()- DPCON scheduler receive function +* @scheduler_handle: DPCON scheduler handle +* @mbuf: Packet mbuf +* @nb_pkts: Number of packets to be received. +* Return Number of received packet. +*/ +__rte_experimental +uint16_t +rte_dpaa2_scheduler_rx (void *scheduler_handle,struct rte_mbuf **mbuf, +uint16_t nb_pkts); +#define RTE_DPAA2_EVENT_PORT_CFG_ATOMIC RTE_BIT32(31)/** RTE_DPAA2_MIX_GROUP_FLOW has same behavio as RTE_DPAA2_FLAT_GROUP_FLOW*/
Signature · 1 line
2.43.0