add hairpin queue support
cover add hairpin queue support
From: Beilei Xing <[email protected]>
This patchset adds hairpin queue support.
It depends on the following two patch set:
https://patches.dpdk.org/project/dpdk/cover/[email protected]/
https://patches.dpdk.org/project/dpdk/cover/[email protected]/
Beilei Xing (10):
net/cpfl: refine structures
net/cpfl: support hairpin queue capbility get common/idpf: support queue groups add/delete net/cpfl: add haipin queue group during vpotr init net/cpfl: support hairpin queue setup and release net/cpfl: support hairpin queue configuration net/cpfl: support hairpin queue start/stop net/cpfl: enable write back based on ITR expire net/cpfl: support peer ports get
net/cpfl: support hairpin bind/unbind
drivers/common/idpf/idpf_common_device.c | 75 ++ drivers/common/idpf/idpf_common_device.h | 4 + drivers/common/idpf/idpf_common_virtchnl.c | 138 +++- drivers/common/idpf/idpf_common_virtchnl.h | 18 + drivers/common/idpf/version.map | 6 + drivers/net/cpfl/cpfl_ethdev.c | 588 +++++++++++++-- drivers/net/cpfl/cpfl_ethdev.h | 33 +- drivers/net/cpfl/cpfl_rxtx.c | 807 +++++++++++++++++++-- drivers/net/cpfl/cpfl_rxtx.h | 67 ++ drivers/net/cpfl/cpfl_rxtx_vec_common.h | 21 +- 10 files changed, 1638 insertions(+), 119 deletions(-)
Signature · 1 line
2.26.2
PATCH 1/10 net/cpfl: refine structures
From: Beilei Xing <[email protected]>
This patch refines some structures to support hairpin queue, cpfl_rx_queue/cpfl_tx_queue/cpfl_vport.
--- drivers/net/cpfl/cpfl_ethdev.c | 85 +++++++----- drivers/net/cpfl/cpfl_ethdev.h | 6 +- drivers/net/cpfl/cpfl_rxtx.c | 175 +++++++++++++++++------- drivers/net/cpfl/cpfl_rxtx.h | 8 ++ drivers/net/cpfl/cpfl_rxtx_vec_common.h | 17 +-- 5 files changed, 196 insertions(+), 95 deletions(-)
drivers/net/cpfl/cpfl_ethdev.c +49 -36
@@ -124,7 +124,8 @@ static int cpfl_dev_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complete) { - struct idpf_vport *vport = dev->data->dev_private; + struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;struct rte_eth_link new_link;unsigned int i;
@@ -156,7 +157,8 @@ cpfl_dev_link_update(struct rte_eth_dev *dev,static int cpfl_dev_info_get (struct rte_eth_dev *dev,struct rte_eth_dev_info *dev_info) { -struct idpf_vport *vport = dev->data->dev_private; +struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;struct idpf_adapter *base = vport->adapter; dev_info->max_rx_queues = base->caps.max_rx_q;
@@ -216,7 +218,8 @@ cpfl_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)static int cpfl_dev_mtu_set (struct rte_eth_dev *dev,uint16_t mtu) { -struct idpf_vport *vport = dev->data->dev_private; +struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;/* mtu setting is forbidden if port is start */ if (dev->data->dev_started) {
@@ -256,12 +259,12 @@ static uint64_t cpfl_get_mbuf_alloc_failed_stats(struct rte_eth_dev *dev) {uint64_t mbuf_alloc_failed =0 ; -struct idpf_rx_queue *rxq; +struct cpfl_rx_queue *cpfl_rxq;int i =0 ;for (i =0 ; i < dev->data->nb_rx_queues; i++) { - rxq = dev->data->rx_queues[i]; - mbuf_alloc_failed +=__atomic_load_n (&rxq->rx_stats.mbuf_alloc_failed, + cpfl_rxq = dev->data->rx_queues[i]; + mbuf_alloc_failed +=__atomic_load_n (&cpfl_rxq->base.rx_stats.mbuf_alloc_failed, __ATOMIC_RELAXED); }
@@ -271,8 +274,8 @@ cpfl_get_mbuf_alloc_failed_stats(struct rte_eth_dev *dev)static int cpfl_dev_stats_get (struct rte_eth_dev *dev,struct rte_eth_stats *stats) { -struct idpf_vport *vport = - (struct idpf_vport *)dev->data->dev_private; +struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;struct virtchnl2_vport_stats *pstats =NULL ;int ret;
@@ -305,20 +308,20 @@ cpfl_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)static void cpfl_reset_mbuf_alloc_failed_stats (struct rte_eth_dev *dev) { -struct idpf_rx_queue *rxq; +struct cpfl_rx_queue *cpfl_rxq;int i;for (i =0 ; i < dev->data->nb_rx_queues; i++) { - rxq = dev->data->rx_queues[i]; -__atomic_store_n (&rxq->rx_stats.mbuf_alloc_failed,0 , __ATOMIC_RELAXED); + cpfl_rxq = dev->data->rx_queues[i]; +__atomic_store_n (&cpfl_rxq->base.rx_stats.mbuf_alloc_failed,0 , __ATOMIC_RELAXED); } }static int cpfl_dev_stats_reset (struct rte_eth_dev *dev) { -struct idpf_vport *vport = - (struct idpf_vport *)dev->data->dev_private; +struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;struct virtchnl2_vport_stats *pstats =NULL ;int ret;
@@ -343,8 +346,8 @@ static int cpfl_dev_xstats_reset(struct rte_eth_dev *dev)static int cpfl_dev_xstats_get (struct rte_eth_dev *dev,struct rte_eth_xstat *xstats,unsigned int n) { -struct idpf_vport *vport = - (struct idpf_vport *)dev->data->dev_private; +struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;struct virtchnl2_vport_stats *pstats =NULL ;unsigned int i;int ret;
@@ -459,7 +462,8 @@ cpfl_rss_reta_update(struct rte_eth_dev *dev, struct rte_eth_rss_reta_entry64 *reta_conf, uint16_t reta_size) { -struct idpf_vport *vport = dev->data->dev_private; +struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;struct idpf_adapter *base = vport->adapter;uint16_t idx, shift;int ret =0 ;
@@ -498,7 +502,8 @@ cpfl_rss_reta_query(struct rte_eth_dev *dev, struct rte_eth_rss_reta_entry64 *reta_conf, uint16_t reta_size) { -struct idpf_vport *vport = dev->data->dev_private; +struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;struct idpf_adapter *base = vport->adapter;uint16_t idx, shift;int ret =0 ;
@@ -536,7 +541,8 @@ static int cpfl_rss_hash_update(struct rte_eth_dev *dev, struct rte_eth_rss_conf *rss_conf) { - struct idpf_vport *vport = dev->data->dev_private; + struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;struct idpf_adapter *base = vport->adapter;int ret =0 ;
@@ -601,7 +607,8 @@ static int cpfl_rss_hash_conf_get(struct rte_eth_dev *dev, struct rte_eth_rss_conf *rss_conf) { - struct idpf_vport *vport = dev->data->dev_private; + struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;struct idpf_adapter *base = vport->adapter;int ret =0 ;
@@ -638,7 +645,8 @@ cpfl_rss_hash_conf_get(struct rte_eth_dev *dev,static int cpfl_dev_configure (struct rte_eth_dev *dev) { -struct idpf_vport *vport = dev->data->dev_private; +struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;struct rte_eth_conf *conf = &dev->data->dev_conf;struct idpf_adapter *base = vport->adapter;int ret;
@@ -710,7 +718,8 @@ cpfl_dev_configure(struct rte_eth_dev *dev)static int cpfl_config_rx_queues_irqs (struct rte_eth_dev *dev) { -struct idpf_vport *vport = dev->data->dev_private; +struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;uint16_t nb_rx_queues = dev->data->nb_rx_queues;return idpf_vport_irq_map_config (vport, nb_rx_queues);
@@ -719,14 +728,14 @@ cpfl_config_rx_queues_irqs(struct rte_eth_dev *dev)static int cpfl_start_queues (struct rte_eth_dev *dev) { -struct idpf_rx_queue *rxq; -struct idpf_tx_queue *txq; +struct cpfl_rx_queue *cpfl_rxq; +struct cpfl_tx_queue *cpfl_txq;int err =0 ;int i;for (i =0 ; i < dev->data->nb_tx_queues; i++) { - txq = dev->data->tx_queues[i]; -if (txq ==NULL || txq->tx_deferred_start) + cpfl_txq = dev->data->tx_queues[i]; +if (cpfl_txq ==NULL || cpfl_txq->base.tx_deferred_start)continue ; err =cpfl_tx_queue_start (dev, i);if (err !=0 ) {
@@ -736,8 +745,8 @@ cpfl_start_queues(struct rte_eth_dev *dev) }for (i =0 ; i < dev->data->nb_rx_queues; i++) { - rxq = dev->data->rx_queues[i]; -if (rxq ==NULL || rxq->rx_deferred_start) + cpfl_rxq = dev->data->rx_queues[i]; +if (cpfl_rxq ==NULL || cpfl_rxq->base.rx_deferred_start)continue ; err =cpfl_rx_queue_start (dev, i);if (err !=0 ) {
@@ -752,7 +761,8 @@ cpfl_start_queues(struct rte_eth_dev *dev)static int cpfl_dev_start (struct rte_eth_dev *dev) { -struct idpf_vport *vport = dev->data->dev_private; +struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;struct idpf_adapter *base = vport->adapter;struct cpfl_adapter_ext *adapter =CPFL_ADAPTER_TO_EXT (base);uint16_t num_allocated_vectors = base->caps.num_allocated_vectors;
@@ -815,7 +825,8 @@ cpfl_dev_start(struct rte_eth_dev *dev)static int cpfl_dev_stop (struct rte_eth_dev *dev) { -struct idpf_vport *vport = dev->data->dev_private; +struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;if (vport->stopped ==1 )return 0 ;
@@ -836,7 +847,8 @@ cpfl_dev_stop(struct rte_eth_dev *dev)static int cpfl_dev_close (struct rte_eth_dev *dev) { -struct idpf_vport *vport = dev->data->dev_private; +struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;struct cpfl_adapter_ext *adapter =CPFL_ADAPTER_TO_EXT (vport->adapter);cpfl_dev_stop (dev);
@@ -846,7 +858,7 @@ cpfl_dev_close(struct rte_eth_dev *dev) adapter->cur_vport_nb--; dev->data->dev_private =NULL ; adapter->vports[vport->sw_idx] =NULL ; -rte_free (vport); +rte_free (cpfl_vport);return 0 ; }
@@ -1051,7 +1063,7 @@ cpfl_find_vport(struct cpfl_adapter_ext *adapter, uint32_t vport_id)int i;for (i =0 ; i < adapter->cur_vport_nb; i++) { - vport = adapter->vports[i]; + vport = &adapter->vports[i]->base;if (vport->vport_id != vport_id)continue ;else
@@ -1328,7 +1340,8 @@ cpfl_vport_idx_alloc(struct cpfl_adapter_ext *adapter)static int cpfl_dev_vport_init (struct rte_eth_dev *dev,void *init_params) { -struct idpf_vport *vport = dev->data->dev_private; +struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;struct cpfl_vport_param *param = init_params;struct cpfl_adapter_ext *adapter = param->adapter;/* for sending create vport virtchnl msg prepare */
@@ -1354,7 +1367,7 @@ cpfl_dev_vport_init(struct rte_eth_dev *dev, void *init_params) goto err; } - adapter->vports[param->idx] = vport; + adapter->vports[param->idx] = cpfl_vport; adapter->cur_vports |=RTE_BIT32 (param->devarg_id); adapter->cur_vport_nb++;
@@ -1470,7 +1483,7 @@ cpfl_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,snprintf (name,sizeof (name),"cpfl_%s_vport_0" , pci_dev->device.name); retval =rte_eth_dev_create (&pci_dev->device, name, -sizeof (struct idpf_vport ), +sizeof (struct cpfl_vport ),NULL ,NULL , cpfl_dev_vport_init, &vport_param);if (retval !=0 )
@@ -1488,7 +1501,7 @@ cpfl_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, pci_dev->device.name, devargs.req_vports[i]); retval =rte_eth_dev_create (&pci_dev->device, name, -sizeof (struct idpf_vport ), +sizeof (struct cpfl_vport ),NULL ,NULL , cpfl_dev_vport_init, &vport_param);if (retval !=0 )
drivers/net/cpfl/cpfl_ethdev.h +5 -1
@@ -69,13 +69,17 @@ struct cpfl_devargs {uint16_t req_vport_nb; }; +struct cpfl_vport { +struct idpf_vport base; +}; +struct cpfl_adapter_ext {TAILQ_ENTRY (cpfl_adapter_ext) next;struct idpf_adapter base;char name[CPFL_ADAPTER_NAME_LEN ]; -struct idpf_vport **vports; +struct cpfl_vport **vports;uint16_t max_vport_nb;uint16_t cur_vports;/* bit mask of created vport */
drivers/net/cpfl/cpfl_rxtx.c +125 -50
401 lines not on this page · raw message
drivers/net/cpfl/cpfl_rxtx.h +8 -0
@@ -23,6 +23,14 @@#define CPFL_SUPPORT_CHAIN_NUM 5 +struct cpfl_rx_queue { +struct idpf_rx_queue base; +}; + +struct cpfl_tx_queue { +struct idpf_tx_queue base; +}; +int cpfl_tx_queue_setup (struct rte_eth_dev *dev,uint16_t queue_idx,uint16_t nb_desc,unsigned int socket_id,const struct rte_eth_txconf *tx_conf);
drivers/net/cpfl/cpfl_rxtx_vec_common.h +9 -8
@@ -76,15 +76,16 @@ cpfl_rx_splitq_vec_default(struct idpf_rx_queue *rxq)static inline int cpfl_rx_vec_dev_check_default (struct rte_eth_dev *dev) { -struct idpf_vport *vport = dev->data->dev_private; -struct idpf_rx_queue *rxq; +struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base; +struct cpfl_rx_queue *cpfl_rxq;int i, default_ret, splitq_ret, ret =CPFL_SCALAR_PATH ;for (i =0 ; i < dev->data->nb_rx_queues; i++) { - rxq = dev->data->rx_queues[i]; - default_ret =cpfl_rx_vec_queue_default (rxq); + cpfl_rxq = dev->data->rx_queues[i]; + default_ret =cpfl_rx_vec_queue_default (&cpfl_rxq->base);if (vport->rxq_model ==VIRTCHNL2_QUEUE_MODEL_SPLIT ) { - splitq_ret =cpfl_rx_splitq_vec_default (rxq); + splitq_ret =cpfl_rx_splitq_vec_default (&cpfl_rxq->base); ret = splitq_ret && default_ret; }else { ret = default_ret;
@@ -100,12 +101,12 @@ static inline int cpfl_tx_vec_dev_check_default(struct rte_eth_dev *dev) {int i; -struct idpf_tx_queue *txq; +struct cpfl_tx_queue *cpfl_txq;int ret =0 ;for (i =0 ; i < dev->data->nb_tx_queues; i++) { - txq = dev->data->tx_queues[i]; - ret =cpfl_tx_vec_queue_default (txq); + cpfl_txq = dev->data->tx_queues[i]; + ret =cpfl_tx_vec_queue_default (&cpfl_txq->base);if (ret ==CPFL_SCALAR_PATH )return CPFL_SCALAR_PATH ; }
Signature · 1 line
2.26.2
PATCH 2/10 net/cpfl: support hairpin queue capbility get
In reply to [email protected]From: Beilei Xing <[email protected]>
This patch adds hairpin_cap_get ops support.
--- drivers/net/cpfl/cpfl_ethdev.c | 13 +++++++++++++ drivers/net/cpfl/cpfl_rxtx.h | 4 ++++ 2 files changed, 17 insertions(+)
drivers/net/cpfl/cpfl_ethdev.c +13 -0
@@ -154,6 +154,18 @@ cpfl_dev_link_update(struct rte_eth_dev *dev,return rte_eth_linkstatus_set (dev, &new_link); } +static int +cpfl_hairpin_cap_get(__rte_unused struct rte_eth_dev *dev, +struct rte_eth_hairpin_cap *cap) +{ + cap->max_nb_queues =CPFL_MAX_P2P_NB_QUEUES ; + cap->max_rx_2_tx =CPFL_MAX_HAIRPINQ_RX_2_TX ; + cap->max_tx_2_rx =CPFL_MAX_HAIRPINQ_TX_2_RX ; + cap->max_nb_desc =CPFL_MAX_HAIRPINQ_NB_DESC ; + +return 0 ; +} +static int cpfl_dev_info_get (struct rte_eth_dev *dev,struct rte_eth_dev_info *dev_info) {
@@ -889,6 +901,7 @@ static const struct eth_dev_ops cpfl_eth_dev_ops = { .xstats_get = cpfl_dev_xstats_get, .xstats_get_names = cpfl_dev_xstats_get_names, .xstats_reset = cpfl_dev_xstats_reset, + .hairpin_cap_get = cpfl_hairpin_cap_get, }; static int
drivers/net/cpfl/cpfl_rxtx.h +4 -0
@@ -13,6 +13,10 @@#define CPFL_MIN_RING_DESC 32#define CPFL_MAX_RING_DESC 4096#define CPFL_DMA_MEM_ALIGN 4096 +#define CPFL_MAX_HAIRPINQ_RX_2_TX 1 +#define CPFL_MAX_HAIRPINQ_TX_2_RX 1 +#define CPFL_MAX_HAIRPINQ_NB_DESC 1024 +#define CPFL_MAX_P2P_NB_QUEUES 16/* Base address of the HW descriptor ring should be 128B aligned. */ #define CPFL_RING_BASE_ALIGN 128
Signature · 1 line
2.26.2
PATCH 3/10 common/idpf: support queue groups add/delete
In reply to [email protected]From: Beilei Xing <[email protected]>
This patch adds queue group add/delete virtual channel support.
--- drivers/common/idpf/idpf_common_virtchnl.c | 66 ++++++++++++++++++++++ drivers/common/idpf/idpf_common_virtchnl.h | 9 +++ drivers/common/idpf/version.map | 2 + 3 files changed, 77 insertions(+)
drivers/common/idpf/idpf_common_virtchnl.c +66 -0
@@ -359,6 +359,72 @@ idpf_vc_vport_destroy(struct idpf_vport *vport)return err; } +int +idpf_vc_queue_grps_add (struct idpf_vport *vport, +struct virtchnl2_add_queue_groups *ptp_queue_grps_info, +uint8_t *ptp_queue_grps_out) +{ +struct idpf_adapter *adapter = vport->adapter; +struct idpf_cmd_info args; +int size, qg_info_size; +int err =-1 ; + + size =sizeof (*ptp_queue_grps_info) + + (ptp_queue_grps_info->qg_info.num_queue_groups -1 ) * +sizeof (struct virtchnl2_queue_group_info ); + +memset (&args,0 ,sizeof (args)); + args.ops =VIRTCHNL2_OP_ADD_QUEUE_GROUPS ; + args.in_args = (uint8_t *)ptp_queue_grps_info; + args.in_args_size = size; + args.out_buffer = adapter->mbx_resp; + args.out_size =IDPF_DFLT_MBX_BUF_SIZE ; + + err =idpf_vc_cmd_execute (adapter, &args); +if (err !=0 ) { +DRV_LOG (ERR , +"Failed to execute command of VIRTCHNL2_OP_ADD_QUEUE_GROUPS" ); +return err; + } + +rte_memcpy (ptp_queue_grps_out, args.out_buffer,IDPF_DFLT_MBX_BUF_SIZE ); +return 0 ; +} + +int idpf_vc_queue_grps_del (struct idpf_vport *vport, +uint16_t num_q_grps, +struct virtchnl2_queue_group_id *qg_ids) +{ +struct idpf_adapter *adapter = vport->adapter; +struct virtchnl2_delete_queue_groups *vc_del_q_grps; +struct idpf_cmd_info args; +int size; +int err; + + size =sizeof (*vc_del_q_grps) + + (num_q_grps -1 ) *sizeof (struct virtchnl2_queue_group_id ); + vc_del_q_grps =rte_zmalloc ("vc_del_q_grps" , size,0 ); + + vc_del_q_grps->vport_id = vport->vport_id; + vc_del_q_grps->num_queue_groups = num_q_grps; +memcpy (vc_del_q_grps->qg_ids, qg_ids, + num_q_grps *sizeof (struct virtchnl2_queue_group_id )); + +memset (&args,0 ,sizeof (args)); + args.ops =VIRTCHNL2_OP_DEL_QUEUE_GROUPS ; + args.in_args = (uint8_t *)vc_del_q_grps; + args.in_args_size = size; + args.out_buffer = adapter->mbx_resp; + args.out_size =IDPF_DFLT_MBX_BUF_SIZE ; + + err =idpf_vc_cmd_execute (adapter, &args); +if (err !=0 ) +DRV_LOG (ERR ,"Failed to execute command of VIRTCHNL2_OP_DEL_QUEUE_GROUPS" ); + +rte_free (vc_del_q_grps); +return err; +} +int idpf_vc_rss_key_set (struct idpf_vport *vport) {
drivers/common/idpf/idpf_common_virtchnl.h +9 -0
@@ -64,4 +64,13 @@ int idpf_vc_ctlq_recv(struct idpf_ctlq_info *cq, u16 *num_q_msg,__rte_internal int idpf_vc_ctlq_post_rx_buffs(struct idpf_hw *hw, struct idpf_ctlq_info *cq,u16 *buff_count,struct idpf_dma_mem **buffs); +__rte_internal +int idpf_vc_queue_grps_del(struct idpf_vport *vport, +uint16_t num_q_grps, +struct virtchnl2_queue_group_id *qg_ids); +__rte_internal +int +idpf_vc_queue_grps_add (struct idpf_vport *vport, +struct virtchnl2_add_queue_groups *ptp_queue_grps_info, +uint8_t *ptp_queue_grps_out);#endif /* _IDPF_COMMON_VIRTCHNL_H_ */
drivers/common/idpf/version.map +2 -0
@@ -48,6 +48,8 @@ INTERNAL { idpf_vc_irq_map_unmap_config; idpf_vc_one_msg_read; idpf_vc_ptype_info_query; + idpf_vc_queue_grps_add; + idpf_vc_queue_grps_del; idpf_vc_queue_switch; idpf_vc_queues_ena_dis; idpf_vc_rss_hash_get;
Signature · 1 line
2.26.2
RE: [PATCH 03/10] common/idpf: support queue groups add/delete
Quoted 29 lines
-----Original Message-----
From: Xing, Beilei <[email protected]>
Sent: Friday, April 21, 2023 2:51 PM
To: Wu, Jingjing <[email protected]>
Cc: [email protected]; Liu, Mingxia <[email protected]>; Xing, Beilei <[email protected]>
Subject: [PATCH 03/10] common/idpf: support queue groups add/deleteFrom: Beilei Xing <[email protected]>
This patch adds queue group add/delete virtual channel support.
Signed-off-by Mingxia Liu <[email protected]>Signed-off-by Beilei Xing <[email protected]>--- drivers/common/idpf/idpf_common_virtchnl.c | 66 ++++++++++++++++++++++ drivers/common/idpf/idpf_common_virtchnl.h | 9 +++ drivers/common/idpf/version.map | 2 + 3 files changed, 77 insertions(+)drivers/common/idpf/idpf_common_virtchnl.c +0
-0
drivers/common/idpf/idpf_common_virtchnl.c idpf_vc_vport_destroy(struct idpf_vport *vport) · line 366
Quoted 8 lines
drivers/common/idpf/idpf_common_virtchnl.c +4
-0@@ -359,6 +359,72 @@ idpf_vc_vport_destroy(struct idpf_vport *vport)return err; } +int +idpf_vc_queue_grps_add (struct idpf_vport *vport, +struct virtchnl2_add_queue_groups *ptp_queue_grps_info, +uint8_t *ptp_queue_grps_out)
[Liu, Mingxia] Better to unify the abbreviation of "port to port" , this patch p2p is used, in the next patch p2p is used.
Quoted 101 lines
drivers/common/idpf/idpf_common_virtchnl.c +62
-0+{ +struct idpf_adapter *adapter = vport->adapter; +struct idpf_cmd_info args; +int size, qg_info_size; +int err =-1 ; + + size =sizeof (*ptp_queue_grps_info) + + (ptp_queue_grps_info->qg_info.num_queue_groups -1 ) * +sizeof (struct virtchnl2_queue_group_info ); + +memset (&args,0 ,sizeof (args)); + args.ops =VIRTCHNL2_OP_ADD_QUEUE_GROUPS ; + args.in_args = (uint8_t *)ptp_queue_grps_info; + args.in_args_size = size; + args.out_buffer = adapter->mbx_resp; + args.out_size =IDPF_DFLT_MBX_BUF_SIZE ; + + err =idpf_vc_cmd_execute (adapter, &args); +if (err !=0 ) { +DRV_LOG (ERR , +"Failed to execute command of VIRTCHNL2_OP_ADD_QUEUE_GROUPS"); +return err; + } + +rte_memcpy (ptp_queue_grps_out, args.out_buffer,IDPF_DFLT_MBX_BUF_SIZE ); +return 0 ; +} + +int idpf_vc_queue_grps_del (struct idpf_vport *vport, +uint16_t num_q_grps, +struct virtchnl2_queue_group_id *qg_ids) { +struct idpf_adapter *adapter = vport->adapter; +struct virtchnl2_delete_queue_groups *vc_del_q_grps; +struct idpf_cmd_info args; +int size; +int err; + + size =sizeof (*vc_del_q_grps) + + (num_q_grps -1 ) *sizeof (struct virtchnl2_queue_group_id ); + vc_del_q_grps =rte_zmalloc ("vc_del_q_grps" , size,0 ); + + vc_del_q_grps->vport_id = vport->vport_id; + vc_del_q_grps->num_queue_groups = num_q_grps; +memcpy (vc_del_q_grps->qg_ids, qg_ids, + num_q_grps *sizeof (struct virtchnl2_queue_group_id )); + +memset (&args,0 ,sizeof (args)); + args.ops =VIRTCHNL2_OP_DEL_QUEUE_GROUPS ; + args.in_args = (uint8_t *)vc_del_q_grps; + args.in_args_size = size; + args.out_buffer = adapter->mbx_resp; + args.out_size =IDPF_DFLT_MBX_BUF_SIZE ; + + err =idpf_vc_cmd_execute (adapter, &args); +if (err !=0 ) +DRV_LOG (ERR ,"Failed to execute command of +VIRTCHNL2_OP_DEL_QUEUE_GROUPS"); + +rte_free (vc_del_q_grps); +return err; +} +int
idpf_vc_rss_key_set(struct idpf_vport *vport){ diff --gita/drivers/common/idpf/idpf_common_virtchnl.hb/drivers/common/idpf/idpf_common_virtchnl.h
indexd479d93c8e..bf1d014c8d100644drivers/common/idpf/idpf_common_virtchnl.h +4
-0@@ -64,4 +64,13 @@ int idpf_vc_ctlq_recv(struct idpf_ctlq_info *cq, u16 *num_q_msg, __rte_internal int idpf_vc_ctlq_post_rx_buffs(structidpf_hw *hw,struct idpf_ctlq_info *cq,u16 *buff_count,struct idpf_dma_mem **buffs); +__rte_internal +int idpf_vc_queue_grps_del(struct idpf_vport *vport, +uint16_t num_q_grps, +struct virtchnl2_queue_group_id *qg_ids);
__rte_internalintdrivers/common/idpf/idpf_common_virtchnl.h +2
-0+idpf_vc_queue_grps_add(struct idpf_vport *vport, + struct virtchnl2_add_queue_groups
*ptp_queue_grps_info,drivers/common/idpf/idpf_common_virtchnl.h +1
-0+ uint8_t *ptp_queue_grps_out);#endif /* _IDPF_COMMON_VIRTCHNL_H_ */ (quoted diff) +0
-0b/drivers/common/idpf/version.map index 7076759024..aa67f7ee27 100644
drivers/common/idpf/version.map +2
-1@@ -48,6 +48,8 @@ INTERNAL { idpf_vc_irq_map_unmap_config; idpf_vc_one_msg_read; idpf_vc_ptype_info_query; + idpf_vc_queue_grps_add; + idpf_vc_queue_grps_del; idpf_vc_queue_switch; idpf_vc_queues_ena_dis; idpf_vc_rss_hash_get; --2.26.2
RE: [PATCH 03/10] common/idpf: support queue groups add/delete
In reply to [email protected]Quoted 29 lines
-----Original Message-----
From: Xing, Beilei <[email protected]>
Sent: Friday, April 21, 2023 2:51 PM
To: Wu, Jingjing <[email protected]>
Cc: [email protected]; Liu, Mingxia <[email protected]>; Xing, Beilei <[email protected]>
Subject: [PATCH 03/10] common/idpf: support queue groups add/deleteFrom: Beilei Xing <[email protected]>
This patch adds queue group add/delete virtual channel support.
Signed-off-by Mingxia Liu <[email protected]>Signed-off-by Beilei Xing <[email protected]>--- drivers/common/idpf/idpf_common_virtchnl.c | 66 ++++++++++++++++++++++ drivers/common/idpf/idpf_common_virtchnl.h | 9 +++ drivers/common/idpf/version.map | 2 + 3 files changed, 77 insertions(+)drivers/common/idpf/idpf_common_virtchnl.c +0
-0
drivers/common/idpf/idpf_common_virtchnl.c idpf_vc_vport_destroy(struct idpf_vport *vport) · line 366
Quoted 8 lines
drivers/common/idpf/idpf_common_virtchnl.c +4
-0@@ -359,6 +359,72 @@ idpf_vc_vport_destroy(struct idpf_vport *vport)return err; } +int +idpf_vc_queue_grps_add (struct idpf_vport *vport, +struct virtchnl2_add_queue_groups *ptp_queue_grps_info, +uint8_t *ptp_queue_grps_out)
[Liu, Mingxia] Better to unify the abbreviation of "port to port" , this patch ptp is used, in the next patch p2p is used.
Quoted 101 lines
drivers/common/idpf/idpf_common_virtchnl.c +62
-0+{ +struct idpf_adapter *adapter = vport->adapter; +struct idpf_cmd_info args; +int size, qg_info_size; +int err =-1 ; + + size =sizeof (*ptp_queue_grps_info) + + (ptp_queue_grps_info->qg_info.num_queue_groups -1 ) * +sizeof (struct virtchnl2_queue_group_info ); + +memset (&args,0 ,sizeof (args)); + args.ops =VIRTCHNL2_OP_ADD_QUEUE_GROUPS ; + args.in_args = (uint8_t *)ptp_queue_grps_info; + args.in_args_size = size; + args.out_buffer = adapter->mbx_resp; + args.out_size =IDPF_DFLT_MBX_BUF_SIZE ; + + err =idpf_vc_cmd_execute (adapter, &args); +if (err !=0 ) { +DRV_LOG (ERR , +"Failed to execute command of VIRTCHNL2_OP_ADD_QUEUE_GROUPS"); +return err; + } + +rte_memcpy (ptp_queue_grps_out, args.out_buffer,IDPF_DFLT_MBX_BUF_SIZE ); +return 0 ; +} + +int idpf_vc_queue_grps_del (struct idpf_vport *vport, +uint16_t num_q_grps, +struct virtchnl2_queue_group_id *qg_ids) { +struct idpf_adapter *adapter = vport->adapter; +struct virtchnl2_delete_queue_groups *vc_del_q_grps; +struct idpf_cmd_info args; +int size; +int err; + + size =sizeof (*vc_del_q_grps) + + (num_q_grps -1 ) *sizeof (struct virtchnl2_queue_group_id ); + vc_del_q_grps =rte_zmalloc ("vc_del_q_grps" , size,0 ); + + vc_del_q_grps->vport_id = vport->vport_id; + vc_del_q_grps->num_queue_groups = num_q_grps; +memcpy (vc_del_q_grps->qg_ids, qg_ids, + num_q_grps *sizeof (struct virtchnl2_queue_group_id )); + +memset (&args,0 ,sizeof (args)); + args.ops =VIRTCHNL2_OP_DEL_QUEUE_GROUPS ; + args.in_args = (uint8_t *)vc_del_q_grps; + args.in_args_size = size; + args.out_buffer = adapter->mbx_resp; + args.out_size =IDPF_DFLT_MBX_BUF_SIZE ; + + err =idpf_vc_cmd_execute (adapter, &args); +if (err !=0 ) +DRV_LOG (ERR ,"Failed to execute command of +VIRTCHNL2_OP_DEL_QUEUE_GROUPS"); + +rte_free (vc_del_q_grps); +return err; +} +int
idpf_vc_rss_key_set(struct idpf_vport *vport){ diff --gita/drivers/common/idpf/idpf_common_virtchnl.hb/drivers/common/idpf/idpf_common_virtchnl.h
indexd479d93c8e..bf1d014c8d100644drivers/common/idpf/idpf_common_virtchnl.h +4
-0@@ -64,4 +64,13 @@ int idpf_vc_ctlq_recv(struct idpf_ctlq_info *cq, u16 *num_q_msg, __rte_internal int idpf_vc_ctlq_post_rx_buffs(structidpf_hw *hw,struct idpf_ctlq_info *cq,u16 *buff_count,struct idpf_dma_mem **buffs); +__rte_internal +int idpf_vc_queue_grps_del(struct idpf_vport *vport, +uint16_t num_q_grps, +struct virtchnl2_queue_group_id *qg_ids);
__rte_internalintdrivers/common/idpf/idpf_common_virtchnl.h +2
-0+idpf_vc_queue_grps_add(struct idpf_vport *vport, + struct virtchnl2_add_queue_groups
*ptp_queue_grps_info,drivers/common/idpf/idpf_common_virtchnl.h +1
-0+ uint8_t *ptp_queue_grps_out);#endif /* _IDPF_COMMON_VIRTCHNL_H_ */ (quoted diff) +0
-0b/drivers/common/idpf/version.map index 7076759024..aa67f7ee27 100644
drivers/common/idpf/version.map +2
-1@@ -48,6 +48,8 @@ INTERNAL { idpf_vc_irq_map_unmap_config; idpf_vc_one_msg_read; idpf_vc_ptype_info_query; + idpf_vc_queue_grps_add; + idpf_vc_queue_grps_del; idpf_vc_queue_switch; idpf_vc_queues_ena_dis; idpf_vc_rss_hash_get; --2.26.2
RE: [PATCH 03/10] common/idpf: support queue groups add/delete
Quoted 41 lines
-----Original Message-----
From: Liu, Mingxia <[email protected]>
Sent: Monday, April 24, 2023 4:50 PM
To: Xing, Beilei <[email protected]>; Wu, Jingjing <[email protected]>
Cc: [email protected]
Subject: RE: [PATCH 03/10] common/idpf: support queue groups add/deleteQuoted 30 lines
-----Original Message-----
From: Xing, Beilei <[email protected]>
Sent: Friday, April 21, 2023 2:51 PM
To: Wu, Jingjing <[email protected]>
Cc: [email protected]; Liu, Mingxia <[email protected]>; Xing, Beilei <[email protected]>
Subject: [PATCH 03/10] common/idpf: support queue groups add/deleteFrom: Beilei Xing <[email protected]>
This patch adds queue group add/delete virtual channel support.
Signed-off-by Mingxia Liu <[email protected]>Signed-off-by Beilei Xing <[email protected]>--- drivers/common/idpf/idpf_common_virtchnl.c | 66 ++++++++++++++++++++++ drivers/common/idpf/idpf_common_virtchnl.h | 9 +++ drivers/common/idpf/version.map | 2 + 3 files changed, 77 insertions(+)drivers/common/idpf/idpf_common_virtchnl.c +0
-0@@ -359,6 +359,72 @@ idpf_vc_vport_destroy(struct idpf_vport *vport)return err; }
Quoted 7 lines
drivers/common/idpf/idpf_common_virtchnl.c idpf_vc_vport_destroy(struct idpf_vport *vport) · line 365
Quoted 5 lines
drivers/common/idpf/idpf_common_virtchnl.c +4
-0+int +idpf_vc_queue_grps_add (struct idpf_vport *vport, +struct virtchnl2_add_queue_groups *ptp_queue_grps_info, +uint8_t *ptp_queue_grps_out)[Liu, Mingxia] Better to unify the abbreviation of "port to port" , this patch ptp is used, in the next patch p2p is used.
Yes, it's refined in v2 patch.
Quoted 101 lines
Quoted 101 lines
drivers/common/idpf/idpf_common_virtchnl.c +62
-0+{ +struct idpf_adapter *adapter = vport->adapter; +struct idpf_cmd_info args; +int size, qg_info_size; +int err =-1 ; + + size =sizeof (*ptp_queue_grps_info) + + (ptp_queue_grps_info->qg_info.num_queue_groups -1 ) * +sizeof (struct virtchnl2_queue_group_info ); + +memset (&args,0 ,sizeof (args)); + args.ops =VIRTCHNL2_OP_ADD_QUEUE_GROUPS ; + args.in_args = (uint8_t *)ptp_queue_grps_info; + args.in_args_size = size; + args.out_buffer = adapter->mbx_resp; + args.out_size =IDPF_DFLT_MBX_BUF_SIZE ; + + err =idpf_vc_cmd_execute (adapter, &args); +if (err !=0 ) { +DRV_LOG (ERR , +"Failed to execute command of VIRTCHNL2_OP_ADD_QUEUE_GROUPS"); +return err; + } + +rte_memcpy (ptp_queue_grps_out, args.out_buffer,IDPF_DFLT_MBX_BUF_SIZE ); +return 0 ; +} + +int idpf_vc_queue_grps_del (struct idpf_vport *vport, +uint16_t num_q_grps, +struct virtchnl2_queue_group_id *qg_ids) { +struct idpf_adapter *adapter = vport->adapter; +struct virtchnl2_delete_queue_groups *vc_del_q_grps; +struct idpf_cmd_info args; +int size; +int err; + + size =sizeof (*vc_del_q_grps) + + (num_q_grps -1 ) *sizeof (struct virtchnl2_queue_group_id ); + vc_del_q_grps =rte_zmalloc ("vc_del_q_grps" , size,0 ); + + vc_del_q_grps->vport_id = vport->vport_id; + vc_del_q_grps->num_queue_groups = num_q_grps; +memcpy (vc_del_q_grps->qg_ids, qg_ids, + num_q_grps *sizeof (struct virtchnl2_queue_group_id )); + +memset (&args,0 ,sizeof (args)); + args.ops =VIRTCHNL2_OP_DEL_QUEUE_GROUPS ; + args.in_args = (uint8_t *)vc_del_q_grps; + args.in_args_size = size; + args.out_buffer = adapter->mbx_resp; + args.out_size =IDPF_DFLT_MBX_BUF_SIZE ; + + err =idpf_vc_cmd_execute (adapter, &args); +if (err !=0 ) +DRV_LOG (ERR ,"Failed to execute command of +VIRTCHNL2_OP_DEL_QUEUE_GROUPS"); + +rte_free (vc_del_q_grps); +return err; +} +int
idpf_vc_rss_key_set(struct idpf_vport *vport){ diff --gita/drivers/common/idpf/idpf_common_virtchnl.hb/drivers/common/idpf/idpf_common_virtchnl.h
indexd479d93c8e..bf1d014c8d100644drivers/common/idpf/idpf_common_virtchnl.h +0
-0@@ -64,4 +64,13 @@ int idpf_vc_ctlq_recv(struct idpf_ctlq_info *cq,u16
*num_q_msg,__rte_internalint idpf_vc_ctlq_post_rx_buffs(structidpf_hw*hw, structidpf_ctlq_info*cq,drivers/common/idpf/idpf_common_virtchnl.h +4
-0u16 *buff_count, struct idpf_dma_mem **buffs); +__rte_internal +int idpf_vc_queue_grps_del(struct idpf_vport *vport, +uint16_t num_q_grps, +struct virtchnl2_queue_group_id *qg_ids);
__rte_internalintdrivers/common/idpf/idpf_common_virtchnl.h +2
-0+idpf_vc_queue_grps_add(struct idpf_vport *vport, + struct virtchnl2_add_queue_groups
*ptp_queue_grps_info,drivers/common/idpf/idpf_common_virtchnl.h +1
-0+ uint8_t *ptp_queue_grps_out); #endif /* _IDPF_COMMON_VIRTCHNL_H_ */ diff --gita/drivers/common/idpf/version.map b/drivers/common/idpf/version.map index 7076759024..aa67f7ee27
100644drivers/common/idpf/version.map +2
-1@@ -48,6 +48,8 @@ INTERNAL { idpf_vc_irq_map_unmap_config; idpf_vc_one_msg_read; idpf_vc_ptype_info_query; + idpf_vc_queue_grps_add; + idpf_vc_queue_grps_del; idpf_vc_queue_switch; idpf_vc_queues_ena_dis; idpf_vc_rss_hash_get; --2.26.2
PATCH 4/10 net/cpfl: add haipin queue group during vpotr init
In reply to [email protected]From: Beilei Xing <[email protected]>
This patch adds haipin queue group during vpotr init.
--- drivers/net/cpfl/cpfl_ethdev.c | 125 +++++++++++++++++++++++++++++++++ drivers/net/cpfl/cpfl_ethdev.h | 17 +++++ drivers/net/cpfl/cpfl_rxtx.h | 4 ++ 3 files changed, 146 insertions(+)
drivers/net/cpfl/cpfl_ethdev.c +125 -0
@@ -856,6 +856,20 @@ cpfl_dev_stop(struct rte_eth_dev *dev)return 0 ; } +static int +cpfl_p2p_queue_grps_del (struct idpf_vport *vport) +{ +struct virtchnl2_queue_group_id qg_ids[CPFL_P2P_NB_QUEUE_GRPS ] = {0 }; +int ret =0 ; + + qg_ids[0 ].queue_group_id =CPFL_P2P_QUEUE_GRP_ID ; + qg_ids[0 ].queue_group_type =VIRTCHNL2_QUEUE_GROUP_P2P ; + ret =idpf_vc_queue_grps_del (vport,CPFL_P2P_NB_QUEUE_GRPS , qg_ids); +if (ret) +PMD_DRV_LOG (ERR ,"Failed to delete p2p queue groups" ); +return ret; +} +static int cpfl_dev_close (struct rte_eth_dev *dev) {
@@ -864,6 +878,9 @@ cpfl_dev_close(struct rte_eth_dev *dev)struct cpfl_adapter_ext *adapter =CPFL_ADAPTER_TO_EXT (vport->adapter);cpfl_dev_stop (dev); + +cpfl_p2p_queue_grps_del (vport); +idpf_vport_deinit (vport); adapter->cur_vports &= ~RTE_BIT32 (vport->devarg_id);
@@ -1350,6 +1367,96 @@ cpfl_vport_idx_alloc(struct cpfl_adapter_ext *adapter)return vport_idx; } +static int +cpfl_p2p_q_grps_add (struct idpf_vport *vport, +struct virtchnl2_add_queue_groups *p2p_queue_grps_info, +uint8_t *p2p_q_vc_out_info) +{ +int ret; + + p2p_queue_grps_info->vport_id = vport->vport_id; + p2p_queue_grps_info->qg_info.num_queue_groups =CPFL_P2P_NB_QUEUE_GRPS ; + p2p_queue_grps_info->qg_info.groups[0 ].num_rx_q =CPFL_MAX_P2P_NB_QUEUES ; + p2p_queue_grps_info->qg_info.groups[0 ].num_rx_bufq =CPFL_P2P_NB_RX_BUFQ ; + p2p_queue_grps_info->qg_info.groups[0 ].num_tx_q =CPFL_MAX_P2P_NB_QUEUES ; + p2p_queue_grps_info->qg_info.groups[0 ].num_tx_complq =CPFL_P2P_NB_TX_COMPLQ ; + p2p_queue_grps_info->qg_info.groups[0 ].qg_id.queue_group_id =CPFL_P2P_QUEUE_GRP_ID ; + p2p_queue_grps_info->qg_info.groups[0 ].qg_id.queue_group_type =VIRTCHNL2_QUEUE_GROUP_P2P ; + p2p_queue_grps_info->qg_info.groups[0 ].rx_q_grp_info.rss_lut_size =0 ; + p2p_queue_grps_info->qg_info.groups[0 ].tx_q_grp_info.tx_tc =0 ; + p2p_queue_grps_info->qg_info.groups[0 ].tx_q_grp_info.priority =0 ; + p2p_queue_grps_info->qg_info.groups[0 ].tx_q_grp_info.is_sp =0 ; + p2p_queue_grps_info->qg_info.groups[0 ].tx_q_grp_info.pir_weight =0 ; + + ret =idpf_vc_queue_grps_add (vport, p2p_queue_grps_info, p2p_q_vc_out_info); +if (ret !=0 ) { +PMD_DRV_LOG (ERR ,"Failed to add p2p queue groups." ); +return ret; + } + +return ret; +} + +static int +cpfl_p2p_queue_info_init (struct cpfl_vport *cpfl_vport, +struct virtchnl2_add_queue_groups *p2p_q_vc_out_info) +{ +struct p2p_queue_chunks_info *p2p_q_chunks_info = &cpfl_vport->p2p_q_chunks_info; +struct virtchnl2_queue_reg_chunks *vc_chunks_out; +int i, type; + +if (p2p_q_vc_out_info->qg_info.groups[0 ].qg_id.queue_group_type != +VIRTCHNL2_QUEUE_GROUP_P2P ) { +PMD_DRV_LOG (ERR ,"Add queue group response mismatch." ); +return -EINVAL ; + } + + vc_chunks_out = &p2p_q_vc_out_info->qg_info.groups[0 ].chunks; + +for (i =0 ; i < vc_chunks_out->num_chunks; i++) { + type = vc_chunks_out->chunks[i].type; +switch (type) { +case VIRTCHNL2_QUEUE_TYPE_TX : + p2p_q_chunks_info->tx_start_qid = + vc_chunks_out->chunks[i].start_queue_id; + p2p_q_chunks_info->tx_qtail_start = + vc_chunks_out->chunks[i].qtail_reg_start; + p2p_q_chunks_info->tx_qtail_spacing = + vc_chunks_out->chunks[i].qtail_reg_spacing; +break ; +case VIRTCHNL2_QUEUE_TYPE_RX : + p2p_q_chunks_info->rx_start_qid = + vc_chunks_out->chunks[i].start_queue_id; + p2p_q_chunks_info->rx_qtail_start = + vc_chunks_out->chunks[i].qtail_reg_start; + p2p_q_chunks_info->rx_qtail_spacing = + vc_chunks_out->chunks[i].qtail_reg_spacing; +break ; +case VIRTCHNL2_QUEUE_TYPE_TX_COMPLETION : + p2p_q_chunks_info->tx_compl_start_qid = + vc_chunks_out->chunks[i].start_queue_id; + p2p_q_chunks_info->tx_compl_qtail_start = + vc_chunks_out->chunks[i].qtail_reg_start; + p2p_q_chunks_info->tx_compl_qtail_spacing = + vc_chunks_out->chunks[i].qtail_reg_spacing; +break ; +case VIRTCHNL2_QUEUE_TYPE_RX_BUFFER : + p2p_q_chunks_info->rx_buf_start_qid = + vc_chunks_out->chunks[i].start_queue_id; + p2p_q_chunks_info->rx_buf_qtail_start = + vc_chunks_out->chunks[i].qtail_reg_start; + p2p_q_chunks_info->rx_buf_qtail_spacing = + vc_chunks_out->chunks[i].qtail_reg_spacing; +break ; +default : +PMD_DRV_LOG (ERR ,"Unsupported queue type" ); +break ; + } + } + +return 0 ; +} +static int cpfl_dev_vport_init (struct rte_eth_dev *dev,void *init_params) {
@@ -1359,6 +1466,8 @@ cpfl_dev_vport_init(struct rte_eth_dev *dev, void *init_params)struct cpfl_adapter_ext *adapter = param->adapter;/* for sending create vport virtchnl msg prepare */ struct virtchnl2_create_vport create_vport_info; +struct virtchnl2_add_queue_groups p2p_queue_grps_info; +uint8_t p2p_q_vc_out_info[IDPF_DFLT_MBX_BUF_SIZE ] = {0 };int ret =0 ; dev->dev_ops = &cpfl_eth_dev_ops;
@@ -1380,6 +1489,19 @@ cpfl_dev_vport_init(struct rte_eth_dev *dev, void *init_params) goto err; } +memset (&p2p_queue_grps_info,0 ,sizeof (p2p_queue_grps_info)); + ret =cpfl_p2p_q_grps_add (vport, &p2p_queue_grps_info, p2p_q_vc_out_info); +if (ret !=0 ) { +PMD_INIT_LOG (ERR ,"Failed to add p2p queue group." ); + goto err_q_grps_add; + } + ret =cpfl_p2p_queue_info_init (cpfl_vport, + (struct virtchnl2_add_queue_groups *)p2p_q_vc_out_info); +if (ret !=0 ) { +PMD_INIT_LOG (ERR ,"Failed to init p2p queue info." ); + goto err_p2p_qinfo_init; + } + adapter->vports[param->idx] = cpfl_vport; adapter->cur_vports |=RTE_BIT32 (param->devarg_id); adapter->cur_vport_nb++;
@@ -1397,6 +1519,9 @@ cpfl_dev_vport_init(struct rte_eth_dev *dev, void *init_params)return 0 ; err_mac_addrs: +err_p2p_qinfo_init: +cpfl_p2p_queue_grps_del (vport); +err_q_grps_add: adapter->vports[param->idx] =NULL ;/* reset */ idpf_vport_deinit (vport); adapter->cur_vports &= ~RTE_BIT32 (param->devarg_id);
drivers/net/cpfl/cpfl_ethdev.h +17 -0
@@ -69,8 +69,25 @@ struct cpfl_devargs {uint16_t req_vport_nb; }; +struct p2p_queue_chunks_info { +uint32_t tx_start_qid; +uint32_t rx_start_qid; +uint32_t tx_compl_start_qid; +uint32_t rx_buf_start_qid; + +uint64_t tx_qtail_start; +uint32_t tx_qtail_spacing; +uint64_t rx_qtail_start; +uint32_t rx_qtail_spacing; +uint64_t tx_compl_qtail_start; +uint32_t tx_compl_qtail_spacing; +uint64_t rx_buf_qtail_start; +uint32_t rx_buf_qtail_spacing; +}; +struct cpfl_vport {struct idpf_vport base; +struct p2p_queue_chunks_info p2p_q_chunks_info; };struct cpfl_adapter_ext {
drivers/net/cpfl/cpfl_rxtx.h +4 -0
@@ -17,6 +17,10 @@#define CPFL_MAX_HAIRPINQ_TX_2_RX 1#define CPFL_MAX_HAIRPINQ_NB_DESC 1024#define CPFL_MAX_P2P_NB_QUEUES 16 +#define CPFL_P2P_NB_RX_BUFQ 1 +#define CPFL_P2P_NB_TX_COMPLQ 1 +#define CPFL_P2P_NB_QUEUE_GRPS 1 +#define CPFL_P2P_QUEUE_GRP_ID 1/* Base address of the HW descriptor ring should be 128B aligned. */ #define CPFL_RING_BASE_ALIGN 128
Signature · 1 line
2.26.2
RE: [PATCH 04/10] net/cpfl: add haipin queue group during vpotr init
Quoted 9 lines
-----Original Message-----
From: Xing, Beilei <[email protected]>
Sent: Friday, April 21, 2023 2:51 PM
To: Wu, Jingjing <[email protected]>
Cc: [email protected]; Liu, Mingxia <[email protected]>; Xing, Beilei <[email protected]>
Subject: [PATCH 04/10] net/cpfl: add haipin queue group during vpotr init
[Liu, Mingxia] vpotr , spelling error?
Quoted 253 lines
From: Beilei Xing <[email protected]>
This patch adds haipin queue group during vpotr init.
Signed-off-by Mingxia Liu <[email protected]>Signed-off-by Beilei Xing <[email protected]>--- drivers/net/cpfl/cpfl_ethdev.c | 125 +++++++++++++++++++++++++++++++++ drivers/net/cpfl/cpfl_ethdev.h | 17 +++++ drivers/net/cpfl/cpfl_rxtx.h | 4 ++ 3 files changed, 146 insertions(+)drivers/net/cpfl/cpfl_ethdev.c +13
-0@@ -856,6 +856,20 @@ cpfl_dev_stop(struct rte_eth_dev *dev)return 0 ; } +static int +cpfl_p2p_queue_grps_del (struct idpf_vport *vport) { +struct virtchnl2_queue_group_id qg_ids[CPFL_P2P_NB_QUEUE_GRPS ] = {0 }; +int ret =0 ; + + qg_ids[0 ].queue_group_id =CPFL_P2P_QUEUE_GRP_ID ; + qg_ids[0 ].queue_group_type =VIRTCHNL2_QUEUE_GROUP_P2P ; + ret =idpf_vc_queue_grps_del (vport,CPFL_P2P_NB_QUEUE_GRPS , qg_ids); +if (ret) +PMD_DRV_LOG (ERR ,"Failed to delete p2p queue groups" ); +return ret; +} +static int cpfl_dev_close(struct rte_eth_dev *dev) { @@ -864,6 +878,9 @@
cpfl_dev_close(struct rte_eth_dev *dev)
structcpfl_adapter_ext*adapter = CPFL_ADAPTER_TO_EXT(vport-Quoted 1 line
adapter);
drivers/net/cpfl/cpfl_ethdev.c +3
-0cpfl_dev_stop (dev); + +cpfl_p2p_queue_grps_del (vport); +idpf_vport_deinit (vport); adapter->cur_vports &= ~RTE_BIT32(vport->devarg_id); @@ -1350,6 +1367,96 @@
cpfl_vport_idx_alloc(struct cpfl_adapter_ext *adapter)drivers/net/cpfl/cpfl_ethdev.c +3
-0return vport_idx; } +static int +cpfl_p2p_q_grps_add (struct idpf_vport *vport, + struct virtchnl2_add_queue_groups
*p2p_queue_grps_info,drivers/net/cpfl/cpfl_ethdev.c +6
-0+ uint8_t *p2p_q_vc_out_info) +{ +int ret; + + p2p_queue_grps_info->vport_id = vport->vport_id; + p2p_queue_grps_info->qg_info.num_queue_groups =
CPFL_P2P_NB_QUEUE_GRPS;drivers/net/cpfl/cpfl_ethdev.c +1
-0+ p2p_queue_grps_info->qg_info.groups[0].num_rx_q =
CPFL_MAX_P2P_NB_QUEUES;drivers/net/cpfl/cpfl_ethdev.c +1
-0+ p2p_queue_grps_info->qg_info.groups[0].num_rx_bufq =
CPFL_P2P_NB_RX_BUFQ;drivers/net/cpfl/cpfl_ethdev.c +1
-0+ p2p_queue_grps_info->qg_info.groups[0].num_tx_q =
CPFL_MAX_P2P_NB_QUEUES;drivers/net/cpfl/cpfl_ethdev.c +1
-0+ p2p_queue_grps_info->qg_info.groups[0].num_tx_complq =
CPFL_P2P_NB_TX_COMPLQ;drivers/net/cpfl/cpfl_ethdev.c +1
-0+ p2p_queue_grps_info->qg_info.groups[0].qg_id.queue_group_id =
CPFL_P2P_QUEUE_GRP_ID;drivers/net/cpfl/cpfl_ethdev.c +1
-0+ p2p_queue_grps_info->qg_info.groups[0 ].qg_id.queue_group_type=
VIRTCHNL2_QUEUE_GROUP_P2P;drivers/net/cpfl/cpfl_ethdev.c +1
-0+ p2p_queue_grps_info-Quoted 1 line
qg_info.groups[0].rx_q_grp_info.rss_lut_size = 0;
drivers/net/cpfl/cpfl_ethdev.c +2
-0+ p2p_queue_grps_info->qg_info.groups[0 ].tx_q_grp_info.tx_tc =0 ; + p2p_queue_grps_info->qg_info.groups[0].tx_q_grp_info.priority =0;
drivers/net/cpfl/cpfl_ethdev.c +2
-0+ p2p_queue_grps_info->qg_info.groups[0 ].tx_q_grp_info.is_sp =0 ; + p2p_queue_grps_info->qg_info.groups[0 ].tx_q_grp_info.pir_weight= 0;
drivers/net/cpfl/cpfl_ethdev.c +2
-0+ + ret = idpf_vc_queue_grps_add(vport, p2p_queue_grps_info,
p2p_q_vc_out_info);drivers/net/cpfl/cpfl_ethdev.c +11
-0+if (ret !=0 ) { +PMD_DRV_LOG (ERR ,"Failed to add p2p queue groups." ); +return ret; + } + +return ret; +} + +static int +cpfl_p2p_queue_info_init (struct cpfl_vport *cpfl_vport, + struct virtchnl2_add_queue_groups
*p2p_q_vc_out_info) {drivers/net/cpfl/cpfl_ethdev.c +1
-0+ struct p2p_queue_chunks_info *p2p_q_chunks_info =
&cpfl_vport->p2p_q_chunks_info;drivers/net/cpfl/cpfl_ethdev.c +4
-0+struct virtchnl2_queue_reg_chunks *vc_chunks_out; +int i, type; + + if (p2p_q_vc_out_info-Quoted 1 line
qg_info.groups[0].qg_id.queue_group_type !=
drivers/net/cpfl/cpfl_ethdev.c +2
-0+ VIRTCHNL2_QUEUE_GROUP_P2P) { + PMD_DRV_LOG(ERR, "Add queue group responsemismatch.");
drivers/net/cpfl/cpfl_ethdev.c +49
-0+return -EINVAL ; + } + + vc_chunks_out = &p2p_q_vc_out_info->qg_info.groups[0 ].chunks; + +for (i =0 ; i < vc_chunks_out->num_chunks; i++) { + type = vc_chunks_out->chunks[i].type; +switch (type) { +case VIRTCHNL2_QUEUE_TYPE_TX : + p2p_q_chunks_info->tx_start_qid = + vc_chunks_out->chunks[i].start_queue_id; + p2p_q_chunks_info->tx_qtail_start = + vc_chunks_out->chunks[i].qtail_reg_start; + p2p_q_chunks_info->tx_qtail_spacing = + vc_chunks_out->chunks[i].qtail_reg_spacing; +break ; +case VIRTCHNL2_QUEUE_TYPE_RX : + p2p_q_chunks_info->rx_start_qid = + vc_chunks_out->chunks[i].start_queue_id; + p2p_q_chunks_info->rx_qtail_start = + vc_chunks_out->chunks[i].qtail_reg_start; + p2p_q_chunks_info->rx_qtail_spacing = + vc_chunks_out->chunks[i].qtail_reg_spacing; +break ; +case VIRTCHNL2_QUEUE_TYPE_TX_COMPLETION : + p2p_q_chunks_info->tx_compl_start_qid = + vc_chunks_out->chunks[i].start_queue_id; + p2p_q_chunks_info->tx_compl_qtail_start = + vc_chunks_out->chunks[i].qtail_reg_start; + p2p_q_chunks_info->tx_compl_qtail_spacing = + vc_chunks_out->chunks[i].qtail_reg_spacing; +break ; +case VIRTCHNL2_QUEUE_TYPE_RX_BUFFER : + p2p_q_chunks_info->rx_buf_start_qid = + vc_chunks_out->chunks[i].start_queue_id; + p2p_q_chunks_info->rx_buf_qtail_start = + vc_chunks_out->chunks[i].qtail_reg_start; + p2p_q_chunks_info->rx_buf_qtail_spacing = + vc_chunks_out->chunks[i].qtail_reg_spacing; +break ; +default : +PMD_DRV_LOG (ERR ,"Unsupported queue type" ); +break ; + } + } + +return 0 ; +} +static int cpfl_dev_vport_init(struct rte_eth_dev *dev, void *init_params) { @@ -1359,6 +1466,8 @@
cpfl_dev_vport_init(struct rte_eth_dev *dev, void *init_params)drivers/net/cpfl/cpfl_ethdev.c +15
-0struct cpfl_adapter_ext *adapter = param->adapter;/* for sending create vport virtchnl msg prepare */ struct virtchnl2_create_vport create_vport_info; +struct virtchnl2_add_queue_groups p2p_queue_grps_info; +uint8_t p2p_q_vc_out_info[IDPF_DFLT_MBX_BUF_SIZE ] = {0 };int ret =0 ; dev->dev_ops = &cpfl_eth_dev_ops;@@ -1380,6 +1489,19 @@ cpfl_dev_vport_init(struct rte_eth_dev *dev, void *init_params) goto err; } +memset (&p2p_queue_grps_info,0 ,sizeof (p2p_queue_grps_info)); + ret =cpfl_p2p_q_grps_add (vport, &p2p_queue_grps_info, p2p_q_vc_out_info); +if (ret !=0 ) { +PMD_INIT_LOG (ERR ,"Failed to add p2p queue group." ); + goto err_q_grps_add; + } + ret =cpfl_p2p_queue_info_init (cpfl_vport, + (struct virtchnl2_add_queue_groups *)p2p_q_vc_out_info); +if (ret !=0 ) { +PMD_INIT_LOG (ERR ,"Failed to init p2p queue info." ); + goto err_p2p_qinfo_init; + } +drivers/net/cpfl/cpfl_ethdev.c +3
-0adapter->vports[param->idx] = cpfl_vport; adapter->cur_vports |=RTE_BIT32 (param->devarg_id); adapter->cur_vport_nb++;@@ -1397,6 +1519,9 @@ cpfl_dev_vport_init(struct rte_eth_dev *dev, void *init_params)return 0 ; err_mac_addrs: +err_p2p_qinfo_init: +cpfl_p2p_queue_grps_del (vport); +err_q_grps_add: adapter->vports[param->idx] =NULL ;/* reset */ idpf_vport_deinit (vport);
adapter->cur_vports&= ~RTE_BIT32(param->devarg_id); diff --gita/drivers/net/cpfl/cpfl_ethdev.hb/drivers/net/cpfl/cpfl_ethdev.hindex81fe9ac4c3..5e2e7a1bfb100644drivers/net/cpfl/cpfl_ethdev.h +17
-0@@ -69,8 +69,25 @@ struct cpfl_devargs {uint16_t req_vport_nb; }; +struct p2p_queue_chunks_info { +uint32_t tx_start_qid; +uint32_t rx_start_qid; +uint32_t tx_compl_start_qid; +uint32_t rx_buf_start_qid; + +uint64_t tx_qtail_start; +uint32_t tx_qtail_spacing; +uint64_t rx_qtail_start; +uint32_t rx_qtail_spacing; +uint64_t tx_compl_qtail_start; +uint32_t tx_compl_qtail_spacing; +uint64_t rx_buf_qtail_start; +uint32_t rx_buf_qtail_spacing; +}; +struct cpfl_vport {struct idpf_vport base; +struct p2p_queue_chunks_info p2p_q_chunks_info; };struct cpfl_adapter_ext {drivers/net/cpfl/cpfl_rxtx.h index renamed from drivers/net/cpfl/cpfl_rxtx.h +0
-0
b2b3537d10..3a87a1f4b3100644drivers/net/cpfl/cpfl_rxtx.h +4
-1@@ -17,6 +17,10 @@#define CPFL_MAX_HAIRPINQ_TX_2_RX 1#define CPFL_MAX_HAIRPINQ_NB_DESC 1024#define CPFL_MAX_P2P_NB_QUEUES 16 +#define CPFL_P2P_NB_RX_BUFQ 1 +#define CPFL_P2P_NB_TX_COMPLQ 1 +#define CPFL_P2P_NB_QUEUE_GRPS 1 +#define CPFL_P2P_QUEUE_GRP_ID 1/* Base address of the HW descriptor ring should be 128B aligned. */ #define CPFL_RING_BASE_ALIGN 128 --2.26.2
RE: [PATCH 04/10] net/cpfl: add haipin queue group during vpotr init
Quoted 19 lines
-----Original Message-----
From: Liu, Mingxia <[email protected]>
Sent: Monday, April 24, 2023 4:55 PM
To: Xing, Beilei <[email protected]>; Wu, Jingjing <[email protected]>
Cc: [email protected]
Subject: RE: [PATCH 04/10] net/cpfl: add haipin queue group during vpotr initQuoted 8 lines
-----Original Message-----
From: Xing, Beilei <[email protected]>
Sent: Friday, April 21, 2023 2:51 PM
To: Wu, Jingjing <[email protected]>
Cc: [email protected]; Liu, Mingxia <[email protected]>; Xing, Beilei <[email protected]>
Subject: [PATCH 04/10] net/cpfl: add haipin queue group during vpotr init
Quoted 1 line
[Liu, Mingxia] vpotr , spelling error?
Good catch, thanks.
Quoted 255 lines
Quoted 255 lines
From: Beilei Xing <[email protected]>
This patch adds haipin queue group during vpotr init.
Signed-off-by Mingxia Liu <[email protected]>Signed-off-by Beilei Xing <[email protected]>--- drivers/net/cpfl/cpfl_ethdev.c | 125 +++++++++++++++++++++++++++++++++ drivers/net/cpfl/cpfl_ethdev.h | 17 +++++ drivers/net/cpfl/cpfl_rxtx.h | 4 ++ 3 files changed, 146 insertions(+)(quoted diff) +0
-0
b/drivers/net/cpfl/cpfl_ethdev.cindex114fc18f5f..ad5ddebd3a100644drivers/net/cpfl/cpfl_ethdev.c +13
-0@@ -856,6 +856,20 @@ cpfl_dev_stop(struct rte_eth_dev *dev)return 0 ; } +static int +cpfl_p2p_queue_grps_del (struct idpf_vport *vport) { +struct virtchnl2_queue_group_id qg_ids[CPFL_P2P_NB_QUEUE_GRPS ] = {0 }; +int ret =0 ; + + qg_ids[0 ].queue_group_id =CPFL_P2P_QUEUE_GRP_ID ; + qg_ids[0 ].queue_group_type =VIRTCHNL2_QUEUE_GROUP_P2P ; + ret =idpf_vc_queue_grps_del (vport,CPFL_P2P_NB_QUEUE_GRPS , qg_ids); +if (ret) +PMD_DRV_LOG (ERR ,"Failed to delete p2p queue groups" ); +return ret; +} +static int cpfl_dev_close(struct rte_eth_dev *dev) { @@ -864,6 +878,9 @@
cpfl_dev_close(struct rte_eth_dev *dev)
structcpfl_adapter_ext*adapter = CPFL_ADAPTER_TO_EXT(vport-Quoted 1 line
adapter);
drivers/net/cpfl/cpfl_ethdev.c +3
-0cpfl_dev_stop (dev); + +cpfl_p2p_queue_grps_del (vport); +idpf_vport_deinit (vport); adapter->cur_vports &= ~RTE_BIT32(vport->devarg_id); @@ -1350,6 +1367,96 @@
cpfl_vport_idx_alloc(struct cpfl_adapter_ext *adapter)drivers/net/cpfl/cpfl_ethdev.c +3
-0return vport_idx; } +static int +cpfl_p2p_q_grps_add (struct idpf_vport *vport, + struct virtchnl2_add_queue_groups
*p2p_queue_grps_info,drivers/net/cpfl/cpfl_ethdev.c +6
-0+ uint8_t *p2p_q_vc_out_info) +{ +int ret; + + p2p_queue_grps_info->vport_id = vport->vport_id; + p2p_queue_grps_info->qg_info.num_queue_groups =
CPFL_P2P_NB_QUEUE_GRPS;drivers/net/cpfl/cpfl_ethdev.c +1
-0+ p2p_queue_grps_info->qg_info.groups[0].num_rx_q =
CPFL_MAX_P2P_NB_QUEUES;drivers/net/cpfl/cpfl_ethdev.c +1
-0+ p2p_queue_grps_info->qg_info.groups[0].num_rx_bufq =
CPFL_P2P_NB_RX_BUFQ;drivers/net/cpfl/cpfl_ethdev.c +1
-0+ p2p_queue_grps_info->qg_info.groups[0].num_tx_q =
CPFL_MAX_P2P_NB_QUEUES;drivers/net/cpfl/cpfl_ethdev.c +1
-0+ p2p_queue_grps_info->qg_info.groups[0].num_tx_complq =
CPFL_P2P_NB_TX_COMPLQ;drivers/net/cpfl/cpfl_ethdev.c +1
-0+ p2p_queue_grps_info->qg_info.groups[0].qg_id.queue_group_id =
CPFL_P2P_QUEUE_GRP_ID;drivers/net/cpfl/cpfl_ethdev.c +1
-0+ p2p_queue_grps_info->qg_info.groups[0 ].qg_id.queue_group_type=
VIRTCHNL2_QUEUE_GROUP_P2P;drivers/net/cpfl/cpfl_ethdev.c +1
-0+ p2p_queue_grps_info-Quoted 1 line
qg_info.groups[0].rx_q_grp_info.rss_lut_size = 0;
drivers/net/cpfl/cpfl_ethdev.c +2
-0+ p2p_queue_grps_info->qg_info.groups[0 ].tx_q_grp_info.tx_tc =0 ; + p2p_queue_grps_info->qg_info.groups[0].tx_q_grp_info.priority =0;
drivers/net/cpfl/cpfl_ethdev.c +2
-0+ p2p_queue_grps_info->qg_info.groups[0 ].tx_q_grp_info.is_sp =0 ; + p2p_queue_grps_info->qg_info.groups[0 ].tx_q_grp_info.pir_weight= 0;
drivers/net/cpfl/cpfl_ethdev.c +2
-0+ + ret = idpf_vc_queue_grps_add(vport, p2p_queue_grps_info,
p2p_q_vc_out_info);drivers/net/cpfl/cpfl_ethdev.c +11
-0+if (ret !=0 ) { +PMD_DRV_LOG (ERR ,"Failed to add p2p queue groups." ); +return ret; + } + +return ret; +} + +static int +cpfl_p2p_queue_info_init (struct cpfl_vport *cpfl_vport, + struct virtchnl2_add_queue_groups
*p2p_q_vc_out_info) {drivers/net/cpfl/cpfl_ethdev.c +1
-0+ struct p2p_queue_chunks_info *p2p_q_chunks_info =
&cpfl_vport->p2p_q_chunks_info;drivers/net/cpfl/cpfl_ethdev.c +4
-0+struct virtchnl2_queue_reg_chunks *vc_chunks_out; +int i, type; + + if (p2p_q_vc_out_info-Quoted 1 line
qg_info.groups[0].qg_id.queue_group_type !=
drivers/net/cpfl/cpfl_ethdev.c +2
-0+ VIRTCHNL2_QUEUE_GROUP_P2P) { + PMD_DRV_LOG(ERR, "Add queue group responsemismatch.");
drivers/net/cpfl/cpfl_ethdev.c +49
-1+return -EINVAL ; + } + + vc_chunks_out = &p2p_q_vc_out_info->qg_info.groups[0 ].chunks; + +for (i =0 ; i < vc_chunks_out->num_chunks; i++) { + type = vc_chunks_out->chunks[i].type; +switch (type) { +case VIRTCHNL2_QUEUE_TYPE_TX : + p2p_q_chunks_info->tx_start_qid = + vc_chunks_out->chunks[i].start_queue_id; + p2p_q_chunks_info->tx_qtail_start = + vc_chunks_out->chunks[i].qtail_reg_start; + p2p_q_chunks_info->tx_qtail_spacing = + vc_chunks_out->chunks[i].qtail_reg_spacing; +break ; +case VIRTCHNL2_QUEUE_TYPE_RX : + p2p_q_chunks_info->rx_start_qid = + vc_chunks_out->chunks[i].start_queue_id; + p2p_q_chunks_info->rx_qtail_start = + vc_chunks_out->chunks[i].qtail_reg_start; + p2p_q_chunks_info->rx_qtail_spacing = + vc_chunks_out->chunks[i].qtail_reg_spacing; +break ; +case VIRTCHNL2_QUEUE_TYPE_TX_COMPLETION : + p2p_q_chunks_info->tx_compl_start_qid = + vc_chunks_out->chunks[i].start_queue_id; + p2p_q_chunks_info->tx_compl_qtail_start = + vc_chunks_out->chunks[i].qtail_reg_start; + p2p_q_chunks_info->tx_compl_qtail_spacing = + vc_chunks_out->chunks[i].qtail_reg_spacing; +break ; +case VIRTCHNL2_QUEUE_TYPE_RX_BUFFER : + p2p_q_chunks_info->rx_buf_start_qid = + vc_chunks_out->chunks[i].start_queue_id; + p2p_q_chunks_info->rx_buf_qtail_start = + vc_chunks_out->chunks[i].qtail_reg_start; + p2p_q_chunks_info->rx_buf_qtail_spacing = + vc_chunks_out->chunks[i].qtail_reg_spacing; +break ; +default : +PMD_DRV_LOG (ERR ,"Unsupported queue type" ); +break ; + } + } + +return 0 ; +} +static int cpfl_dev_vport_init(struct rte_eth_dev *dev, void *init_params) { @@ -1359,6 +1466,8 @@
cpfl_dev_vport_init(struct rte_eth_dev *dev, void *init_params)drivers/net/cpfl/cpfl_ethdev.c +15
-0struct cpfl_adapter_ext *adapter = param->adapter;/* for sending create vport virtchnl msg prepare */ struct virtchnl2_create_vport create_vport_info; +struct virtchnl2_add_queue_groups p2p_queue_grps_info; +uint8_t p2p_q_vc_out_info[IDPF_DFLT_MBX_BUF_SIZE ] = {0 };int ret =0 ; dev->dev_ops = &cpfl_eth_dev_ops;@@ -1380,6 +1489,19 @@ cpfl_dev_vport_init(struct rte_eth_dev *dev, void *init_params) goto err; } +memset (&p2p_queue_grps_info,0 ,sizeof (p2p_queue_grps_info)); + ret =cpfl_p2p_q_grps_add (vport, &p2p_queue_grps_info, p2p_q_vc_out_info); +if (ret !=0 ) { +PMD_INIT_LOG (ERR ,"Failed to add p2p queue group." ); + goto err_q_grps_add; + } + ret =cpfl_p2p_queue_info_init (cpfl_vport, + (struct virtchnl2_add_queue_groups *)p2p_q_vc_out_info); +if (ret !=0 ) { +PMD_INIT_LOG (ERR ,"Failed to init p2p queue info." ); + goto err_p2p_qinfo_init; + } +drivers/net/cpfl/cpfl_ethdev.c +3
-0adapter->vports[param->idx] = cpfl_vport; adapter->cur_vports |=RTE_BIT32 (param->devarg_id); adapter->cur_vport_nb++;@@ -1397,6 +1519,9 @@ cpfl_dev_vport_init(struct rte_eth_dev *dev, void *init_params)return 0 ; err_mac_addrs: +err_p2p_qinfo_init: +cpfl_p2p_queue_grps_del (vport); +err_q_grps_add: adapter->vports[param->idx] =NULL ;/* reset */ idpf_vport_deinit (vport);
adapter->cur_vports&= ~RTE_BIT32(param->devarg_id); diff --gita/drivers/net/cpfl/cpfl_ethdev.hb/drivers/net/cpfl/cpfl_ethdev.hindex81fe9ac4c3..5e2e7a1bfb100644drivers/net/cpfl/cpfl_ethdev.h +17
-0@@ -69,8 +69,25 @@ struct cpfl_devargs {uint16_t req_vport_nb; }; +struct p2p_queue_chunks_info { +uint32_t tx_start_qid; +uint32_t rx_start_qid; +uint32_t tx_compl_start_qid; +uint32_t rx_buf_start_qid; + +uint64_t tx_qtail_start; +uint32_t tx_qtail_spacing; +uint64_t rx_qtail_start; +uint32_t rx_qtail_spacing; +uint64_t tx_compl_qtail_start; +uint32_t tx_compl_qtail_spacing; +uint64_t rx_buf_qtail_start; +uint32_t rx_buf_qtail_spacing; +}; +struct cpfl_vport {struct idpf_vport base; +struct p2p_queue_chunks_info p2p_q_chunks_info; };struct cpfl_adapter_ext {(quoted diff) +0
-0
b/drivers/net/cpfl/cpfl_rxtx.hindexb2b3537d10..3a87a1f4b3100644drivers/net/cpfl/cpfl_rxtx.h +4
-1@@ -17,6 +17,10 @@#define CPFL_MAX_HAIRPINQ_TX_2_RX 1#define CPFL_MAX_HAIRPINQ_NB_DESC 1024#define CPFL_MAX_P2P_NB_QUEUES 16 +#define CPFL_P2P_NB_RX_BUFQ 1 +#define CPFL_P2P_NB_TX_COMPLQ 1 +#define CPFL_P2P_NB_QUEUE_GRPS 1 +#define CPFL_P2P_QUEUE_GRP_ID 1/* Base address of the HW descriptor ring should be 128B aligned. */ #define CPFL_RING_BASE_ALIGN 128 --2.26.2
PATCH 5/10 net/cpfl: support hairpin queue setup and release
In reply to [email protected]From: Beilei Xing <[email protected]>
Support hairpin Rx/Tx queue setup and release.
--- drivers/net/cpfl/cpfl_ethdev.c | 6 + drivers/net/cpfl/cpfl_ethdev.h | 10 + drivers/net/cpfl/cpfl_rxtx.c | 373 +++++++++++++++++++++++- drivers/net/cpfl/cpfl_rxtx.h | 28 ++ drivers/net/cpfl/cpfl_rxtx_vec_common.h | 4 + 5 files changed, 420 insertions(+), 1 deletion(-)
drivers/net/cpfl/cpfl_ethdev.c +6 -0
@@ -878,6 +878,10 @@ cpfl_dev_close(struct rte_eth_dev *dev)struct cpfl_adapter_ext *adapter =CPFL_ADAPTER_TO_EXT (vport->adapter);cpfl_dev_stop (dev); +if (cpfl_vport->p2p_mp) { +rte_mempool_free (cpfl_vport->p2p_mp); + cpfl_vport->p2p_mp =NULL ; + }cpfl_p2p_queue_grps_del (vport);
@@ -919,6 +923,8 @@ static const struct eth_dev_ops cpfl_eth_dev_ops = { .xstats_get_names = cpfl_dev_xstats_get_names, .xstats_reset = cpfl_dev_xstats_reset, .hairpin_cap_get = cpfl_hairpin_cap_get, + .rx_hairpin_queue_setup = cpfl_rx_hairpin_queue_setup, + .tx_hairpin_queue_setup = cpfl_tx_hairpin_queue_setup, }; static int
drivers/net/cpfl/cpfl_ethdev.h +10 -0
@@ -88,6 +88,16 @@ struct p2p_queue_chunks_info {struct cpfl_vport {struct idpf_vport base;struct p2p_queue_chunks_info p2p_q_chunks_info; + +struct rte_mempool *p2p_mp; + +uint16_t nb_data_rxq; +uint16_t nb_data_txq; +uint16_t nb_p2p_rxq; +uint16_t nb_p2p_txq; + +struct idpf_rx_queue *p2p_rx_bufq; +struct idpf_tx_queue *p2p_tx_complq; };struct cpfl_adapter_ext {
drivers/net/cpfl/cpfl_rxtx.c +372 -1
409 lines not on this page · raw message
drivers/net/cpfl/cpfl_rxtx.h +28 -0
@@ -13,6 +13,7 @@#define CPFL_MIN_RING_DESC 32#define CPFL_MAX_RING_DESC 4096#define CPFL_DMA_MEM_ALIGN 4096 +#define CPFL_P2P_DESC_LEN 16#define CPFL_MAX_HAIRPINQ_RX_2_TX 1#define CPFL_MAX_HAIRPINQ_TX_2_RX 1#define CPFL_MAX_HAIRPINQ_NB_DESC 1024
@@ -21,6 +22,10 @@#define CPFL_P2P_NB_TX_COMPLQ 1#define CPFL_P2P_NB_QUEUE_GRPS 1#define CPFL_P2P_QUEUE_GRP_ID 1 +#define CPFL_P2P_NB_MBUF 4096 +#define CPFL_P2P_CACHE_SIZE 250 +#define CPFL_P2P_MBUF_SIZE 2048 +#define CPFL_P2P_RING_BUF 128/* Base address of the HW descriptor ring should be 128B aligned. */ #define CPFL_RING_BASE_ALIGN 128
@@ -31,12 +36,28 @@#define CPFL_SUPPORT_CHAIN_NUM 5 +struct cpfl_rxq_hairpin_info { +bool hairpin_q;/* if rx queue is a hairpin queue */ +bool manual_bind;/* for cross vport */ +uint16_t peer_txp; +uint16_t peer_txq_id; +}; +struct cpfl_rx_queue {struct idpf_rx_queue base; +struct cpfl_rxq_hairpin_info hairpin_info; +}; + +struct cpfl_txq_hairpin_info { +bool hairpin_q;/* if tx queue is a hairpin queue */ +bool manual_bind;/* for cross vport */ +uint16_t peer_rxp; +uint16_t peer_rxq_id; };struct cpfl_tx_queue {struct idpf_tx_queue base; +struct cpfl_txq_hairpin_info hairpin_info; }; int cpfl_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
@@ -57,4 +78,11 @@ void cpfl_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid);void cpfl_dev_rx_queue_release (struct rte_eth_dev *dev,uint16_t qid);void cpfl_set_rx_function (struct rte_eth_dev *dev);void cpfl_set_tx_function (struct rte_eth_dev *dev); +uint16_t cpfl_hw_qid_get (uint16_t start_qid,uint16_t offset); +uint64_t cpfl_hw_qtail_get (uint64_t tail_start,uint16_t offset,uint64_t tail_spacing); +int cpfl_rx_hairpin_queue_setup (struct rte_eth_dev *dev,uint16_t queue_idx, +uint16_t nb_desc,const struct rte_eth_hairpin_conf *conf); +int cpfl_tx_hairpin_queue_setup (struct rte_eth_dev *dev,uint16_t queue_idx, +uint16_t nb_desc, +const struct rte_eth_hairpin_conf *conf);#endif /* _CPFL_RXTX_H_ */
drivers/net/cpfl/cpfl_rxtx_vec_common.h +4 -0
@@ -85,6 +85,8 @@ cpfl_rx_vec_dev_check_default(struct rte_eth_dev *dev) cpfl_rxq = dev->data->rx_queues[i]; default_ret =cpfl_rx_vec_queue_default (&cpfl_rxq->base);if (vport->rxq_model ==VIRTCHNL2_QUEUE_MODEL_SPLIT ) { +if (cpfl_rxq->hairpin_info.hairpin_q) +continue ; splitq_ret =cpfl_rx_splitq_vec_default (&cpfl_rxq->base); ret = splitq_ret && default_ret; }else {
@@ -106,6 +108,8 @@ cpfl_tx_vec_dev_check_default(struct rte_eth_dev *dev)for (i =0 ; i < dev->data->nb_tx_queues; i++) { cpfl_txq = dev->data->tx_queues[i]; +if (cpfl_txq->hairpin_info.hairpin_q) +continue ; ret =cpfl_tx_vec_queue_default (&cpfl_txq->base);if (ret ==CPFL_SCALAR_PATH )return CPFL_SCALAR_PATH ;
Signature · 1 line
2.26.2
PATCH 6/10 net/cpfl: support hairpin queue configuration
In reply to [email protected]From: Beilei Xing <[email protected]>
This patch supports Rx/Tx hairpin queue configuration.
--- drivers/common/idpf/idpf_common_virtchnl.c | 70 +++++++++++ drivers/common/idpf/idpf_common_virtchnl.h | 6 + drivers/common/idpf/version.map | 2 + drivers/net/cpfl/cpfl_ethdev.c | 136 ++++++++++++++++++++- drivers/net/cpfl/cpfl_rxtx.c | 80 ++++++++++++ drivers/net/cpfl/cpfl_rxtx.h | 7 ++ 6 files changed, 297 insertions(+), 4 deletions(-)
drivers/common/idpf/idpf_common_virtchnl.c +70 -0
@@ -1050,6 +1050,41 @@ idpf_vc_rxq_config(struct idpf_vport *vport, struct idpf_rx_queue *rxq)return err; } +int idpf_vc_rxq_config_by_info (struct idpf_vport *vport,struct virtchnl2_rxq_info *rxq_info, +uint16_t num_qs) +{ +struct idpf_adapter *adapter = vport->adapter; +struct virtchnl2_config_rx_queues *vc_rxqs =NULL ; +struct idpf_cmd_info args; +int size, err, i; + + size =sizeof (*vc_rxqs) + (num_qs -1 ) * +sizeof (struct virtchnl2_rxq_info ); + vc_rxqs =rte_zmalloc ("cfg_rxqs" , size,0 ); +if (vc_rxqs ==NULL ) { +DRV_LOG (ERR ,"Failed to allocate virtchnl2_config_rx_queues" ); + err = -ENOMEM ; +return err; + } + vc_rxqs->vport_id = vport->vport_id; + vc_rxqs->num_qinfo = num_qs; +memcpy (vc_rxqs->qinfo, rxq_info, num_qs *sizeof (struct virtchnl2_rxq_info )); + +memset (&args,0 ,sizeof (args)); + args.ops =VIRTCHNL2_OP_CONFIG_RX_QUEUES ; + args.in_args = (uint8_t *)vc_rxqs; + args.in_args_size = size; + args.out_buffer = adapter->mbx_resp; + args.out_size =IDPF_DFLT_MBX_BUF_SIZE ; + + err =idpf_vc_cmd_execute (adapter, &args); +rte_free (vc_rxqs); +if (err !=0 ) +DRV_LOG (ERR ,"Failed to execute command of VIRTCHNL2_OP_CONFIG_RX_QUEUES" ); + +return err; +} +int idpf_vc_txq_config (struct idpf_vport *vport,struct idpf_tx_queue *txq) {
@@ -1121,6 +1156,41 @@ idpf_vc_txq_config(struct idpf_vport *vport, struct idpf_tx_queue *txq)return err; } +int +idpf_vc_txq_config_by_info (struct idpf_vport *vport,struct virtchnl2_txq_info *txq_info, +uint16_t num_qs) +{ +struct idpf_adapter *adapter = vport->adapter; +struct virtchnl2_config_tx_queues *vc_txqs =NULL ; +struct idpf_cmd_info args; +int size, err; + + size =sizeof (*vc_txqs) + (num_qs -1 ) *sizeof (struct virtchnl2_txq_info ); + vc_txqs =rte_zmalloc ("cfg_txqs" , size,0 ); +if (vc_txqs ==NULL ) { +DRV_LOG (ERR ,"Failed to allocate virtchnl2_config_tx_queues" ); + err = -ENOMEM ; +return err; + } + vc_txqs->vport_id = vport->vport_id; + vc_txqs->num_qinfo = num_qs; +memcpy (vc_txqs->qinfo, txq_info, num_qs *sizeof (struct virtchnl2_txq_info )); + +memset (&args,0 ,sizeof (args)); + args.ops =VIRTCHNL2_OP_CONFIG_TX_QUEUES ; + args.in_args = (uint8_t *)vc_txqs; + args.in_args_size = size; + args.out_buffer = adapter->mbx_resp; + args.out_size =IDPF_DFLT_MBX_BUF_SIZE ; + + err =idpf_vc_cmd_execute (adapter, &args); +rte_free (vc_txqs); +if (err !=0 ) +DRV_LOG (ERR ,"Failed to execute command of VIRTCHNL2_OP_CONFIG_TX_QUEUES" ); + +return err; +} +int idpf_vc_ctlq_recv (struct idpf_ctlq_info *cq,u16 *num_q_msg,struct idpf_ctlq_msg *q_msg)
drivers/common/idpf/idpf_common_virtchnl.h +6 -0
@@ -65,6 +65,12 @@ __rte_internalint idpf_vc_ctlq_post_rx_buffs (struct idpf_hw *hw,struct idpf_ctlq_info *cq,u16 *buff_count,struct idpf_dma_mem **buffs);__rte_internal +int idpf_vc_rxq_config_by_info(struct idpf_vport *vport, struct virtchnl2_rxq_info *rxq_info, +uint16_t num_qs); +__rte_internal +int idpf_vc_txq_config_by_info(struct idpf_vport *vport, struct virtchnl2_txq_info *txq_info, +uint16_t num_qs); +__rte_internal int idpf_vc_queue_grps_del(struct idpf_vport *vport,uint16_t num_q_grps,struct virtchnl2_queue_group_id *qg_ids);
drivers/common/idpf/version.map +2 -0
@@ -59,8 +59,10 @@ INTERNAL { idpf_vc_rss_lut_get; idpf_vc_rss_lut_set; idpf_vc_rxq_config; + idpf_vc_rxq_config_by_info; idpf_vc_stats_query; idpf_vc_txq_config; + idpf_vc_txq_config_by_info; idpf_vc_vectors_alloc; idpf_vc_vectors_dealloc; idpf_vc_vport_create;
drivers/net/cpfl/cpfl_ethdev.c +132 -4
164 lines not on this page · raw message
drivers/net/cpfl/cpfl_rxtx.c +80 -0
86 lines not on this page · raw message
drivers/net/cpfl/cpfl_rxtx.h +7 -0
@@ -30,12 +30,15 @@#define CPFL_RING_BASE_ALIGN 128#define CPFL_DEFAULT_RX_FREE_THRESH 32 +#define CPFL_RXBUF_LOW_WATERMARK 64#define CPFL_DEFAULT_TX_RS_THRESH 32#define CPFL_DEFAULT_TX_FREE_THRESH 32#define CPFL_SUPPORT_CHAIN_NUM 5 +#define CPFL_RX_BUF_STRIDE 64 +struct cpfl_rxq_hairpin_info {bool hairpin_q;/* if rx queue is a hairpin queue */ bool manual_bind;/* for cross vport */
@@ -85,4 +88,8 @@ int cpfl_rx_hairpin_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,int cpfl_tx_hairpin_queue_setup (struct rte_eth_dev *dev,uint16_t queue_idx,uint16_t nb_desc,const struct rte_eth_hairpin_conf *conf); +int cpfl_hairpin_tx_complq_config (struct cpfl_vport *cpfl_vport); +int cpfl_hairpin_txq_config (struct idpf_vport *vport,struct cpfl_tx_queue *cpfl_txq); +int cpfl_hairpin_rx_bufq_config (struct cpfl_vport *cpfl_vport); +int cpfl_hairpin_rxq_config (struct idpf_vport *vport,struct cpfl_rx_queue *cpfl_rxq);#endif /* _CPFL_RXTX_H_ */
Signature · 1 line
2.26.2
RE: [PATCH 06/10] net/cpfl: support hairpin queue configuration
Quoted 261 lines
-----Original Message-----
From: Xing, Beilei <[email protected]>
Sent: Friday, April 21, 2023 2:51 PM
To: Wu, Jingjing <[email protected]>
Cc: [email protected]; Liu, Mingxia <[email protected]>; Xing, Beilei <[email protected]>; Wang, Xiao W <[email protected]>
Subject: [PATCH 06/10] net/cpfl: support hairpin queue configurationFrom: Beilei Xing <[email protected]>
This patch supports Rx/Tx hairpin queue configuration.
Signed-off-by Xiao Wang <[email protected]>Signed-off-by Mingxia Liu <[email protected]>Signed-off-by Beilei Xing <[email protected]>--- drivers/common/idpf/idpf_common_virtchnl.c | 70 +++++++++++ drivers/common/idpf/idpf_common_virtchnl.h | 6 + drivers/common/idpf/version.map | 2 + drivers/net/cpfl/cpfl_ethdev.c | 136 ++++++++++++++++++++- drivers/net/cpfl/cpfl_rxtx.c | 80 ++++++++++++ drivers/net/cpfl/cpfl_rxtx.h | 7 ++ 6 files changed, 297 insertions(+), 4 deletions(-)drivers/common/idpf/idpf_common_virtchnl.c +37
-0@@ -1050,6 +1050,41 @@ idpf_vc_rxq_config(struct idpf_vport *vport, struct idpf_rx_queue *rxq)return err; } +int idpf_vc_rxq_config_by_info (struct idpf_vport *vport,struct virtchnl2_rxq_info *rxq_info, +uint16_t num_qs) +{ +struct idpf_adapter *adapter = vport->adapter; +struct virtchnl2_config_rx_queues *vc_rxqs =NULL ; +struct idpf_cmd_info args; +int size, err, i; + + size =sizeof (*vc_rxqs) + (num_qs -1 ) * +sizeof (struct virtchnl2_rxq_info ); + vc_rxqs =rte_zmalloc ("cfg_rxqs" , size,0 ); +if (vc_rxqs ==NULL ) { +DRV_LOG (ERR ,"Failed to allocate virtchnl2_config_rx_queues" ); + err = -ENOMEM ; +return err; + } + vc_rxqs->vport_id = vport->vport_id; + vc_rxqs->num_qinfo = num_qs; +memcpy (vc_rxqs->qinfo, rxq_info, num_qs *sizeof (struct +virtchnl2_rxq_info )); + +memset (&args,0 ,sizeof (args)); + args.ops =VIRTCHNL2_OP_CONFIG_RX_QUEUES ; + args.in_args = (uint8_t *)vc_rxqs; + args.in_args_size = size; + args.out_buffer = adapter->mbx_resp; + args.out_size =IDPF_DFLT_MBX_BUF_SIZE ; + + err =idpf_vc_cmd_execute (adapter, &args); +rte_free (vc_rxqs); +if (err !=0 ) +DRV_LOG (ERR ,"Failed to execute command of +VIRTCHNL2_OP_CONFIG_RX_QUEUES"); + +return err; +} +int idpf_vc_txq_config(struct idpf_vport *vport, struct idpf_tx_queue *txq) { @@ -1121,6 +1156,41 @@
idpf_vc_txq_config(struct idpf_vport *vport, struct idpf_tx_queue *txq)drivers/common/idpf/idpf_common_virtchnl.c +2
-0return err; } +int +idpf_vc_txq_config_by_info(struct idpf_vport *vport, struct virtchnl2_txq_info
*txq_info,drivers/common/idpf/idpf_common_virtchnl.c +35
-0+ uint16_t num_qs) +{ +struct idpf_adapter *adapter = vport->adapter; +struct virtchnl2_config_tx_queues *vc_txqs =NULL ; +struct idpf_cmd_info args; +int size, err; + + size =sizeof (*vc_txqs) + (num_qs -1 ) *sizeof (struct virtchnl2_txq_info ); + vc_txqs =rte_zmalloc ("cfg_txqs" , size,0 ); +if (vc_txqs ==NULL ) { +DRV_LOG (ERR ,"Failed to allocate virtchnl2_config_tx_queues" ); + err = -ENOMEM ; +return err; + } + vc_txqs->vport_id = vport->vport_id; + vc_txqs->num_qinfo = num_qs; +memcpy (vc_txqs->qinfo, txq_info, num_qs *sizeof (struct +virtchnl2_txq_info )); + +memset (&args,0 ,sizeof (args)); + args.ops =VIRTCHNL2_OP_CONFIG_TX_QUEUES ; + args.in_args = (uint8_t *)vc_txqs; + args.in_args_size = size; + args.out_buffer = adapter->mbx_resp; + args.out_size =IDPF_DFLT_MBX_BUF_SIZE ; + + err =idpf_vc_cmd_execute (adapter, &args); +rte_free (vc_txqs); +if (err !=0 ) +DRV_LOG (ERR ,"Failed to execute command of +VIRTCHNL2_OP_CONFIG_TX_QUEUES"); + +return err; +} +int idpf_vc_ctlq_recv (struct idpf_ctlq_info *cq,u16 *num_q_msg,struct idpf_ctlq_msg *q_msg)drivers/common/idpf/idpf_common_virtchnl.h +0
-0@@ -65,6 +65,12 @@ __rte_internalint idpf_vc_ctlq_post_rx_buffs (struct idpf_hw *hw,struct idpf_ctlq_info *cq,u16 *buff_count,struct idpf_dma_mem **buffs);
__rte_internal
+int idpf_vc_rxq_config_by_info(structidpf_vport*vport, structvirtchnl2_rxq_info*rxq_info,drivers/common/idpf/idpf_common_virtchnl.h +3
-0+ uint16_t num_qs); +__rte_internal +int idpf_vc_txq_config_by_info(struct idpf_vport *vport, struct
virtchnl2_txq_info*txq_info,drivers/common/idpf/idpf_common_virtchnl.h +2
-0+ uint16_t num_qs); +__rte_internal int idpf_vc_queue_grps_del(struct idpf_vport *vport,uint16_t num_q_grps, struct virtchnl2_queue_group_id *qg_ids); diff --gita/drivers/common/idpf/version.map b/drivers/common/idpf/version.map index
aa67f7ee27..a339a4bf8e100644drivers/common/idpf/version.map +2
-0@@ -59,8 +59,10 @@ INTERNAL { idpf_vc_rss_lut_get; idpf_vc_rss_lut_set; idpf_vc_rxq_config; + idpf_vc_rxq_config_by_info; idpf_vc_stats_query; idpf_vc_txq_config; + idpf_vc_txq_config_by_info; idpf_vc_vectors_alloc; idpf_vc_vectors_dealloc; idpf_vc_vport_create;drivers/net/cpfl/cpfl_ethdev.c index renamed from drivers/net/cpfl/cpfl_ethdev.c +0
-0
d3300f17cc..13edf2e706100644drivers/net/cpfl/cpfl_ethdev.c +79
-1@@ -737,32 +737,160 @@ cpfl_config_rx_queues_irqs(struct rte_eth_dev *dev)return idpf_vport_irq_map_config (vport, nb_rx_queues); } +/* Update hairpin_info for dev's tx hairpin queue */ static int +cpfl_txq_hairpin_info_update (struct rte_eth_dev *dev,uint16_t rx_port) +{ +struct cpfl_vport *cpfl_tx_vport = dev->data->dev_private; +struct rte_eth_dev *peer_dev = &rte_eth_devices[rx_port]; +struct cpfl_vport *cpfl_rx_vport = peer_dev->data->dev_private; +struct cpfl_txq_hairpin_info *hairpin_info; +struct cpfl_tx_queue *cpfl_txq; +int i; + +for (i = cpfl_tx_vport->nb_data_txq; i < dev->data->nb_tx_queues; i++) { + cpfl_txq = dev->data->tx_queues[i]; + hairpin_info = &cpfl_txq->hairpin_info; +if (hairpin_info->peer_rxp != rx_port) { +PMD_DRV_LOG (ERR ,"port %d is not the peer port" , rx_port); +return -EINVAL ; + } + hairpin_info->peer_rxq_id = +cpfl_hw_qid_get (cpfl_rx_vport- >p2p_q_chunks_info.rx_start_qid, + hairpin_info->peer_rxq_id - cpfl_rx_vport->nb_data_rxq); + } + +return 0 ; +} + +/* Bind Rx hairpin queue's memory zone to peer Tx hairpin queue's +memory zone */ static void cpfl_rxq_hairpin_mz_bind (struct rte_eth_dev +*dev) { +struct cpfl_vport *cpfl_rx_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_rx_vport->base; +struct idpf_adapter *adapter = vport->adapter; +struct idpf_hw *hw = &adapter->hw; +struct cpfl_rx_queue *cpfl_rxq; +struct cpfl_tx_queue *cpfl_txq; +struct rte_eth_dev *peer_dev; +const struct rte_memzone *mz; +uint16_t peer_tx_port; +uint16_t peer_tx_qid; +int i; + +for (i = cpfl_rx_vport->nb_data_rxq; i < dev->data->nb_rx_queues; i++) { + cpfl_rxq = dev->data->rx_queues[i]; + peer_tx_port = cpfl_rxq->hairpin_info.peer_txp; + peer_tx_qid = cpfl_rxq->hairpin_info.peer_txq_id; + peer_dev = &rte_eth_devices[peer_tx_port]; + cpfl_txq = peer_dev->data->tx_queues[peer_tx_qid]; + +/* bind rx queue */ + mz = cpfl_txq->base.mz; + cpfl_rxq->base.rx_ring_phys_addr = mz->iova; + cpfl_rxq->base.rx_ring = mz->addr; + cpfl_rxq->base.mz = mz; + +/* bind rx buffer queue */ + mz = cpfl_txq->base.complq->mz; + cpfl_rxq->base.bufq1->rx_ring_phys_addr = mz->iova; + cpfl_rxq->base.bufq1->rx_ring = mz->addr; + cpfl_rxq->base.bufq1->mz = mz; + cpfl_rxq->base.bufq1->qrx_tail = hw->hw_addr + +cpfl_hw_qtail_get (cpfl_rx_vport- >p2p_q_chunks_info.rx_buf_qtail_start, +0 , cpfl_rx_vport- >p2p_q_chunks_info.rx_buf_qtail_spacing); + } +} +static int cpfl_start_queues (struct rte_eth_dev *dev) { +struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;struct cpfl_rx_queue *cpfl_rxq;struct cpfl_tx_queue *cpfl_txq; +int tx_cmplq_flag =0 ; +int rx_bufq_flag =0 ; +int flag =0 ;int err =0 ;int i; +/* For normal data queues, configure, init and enale Txq. +* For non-cross vport hairpin queues, configure Txq. +*/ for (i =0 ; i < dev->data->nb_tx_queues; i++) { cpfl_txq = dev->data->tx_queues[i];if (cpfl_txq ==NULL || cpfl_txq->base.tx_deferred_start)continue ; - err =cpfl_tx_queue_start (dev, i); +if (!cpfl_txq->hairpin_info.hairpin_q) { + err =cpfl_tx_queue_start (dev, i); +if (err !=0 ) { + PMD_DRV_LOG(ERR, "Fail to start Tx queue %u", i); + return err; + } + }else if (!cpfl_txq->hairpin_info.manual_bind) {
drivers/net/cpfl/cpfl_ethdev.c cpfl_config_rx_queues_irqs(struct rte_eth_dev *dev) · line 844
Quoted 10 lines
drivers/net/cpfl/cpfl_ethdev.c +8
-0+if (flag ==0 ) { + err =cpfl_txq_hairpin_info_update (dev, + cpfl_txq- >hairpin_info.peer_rxp); +if (err !=0 ) { + PMD_DRV_LOG(ERR, "Fail to update Tx hairpin queue info"); + return err; + } + flag =1 ;
[Liu, Mingxia] The variable flag is not been used, can it be removed?
Quoted 21 lines
drivers/net/cpfl/cpfl_ethdev.c +11
-0+ } + err =cpfl_hairpin_txq_config (vport, cpfl_txq); +if (err !=0 ) { + PMD_DRV_LOG(ERR, "Fail to configure hairpin Tx queue %u", i); + return err; + } + tx_cmplq_flag =1 ; + } + } + +/* For non-cross vport hairpin queues, configure Tx completion queue first.*/
drivers/net/cpfl/cpfl_ethdev.c +3
-1+if (tx_cmplq_flag ==1 && cpfl_vport->p2p_tx_complq !=NULL ) { + err =cpfl_hairpin_tx_complq_config (cpfl_vport);if (err !=0 ) { -PMD_DRV_LOG (ERR ,"Fail to start Tx queue %u" , i); + PMD_DRV_LOG(ERR, "Fail to config Tx completionqueue");
drivers/net/cpfl/cpfl_ethdev.c cpfl_config_rx_queues_irqs(struct rte_eth_dev *dev) · line 858
Quoted 3 lines
drivers/net/cpfl/cpfl_ethdev.c +0
-0return err; } }
[Liu, Mingxia] Better to move this code next to
+ err = cpfl_hairpin_txq_config(vport, cpfl_txq);
+ if (err != 0) {
+ PMD_DRV_LOG(ERR, "Fail to configure hairpin Tx queue %u", i);
+ return err;
+ }
When cpfl_rxq->hairpin_info.hairpin_q is true, then cpfl_vport->p2p_tx_complq is not null, right ? And remove tx_cmplq_flag?
Quoted 33 lines
drivers/net/cpfl/cpfl_ethdev.c +8
-1+/* For normal data queues, configure, init and enale Rxq. +* For non-cross vport hairpin queues, configure Rxq, and then init Rxq. +*/ +cpfl_rxq_hairpin_mz_bind (dev);for (i =0 ; i < dev->data->nb_rx_queues; i++) { cpfl_rxq = dev->data->rx_queues[i];if (cpfl_rxq ==NULL || cpfl_rxq->base.rx_deferred_start)continue ; - err =cpfl_rx_queue_start (dev, i); +if (!cpfl_rxq->hairpin_info.hairpin_q) { + err =cpfl_rx_queue_start (dev, i); +if (err !=0 ) { + PMD_DRV_LOG(ERR, "Fail to start Rxqueue %u", i);
drivers/net/cpfl/cpfl_ethdev.c +6
-0+return err; + } + }else if (!cpfl_rxq->hairpin_info.manual_bind) { + err =cpfl_hairpin_rxq_config (vport, cpfl_rxq); +if (err !=0 ) { + PMD_DRV_LOG(ERR, "Fail to configure hairpinRx queue %u", i);
drivers/net/cpfl/cpfl_ethdev.c +5
-0+return err; + } + err =cpfl_rx_queue_init (dev, i); +if (err !=0 ) { + PMD_DRV_LOG(ERR, "Fail to init hairpin Rxqueue %u", i);
drivers/net/cpfl/cpfl_ethdev.c +6
-0+return err; + } + rx_bufq_flag =1 ; + } + } +
drivers/net/cpfl/cpfl_ethdev.c cpfl_config_rx_queues_irqs(struct rte_eth_dev *dev) · line 896
Quoted 10 lines
drivers/net/cpfl/cpfl_ethdev.c +4
-1+/* For non-cross vport hairpin queues, configure Rx buffer queue.*/ +if (rx_bufq_flag ==1 && cpfl_vport->p2p_rx_bufq !=NULL ) { + err =cpfl_hairpin_rx_bufq_config (cpfl_vport);if (err !=0 ) { -PMD_DRV_LOG (ERR ,"Fail to start Rx queue %u" , i); +PMD_DRV_LOG (ERR ,"Fail to config Rx buffer queue" );return err; } }
[Liu, Mingxia] Similar to above.
Quoted 120 lines
drivers/net/cpfl/cpfl_rxtx.c index renamed from drivers/net/cpfl/cpfl_rxtx.c +0
-0
64ed331a6d..040beb5bac100644drivers/net/cpfl/cpfl_rxtx.c +74
-0@@ -930,6 +930,86 @@ cpfl_tx_hairpin_queue_setup(struct rte_eth_dev *dev,uint16_t queue_idx, return 0; } +int +cpfl_hairpin_rx_bufq_config (struct cpfl_vport *cpfl_vport) { +struct idpf_rx_queue *rx_bufq = cpfl_vport->p2p_rx_bufq; +struct virtchnl2_rxq_info rxq_info[1 ] = {0 }; + + rxq_info[0 ].type =VIRTCHNL2_QUEUE_TYPE_RX_BUFFER ; + rxq_info[0 ].queue_id = rx_bufq->queue_id; + rxq_info[0 ].ring_len = rx_bufq->nb_rx_desc; + rxq_info[0 ].dma_ring_addr = rx_bufq->rx_ring_phys_addr; + rxq_info[0 ].desc_ids =VIRTCHNL2_RXDID_2_FLEX_SPLITQ_M ; + rxq_info[0 ].rx_buffer_low_watermark =CPFL_RXBUF_LOW_WATERMARK ; + rxq_info[0 ].model =VIRTCHNL2_QUEUE_MODEL_SPLIT ; + rxq_info[0 ].data_buffer_size = rx_bufq->rx_buf_len; + rxq_info[0 ].buffer_notif_stride =CPFL_RX_BUF_STRIDE ; + +return idpf_vc_rxq_config_by_info (&cpfl_vport->base, rxq_info,1 ); } + +int +cpfl_hairpin_rxq_config (struct idpf_vport *vport,struct cpfl_rx_queue +*cpfl_rxq) { +struct virtchnl2_rxq_info rxq_info[1 ] = {0 }; +struct idpf_rx_queue *rxq = &cpfl_rxq->base; + + rxq_info[0 ].type =VIRTCHNL2_QUEUE_TYPE_RX ; + rxq_info[0 ].queue_id = rxq->queue_id; + rxq_info[0 ].ring_len = rxq->nb_rx_desc; + rxq_info[0 ].dma_ring_addr = rxq->rx_ring_phys_addr; + rxq_info[0 ].rx_bufq1_id = rxq->bufq1->queue_id; + rxq_info[0 ].max_pkt_size = vport->max_pkt_len; + rxq_info[0 ].desc_ids =VIRTCHNL2_RXDID_2_FLEX_SPLITQ_M ; + rxq_info[0 ].qflags |=VIRTCHNL2_RX_DESC_SIZE_16BYTE ; + + rxq_info[0 ].data_buffer_size = rxq->rx_buf_len; + rxq_info[0 ].model =VIRTCHNL2_QUEUE_MODEL_SPLIT ; + rxq_info[0 ].rx_buffer_low_watermark =CPFL_RXBUF_LOW_WATERMARK ; + +PMD_DRV_LOG (NOTICE ,"hairpin: vport %u, Rxq id 0x%x" , + vport->vport_id, rxq_info[0 ].queue_id); + +return idpf_vc_rxq_config_by_info (vport, rxq_info,1 ); } + +int +cpfl_hairpin_tx_complq_config (struct cpfl_vport *cpfl_vport) { +struct idpf_tx_queue *tx_complq = cpfl_vport->p2p_tx_complq; +struct virtchnl2_txq_info txq_info[1 ] = {0 }; + + txq_info[0 ].dma_ring_addr = tx_complq->tx_ring_phys_addr; + txq_info[0 ].type =VIRTCHNL2_QUEUE_TYPE_TX_COMPLETION ; + txq_info[0 ].queue_id = tx_complq->queue_id; + txq_info[0 ].ring_len = tx_complq->nb_tx_desc; + txq_info[0 ].peer_rx_queue_id = cpfl_vport->p2p_rx_bufq->queue_id; + txq_info[0 ].model =VIRTCHNL2_QUEUE_MODEL_SPLIT ; + txq_info[0 ].sched_mode =VIRTCHNL2_TXQ_SCHED_MODE_FLOW ; + +return idpf_vc_txq_config_by_info (&cpfl_vport->base, txq_info,1 ); } + +int +cpfl_hairpin_txq_config (struct idpf_vport *vport,struct cpfl_tx_queue +*cpfl_txq) { +struct idpf_tx_queue *txq = &cpfl_txq->base; +struct virtchnl2_txq_info txq_info[1 ] = {0 }; + + txq_info[0 ].dma_ring_addr = txq->tx_ring_phys_addr; + txq_info[0 ].type =VIRTCHNL2_QUEUE_TYPE_TX ; + txq_info[0 ].queue_id = txq->queue_id; + txq_info[0 ].ring_len = txq->nb_tx_desc; + txq_info[0 ].tx_compl_queue_id = txq->complq->queue_id; + txq_info[0 ].relative_queue_id = txq->queue_id; + txq_info[0 ].peer_rx_queue_id = cpfl_txq->hairpin_info.peer_rxq_id; + txq_info[0 ].model =VIRTCHNL2_QUEUE_MODEL_SPLIT ; + txq_info[0 ].sched_mode =VIRTCHNL2_TXQ_SCHED_MODE_FLOW ; + +return idpf_vc_txq_config_by_info (vport, txq_info,1 ); } +int cpfl_rx_queue_init(struct rte_eth_dev *dev, uint16_t rx_queue_id) { diff --git
a/drivers/net/cpfl/cpfl_rxtx.hb/drivers/net/cpfl/cpfl_rxtx.hindexd844c9f057..b01ce5edf9100644drivers/net/cpfl/cpfl_rxtx.h +8
-1@@ -30,12 +30,15 @@#define CPFL_RING_BASE_ALIGN 128#define CPFL_DEFAULT_RX_FREE_THRESH 32 +#define CPFL_RXBUF_LOW_WATERMARK 64#define CPFL_DEFAULT_TX_RS_THRESH 32#define CPFL_DEFAULT_TX_FREE_THRESH 32#define CPFL_SUPPORT_CHAIN_NUM 5 +#define CPFL_RX_BUF_STRIDE 64 +struct cpfl_rxq_hairpin_info {bool hairpin_q;/* if rx queue is a hairpin queue */ bool manual_bind;/* for cross vport */ @@ -85,4 +88,8 @@ int cpfl_rx_hairpin_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx, int cpfl_tx_hairpin_queue_setup(struct rte_eth_dev *dev,uint16_t queue_idx,uint16_t nb_desc,const struct rte_eth_hairpin_conf *conf); +int cpfl_hairpin_tx_complq_config (struct cpfl_vport *cpfl_vport);int +cpfl_hairpin_txq_config (struct idpf_vport *vport,struct cpfl_tx_queue +*cpfl_txq);int cpfl_hairpin_rx_bufq_config (struct cpfl_vport +*cpfl_vport);int cpfl_hairpin_rxq_config (struct idpf_vport *vport, +struct cpfl_rx_queue *cpfl_rxq);#endif /* _CPFL_RXTX_H_ */ --2.26.2
RE: [PATCH 06/10] net/cpfl: support hairpin queue configuration
Quoted 40 lines
-----Original Message-----
From: Liu, Mingxia <[email protected]>
Sent: Monday, April 24, 2023 5:48 PM
To: Xing, Beilei <[email protected]>; Wu, Jingjing <[email protected]>
Cc: [email protected]; Wang, Xiao W <[email protected]>
Subject: RE: [PATCH 06/10] net/cpfl: support hairpin queue configurationQuoted 29 lines
-----Original Message-----
From: Xing, Beilei <[email protected]>
Sent: Friday, April 21, 2023 2:51 PM
To: Wu, Jingjing <[email protected]>
Cc: [email protected]; Liu, Mingxia <[email protected]>; Xing, Beilei <[email protected]>; Wang, Xiao W <[email protected]>
Subject: [PATCH 06/10] net/cpfl: support hairpin queue configurationFrom: Beilei Xing <[email protected]>
This patch supports Rx/Tx hairpin queue configuration.
Signed-off-by Xiao Wang <[email protected]>Signed-off-by Mingxia Liu <[email protected]>Signed-off-by Beilei Xing <[email protected]>--- drivers/common/idpf/idpf_common_virtchnl.c | 70 +++++++++++ drivers/common/idpf/idpf_common_virtchnl.h | 6 + drivers/common/idpf/version.map | 2 + drivers/net/cpfl/cpfl_ethdev.c | 136 ++++++++++++++++++++- drivers/net/cpfl/cpfl_rxtx.c | 80 ++++++++++++ drivers/net/cpfl/cpfl_rxtx.h | 7 ++ 6 files changed, 297 insertions(+), 4 deletions(-)drivers/common/idpf/idpf_common_virtchnl.c +0
-0
<...>
Quoted 32 lines
Quoted 32 lines
static int
cpfl_start_queues(struct rte_eth_dev *dev){drivers/common/idpf/idpf_common_virtchnl.c +12
-1+struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;struct cpfl_rx_queue *cpfl_rxq;struct cpfl_tx_queue *cpfl_txq; +int tx_cmplq_flag =0 ; +int rx_bufq_flag =0 ; +int flag =0 ;int err =0 ;int i; +/* For normal data queues, configure, init and enale Txq. +* For non-cross vport hairpin queues, configure Txq. +*/ for (i =0 ; i < dev->data->nb_tx_queues; i++) { cpfl_txq = dev->data->tx_queues[i];if (cpfl_txq ==NULL || cpfl_txq->base.tx_deferred_start)continue ; - err =cpfl_tx_queue_start (dev, i); +if (!cpfl_txq->hairpin_info.hairpin_q) { + err =cpfl_tx_queue_start (dev, i); +if (err !=0 ) { + PMD_DRV_LOG(ERR, "Fail to start Txqueue %u", i);
drivers/common/idpf/idpf_common_virtchnl.c +6
-0+return err; + } + }else if (!cpfl_txq->hairpin_info.manual_bind) { +if (flag ==0 ) { + err = cpfl_txq_hairpin_info_update(dev, + cpfl_txq-Quoted 1 line
hairpin_info.peer_rxp);
Quoted 8 lines
drivers/common/idpf/idpf_common_virtchnl.c
Quoted 2 lines
drivers/common/idpf/idpf_common_virtchnl.c +2
-0+if (err !=0 ) { + PMD_DRV_LOG(ERR, "Fail to updateTx
drivers/common/idpf/idpf_common_virtchnl.c
Quoted 4 lines
hairpin queue info");
drivers/common/idpf/idpf_common_virtchnl.c +3
-0+return err; + } + flag =1 ;[Liu, Mingxia] The variable flag is not been used, can it be removed?
It's used in above code, txq_hairpin_info should be updated once.
Quoted 32 lines
Quoted 21 lines
drivers/common/idpf/idpf_common_virtchnl.c +4
-0+ } + err =cpfl_hairpin_txq_config (vport, cpfl_txq); +if (err !=0 ) { + PMD_DRV_LOG(ERR, "Fail to configure hairpinTx queue %u", i);
drivers/common/idpf/idpf_common_virtchnl.c +7
-0+return err; + } + tx_cmplq_flag =1 ; + } + } + +/* For non-cross vport hairpin queues, configure Tx completion queue first.*/
drivers/common/idpf/idpf_common_virtchnl.c +3
-1+if (tx_cmplq_flag ==1 && cpfl_vport->p2p_tx_complq !=NULL ) { + err =cpfl_hairpin_tx_complq_config (cpfl_vport);if (err !=0 ) { -PMD_DRV_LOG (ERR ,"Fail to start Tx queue %u" , i); + PMD_DRV_LOG(ERR, "Fail to config Tx completionqueue");
drivers/common/idpf/idpf_common_virtchnl.c
Quoted 3 lines
drivers/common/idpf/idpf_common_virtchnl.c +0
-0return err; } }[Liu, Mingxia] Better to move this code next to
drivers/net/cpfl/cpfl_ethdev.c +3
-0+ err =cpfl_hairpin_txq_config (vport, cpfl_txq); +if (err !=0 ) { + PMD_DRV_LOG(ERR, "Fail to configure hairpinTx queue %u", i);
(quoted diff) +2
-0+ return err; + }When
cpfl_rxq->hairpin_info.hairpin_qis true, then cpfl_vport-
Quoted 2 lines
Quoted 1 line
p2p_tx_complqis not null, right ?And remove
tx_cmplq_flag?
Hairpin tx completion queue should only be configured once, so it should not be in for loop. However, code is refined in v2.
Quoted 169 lines
Quoted 34 lines
drivers/common/idpf/idpf_common_virtchnl.c +8
-1+/* For normal data queues, configure, init and enale Rxq. +* For non-cross vport hairpin queues, configure Rxq, and then init Rxq. +*/ +cpfl_rxq_hairpin_mz_bind (dev);for (i =0 ; i < dev->data->nb_rx_queues; i++) { cpfl_rxq = dev->data->rx_queues[i];if (cpfl_rxq ==NULL || cpfl_rxq->base.rx_deferred_start)continue ; - err =cpfl_rx_queue_start (dev, i); +if (!cpfl_rxq->hairpin_info.hairpin_q) { + err =cpfl_rx_queue_start (dev, i); +if (err !=0 ) { + PMD_DRV_LOG(ERR, "Fail to start Rxqueue %u", i);
drivers/common/idpf/idpf_common_virtchnl.c +6
-0+return err; + } + }else if (!cpfl_rxq->hairpin_info.manual_bind) { + err =cpfl_hairpin_rxq_config (vport, cpfl_rxq); +if (err !=0 ) { + PMD_DRV_LOG(ERR, "Fail to configure hairpinRx queue %u", i);
drivers/common/idpf/idpf_common_virtchnl.c +5
-0+return err; + } + err =cpfl_rx_queue_init (dev, i); +if (err !=0 ) { + PMD_DRV_LOG(ERR, "Fail to init hairpin Rxqueue %u", i);
drivers/common/idpf/idpf_common_virtchnl.c +6
-0+return err; + } + rx_bufq_flag =1 ; + } + } +drivers/common/idpf/idpf_common_virtchnl.c
Quoted 10 lines
drivers/common/idpf/idpf_common_virtchnl.c +4
-1+/* For non-cross vport hairpin queues, configure Rx buffer queue.*/ +if (rx_bufq_flag ==1 && cpfl_vport->p2p_rx_bufq !=NULL ) { + err =cpfl_hairpin_rx_bufq_config (cpfl_vport);if (err !=0 ) { -PMD_DRV_LOG (ERR ,"Fail to start Rx queue %u" , i); +PMD_DRV_LOG (ERR ,"Fail to config Rx buffer queue" );return err; } }[Liu, Mingxia] Similar to above.
Quoted 123 lines
(quoted diff) +0
-0
b/drivers/net/cpfl/cpfl_rxtx.cindex64ed331a6d..040beb5bac100644drivers/net/cpfl/cpfl_rxtx.c +76
-0@@ -930,6 +930,86 @@ cpfl_tx_hairpin_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx, return 0; } +int +cpfl_hairpin_rx_bufq_config (struct cpfl_vport *cpfl_vport) { +struct idpf_rx_queue *rx_bufq = cpfl_vport->p2p_rx_bufq; +struct virtchnl2_rxq_info rxq_info[1 ] = {0 }; + + rxq_info[0 ].type =VIRTCHNL2_QUEUE_TYPE_RX_BUFFER ; + rxq_info[0 ].queue_id = rx_bufq->queue_id; + rxq_info[0 ].ring_len = rx_bufq->nb_rx_desc; + rxq_info[0 ].dma_ring_addr = rx_bufq->rx_ring_phys_addr; + rxq_info[0 ].desc_ids =VIRTCHNL2_RXDID_2_FLEX_SPLITQ_M ; + rxq_info[0 ].rx_buffer_low_watermark =CPFL_RXBUF_LOW_WATERMARK ; + rxq_info[0 ].model =VIRTCHNL2_QUEUE_MODEL_SPLIT ; + rxq_info[0 ].data_buffer_size = rx_bufq->rx_buf_len; + rxq_info[0 ].buffer_notif_stride =CPFL_RX_BUF_STRIDE ; + +return idpf_vc_rxq_config_by_info (&cpfl_vport->base, rxq_info,1 ); } + +int +cpfl_hairpin_rxq_config (struct idpf_vport *vport,struct +cpfl_rx_queue +*cpfl_rxq) { +struct virtchnl2_rxq_info rxq_info[1 ] = {0 }; +struct idpf_rx_queue *rxq = &cpfl_rxq->base; + + rxq_info[0 ].type =VIRTCHNL2_QUEUE_TYPE_RX ; + rxq_info[0 ].queue_id = rxq->queue_id; + rxq_info[0 ].ring_len = rxq->nb_rx_desc; + rxq_info[0 ].dma_ring_addr = rxq->rx_ring_phys_addr; + rxq_info[0 ].rx_bufq1_id = rxq->bufq1->queue_id; + rxq_info[0 ].max_pkt_size = vport->max_pkt_len; + rxq_info[0 ].desc_ids =VIRTCHNL2_RXDID_2_FLEX_SPLITQ_M ; + rxq_info[0 ].qflags |=VIRTCHNL2_RX_DESC_SIZE_16BYTE ; + + rxq_info[0 ].data_buffer_size = rxq->rx_buf_len; + rxq_info[0 ].model =VIRTCHNL2_QUEUE_MODEL_SPLIT ; + rxq_info[0 ].rx_buffer_low_watermark =CPFL_RXBUF_LOW_WATERMARK ; + +PMD_DRV_LOG (NOTICE ,"hairpin: vport %u, Rxq id 0x%x" , + vport->vport_id, rxq_info[0 ].queue_id); + +return idpf_vc_rxq_config_by_info (vport, rxq_info,1 ); } + +int +cpfl_hairpin_tx_complq_config (struct cpfl_vport *cpfl_vport) { +struct idpf_tx_queue *tx_complq = cpfl_vport->p2p_tx_complq; +struct virtchnl2_txq_info txq_info[1 ] = {0 }; + + txq_info[0 ].dma_ring_addr = tx_complq->tx_ring_phys_addr; + txq_info[0 ].type =VIRTCHNL2_QUEUE_TYPE_TX_COMPLETION ; + txq_info[0 ].queue_id = tx_complq->queue_id; + txq_info[0 ].ring_len = tx_complq->nb_tx_desc; + txq_info[0 ].peer_rx_queue_id = cpfl_vport->p2p_rx_bufq->queue_id; + txq_info[0 ].model =VIRTCHNL2_QUEUE_MODEL_SPLIT ; + txq_info[0 ].sched_mode =VIRTCHNL2_TXQ_SCHED_MODE_FLOW ; + +return idpf_vc_txq_config_by_info (&cpfl_vport->base, txq_info,1 ); } + +int +cpfl_hairpin_txq_config (struct idpf_vport *vport,struct +cpfl_tx_queue +*cpfl_txq) { +struct idpf_tx_queue *txq = &cpfl_txq->base; +struct virtchnl2_txq_info txq_info[1 ] = {0 }; + + txq_info[0 ].dma_ring_addr = txq->tx_ring_phys_addr; + txq_info[0 ].type =VIRTCHNL2_QUEUE_TYPE_TX ; + txq_info[0 ].queue_id = txq->queue_id; + txq_info[0 ].ring_len = txq->nb_tx_desc; + txq_info[0 ].tx_compl_queue_id = txq->complq->queue_id; + txq_info[0 ].relative_queue_id = txq->queue_id; + txq_info[0 ].peer_rx_queue_id = cpfl_txq->hairpin_info.peer_rxq_id; + txq_info[0 ].model =VIRTCHNL2_QUEUE_MODEL_SPLIT ; + txq_info[0 ].sched_mode =VIRTCHNL2_TXQ_SCHED_MODE_FLOW ; + +return idpf_vc_txq_config_by_info (vport, txq_info,1 ); } +int cpfl_rx_queue_init (struct rte_eth_dev *dev,uint16_t rx_queue_id) {(quoted diff) +0
-0
b/drivers/net/cpfl/cpfl_rxtx.hindexd844c9f057..b01ce5edf9100644drivers/net/cpfl/cpfl_rxtx.h +8
-1@@ -30,12 +30,15 @@#define CPFL_RING_BASE_ALIGN 128#define CPFL_DEFAULT_RX_FREE_THRESH 32 +#define CPFL_RXBUF_LOW_WATERMARK 64#define CPFL_DEFAULT_TX_RS_THRESH 32#define CPFL_DEFAULT_TX_FREE_THRESH 32#define CPFL_SUPPORT_CHAIN_NUM 5 +#define CPFL_RX_BUF_STRIDE 64 +struct cpfl_rxq_hairpin_info {bool hairpin_q;/* if rx queue is a hairpin queue */ bool manual_bind;/* for cross vport */ @@ -85,4 +88,8 @@ int cpfl_rx_hairpin_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx, int cpfl_tx_hairpin_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx, uint16_t nb_desc, const struct rte_eth_hairpin_conf *conf); +int cpfl_hairpin_tx_complq_config (struct cpfl_vport *cpfl_vport);int +cpfl_hairpin_txq_config (struct idpf_vport *vport,struct +cpfl_tx_queue *cpfl_txq);int cpfl_hairpin_rx_bufq_config (struct +cpfl_vport *cpfl_vport);int cpfl_hairpin_rxq_config (struct +idpf_vport *vport,struct cpfl_rx_queue *cpfl_rxq);#endif /* _CPFL_RXTX_H_ */ --2.26.2
PATCH 7/10 net/cpfl: support hairpin queue start/stop
In reply to [email protected]From: Beilei Xing <[email protected]>
This patch supports Rx/Tx hairpin queue start/stop.
--- drivers/common/idpf/idpf_common_virtchnl.c | 2 +- drivers/common/idpf/idpf_common_virtchnl.h | 3 + drivers/common/idpf/version.map | 1 + drivers/net/cpfl/cpfl_ethdev.c | 39 ++++++ drivers/net/cpfl/cpfl_rxtx.c | 153 ++++++++++++++++++--- drivers/net/cpfl/cpfl_rxtx.h | 14 ++ 6 files changed, 193 insertions(+), 19 deletions(-)
drivers/common/idpf/idpf_common_virtchnl.c +1 -1
@@ -733,7 +733,7 @@ idpf_vc_vectors_dealloc(struct idpf_vport *vport)return err; } -static int +int idpf_vc_ena_dis_one_queue (struct idpf_vport *vport,uint16_t qid,uint32_t type,bool on) {
drivers/common/idpf/idpf_common_virtchnl.h +3 -0
@@ -71,6 +71,9 @@ __rte_internalint idpf_vc_txq_config_by_info (struct idpf_vport *vport,struct virtchnl2_txq_info *txq_info,uint16_t num_qs);__rte_internal +int idpf_vc_ena_dis_one_queue(struct idpf_vport *vport, uint16_t qid, +uint32_t type,bool on); +__rte_internal int idpf_vc_queue_grps_del(struct idpf_vport *vport,uint16_t num_q_grps,struct virtchnl2_queue_group_id *qg_ids);
drivers/common/idpf/version.map +1 -0
@@ -45,6 +45,7 @@ INTERNAL { idpf_vc_cmd_execute; idpf_vc_ctlq_post_rx_buffs; idpf_vc_ctlq_recv; + idpf_vc_ena_dis_one_queue; idpf_vc_irq_map_unmap_config; idpf_vc_one_msg_read; idpf_vc_ptype_info_query;
drivers/net/cpfl/cpfl_ethdev.c +39 -0
@@ -895,6 +895,45 @@ cpfl_start_queues(struct rte_eth_dev *dev) } } +/* For non-cross vport hairpin queues, enable Tx queue and Rx queue, +* then enable Tx completion queue and Rx buffer queue. +*/ +for (i =0 ; i < dev->data->nb_tx_queues; i++) { + cpfl_txq = dev->data->tx_queues[i]; +if (cpfl_txq->hairpin_info.hairpin_q && !cpfl_txq->hairpin_info.manual_bind) { + err =cpfl_switch_hairpin_rxtx_queue (cpfl_vport, + i - cpfl_vport->nb_data_txq, + false, true); +if (err) +PMD_DRV_LOG (ERR ,"Failed to switch hairpin TX queue %u on" , + i); +else + cpfl_txq->base.q_started = true; + } + } + +for (i =0 ; i < dev->data->nb_rx_queues; i++) { + cpfl_rxq = dev->data->rx_queues[i]; +if (cpfl_rxq->hairpin_info.hairpin_q && !cpfl_rxq->hairpin_info.manual_bind) { + err =cpfl_switch_hairpin_rxtx_queue (cpfl_vport, + i - cpfl_vport->nb_data_rxq, + true, true); +if (err) +PMD_DRV_LOG (ERR ,"Failed to switch hairpin RX queue %u on" , + i); +else + cpfl_rxq->base.q_started = true; + } + } + +if (tx_cmplq_flag ==1 && rx_bufq_flag ==1 ) { + err =cpfl_switch_hairpin_bufq_complq (cpfl_vport, true); +if (err !=0 ) { +PMD_DRV_LOG (ERR ,"Failed to switch hairpin Tx complq and Rx bufq" ); +return err; + } + } +return err; }
drivers/net/cpfl/cpfl_rxtx.c +135 -18
207 lines not on this page · raw message
drivers/net/cpfl/cpfl_rxtx.h +14 -0
@@ -39,6 +39,17 @@#define CPFL_RX_BUF_STRIDE 64 +/* The value written in the RX buffer queue tail register, +* and in WritePTR field in the TX completion queue context, +* must be a multiple of 8. +*/ +#define CPFL_HAIRPIN_Q_TAIL_AUX_VALUE 8 + +struct virtchnl2_p2p_rx_buf_desc { +__le64 reserve0; +__le64 pkt_addr;/* Packet buffer address */ +}; +struct cpfl_rxq_hairpin_info {bool hairpin_q;/* if rx queue is a hairpin queue */ bool manual_bind;/* for cross vport */
@@ -92,4 +103,7 @@ int cpfl_hairpin_tx_complq_config(struct cpfl_vport *cpfl_vport);int cpfl_hairpin_txq_config (struct idpf_vport *vport,struct cpfl_tx_queue *cpfl_txq);int cpfl_hairpin_rx_bufq_config (struct cpfl_vport *cpfl_vport);int cpfl_hairpin_rxq_config (struct idpf_vport *vport,struct cpfl_rx_queue *cpfl_rxq); +int cpfl_switch_hairpin_bufq_complq (struct cpfl_vport *cpfl_vport,bool on); +int cpfl_switch_hairpin_rxtx_queue (struct cpfl_vport *cpfl_vport,uint16_t qid, +bool rx,bool on);#endif /* _CPFL_RXTX_H_ */
Signature · 1 line
2.26.2
PATCH 8/10 net/cpfl: enable write back based on ITR expire
In reply to [email protected]From: Beilei Xing <[email protected]>
This patch enabls write back based on ITR expire
(WR_ON_ITR) for hairpin queue.
--- drivers/common/idpf/idpf_common_device.c | 75 ++++++++++++++++++++++++ drivers/common/idpf/idpf_common_device.h | 4 ++ drivers/common/idpf/version.map | 1 + drivers/net/cpfl/cpfl_ethdev.c | 13 +++- 4 files changed, 92 insertions(+), 1 deletion(-)
drivers/common/idpf/idpf_common_device.c +75 -0
@@ -559,6 +559,81 @@ idpf_vport_irq_map_config(struct idpf_vport *vport, uint16_t nb_rx_queues)return ret; } +int +idpf_vport_irq_map_config_by_qids (struct idpf_vport *vport,uint32_t *qids,uint16_t nb_rx_queues) +{ +struct idpf_adapter *adapter = vport->adapter; +struct virtchnl2_queue_vector *qv_map; +struct idpf_hw *hw = &adapter->hw; +uint32_t dynctl_val, itrn_val; +uint32_t dynctl_reg_start; +uint32_t itrn_reg_start; +uint16_t i; +int ret; + + qv_map =rte_zmalloc ("qv_map" , + nb_rx_queues * +sizeof (struct virtchnl2_queue_vector ),0 ); +if (qv_map ==NULL ) { +DRV_LOG (ERR ,"Failed to allocate %d queue-vector map" , + nb_rx_queues); + ret = -ENOMEM ; + goto qv_map_alloc_err; + } + +/* Rx interrupt disabled, Map interrupt only for writeback */ + +/* The capability flags adapter->caps.other_caps should be +* compared with bit VIRTCHNL2_CAP_WB_ON_ITR here. The if +* condition should be updated when the FW can return the +* correct flag bits. +*/ + dynctl_reg_start = + vport->recv_vectors->vchunks.vchunks->dynctl_reg_start; + itrn_reg_start = + vport->recv_vectors->vchunks.vchunks->itrn_reg_start; + dynctl_val =IDPF_READ_REG (hw, dynctl_reg_start); +DRV_LOG (DEBUG ,"Value of dynctl_reg_start is 0x%x" , dynctl_val); + itrn_val =IDPF_READ_REG (hw, itrn_reg_start); +DRV_LOG (DEBUG ,"Value of itrn_reg_start is 0x%x" , itrn_val); +/* Force write-backs by setting WB_ON_ITR bit in DYN_CTL +* register. WB_ON_ITR and INTENA are mutually exclusive +* bits. Setting WB_ON_ITR bits means TX and RX Descs +* are written back based on ITR expiration irrespective +* of INTENA setting. +*/ +/* TBD: need to tune INTERVAL value for better performance. */ + itrn_val = (itrn_val ==0 ) ?IDPF_DFLT_INTERVAL : itrn_val; + dynctl_val =VIRTCHNL2_ITR_IDX_0 << +PF_GLINT_DYN_CTL_ITR_INDX_S | +PF_GLINT_DYN_CTL_WB_ON_ITR_M | + itrn_val <<PF_GLINT_DYN_CTL_INTERVAL_S ; +IDPF_WRITE_REG (hw, dynctl_reg_start, dynctl_val); + +for (i =0 ; i < nb_rx_queues; i++) { +/* map all queues to the same vector */ + qv_map[i].queue_id = qids[i]; + qv_map[i].vector_id = + vport->recv_vectors->vchunks.vchunks->start_vector_id; + } + vport->qv_map = qv_map; + + ret =idpf_vc_irq_map_unmap_config (vport, nb_rx_queues, true); +if (ret !=0 ) { +DRV_LOG (ERR ,"config interrupt mapping failed" ); + goto config_irq_map_err; + } + +return 0 ; + +config_irq_map_err: +rte_free (vport->qv_map); + vport->qv_map =NULL ; + +qv_map_alloc_err: +return ret; +} +int idpf_vport_irq_unmap_config (struct idpf_vport *vport,uint16_t nb_rx_queues) {
drivers/common/idpf/idpf_common_device.h +4 -0
@@ -212,5 +212,9 @@ int idpf_vport_info_init(struct idpf_vport *vport, struct virtchnl2_create_vport *vport_info);__rte_internal void idpf_vport_stats_update(struct virtchnl2_vport_stats *oes, struct virtchnl2_vport_stats *nes); +__rte_internal +int idpf_vport_irq_map_config_by_qids(struct idpf_vport *vport, +uint32_t *qids, +uint16_t nb_rx_queues);#endif /* _IDPF_COMMON_DEVICE_H_ */
drivers/common/idpf/version.map +1 -0
@@ -74,6 +74,7 @@ INTERNAL { idpf_vport_info_init; idpf_vport_init; idpf_vport_irq_map_config; + idpf_vport_irq_map_config_by_qids; idpf_vport_irq_unmap_config; idpf_vport_rss_config; idpf_vport_stats_update;
drivers/net/cpfl/cpfl_ethdev.c +12 -1
@@ -730,11 +730,22 @@ cpfl_dev_configure(struct rte_eth_dev *dev)static int cpfl_config_rx_queues_irqs (struct rte_eth_dev *dev) { +uint32_t qids[CPFL_MAX_P2P_NB_QUEUES +IDPF_DEFAULT_RXQ_NUM ] = {0 };struct cpfl_vport *cpfl_vport = dev->data->dev_private;struct idpf_vport *vport = &cpfl_vport->base;uint16_t nb_rx_queues = dev->data->nb_rx_queues; +struct cpfl_rx_queue *cpfl_rxq; +int i; -return idpf_vport_irq_map_config (vport, nb_rx_queues); +for (i =0 ; i < nb_rx_queues; i++) { + cpfl_rxq = dev->data->rx_queues[i]; +if (cpfl_rxq->hairpin_info.hairpin_q) + qids[i] =cpfl_hw_qid_get (cpfl_vport->p2p_q_chunks_info.rx_start_qid, + (i - cpfl_vport->nb_data_rxq)); +else + qids[i] =cpfl_hw_qid_get (vport->chunks_info.rx_start_qid, i); + } +return idpf_vport_irq_map_config_by_qids (vport, qids, nb_rx_queues); }/* Update hairpin_info for dev's tx hairpin queue */
Signature · 1 line
2.26.2
PATCH 9/10 net/cpfl: support peer ports get
In reply to [email protected]From: Beilei Xing <[email protected]>
This patch supports get hairpin peer ports.
--- drivers/net/cpfl/cpfl_ethdev.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+)
drivers/net/cpfl/cpfl_ethdev.c +34 -0
@@ -1074,6 +1074,39 @@ cpfl_dev_close(struct rte_eth_dev *dev)return 0 ; } +static int +cpfl_hairpin_get_peer_ports (struct rte_eth_dev *dev,uint16_t *peer_ports, + __rte_unused size_t len, uint32_t tx) +{ +struct cpfl_vport *cpfl_vport = + (struct cpfl_vport *)dev->data->dev_private; +struct idpf_tx_queue *txq; +struct idpf_rx_queue *rxq; +struct cpfl_tx_queue *cpfl_txq; +struct cpfl_rx_queue *cpfl_rxq; +int i, j; + +if (tx >0 ) { +for (i = cpfl_vport->nb_data_txq, j =0 ; i < dev->data->nb_tx_queues; i++, j++) { + txq = dev->data->tx_queues[i]; +if (txq ==NULL ) +return -EINVAL ; + cpfl_txq = (struct cpfl_tx_queue *)txq; + peer_ports[j] = cpfl_txq->hairpin_info.peer_rxp; + } + }else if (tx ==0 ) { +for (i = cpfl_vport->nb_data_rxq, j =0 ; i < dev->data->nb_rx_queues; i++, j++) { + rxq = dev->data->rx_queues[i]; +if (rxq ==NULL ) +return -EINVAL ; + cpfl_rxq = (struct cpfl_rx_queue *)rxq; + peer_ports[j] = cpfl_rxq->hairpin_info.peer_txp; + } + } + +return j; +} +static const struct eth_dev_ops cpfl_eth_dev_ops = { .dev_configure = cpfl_dev_configure, .dev_close = cpfl_dev_close,
@@ -1103,6 +1136,7 @@ static const struct eth_dev_ops cpfl_eth_dev_ops = { .hairpin_cap_get = cpfl_hairpin_cap_get, .rx_hairpin_queue_setup = cpfl_rx_hairpin_queue_setup, .tx_hairpin_queue_setup = cpfl_tx_hairpin_queue_setup, + .hairpin_get_peer_ports = cpfl_hairpin_get_peer_ports, }; static int
Signature · 1 line
2.26.2
PATCH 10/10 net/cpfl: support hairpin bind/unbind
In reply to [email protected]From: Beilei Xing <[email protected]>
This patch supports hairpin_bind/unbind ops.
--- drivers/net/cpfl/cpfl_ethdev.c | 137 +++++++++++++++++++++++++++++++++ drivers/net/cpfl/cpfl_rxtx.c | 28 +++++++ drivers/net/cpfl/cpfl_rxtx.h | 2 + 3 files changed, 167 insertions(+)
drivers/net/cpfl/cpfl_ethdev.c +137 -0
@@ -1107,6 +1107,141 @@ cpfl_hairpin_get_peer_ports(struct rte_eth_dev *dev, uint16_t *peer_ports,return j; } +static int +cpfl_hairpin_bind (struct rte_eth_dev *dev,uint16_t rx_port) +{ +struct cpfl_vport *cpfl_tx_vport = dev->data->dev_private; +struct idpf_vport *tx_vport = &cpfl_tx_vport->base; +struct cpfl_vport *cpfl_rx_vport; +struct cpfl_tx_queue *cpfl_txq; +struct cpfl_rx_queue *cpfl_rxq; +struct rte_eth_dev *peer_dev; +struct idpf_vport *rx_vport; +int err =0 ; +int i; + + err =cpfl_txq_hairpin_info_update (dev, rx_port); +if (err !=0 ) { +PMD_DRV_LOG (ERR ,"Fail to update Tx hairpin queue info." ); +return err; + } + +/* configure hairpin queues */ +for (i = cpfl_tx_vport->nb_data_txq; i < dev->data->nb_tx_queues; i++) { + cpfl_txq = dev->data->tx_queues[i]; + err =cpfl_hairpin_txq_config (tx_vport, cpfl_txq); +if (err !=0 ) { +PMD_DRV_LOG (ERR ,"Fail to configure hairpin Tx queue %u" , i); +return err; + } + } + + err =cpfl_hairpin_tx_complq_config (cpfl_tx_vport); +if (err !=0 ) { +PMD_DRV_LOG (ERR ,"Fail to config Tx completion queue" ); +return err; + } + + peer_dev = &rte_eth_devices[rx_port]; + cpfl_rx_vport = (struct cpfl_vport *)peer_dev->data->dev_private; + rx_vport = &cpfl_rx_vport->base; +cpfl_rxq_hairpin_mz_bind (peer_dev); + +for (i = cpfl_rx_vport->nb_data_rxq; i < peer_dev->data->nb_rx_queues; i++) { + cpfl_rxq = peer_dev->data->rx_queues[i]; + err =cpfl_hairpin_rxq_config (rx_vport, cpfl_rxq); +if (err !=0 ) { +PMD_DRV_LOG (ERR ,"Fail to configure hairpin Rx queue %u" , i); +return err; + } + err =cpfl_rx_queue_init (peer_dev, i); +if (err !=0 ) { +PMD_DRV_LOG (ERR ,"Fail to init hairpin Rx queue %u" , i); +return err; + } + } + + err =cpfl_hairpin_rx_bufq_config (cpfl_rx_vport); +if (err !=0 ) { +PMD_DRV_LOG (ERR ,"Fail to config Rx buffer queue" ); +return err; + } + +/* enable hairpin queues */ +for (i = cpfl_tx_vport->nb_data_txq; i < dev->data->nb_tx_queues; i++) { + cpfl_txq = dev->data->tx_queues[i]; + err =cpfl_switch_hairpin_rxtx_queue (cpfl_tx_vport, + i - cpfl_tx_vport->nb_data_txq, + false, true); +if (err !=0 ) { +PMD_DRV_LOG (ERR ,"Failed to switch hairpin TX queue %u on" , + i); +return err; + } + cpfl_txq->base.q_started = true; + } + + err =cpfl_switch_hairpin_complq (cpfl_tx_vport, true); +if (err !=0 ) { +PMD_DRV_LOG (ERR ,"Failed to switch hairpin Tx complq" ); +return err; + } + +for (i = cpfl_rx_vport->nb_data_rxq; i < peer_dev->data->nb_rx_queues; i++) { + cpfl_rxq = peer_dev->data->rx_queues[i]; + err =cpfl_switch_hairpin_rxtx_queue (cpfl_rx_vport, + i - cpfl_rx_vport->nb_data_rxq, + true, true); +if (err !=0 ) { +PMD_DRV_LOG (ERR ,"Failed to switch hairpin RX queue %u on" , + i); + } + cpfl_rxq->base.q_started = true; + } + + err =cpfl_switch_hairpin_bufq (cpfl_rx_vport, true); +if (err !=0 ) { +PMD_DRV_LOG (ERR ,"Failed to switch hairpin Rx buffer queue" ); +return err; + } + +return 0 ; +} + +static int +cpfl_hairpin_unbind (struct rte_eth_dev *dev,uint16_t rx_port) +{ +struct cpfl_vport *cpfl_tx_vport = dev->data->dev_private; +struct rte_eth_dev *peer_dev = &rte_eth_devices[rx_port]; +struct cpfl_vport *cpfl_rx_vport = peer_dev->data->dev_private; +struct cpfl_tx_queue *cpfl_txq; +struct cpfl_rx_queue *cpfl_rxq; +int i; + +/* disable hairpin queues */ +for (i = cpfl_tx_vport->nb_data_txq; i < dev->data->nb_tx_queues; i++) { + cpfl_txq = dev->data->tx_queues[i]; +cpfl_switch_hairpin_rxtx_queue (cpfl_tx_vport, + i - cpfl_tx_vport->nb_data_txq, + false, false); + cpfl_txq->base.q_started = false; + } + +cpfl_switch_hairpin_complq (cpfl_tx_vport, false); + +for (i = cpfl_rx_vport->nb_data_rxq; i < peer_dev->data->nb_rx_queues; i++) { + cpfl_rxq = peer_dev->data->rx_queues[i]; +cpfl_switch_hairpin_rxtx_queue (cpfl_rx_vport, + i - cpfl_rx_vport->nb_data_rxq, + true, false); + cpfl_rxq->base.q_started = false; + } + +cpfl_switch_hairpin_bufq (cpfl_rx_vport, false); + +return 0 ; +} +static const struct eth_dev_ops cpfl_eth_dev_ops = { .dev_configure = cpfl_dev_configure, .dev_close = cpfl_dev_close,
@@ -1137,6 +1272,8 @@ static const struct eth_dev_ops cpfl_eth_dev_ops = { .rx_hairpin_queue_setup = cpfl_rx_hairpin_queue_setup, .tx_hairpin_queue_setup = cpfl_tx_hairpin_queue_setup, .hairpin_get_peer_ports = cpfl_hairpin_get_peer_ports, + .hairpin_bind = cpfl_hairpin_bind, + .hairpin_unbind = cpfl_hairpin_unbind, }; static int
drivers/net/cpfl/cpfl_rxtx.c +28 -0
@@ -1030,6 +1030,34 @@ cpfl_switch_hairpin_bufq_complq(struct cpfl_vport *cpfl_vport, bool on)return err; } +int +cpfl_switch_hairpin_complq (struct cpfl_vport *cpfl_vport,bool on) +{ +struct idpf_vport *vport = &cpfl_vport->base; +uint32_t type; +int err, queue_id; + + type =VIRTCHNL2_QUEUE_TYPE_TX_COMPLETION ; + queue_id = cpfl_vport->p2p_tx_complq->queue_id; + err =idpf_vc_ena_dis_one_queue (vport, queue_id, type, on); + +return err; +} + +int +cpfl_switch_hairpin_bufq (struct cpfl_vport *cpfl_vport,bool on) +{ +struct idpf_vport *vport = &cpfl_vport->base; +uint32_t type; +int err, queue_id; + + type =VIRTCHNL2_QUEUE_TYPE_RX_BUFFER ; + queue_id = cpfl_vport->p2p_rx_bufq->queue_id; + err =idpf_vc_ena_dis_one_queue (vport, queue_id, type, on); + +return err; +} +int cpfl_switch_hairpin_rxtx_queue (struct cpfl_vport *cpfl_vport,uint16_t logic_qid,bool rx,bool on)
drivers/net/cpfl/cpfl_rxtx.h +2 -0
@@ -104,6 +104,8 @@ int cpfl_hairpin_txq_config(struct idpf_vport *vport, struct cpfl_tx_queue *cpflint cpfl_hairpin_rx_bufq_config (struct cpfl_vport *cpfl_vport);int cpfl_hairpin_rxq_config (struct idpf_vport *vport,struct cpfl_rx_queue *cpfl_rxq);int cpfl_switch_hairpin_bufq_complq (struct cpfl_vport *cpfl_vport,bool on); +int cpfl_switch_hairpin_complq (struct cpfl_vport *cpfl_vport,bool on); +int cpfl_switch_hairpin_bufq (struct cpfl_vport *cpfl_vport,bool on);int cpfl_switch_hairpin_rxtx_queue (struct cpfl_vport *cpfl_vport,uint16_t qid,bool rx,bool on);#endif /* _CPFL_RXTX_H_ */
Signature · 1 line
2.26.2
v2 cover add hairpin queue support
In reply to [email protected]From: Beilei Xing <[email protected]>
This patchset adds hairpin queue support.
v2 changes:
- change hairpin rx queus configuration sequence.
- code refine.
Beilei Xing (10):
net/cpfl: refine structures
net/cpfl: support hairpin queue capbility get common/idpf: support queue groups add/delete net/cpfl: add haipin queue group during vport init net/cpfl: support hairpin queue setup and release net/cpfl: support hairpin queue configuration net/cpfl: support hairpin queue start/stop net/cpfl: enable write back based on ITR expire net/cpfl: support peer ports get
net/cpfl: support hairpin bind/unbind
drivers/common/idpf/idpf_common_device.c | 75 ++ drivers/common/idpf/idpf_common_device.h | 4 + drivers/common/idpf/idpf_common_virtchnl.c | 138 +++- drivers/common/idpf/idpf_common_virtchnl.h | 18 + drivers/common/idpf/version.map | 6 + drivers/net/cpfl/cpfl_ethdev.c | 591 +++++++++++++-- drivers/net/cpfl/cpfl_ethdev.h | 36 +- drivers/net/cpfl/cpfl_rxtx.c | 807 +++++++++++++++++++-- drivers/net/cpfl/cpfl_rxtx.h | 65 ++ drivers/net/cpfl/cpfl_rxtx_vec_common.h | 21 +- 10 files changed, 1642 insertions(+), 119 deletions(-)
Signature · 1 line
2.26.2
PATCH v2 1/10 net/cpfl: refine structures
From: Beilei Xing <[email protected]>
This patch refines some structures to support hairpin queue, cpfl_rx_queue/cpfl_tx_queue/cpfl_vport.
--- drivers/net/cpfl/cpfl_ethdev.c | 85 +++++++----- drivers/net/cpfl/cpfl_ethdev.h | 6 +- drivers/net/cpfl/cpfl_rxtx.c | 175 +++++++++++++++++------- drivers/net/cpfl/cpfl_rxtx.h | 8 ++ drivers/net/cpfl/cpfl_rxtx_vec_common.h | 17 +-- 5 files changed, 196 insertions(+), 95 deletions(-)
drivers/net/cpfl/cpfl_ethdev.c +49 -36
@@ -124,7 +124,8 @@ static int cpfl_dev_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complete) { - struct idpf_vport *vport = dev->data->dev_private; + struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;struct rte_eth_link new_link;unsigned int i;
@@ -156,7 +157,8 @@ cpfl_dev_link_update(struct rte_eth_dev *dev,static int cpfl_dev_info_get (struct rte_eth_dev *dev,struct rte_eth_dev_info *dev_info) { -struct idpf_vport *vport = dev->data->dev_private; +struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;struct idpf_adapter *base = vport->adapter; dev_info->max_rx_queues = base->caps.max_rx_q;
@@ -216,7 +218,8 @@ cpfl_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)static int cpfl_dev_mtu_set (struct rte_eth_dev *dev,uint16_t mtu) { -struct idpf_vport *vport = dev->data->dev_private; +struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;/* mtu setting is forbidden if port is start */ if (dev->data->dev_started) {
@@ -256,12 +259,12 @@ static uint64_t cpfl_get_mbuf_alloc_failed_stats(struct rte_eth_dev *dev) {uint64_t mbuf_alloc_failed =0 ; -struct idpf_rx_queue *rxq; +struct cpfl_rx_queue *cpfl_rxq;int i =0 ;for (i =0 ; i < dev->data->nb_rx_queues; i++) { - rxq = dev->data->rx_queues[i]; - mbuf_alloc_failed +=__atomic_load_n (&rxq->rx_stats.mbuf_alloc_failed, + cpfl_rxq = dev->data->rx_queues[i]; + mbuf_alloc_failed +=__atomic_load_n (&cpfl_rxq->base.rx_stats.mbuf_alloc_failed, __ATOMIC_RELAXED); }
@@ -271,8 +274,8 @@ cpfl_get_mbuf_alloc_failed_stats(struct rte_eth_dev *dev)static int cpfl_dev_stats_get (struct rte_eth_dev *dev,struct rte_eth_stats *stats) { -struct idpf_vport *vport = - (struct idpf_vport *)dev->data->dev_private; +struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;struct virtchnl2_vport_stats *pstats =NULL ;int ret;
@@ -305,20 +308,20 @@ cpfl_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)static void cpfl_reset_mbuf_alloc_failed_stats (struct rte_eth_dev *dev) { -struct idpf_rx_queue *rxq; +struct cpfl_rx_queue *cpfl_rxq;int i;for (i =0 ; i < dev->data->nb_rx_queues; i++) { - rxq = dev->data->rx_queues[i]; -__atomic_store_n (&rxq->rx_stats.mbuf_alloc_failed,0 , __ATOMIC_RELAXED); + cpfl_rxq = dev->data->rx_queues[i]; +__atomic_store_n (&cpfl_rxq->base.rx_stats.mbuf_alloc_failed,0 , __ATOMIC_RELAXED); } }static int cpfl_dev_stats_reset (struct rte_eth_dev *dev) { -struct idpf_vport *vport = - (struct idpf_vport *)dev->data->dev_private; +struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;struct virtchnl2_vport_stats *pstats =NULL ;int ret;
@@ -343,8 +346,8 @@ static int cpfl_dev_xstats_reset(struct rte_eth_dev *dev)static int cpfl_dev_xstats_get (struct rte_eth_dev *dev,struct rte_eth_xstat *xstats,unsigned int n) { -struct idpf_vport *vport = - (struct idpf_vport *)dev->data->dev_private; +struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;struct virtchnl2_vport_stats *pstats =NULL ;unsigned int i;int ret;
@@ -459,7 +462,8 @@ cpfl_rss_reta_update(struct rte_eth_dev *dev, struct rte_eth_rss_reta_entry64 *reta_conf, uint16_t reta_size) { -struct idpf_vport *vport = dev->data->dev_private; +struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;struct idpf_adapter *base = vport->adapter;uint16_t idx, shift;int ret =0 ;
@@ -498,7 +502,8 @@ cpfl_rss_reta_query(struct rte_eth_dev *dev, struct rte_eth_rss_reta_entry64 *reta_conf, uint16_t reta_size) { -struct idpf_vport *vport = dev->data->dev_private; +struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;struct idpf_adapter *base = vport->adapter;uint16_t idx, shift;int ret =0 ;
@@ -536,7 +541,8 @@ static int cpfl_rss_hash_update(struct rte_eth_dev *dev, struct rte_eth_rss_conf *rss_conf) { - struct idpf_vport *vport = dev->data->dev_private; + struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;struct idpf_adapter *base = vport->adapter;int ret =0 ;
@@ -601,7 +607,8 @@ static int cpfl_rss_hash_conf_get(struct rte_eth_dev *dev, struct rte_eth_rss_conf *rss_conf) { - struct idpf_vport *vport = dev->data->dev_private; + struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;struct idpf_adapter *base = vport->adapter;int ret =0 ;
@@ -638,7 +645,8 @@ cpfl_rss_hash_conf_get(struct rte_eth_dev *dev,static int cpfl_dev_configure (struct rte_eth_dev *dev) { -struct idpf_vport *vport = dev->data->dev_private; +struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;struct rte_eth_conf *conf = &dev->data->dev_conf;struct idpf_adapter *base = vport->adapter;int ret;
@@ -710,7 +718,8 @@ cpfl_dev_configure(struct rte_eth_dev *dev)static int cpfl_config_rx_queues_irqs (struct rte_eth_dev *dev) { -struct idpf_vport *vport = dev->data->dev_private; +struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;uint16_t nb_rx_queues = dev->data->nb_rx_queues;return idpf_vport_irq_map_config (vport, nb_rx_queues);
@@ -719,14 +728,14 @@ cpfl_config_rx_queues_irqs(struct rte_eth_dev *dev)static int cpfl_start_queues (struct rte_eth_dev *dev) { -struct idpf_rx_queue *rxq; -struct idpf_tx_queue *txq; +struct cpfl_rx_queue *cpfl_rxq; +struct cpfl_tx_queue *cpfl_txq;int err =0 ;int i;for (i =0 ; i < dev->data->nb_tx_queues; i++) { - txq = dev->data->tx_queues[i]; -if (txq ==NULL || txq->tx_deferred_start) + cpfl_txq = dev->data->tx_queues[i]; +if (cpfl_txq ==NULL || cpfl_txq->base.tx_deferred_start)continue ; err =cpfl_tx_queue_start (dev, i);if (err !=0 ) {
@@ -736,8 +745,8 @@ cpfl_start_queues(struct rte_eth_dev *dev) }for (i =0 ; i < dev->data->nb_rx_queues; i++) { - rxq = dev->data->rx_queues[i]; -if (rxq ==NULL || rxq->rx_deferred_start) + cpfl_rxq = dev->data->rx_queues[i]; +if (cpfl_rxq ==NULL || cpfl_rxq->base.rx_deferred_start)continue ; err =cpfl_rx_queue_start (dev, i);if (err !=0 ) {
@@ -752,7 +761,8 @@ cpfl_start_queues(struct rte_eth_dev *dev)static int cpfl_dev_start (struct rte_eth_dev *dev) { -struct idpf_vport *vport = dev->data->dev_private; +struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;struct idpf_adapter *base = vport->adapter;struct cpfl_adapter_ext *adapter =CPFL_ADAPTER_TO_EXT (base);uint16_t num_allocated_vectors = base->caps.num_allocated_vectors;
@@ -815,7 +825,8 @@ cpfl_dev_start(struct rte_eth_dev *dev)static int cpfl_dev_stop (struct rte_eth_dev *dev) { -struct idpf_vport *vport = dev->data->dev_private; +struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;if (vport->stopped ==1 )return 0 ;
@@ -836,7 +847,8 @@ cpfl_dev_stop(struct rte_eth_dev *dev)static int cpfl_dev_close (struct rte_eth_dev *dev) { -struct idpf_vport *vport = dev->data->dev_private; +struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;struct cpfl_adapter_ext *adapter =CPFL_ADAPTER_TO_EXT (vport->adapter);cpfl_dev_stop (dev);
@@ -846,7 +858,7 @@ cpfl_dev_close(struct rte_eth_dev *dev) adapter->cur_vport_nb--; dev->data->dev_private =NULL ; adapter->vports[vport->sw_idx] =NULL ; -rte_free (vport); +rte_free (cpfl_vport);return 0 ; }
@@ -1051,7 +1063,7 @@ cpfl_find_vport(struct cpfl_adapter_ext *adapter, uint32_t vport_id)int i;for (i =0 ; i < adapter->cur_vport_nb; i++) { - vport = adapter->vports[i]; + vport = &adapter->vports[i]->base;if (vport->vport_id != vport_id)continue ;else
@@ -1328,7 +1340,8 @@ cpfl_vport_idx_alloc(struct cpfl_adapter_ext *adapter)static int cpfl_dev_vport_init (struct rte_eth_dev *dev,void *init_params) { -struct idpf_vport *vport = dev->data->dev_private; +struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;struct cpfl_vport_param *param = init_params;struct cpfl_adapter_ext *adapter = param->adapter;/* for sending create vport virtchnl msg prepare */
@@ -1354,7 +1367,7 @@ cpfl_dev_vport_init(struct rte_eth_dev *dev, void *init_params) goto err; } - adapter->vports[param->idx] = vport; + adapter->vports[param->idx] = cpfl_vport; adapter->cur_vports |=RTE_BIT32 (param->devarg_id); adapter->cur_vport_nb++;
@@ -1470,7 +1483,7 @@ cpfl_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,snprintf (name,sizeof (name),"cpfl_%s_vport_0" , pci_dev->device.name); retval =rte_eth_dev_create (&pci_dev->device, name, -sizeof (struct idpf_vport ), +sizeof (struct cpfl_vport ),NULL ,NULL , cpfl_dev_vport_init, &vport_param);if (retval !=0 )
@@ -1488,7 +1501,7 @@ cpfl_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, pci_dev->device.name, devargs.req_vports[i]); retval =rte_eth_dev_create (&pci_dev->device, name, -sizeof (struct idpf_vport ), +sizeof (struct cpfl_vport ),NULL ,NULL , cpfl_dev_vport_init, &vport_param);if (retval !=0 )
drivers/net/cpfl/cpfl_ethdev.h +5 -1
@@ -69,13 +69,17 @@ struct cpfl_devargs {uint16_t req_vport_nb; }; +struct cpfl_vport { +struct idpf_vport base; +}; +struct cpfl_adapter_ext {TAILQ_ENTRY (cpfl_adapter_ext) next;struct idpf_adapter base;char name[CPFL_ADAPTER_NAME_LEN ]; -struct idpf_vport **vports; +struct cpfl_vport **vports;uint16_t max_vport_nb;uint16_t cur_vports;/* bit mask of created vport */
drivers/net/cpfl/cpfl_rxtx.c +125 -50
401 lines not on this page · raw message
drivers/net/cpfl/cpfl_rxtx.h +8 -0
@@ -23,6 +23,14 @@#define CPFL_SUPPORT_CHAIN_NUM 5 +struct cpfl_rx_queue { +struct idpf_rx_queue base; +}; + +struct cpfl_tx_queue { +struct idpf_tx_queue base; +}; +int cpfl_tx_queue_setup (struct rte_eth_dev *dev,uint16_t queue_idx,uint16_t nb_desc,unsigned int socket_id,const struct rte_eth_txconf *tx_conf);
drivers/net/cpfl/cpfl_rxtx_vec_common.h +9 -8
@@ -76,15 +76,16 @@ cpfl_rx_splitq_vec_default(struct idpf_rx_queue *rxq)static inline int cpfl_rx_vec_dev_check_default (struct rte_eth_dev *dev) { -struct idpf_vport *vport = dev->data->dev_private; -struct idpf_rx_queue *rxq; +struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base; +struct cpfl_rx_queue *cpfl_rxq;int i, default_ret, splitq_ret, ret =CPFL_SCALAR_PATH ;for (i =0 ; i < dev->data->nb_rx_queues; i++) { - rxq = dev->data->rx_queues[i]; - default_ret =cpfl_rx_vec_queue_default (rxq); + cpfl_rxq = dev->data->rx_queues[i]; + default_ret =cpfl_rx_vec_queue_default (&cpfl_rxq->base);if (vport->rxq_model ==VIRTCHNL2_QUEUE_MODEL_SPLIT ) { - splitq_ret =cpfl_rx_splitq_vec_default (rxq); + splitq_ret =cpfl_rx_splitq_vec_default (&cpfl_rxq->base); ret = splitq_ret && default_ret; }else { ret = default_ret;
@@ -100,12 +101,12 @@ static inline int cpfl_tx_vec_dev_check_default(struct rte_eth_dev *dev) {int i; -struct idpf_tx_queue *txq; +struct cpfl_tx_queue *cpfl_txq;int ret =0 ;for (i =0 ; i < dev->data->nb_tx_queues; i++) { - txq = dev->data->tx_queues[i]; - ret =cpfl_tx_vec_queue_default (txq); + cpfl_txq = dev->data->tx_queues[i]; + ret =cpfl_tx_vec_queue_default (&cpfl_txq->base);if (ret ==CPFL_SCALAR_PATH )return CPFL_SCALAR_PATH ; }
Signature · 1 line
2.26.2
PATCH v2 2/10 net/cpfl: support hairpin queue capbility get
In reply to [email protected]From: Beilei Xing <[email protected]>
This patch adds hairpin_cap_get ops support.
--- drivers/net/cpfl/cpfl_ethdev.c | 13 +++++++++++++ drivers/net/cpfl/cpfl_rxtx.h | 4 ++++ 2 files changed, 17 insertions(+)
drivers/net/cpfl/cpfl_ethdev.c +13 -0
@@ -154,6 +154,18 @@ cpfl_dev_link_update(struct rte_eth_dev *dev,return rte_eth_linkstatus_set (dev, &new_link); } +static int +cpfl_hairpin_cap_get(__rte_unused struct rte_eth_dev *dev, +struct rte_eth_hairpin_cap *cap) +{ + cap->max_nb_queues =CPFL_MAX_P2P_NB_QUEUES ; + cap->max_rx_2_tx =CPFL_MAX_HAIRPINQ_RX_2_TX ; + cap->max_tx_2_rx =CPFL_MAX_HAIRPINQ_TX_2_RX ; + cap->max_nb_desc =CPFL_MAX_HAIRPINQ_NB_DESC ; + +return 0 ; +} +static int cpfl_dev_info_get (struct rte_eth_dev *dev,struct rte_eth_dev_info *dev_info) {
@@ -889,6 +901,7 @@ static const struct eth_dev_ops cpfl_eth_dev_ops = { .xstats_get = cpfl_dev_xstats_get, .xstats_get_names = cpfl_dev_xstats_get_names, .xstats_reset = cpfl_dev_xstats_reset, + .hairpin_cap_get = cpfl_hairpin_cap_get, }; static int
drivers/net/cpfl/cpfl_rxtx.h +4 -0
@@ -13,6 +13,10 @@#define CPFL_MIN_RING_DESC 32#define CPFL_MAX_RING_DESC 4096#define CPFL_DMA_MEM_ALIGN 4096 +#define CPFL_MAX_HAIRPINQ_RX_2_TX 1 +#define CPFL_MAX_HAIRPINQ_TX_2_RX 1 +#define CPFL_MAX_HAIRPINQ_NB_DESC 1024 +#define CPFL_MAX_P2P_NB_QUEUES 16/* Base address of the HW descriptor ring should be 128B aligned. */ #define CPFL_RING_BASE_ALIGN 128
Signature · 1 line
2.26.2
PATCH v2 3/10 common/idpf: support queue groups add/delete
In reply to [email protected]From: Beilei Xing <[email protected]>
This patch adds queue group add/delete virtual channel support.
--- drivers/common/idpf/idpf_common_virtchnl.c | 66 ++++++++++++++++++++++ drivers/common/idpf/idpf_common_virtchnl.h | 9 +++ drivers/common/idpf/version.map | 2 + 3 files changed, 77 insertions(+)
drivers/common/idpf/idpf_common_virtchnl.c +66 -0
@@ -359,6 +359,72 @@ idpf_vc_vport_destroy(struct idpf_vport *vport)return err; } +int +idpf_vc_queue_grps_add (struct idpf_vport *vport, +struct virtchnl2_add_queue_groups *p2p_queue_grps_info, +uint8_t *p2p_queue_grps_out) +{ +struct idpf_adapter *adapter = vport->adapter; +struct idpf_cmd_info args; +int size, qg_info_size; +int err =-1 ; + + size =sizeof (*p2p_queue_grps_info) + + (p2p_queue_grps_info->qg_info.num_queue_groups -1 ) * +sizeof (struct virtchnl2_queue_group_info ); + +memset (&args,0 ,sizeof (args)); + args.ops =VIRTCHNL2_OP_ADD_QUEUE_GROUPS ; + args.in_args = (uint8_t *)p2p_queue_grps_info; + args.in_args_size = size; + args.out_buffer = adapter->mbx_resp; + args.out_size =IDPF_DFLT_MBX_BUF_SIZE ; + + err =idpf_vc_cmd_execute (adapter, &args); +if (err !=0 ) { +DRV_LOG (ERR , +"Failed to execute command of VIRTCHNL2_OP_ADD_QUEUE_GROUPS" ); +return err; + } + +rte_memcpy (p2p_queue_grps_out, args.out_buffer,IDPF_DFLT_MBX_BUF_SIZE ); +return 0 ; +} + +int idpf_vc_queue_grps_del (struct idpf_vport *vport, +uint16_t num_q_grps, +struct virtchnl2_queue_group_id *qg_ids) +{ +struct idpf_adapter *adapter = vport->adapter; +struct virtchnl2_delete_queue_groups *vc_del_q_grps; +struct idpf_cmd_info args; +int size; +int err; + + size =sizeof (*vc_del_q_grps) + + (num_q_grps -1 ) *sizeof (struct virtchnl2_queue_group_id ); + vc_del_q_grps =rte_zmalloc ("vc_del_q_grps" , size,0 ); + + vc_del_q_grps->vport_id = vport->vport_id; + vc_del_q_grps->num_queue_groups = num_q_grps; +memcpy (vc_del_q_grps->qg_ids, qg_ids, + num_q_grps *sizeof (struct virtchnl2_queue_group_id )); + +memset (&args,0 ,sizeof (args)); + args.ops =VIRTCHNL2_OP_DEL_QUEUE_GROUPS ; + args.in_args = (uint8_t *)vc_del_q_grps; + args.in_args_size = size; + args.out_buffer = adapter->mbx_resp; + args.out_size =IDPF_DFLT_MBX_BUF_SIZE ; + + err =idpf_vc_cmd_execute (adapter, &args); +if (err !=0 ) +DRV_LOG (ERR ,"Failed to execute command of VIRTCHNL2_OP_DEL_QUEUE_GROUPS" ); + +rte_free (vc_del_q_grps); +return err; +} +int idpf_vc_rss_key_set (struct idpf_vport *vport) {
drivers/common/idpf/idpf_common_virtchnl.h +9 -0
@@ -64,4 +64,13 @@ int idpf_vc_ctlq_recv(struct idpf_ctlq_info *cq, u16 *num_q_msg,__rte_internal int idpf_vc_ctlq_post_rx_buffs(struct idpf_hw *hw, struct idpf_ctlq_info *cq,u16 *buff_count,struct idpf_dma_mem **buffs); +__rte_internal +int idpf_vc_queue_grps_del(struct idpf_vport *vport, +uint16_t num_q_grps, +struct virtchnl2_queue_group_id *qg_ids); +__rte_internal +int +idpf_vc_queue_grps_add (struct idpf_vport *vport, +struct virtchnl2_add_queue_groups *ptp_queue_grps_info, +uint8_t *ptp_queue_grps_out);#endif /* _IDPF_COMMON_VIRTCHNL_H_ */
drivers/common/idpf/version.map +2 -0
@@ -48,6 +48,8 @@ INTERNAL { idpf_vc_irq_map_unmap_config; idpf_vc_one_msg_read; idpf_vc_ptype_info_query; + idpf_vc_queue_grps_add; + idpf_vc_queue_grps_del; idpf_vc_queue_switch; idpf_vc_queues_ena_dis; idpf_vc_rss_hash_get;
Signature · 1 line
2.26.2
PATCH v2 4/10 net/cpfl: add haipin queue group during vport init
In reply to [email protected]From: Beilei Xing <[email protected]>
This patch adds haipin queue group during vport init.
--- drivers/net/cpfl/cpfl_ethdev.c | 130 +++++++++++++++++++++++++++++++++ drivers/net/cpfl/cpfl_ethdev.h | 18 +++++ drivers/net/cpfl/cpfl_rxtx.h | 4 + 3 files changed, 152 insertions(+)
drivers/net/cpfl/cpfl_ethdev.c +130 -0
@@ -856,6 +856,20 @@ cpfl_dev_stop(struct rte_eth_dev *dev)return 0 ; } +static int +cpfl_p2p_queue_grps_del (struct idpf_vport *vport) +{ +struct virtchnl2_queue_group_id qg_ids[CPFL_P2P_NB_QUEUE_GRPS ] = {0 }; +int ret =0 ; + + qg_ids[0 ].queue_group_id =CPFL_P2P_QUEUE_GRP_ID ; + qg_ids[0 ].queue_group_type =VIRTCHNL2_QUEUE_GROUP_P2P ; + ret =idpf_vc_queue_grps_del (vport,CPFL_P2P_NB_QUEUE_GRPS , qg_ids); +if (ret) +PMD_DRV_LOG (ERR ,"Failed to delete p2p queue groups" ); +return ret; +} +static int cpfl_dev_close (struct rte_eth_dev *dev) {
@@ -864,6 +878,10 @@ cpfl_dev_close(struct rte_eth_dev *dev)struct cpfl_adapter_ext *adapter =CPFL_ADAPTER_TO_EXT (vport->adapter);cpfl_dev_stop (dev); + +if (!adapter->base.is_rx_singleq && !adapter->base.is_tx_singleq) +cpfl_p2p_queue_grps_del (vport); +idpf_vport_deinit (vport); adapter->cur_vports &= ~RTE_BIT32 (vport->devarg_id);
@@ -1350,6 +1368,96 @@ cpfl_vport_idx_alloc(struct cpfl_adapter_ext *adapter)return vport_idx; } +static int +cpfl_p2p_q_grps_add (struct idpf_vport *vport, +struct virtchnl2_add_queue_groups *p2p_queue_grps_info, +uint8_t *p2p_q_vc_out_info) +{ +int ret; + + p2p_queue_grps_info->vport_id = vport->vport_id; + p2p_queue_grps_info->qg_info.num_queue_groups =CPFL_P2P_NB_QUEUE_GRPS ; + p2p_queue_grps_info->qg_info.groups[0 ].num_rx_q =CPFL_MAX_P2P_NB_QUEUES ; + p2p_queue_grps_info->qg_info.groups[0 ].num_rx_bufq =CPFL_P2P_NB_RX_BUFQ ; + p2p_queue_grps_info->qg_info.groups[0 ].num_tx_q =CPFL_MAX_P2P_NB_QUEUES ; + p2p_queue_grps_info->qg_info.groups[0 ].num_tx_complq =CPFL_P2P_NB_TX_COMPLQ ; + p2p_queue_grps_info->qg_info.groups[0 ].qg_id.queue_group_id =CPFL_P2P_QUEUE_GRP_ID ; + p2p_queue_grps_info->qg_info.groups[0 ].qg_id.queue_group_type =VIRTCHNL2_QUEUE_GROUP_P2P ; + p2p_queue_grps_info->qg_info.groups[0 ].rx_q_grp_info.rss_lut_size =0 ; + p2p_queue_grps_info->qg_info.groups[0 ].tx_q_grp_info.tx_tc =0 ; + p2p_queue_grps_info->qg_info.groups[0 ].tx_q_grp_info.priority =0 ; + p2p_queue_grps_info->qg_info.groups[0 ].tx_q_grp_info.is_sp =0 ; + p2p_queue_grps_info->qg_info.groups[0 ].tx_q_grp_info.pir_weight =0 ; + + ret =idpf_vc_queue_grps_add (vport, p2p_queue_grps_info, p2p_q_vc_out_info); +if (ret !=0 ) { +PMD_DRV_LOG (ERR ,"Failed to add p2p queue groups." ); +return ret; + } + +return ret; +} + +static int +cpfl_p2p_queue_info_init (struct cpfl_vport *cpfl_vport, +struct virtchnl2_add_queue_groups *p2p_q_vc_out_info) +{ +struct p2p_queue_chunks_info *p2p_q_chunks_info = &cpfl_vport->p2p_q_chunks_info; +struct virtchnl2_queue_reg_chunks *vc_chunks_out; +int i, type; + +if (p2p_q_vc_out_info->qg_info.groups[0 ].qg_id.queue_group_type != +VIRTCHNL2_QUEUE_GROUP_P2P ) { +PMD_DRV_LOG (ERR ,"Add queue group response mismatch." ); +return -EINVAL ; + } + + vc_chunks_out = &p2p_q_vc_out_info->qg_info.groups[0 ].chunks; + +for (i =0 ; i < vc_chunks_out->num_chunks; i++) { + type = vc_chunks_out->chunks[i].type; +switch (type) { +case VIRTCHNL2_QUEUE_TYPE_TX : + p2p_q_chunks_info->tx_start_qid = + vc_chunks_out->chunks[i].start_queue_id; + p2p_q_chunks_info->tx_qtail_start = + vc_chunks_out->chunks[i].qtail_reg_start; + p2p_q_chunks_info->tx_qtail_spacing = + vc_chunks_out->chunks[i].qtail_reg_spacing; +break ; +case VIRTCHNL2_QUEUE_TYPE_RX : + p2p_q_chunks_info->rx_start_qid = + vc_chunks_out->chunks[i].start_queue_id; + p2p_q_chunks_info->rx_qtail_start = + vc_chunks_out->chunks[i].qtail_reg_start; + p2p_q_chunks_info->rx_qtail_spacing = + vc_chunks_out->chunks[i].qtail_reg_spacing; +break ; +case VIRTCHNL2_QUEUE_TYPE_TX_COMPLETION : + p2p_q_chunks_info->tx_compl_start_qid = + vc_chunks_out->chunks[i].start_queue_id; + p2p_q_chunks_info->tx_compl_qtail_start = + vc_chunks_out->chunks[i].qtail_reg_start; + p2p_q_chunks_info->tx_compl_qtail_spacing = + vc_chunks_out->chunks[i].qtail_reg_spacing; +break ; +case VIRTCHNL2_QUEUE_TYPE_RX_BUFFER : + p2p_q_chunks_info->rx_buf_start_qid = + vc_chunks_out->chunks[i].start_queue_id; + p2p_q_chunks_info->rx_buf_qtail_start = + vc_chunks_out->chunks[i].qtail_reg_start; + p2p_q_chunks_info->rx_buf_qtail_spacing = + vc_chunks_out->chunks[i].qtail_reg_spacing; +break ; +default : +PMD_DRV_LOG (ERR ,"Unsupported queue type" ); +break ; + } + } + +return 0 ; +} +static int cpfl_dev_vport_init (struct rte_eth_dev *dev,void *init_params) {
@@ -1359,6 +1467,8 @@ cpfl_dev_vport_init(struct rte_eth_dev *dev, void *init_params)struct cpfl_adapter_ext *adapter = param->adapter;/* for sending create vport virtchnl msg prepare */ struct virtchnl2_create_vport create_vport_info; +struct virtchnl2_add_queue_groups p2p_queue_grps_info; +uint8_t p2p_q_vc_out_info[IDPF_DFLT_MBX_BUF_SIZE ] = {0 };int ret =0 ; dev->dev_ops = &cpfl_eth_dev_ops;
@@ -1394,8 +1504,28 @@ cpfl_dev_vport_init(struct rte_eth_dev *dev, void *init_params)rte_ether_addr_copy ((struct rte_ether_addr *)vport->default_mac_addr, &dev->data->mac_addrs[0 ]); +if (!adapter->base.is_rx_singleq && !adapter->base.is_tx_singleq) { +memset (&p2p_queue_grps_info,0 ,sizeof (p2p_queue_grps_info)); + ret =cpfl_p2p_q_grps_add (vport, &p2p_queue_grps_info, p2p_q_vc_out_info); +if (ret !=0 ) { +PMD_INIT_LOG (ERR ,"Failed to add p2p queue group." ); + goto err_q_grps_add; + } + ret =cpfl_p2p_queue_info_init (cpfl_vport, + (struct virtchnl2_add_queue_groups *)p2p_q_vc_out_info); +if (ret !=0 ) { +PMD_INIT_LOG (ERR ,"Failed to init p2p queue info." ); + goto err_p2p_qinfo_init; + } + } +return 0 ; +err_p2p_qinfo_init: +cpfl_p2p_queue_grps_del (vport); +err_q_grps_add: +rte_free (dev->data->mac_addrs); + dev->data->mac_addrs =NULL ; err_mac_addrs: adapter->vports[param->idx] =NULL ;/* reset */ idpf_vport_deinit (vport);
drivers/net/cpfl/cpfl_ethdev.h +18 -0
@@ -56,6 +56,7 @@/* Device IDs */ #define IDPF_DEV_ID_CPF 0x1453 +#define VIRTCHNL2_QUEUE_GROUP_P2P 0x100struct cpfl_vport_param {struct cpfl_adapter_ext *adapter;
@@ -69,8 +70,25 @@ struct cpfl_devargs {uint16_t req_vport_nb; }; +struct p2p_queue_chunks_info { +uint32_t tx_start_qid; +uint32_t rx_start_qid; +uint32_t tx_compl_start_qid; +uint32_t rx_buf_start_qid; + +uint64_t tx_qtail_start; +uint32_t tx_qtail_spacing; +uint64_t rx_qtail_start; +uint32_t rx_qtail_spacing; +uint64_t tx_compl_qtail_start; +uint32_t tx_compl_qtail_spacing; +uint64_t rx_buf_qtail_start; +uint32_t rx_buf_qtail_spacing; +}; +struct cpfl_vport {struct idpf_vport base; +struct p2p_queue_chunks_info p2p_q_chunks_info; };struct cpfl_adapter_ext {
drivers/net/cpfl/cpfl_rxtx.h +4 -0
@@ -17,6 +17,10 @@#define CPFL_MAX_HAIRPINQ_TX_2_RX 1#define CPFL_MAX_HAIRPINQ_NB_DESC 1024#define CPFL_MAX_P2P_NB_QUEUES 16 +#define CPFL_P2P_NB_RX_BUFQ 1 +#define CPFL_P2P_NB_TX_COMPLQ 1 +#define CPFL_P2P_NB_QUEUE_GRPS 1 +#define CPFL_P2P_QUEUE_GRP_ID 1/* Base address of the HW descriptor ring should be 128B aligned. */ #define CPFL_RING_BASE_ALIGN 128
Signature · 1 line
2.26.2
PATCH v2 4/10 net/cpfl: add haipin queue group during vpotr init
In reply to [email protected]From: Beilei Xing <[email protected]>
This patch adds haipin queue group during vpotr init.
--- drivers/net/cpfl/cpfl_ethdev.c | 130 +++++++++++++++++++++++++++++++++ drivers/net/cpfl/cpfl_ethdev.h | 18 +++++ drivers/net/cpfl/cpfl_rxtx.h | 4 + 3 files changed, 152 insertions(+)
drivers/net/cpfl/cpfl_ethdev.c +130 -0
@@ -856,6 +856,20 @@ cpfl_dev_stop(struct rte_eth_dev *dev)return 0 ; } +static int +cpfl_p2p_queue_grps_del (struct idpf_vport *vport) +{ +struct virtchnl2_queue_group_id qg_ids[CPFL_P2P_NB_QUEUE_GRPS ] = {0 }; +int ret =0 ; + + qg_ids[0 ].queue_group_id =CPFL_P2P_QUEUE_GRP_ID ; + qg_ids[0 ].queue_group_type =VIRTCHNL2_QUEUE_GROUP_P2P ; + ret =idpf_vc_queue_grps_del (vport,CPFL_P2P_NB_QUEUE_GRPS , qg_ids); +if (ret) +PMD_DRV_LOG (ERR ,"Failed to delete p2p queue groups" ); +return ret; +} +static int cpfl_dev_close (struct rte_eth_dev *dev) {
@@ -864,6 +878,10 @@ cpfl_dev_close(struct rte_eth_dev *dev)struct cpfl_adapter_ext *adapter =CPFL_ADAPTER_TO_EXT (vport->adapter);cpfl_dev_stop (dev); + +if (!adapter->base.is_rx_singleq && !adapter->base.is_tx_singleq) +cpfl_p2p_queue_grps_del (vport); +idpf_vport_deinit (vport); adapter->cur_vports &= ~RTE_BIT32 (vport->devarg_id);
@@ -1350,6 +1368,96 @@ cpfl_vport_idx_alloc(struct cpfl_adapter_ext *adapter)return vport_idx; } +static int +cpfl_p2p_q_grps_add (struct idpf_vport *vport, +struct virtchnl2_add_queue_groups *p2p_queue_grps_info, +uint8_t *p2p_q_vc_out_info) +{ +int ret; + + p2p_queue_grps_info->vport_id = vport->vport_id; + p2p_queue_grps_info->qg_info.num_queue_groups =CPFL_P2P_NB_QUEUE_GRPS ; + p2p_queue_grps_info->qg_info.groups[0 ].num_rx_q =CPFL_MAX_P2P_NB_QUEUES ; + p2p_queue_grps_info->qg_info.groups[0 ].num_rx_bufq =CPFL_P2P_NB_RX_BUFQ ; + p2p_queue_grps_info->qg_info.groups[0 ].num_tx_q =CPFL_MAX_P2P_NB_QUEUES ; + p2p_queue_grps_info->qg_info.groups[0 ].num_tx_complq =CPFL_P2P_NB_TX_COMPLQ ; + p2p_queue_grps_info->qg_info.groups[0 ].qg_id.queue_group_id =CPFL_P2P_QUEUE_GRP_ID ; + p2p_queue_grps_info->qg_info.groups[0 ].qg_id.queue_group_type =VIRTCHNL2_QUEUE_GROUP_P2P ; + p2p_queue_grps_info->qg_info.groups[0 ].rx_q_grp_info.rss_lut_size =0 ; + p2p_queue_grps_info->qg_info.groups[0 ].tx_q_grp_info.tx_tc =0 ; + p2p_queue_grps_info->qg_info.groups[0 ].tx_q_grp_info.priority =0 ; + p2p_queue_grps_info->qg_info.groups[0 ].tx_q_grp_info.is_sp =0 ; + p2p_queue_grps_info->qg_info.groups[0 ].tx_q_grp_info.pir_weight =0 ; + + ret =idpf_vc_queue_grps_add (vport, p2p_queue_grps_info, p2p_q_vc_out_info); +if (ret !=0 ) { +PMD_DRV_LOG (ERR ,"Failed to add p2p queue groups." ); +return ret; + } + +return ret; +} + +static int +cpfl_p2p_queue_info_init (struct cpfl_vport *cpfl_vport, +struct virtchnl2_add_queue_groups *p2p_q_vc_out_info) +{ +struct p2p_queue_chunks_info *p2p_q_chunks_info = &cpfl_vport->p2p_q_chunks_info; +struct virtchnl2_queue_reg_chunks *vc_chunks_out; +int i, type; + +if (p2p_q_vc_out_info->qg_info.groups[0 ].qg_id.queue_group_type != +VIRTCHNL2_QUEUE_GROUP_P2P ) { +PMD_DRV_LOG (ERR ,"Add queue group response mismatch." ); +return -EINVAL ; + } + + vc_chunks_out = &p2p_q_vc_out_info->qg_info.groups[0 ].chunks; + +for (i =0 ; i < vc_chunks_out->num_chunks; i++) { + type = vc_chunks_out->chunks[i].type; +switch (type) { +case VIRTCHNL2_QUEUE_TYPE_TX : + p2p_q_chunks_info->tx_start_qid = + vc_chunks_out->chunks[i].start_queue_id; + p2p_q_chunks_info->tx_qtail_start = + vc_chunks_out->chunks[i].qtail_reg_start; + p2p_q_chunks_info->tx_qtail_spacing = + vc_chunks_out->chunks[i].qtail_reg_spacing; +break ; +case VIRTCHNL2_QUEUE_TYPE_RX : + p2p_q_chunks_info->rx_start_qid = + vc_chunks_out->chunks[i].start_queue_id; + p2p_q_chunks_info->rx_qtail_start = + vc_chunks_out->chunks[i].qtail_reg_start; + p2p_q_chunks_info->rx_qtail_spacing = + vc_chunks_out->chunks[i].qtail_reg_spacing; +break ; +case VIRTCHNL2_QUEUE_TYPE_TX_COMPLETION : + p2p_q_chunks_info->tx_compl_start_qid = + vc_chunks_out->chunks[i].start_queue_id; + p2p_q_chunks_info->tx_compl_qtail_start = + vc_chunks_out->chunks[i].qtail_reg_start; + p2p_q_chunks_info->tx_compl_qtail_spacing = + vc_chunks_out->chunks[i].qtail_reg_spacing; +break ; +case VIRTCHNL2_QUEUE_TYPE_RX_BUFFER : + p2p_q_chunks_info->rx_buf_start_qid = + vc_chunks_out->chunks[i].start_queue_id; + p2p_q_chunks_info->rx_buf_qtail_start = + vc_chunks_out->chunks[i].qtail_reg_start; + p2p_q_chunks_info->rx_buf_qtail_spacing = + vc_chunks_out->chunks[i].qtail_reg_spacing; +break ; +default : +PMD_DRV_LOG (ERR ,"Unsupported queue type" ); +break ; + } + } + +return 0 ; +} +static int cpfl_dev_vport_init (struct rte_eth_dev *dev,void *init_params) {
@@ -1359,6 +1467,8 @@ cpfl_dev_vport_init(struct rte_eth_dev *dev, void *init_params)struct cpfl_adapter_ext *adapter = param->adapter;/* for sending create vport virtchnl msg prepare */ struct virtchnl2_create_vport create_vport_info; +struct virtchnl2_add_queue_groups p2p_queue_grps_info; +uint8_t p2p_q_vc_out_info[IDPF_DFLT_MBX_BUF_SIZE ] = {0 };int ret =0 ; dev->dev_ops = &cpfl_eth_dev_ops;
@@ -1394,8 +1504,28 @@ cpfl_dev_vport_init(struct rte_eth_dev *dev, void *init_params)rte_ether_addr_copy ((struct rte_ether_addr *)vport->default_mac_addr, &dev->data->mac_addrs[0 ]); +if (!adapter->base.is_rx_singleq && !adapter->base.is_tx_singleq) { +memset (&p2p_queue_grps_info,0 ,sizeof (p2p_queue_grps_info)); + ret =cpfl_p2p_q_grps_add (vport, &p2p_queue_grps_info, p2p_q_vc_out_info); +if (ret !=0 ) { +PMD_INIT_LOG (ERR ,"Failed to add p2p queue group." ); + goto err_q_grps_add; + } + ret =cpfl_p2p_queue_info_init (cpfl_vport, + (struct virtchnl2_add_queue_groups *)p2p_q_vc_out_info); +if (ret !=0 ) { +PMD_INIT_LOG (ERR ,"Failed to init p2p queue info." ); + goto err_p2p_qinfo_init; + } + } +return 0 ; +err_p2p_qinfo_init: +cpfl_p2p_queue_grps_del (vport); +err_q_grps_add: +rte_free (dev->data->mac_addrs); + dev->data->mac_addrs =NULL ; err_mac_addrs: adapter->vports[param->idx] =NULL ;/* reset */ idpf_vport_deinit (vport);
drivers/net/cpfl/cpfl_ethdev.h +18 -0
@@ -56,6 +56,7 @@/* Device IDs */ #define IDPF_DEV_ID_CPF 0x1453 +#define VIRTCHNL2_QUEUE_GROUP_P2P 0x100struct cpfl_vport_param {struct cpfl_adapter_ext *adapter;
@@ -69,8 +70,25 @@ struct cpfl_devargs {uint16_t req_vport_nb; }; +struct p2p_queue_chunks_info { +uint32_t tx_start_qid; +uint32_t rx_start_qid; +uint32_t tx_compl_start_qid; +uint32_t rx_buf_start_qid; + +uint64_t tx_qtail_start; +uint32_t tx_qtail_spacing; +uint64_t rx_qtail_start; +uint32_t rx_qtail_spacing; +uint64_t tx_compl_qtail_start; +uint32_t tx_compl_qtail_spacing; +uint64_t rx_buf_qtail_start; +uint32_t rx_buf_qtail_spacing; +}; +struct cpfl_vport {struct idpf_vport base; +struct p2p_queue_chunks_info p2p_q_chunks_info; };struct cpfl_adapter_ext {
drivers/net/cpfl/cpfl_rxtx.h +4 -0
@@ -17,6 +17,10 @@#define CPFL_MAX_HAIRPINQ_TX_2_RX 1#define CPFL_MAX_HAIRPINQ_NB_DESC 1024#define CPFL_MAX_P2P_NB_QUEUES 16 +#define CPFL_P2P_NB_RX_BUFQ 1 +#define CPFL_P2P_NB_TX_COMPLQ 1 +#define CPFL_P2P_NB_QUEUE_GRPS 1 +#define CPFL_P2P_QUEUE_GRP_ID 1/* Base address of the HW descriptor ring should be 128B aligned. */ #define CPFL_RING_BASE_ALIGN 128
Signature · 1 line
2.26.2
PATCH v2 5/10 net/cpfl: support hairpin queue setup and release
In reply to [email protected]From: Beilei Xing <[email protected]>
Support hairpin Rx/Tx queue setup and release.
--- drivers/net/cpfl/cpfl_ethdev.c | 6 + drivers/net/cpfl/cpfl_ethdev.h | 12 + drivers/net/cpfl/cpfl_rxtx.c | 373 +++++++++++++++++++++++- drivers/net/cpfl/cpfl_rxtx.h | 26 ++ drivers/net/cpfl/cpfl_rxtx_vec_common.h | 4 + 5 files changed, 420 insertions(+), 1 deletion(-)
drivers/net/cpfl/cpfl_ethdev.c +6 -0
@@ -878,6 +878,10 @@ cpfl_dev_close(struct rte_eth_dev *dev)struct cpfl_adapter_ext *adapter =CPFL_ADAPTER_TO_EXT (vport->adapter);cpfl_dev_stop (dev); +if (cpfl_vport->p2p_mp) { +rte_mempool_free (cpfl_vport->p2p_mp); + cpfl_vport->p2p_mp =NULL ; + }if (!adapter->base.is_rx_singleq && !adapter->base.is_tx_singleq)cpfl_p2p_queue_grps_del (vport);
@@ -920,6 +924,8 @@ static const struct eth_dev_ops cpfl_eth_dev_ops = { .xstats_get_names = cpfl_dev_xstats_get_names, .xstats_reset = cpfl_dev_xstats_reset, .hairpin_cap_get = cpfl_hairpin_cap_get, + .rx_hairpin_queue_setup = cpfl_rx_hairpin_queue_setup, + .tx_hairpin_queue_setup = cpfl_tx_hairpin_queue_setup, }; static int
drivers/net/cpfl/cpfl_ethdev.h +12 -0
@@ -89,6 +89,18 @@ struct p2p_queue_chunks_info {struct cpfl_vport {struct idpf_vport base;struct p2p_queue_chunks_info p2p_q_chunks_info; + +struct rte_mempool *p2p_mp; + +uint16_t nb_data_rxq; +uint16_t nb_data_txq; +uint16_t nb_p2p_rxq; +uint16_t nb_p2p_txq; + +struct idpf_rx_queue *p2p_rx_bufq; +struct idpf_tx_queue *p2p_tx_complq; +bool p2p_manual_bind; + };struct cpfl_adapter_ext {
drivers/net/cpfl/cpfl_rxtx.c +372 -1
409 lines not on this page · raw message
drivers/net/cpfl/cpfl_rxtx.h +26 -0
@@ -13,6 +13,7 @@#define CPFL_MIN_RING_DESC 32#define CPFL_MAX_RING_DESC 4096#define CPFL_DMA_MEM_ALIGN 4096 +#define CPFL_P2P_DESC_LEN 16#define CPFL_MAX_HAIRPINQ_RX_2_TX 1#define CPFL_MAX_HAIRPINQ_TX_2_RX 1#define CPFL_MAX_HAIRPINQ_NB_DESC 1024
@@ -21,6 +22,10 @@#define CPFL_P2P_NB_TX_COMPLQ 1#define CPFL_P2P_NB_QUEUE_GRPS 1#define CPFL_P2P_QUEUE_GRP_ID 1 +#define CPFL_P2P_NB_MBUF 4096 +#define CPFL_P2P_CACHE_SIZE 250 +#define CPFL_P2P_MBUF_SIZE 2048 +#define CPFL_P2P_RING_BUF 128/* Base address of the HW descriptor ring should be 128B aligned. */ #define CPFL_RING_BASE_ALIGN 128
@@ -31,12 +36,26 @@#define CPFL_SUPPORT_CHAIN_NUM 5 +struct cpfl_rxq_hairpin_info { +bool hairpin_q;/* if rx queue is a hairpin queue */ +uint16_t peer_txp; +uint16_t peer_txq_id; +}; +struct cpfl_rx_queue {struct idpf_rx_queue base; +struct cpfl_rxq_hairpin_info hairpin_info; +}; + +struct cpfl_txq_hairpin_info { +bool hairpin_q;/* if tx queue is a hairpin queue */ +uint16_t peer_rxp; +uint16_t peer_rxq_id; };struct cpfl_tx_queue {struct idpf_tx_queue base; +struct cpfl_txq_hairpin_info hairpin_info; }; int cpfl_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
@@ -57,4 +76,11 @@ void cpfl_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid);void cpfl_dev_rx_queue_release (struct rte_eth_dev *dev,uint16_t qid);void cpfl_set_rx_function (struct rte_eth_dev *dev);void cpfl_set_tx_function (struct rte_eth_dev *dev); +uint16_t cpfl_hw_qid_get (uint16_t start_qid,uint16_t offset); +uint64_t cpfl_hw_qtail_get (uint64_t tail_start,uint16_t offset,uint64_t tail_spacing); +int cpfl_rx_hairpin_queue_setup (struct rte_eth_dev *dev,uint16_t queue_idx, +uint16_t nb_desc,const struct rte_eth_hairpin_conf *conf); +int cpfl_tx_hairpin_queue_setup (struct rte_eth_dev *dev,uint16_t queue_idx, +uint16_t nb_desc, +const struct rte_eth_hairpin_conf *conf);#endif /* _CPFL_RXTX_H_ */
drivers/net/cpfl/cpfl_rxtx_vec_common.h +4 -0
@@ -85,6 +85,8 @@ cpfl_rx_vec_dev_check_default(struct rte_eth_dev *dev) cpfl_rxq = dev->data->rx_queues[i]; default_ret =cpfl_rx_vec_queue_default (&cpfl_rxq->base);if (vport->rxq_model ==VIRTCHNL2_QUEUE_MODEL_SPLIT ) { +if (cpfl_rxq->hairpin_info.hairpin_q) +continue ; splitq_ret =cpfl_rx_splitq_vec_default (&cpfl_rxq->base); ret = splitq_ret && default_ret; }else {
@@ -106,6 +108,8 @@ cpfl_tx_vec_dev_check_default(struct rte_eth_dev *dev)for (i =0 ; i < dev->data->nb_tx_queues; i++) { cpfl_txq = dev->data->tx_queues[i]; +if (cpfl_txq->hairpin_info.hairpin_q) +continue ; ret =cpfl_tx_vec_queue_default (&cpfl_txq->base);if (ret ==CPFL_SCALAR_PATH )return CPFL_SCALAR_PATH ;
Signature · 1 line
2.26.2
PATCH v2 6/10 net/cpfl: support hairpin queue configuration
In reply to [email protected]From: Beilei Xing <[email protected]>
This patch supports Rx/Tx hairpin queue configuration.
--- drivers/common/idpf/idpf_common_virtchnl.c | 70 +++++++++++ drivers/common/idpf/idpf_common_virtchnl.h | 6 + drivers/common/idpf/version.map | 2 + drivers/net/cpfl/cpfl_ethdev.c | 136 ++++++++++++++++++++- drivers/net/cpfl/cpfl_rxtx.c | 80 ++++++++++++ drivers/net/cpfl/cpfl_rxtx.h | 7 ++ 6 files changed, 295 insertions(+), 6 deletions(-)
drivers/common/idpf/idpf_common_virtchnl.c +70 -0
@@ -1050,6 +1050,41 @@ idpf_vc_rxq_config(struct idpf_vport *vport, struct idpf_rx_queue *rxq)return err; } +int idpf_vc_rxq_config_by_info (struct idpf_vport *vport,struct virtchnl2_rxq_info *rxq_info, +uint16_t num_qs) +{ +struct idpf_adapter *adapter = vport->adapter; +struct virtchnl2_config_rx_queues *vc_rxqs =NULL ; +struct idpf_cmd_info args; +int size, err, i; + + size =sizeof (*vc_rxqs) + (num_qs -1 ) * +sizeof (struct virtchnl2_rxq_info ); + vc_rxqs =rte_zmalloc ("cfg_rxqs" , size,0 ); +if (vc_rxqs ==NULL ) { +DRV_LOG (ERR ,"Failed to allocate virtchnl2_config_rx_queues" ); + err = -ENOMEM ; +return err; + } + vc_rxqs->vport_id = vport->vport_id; + vc_rxqs->num_qinfo = num_qs; +memcpy (vc_rxqs->qinfo, rxq_info, num_qs *sizeof (struct virtchnl2_rxq_info )); + +memset (&args,0 ,sizeof (args)); + args.ops =VIRTCHNL2_OP_CONFIG_RX_QUEUES ; + args.in_args = (uint8_t *)vc_rxqs; + args.in_args_size = size; + args.out_buffer = adapter->mbx_resp; + args.out_size =IDPF_DFLT_MBX_BUF_SIZE ; + + err =idpf_vc_cmd_execute (adapter, &args); +rte_free (vc_rxqs); +if (err !=0 ) +DRV_LOG (ERR ,"Failed to execute command of VIRTCHNL2_OP_CONFIG_RX_QUEUES" ); + +return err; +} +int idpf_vc_txq_config (struct idpf_vport *vport,struct idpf_tx_queue *txq) {
@@ -1121,6 +1156,41 @@ idpf_vc_txq_config(struct idpf_vport *vport, struct idpf_tx_queue *txq)return err; } +int +idpf_vc_txq_config_by_info (struct idpf_vport *vport,struct virtchnl2_txq_info *txq_info, +uint16_t num_qs) +{ +struct idpf_adapter *adapter = vport->adapter; +struct virtchnl2_config_tx_queues *vc_txqs =NULL ; +struct idpf_cmd_info args; +int size, err; + + size =sizeof (*vc_txqs) + (num_qs -1 ) *sizeof (struct virtchnl2_txq_info ); + vc_txqs =rte_zmalloc ("cfg_txqs" , size,0 ); +if (vc_txqs ==NULL ) { +DRV_LOG (ERR ,"Failed to allocate virtchnl2_config_tx_queues" ); + err = -ENOMEM ; +return err; + } + vc_txqs->vport_id = vport->vport_id; + vc_txqs->num_qinfo = num_qs; +memcpy (vc_txqs->qinfo, txq_info, num_qs *sizeof (struct virtchnl2_txq_info )); + +memset (&args,0 ,sizeof (args)); + args.ops =VIRTCHNL2_OP_CONFIG_TX_QUEUES ; + args.in_args = (uint8_t *)vc_txqs; + args.in_args_size = size; + args.out_buffer = adapter->mbx_resp; + args.out_size =IDPF_DFLT_MBX_BUF_SIZE ; + + err =idpf_vc_cmd_execute (adapter, &args); +rte_free (vc_txqs); +if (err !=0 ) +DRV_LOG (ERR ,"Failed to execute command of VIRTCHNL2_OP_CONFIG_TX_QUEUES" ); + +return err; +} +int idpf_vc_ctlq_recv (struct idpf_ctlq_info *cq,u16 *num_q_msg,struct idpf_ctlq_msg *q_msg)
drivers/common/idpf/idpf_common_virtchnl.h +6 -0
@@ -65,6 +65,12 @@ __rte_internalint idpf_vc_ctlq_post_rx_buffs (struct idpf_hw *hw,struct idpf_ctlq_info *cq,u16 *buff_count,struct idpf_dma_mem **buffs);__rte_internal +int idpf_vc_rxq_config_by_info(struct idpf_vport *vport, struct virtchnl2_rxq_info *rxq_info, +uint16_t num_qs); +__rte_internal +int idpf_vc_txq_config_by_info(struct idpf_vport *vport, struct virtchnl2_txq_info *txq_info, +uint16_t num_qs); +__rte_internal int idpf_vc_queue_grps_del(struct idpf_vport *vport,uint16_t num_q_grps,struct virtchnl2_queue_group_id *qg_ids);
drivers/common/idpf/version.map +2 -0
@@ -59,8 +59,10 @@ INTERNAL { idpf_vc_rss_lut_get; idpf_vc_rss_lut_set; idpf_vc_rxq_config; + idpf_vc_rxq_config_by_info; idpf_vc_stats_query; idpf_vc_txq_config; + idpf_vc_txq_config_by_info; idpf_vc_vectors_alloc; idpf_vc_vectors_dealloc; idpf_vc_vport_create;
drivers/net/cpfl/cpfl_ethdev.c +130 -6
163 lines not on this page · raw message
drivers/net/cpfl/cpfl_rxtx.c +80 -0
86 lines not on this page · raw message
drivers/net/cpfl/cpfl_rxtx.h +7 -0
@@ -30,12 +30,15 @@#define CPFL_RING_BASE_ALIGN 128#define CPFL_DEFAULT_RX_FREE_THRESH 32 +#define CPFL_RXBUF_LOW_WATERMARK 64#define CPFL_DEFAULT_TX_RS_THRESH 32#define CPFL_DEFAULT_TX_FREE_THRESH 32#define CPFL_SUPPORT_CHAIN_NUM 5 +#define CPFL_RX_BUF_STRIDE 64 +struct cpfl_rxq_hairpin_info {bool hairpin_q;/* if rx queue is a hairpin queue */ uint16_t peer_txp;
@@ -83,4 +86,8 @@ int cpfl_rx_hairpin_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,int cpfl_tx_hairpin_queue_setup (struct rte_eth_dev *dev,uint16_t queue_idx,uint16_t nb_desc,const struct rte_eth_hairpin_conf *conf); +int cpfl_hairpin_tx_complq_config (struct cpfl_vport *cpfl_vport); +int cpfl_hairpin_txq_config (struct idpf_vport *vport,struct cpfl_tx_queue *cpfl_txq); +int cpfl_hairpin_rx_bufq_config (struct cpfl_vport *cpfl_vport); +int cpfl_hairpin_rxq_config (struct idpf_vport *vport,struct cpfl_rx_queue *cpfl_rxq);#endif /* _CPFL_RXTX_H_ */
Signature · 1 line
2.26.2
PATCH v2 7/10 net/cpfl: support hairpin queue start/stop
In reply to [email protected]From: Beilei Xing <[email protected]>
This patch supports Rx/Tx hairpin queue start/stop.
--- drivers/common/idpf/idpf_common_virtchnl.c | 2 +- drivers/common/idpf/idpf_common_virtchnl.h | 3 + drivers/common/idpf/version.map | 1 + drivers/net/cpfl/cpfl_ethdev.c | 41 ++++++ drivers/net/cpfl/cpfl_rxtx.c | 153 ++++++++++++++++++--- drivers/net/cpfl/cpfl_rxtx.h | 14 ++ 6 files changed, 195 insertions(+), 19 deletions(-)
drivers/common/idpf/idpf_common_virtchnl.c +1 -1
@@ -733,7 +733,7 @@ idpf_vc_vectors_dealloc(struct idpf_vport *vport)return err; } -static int +int idpf_vc_ena_dis_one_queue (struct idpf_vport *vport,uint16_t qid,uint32_t type,bool on) {
drivers/common/idpf/idpf_common_virtchnl.h +3 -0
@@ -71,6 +71,9 @@ __rte_internalint idpf_vc_txq_config_by_info (struct idpf_vport *vport,struct virtchnl2_txq_info *txq_info,uint16_t num_qs);__rte_internal +int idpf_vc_ena_dis_one_queue(struct idpf_vport *vport, uint16_t qid, +uint32_t type,bool on); +__rte_internal int idpf_vc_queue_grps_del(struct idpf_vport *vport,uint16_t num_q_grps,struct virtchnl2_queue_group_id *qg_ids);
drivers/common/idpf/version.map +1 -0
@@ -45,6 +45,7 @@ INTERNAL { idpf_vc_cmd_execute; idpf_vc_ctlq_post_rx_buffs; idpf_vc_ctlq_recv; + idpf_vc_ena_dis_one_queue; idpf_vc_irq_map_unmap_config; idpf_vc_one_msg_read; idpf_vc_ptype_info_query;
drivers/net/cpfl/cpfl_ethdev.c +41 -0
47 lines not on this page · raw message
drivers/net/cpfl/cpfl_rxtx.c +135 -18
207 lines not on this page · raw message
drivers/net/cpfl/cpfl_rxtx.h +14 -0
@@ -39,6 +39,17 @@#define CPFL_RX_BUF_STRIDE 64 +/* The value written in the RX buffer queue tail register, +* and in WritePTR field in the TX completion queue context, +* must be a multiple of 8. +*/ +#define CPFL_HAIRPIN_Q_TAIL_AUX_VALUE 8 + +struct virtchnl2_p2p_rx_buf_desc { +__le64 reserve0; +__le64 pkt_addr;/* Packet buffer address */ +}; +struct cpfl_rxq_hairpin_info {bool hairpin_q;/* if rx queue is a hairpin queue */ uint16_t peer_txp;
@@ -90,4 +101,7 @@ int cpfl_hairpin_tx_complq_config(struct cpfl_vport *cpfl_vport);int cpfl_hairpin_txq_config (struct idpf_vport *vport,struct cpfl_tx_queue *cpfl_txq);int cpfl_hairpin_rx_bufq_config (struct cpfl_vport *cpfl_vport);int cpfl_hairpin_rxq_config (struct idpf_vport *vport,struct cpfl_rx_queue *cpfl_rxq); +int cpfl_switch_hairpin_bufq_complq (struct cpfl_vport *cpfl_vport,bool on); +int cpfl_switch_hairpin_rxtx_queue (struct cpfl_vport *cpfl_vport,uint16_t qid, +bool rx,bool on);#endif /* _CPFL_RXTX_H_ */
Signature · 1 line
2.26.2
PATCH v2 8/10 net/cpfl: enable write back based on ITR expire
In reply to [email protected]From: Beilei Xing <[email protected]>
This patch enabls write back based on ITR expire
(WR_ON_ITR) for hairpin queue.
--- drivers/common/idpf/idpf_common_device.c | 75 ++++++++++++++++++++++++ drivers/common/idpf/idpf_common_device.h | 4 ++ drivers/common/idpf/version.map | 1 + drivers/net/cpfl/cpfl_ethdev.c | 13 +++- 4 files changed, 92 insertions(+), 1 deletion(-)
drivers/common/idpf/idpf_common_device.c +75 -0
@@ -559,6 +559,81 @@ idpf_vport_irq_map_config(struct idpf_vport *vport, uint16_t nb_rx_queues)return ret; } +int +idpf_vport_irq_map_config_by_qids (struct idpf_vport *vport,uint32_t *qids,uint16_t nb_rx_queues) +{ +struct idpf_adapter *adapter = vport->adapter; +struct virtchnl2_queue_vector *qv_map; +struct idpf_hw *hw = &adapter->hw; +uint32_t dynctl_val, itrn_val; +uint32_t dynctl_reg_start; +uint32_t itrn_reg_start; +uint16_t i; +int ret; + + qv_map =rte_zmalloc ("qv_map" , + nb_rx_queues * +sizeof (struct virtchnl2_queue_vector ),0 ); +if (qv_map ==NULL ) { +DRV_LOG (ERR ,"Failed to allocate %d queue-vector map" , + nb_rx_queues); + ret = -ENOMEM ; + goto qv_map_alloc_err; + } + +/* Rx interrupt disabled, Map interrupt only for writeback */ + +/* The capability flags adapter->caps.other_caps should be +* compared with bit VIRTCHNL2_CAP_WB_ON_ITR here. The if +* condition should be updated when the FW can return the +* correct flag bits. +*/ + dynctl_reg_start = + vport->recv_vectors->vchunks.vchunks->dynctl_reg_start; + itrn_reg_start = + vport->recv_vectors->vchunks.vchunks->itrn_reg_start; + dynctl_val =IDPF_READ_REG (hw, dynctl_reg_start); +DRV_LOG (DEBUG ,"Value of dynctl_reg_start is 0x%x" , dynctl_val); + itrn_val =IDPF_READ_REG (hw, itrn_reg_start); +DRV_LOG (DEBUG ,"Value of itrn_reg_start is 0x%x" , itrn_val); +/* Force write-backs by setting WB_ON_ITR bit in DYN_CTL +* register. WB_ON_ITR and INTENA are mutually exclusive +* bits. Setting WB_ON_ITR bits means TX and RX Descs +* are written back based on ITR expiration irrespective +* of INTENA setting. +*/ +/* TBD: need to tune INTERVAL value for better performance. */ + itrn_val = (itrn_val ==0 ) ?IDPF_DFLT_INTERVAL : itrn_val; + dynctl_val =VIRTCHNL2_ITR_IDX_0 << +PF_GLINT_DYN_CTL_ITR_INDX_S | +PF_GLINT_DYN_CTL_WB_ON_ITR_M | + itrn_val <<PF_GLINT_DYN_CTL_INTERVAL_S ; +IDPF_WRITE_REG (hw, dynctl_reg_start, dynctl_val); + +for (i =0 ; i < nb_rx_queues; i++) { +/* map all queues to the same vector */ + qv_map[i].queue_id = qids[i]; + qv_map[i].vector_id = + vport->recv_vectors->vchunks.vchunks->start_vector_id; + } + vport->qv_map = qv_map; + + ret =idpf_vc_irq_map_unmap_config (vport, nb_rx_queues, true); +if (ret !=0 ) { +DRV_LOG (ERR ,"config interrupt mapping failed" ); + goto config_irq_map_err; + } + +return 0 ; + +config_irq_map_err: +rte_free (vport->qv_map); + vport->qv_map =NULL ; + +qv_map_alloc_err: +return ret; +} +int idpf_vport_irq_unmap_config (struct idpf_vport *vport,uint16_t nb_rx_queues) {
drivers/common/idpf/idpf_common_device.h +4 -0
@@ -212,5 +212,9 @@ int idpf_vport_info_init(struct idpf_vport *vport, struct virtchnl2_create_vport *vport_info);__rte_internal void idpf_vport_stats_update(struct virtchnl2_vport_stats *oes, struct virtchnl2_vport_stats *nes); +__rte_internal +int idpf_vport_irq_map_config_by_qids(struct idpf_vport *vport, +uint32_t *qids, +uint16_t nb_rx_queues);#endif /* _IDPF_COMMON_DEVICE_H_ */
drivers/common/idpf/version.map +1 -0
@@ -74,6 +74,7 @@ INTERNAL { idpf_vport_info_init; idpf_vport_init; idpf_vport_irq_map_config; + idpf_vport_irq_map_config_by_qids; idpf_vport_irq_unmap_config; idpf_vport_rss_config; idpf_vport_stats_update;
drivers/net/cpfl/cpfl_ethdev.c +12 -1
@@ -730,11 +730,22 @@ cpfl_dev_configure(struct rte_eth_dev *dev)static int cpfl_config_rx_queues_irqs (struct rte_eth_dev *dev) { +uint32_t qids[CPFL_MAX_P2P_NB_QUEUES +IDPF_DEFAULT_RXQ_NUM ] = {0 };struct cpfl_vport *cpfl_vport = dev->data->dev_private;struct idpf_vport *vport = &cpfl_vport->base;uint16_t nb_rx_queues = dev->data->nb_rx_queues; +struct cpfl_rx_queue *cpfl_rxq; +int i; -return idpf_vport_irq_map_config (vport, nb_rx_queues); +for (i =0 ; i < nb_rx_queues; i++) { + cpfl_rxq = dev->data->rx_queues[i]; +if (cpfl_rxq->hairpin_info.hairpin_q) + qids[i] =cpfl_hw_qid_get (cpfl_vport->p2p_q_chunks_info.rx_start_qid, + (i - cpfl_vport->nb_data_rxq)); +else + qids[i] =cpfl_hw_qid_get (vport->chunks_info.rx_start_qid, i); + } +return idpf_vport_irq_map_config_by_qids (vport, qids, nb_rx_queues); }/* Update hairpin_info for dev's tx hairpin queue */
Signature · 1 line
2.26.2
PATCH v2 9/10 net/cpfl: support peer ports get
In reply to [email protected]From: Beilei Xing <[email protected]>
This patch supports get hairpin peer ports.
--- drivers/net/cpfl/cpfl_ethdev.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+)
drivers/net/cpfl/cpfl_ethdev.c +34 -0
@@ -1073,6 +1073,39 @@ cpfl_dev_close(struct rte_eth_dev *dev)return 0 ; } +static int +cpfl_hairpin_get_peer_ports (struct rte_eth_dev *dev,uint16_t *peer_ports, + __rte_unused size_t len, uint32_t tx) +{ +struct cpfl_vport *cpfl_vport = + (struct cpfl_vport *)dev->data->dev_private; +struct idpf_tx_queue *txq; +struct idpf_rx_queue *rxq; +struct cpfl_tx_queue *cpfl_txq; +struct cpfl_rx_queue *cpfl_rxq; +int i, j; + +if (tx >0 ) { +for (i = cpfl_vport->nb_data_txq, j =0 ; i < dev->data->nb_tx_queues; i++, j++) { + txq = dev->data->tx_queues[i]; +if (txq ==NULL ) +return -EINVAL ; + cpfl_txq = (struct cpfl_tx_queue *)txq; + peer_ports[j] = cpfl_txq->hairpin_info.peer_rxp; + } + }else if (tx ==0 ) { +for (i = cpfl_vport->nb_data_rxq, j =0 ; i < dev->data->nb_rx_queues; i++, j++) { + rxq = dev->data->rx_queues[i]; +if (rxq ==NULL ) +return -EINVAL ; + cpfl_rxq = (struct cpfl_rx_queue *)rxq; + peer_ports[j] = cpfl_rxq->hairpin_info.peer_txp; + } + } + +return j; +} +static const struct eth_dev_ops cpfl_eth_dev_ops = { .dev_configure = cpfl_dev_configure, .dev_close = cpfl_dev_close,
@@ -1102,6 +1135,7 @@ static const struct eth_dev_ops cpfl_eth_dev_ops = { .hairpin_cap_get = cpfl_hairpin_cap_get, .rx_hairpin_queue_setup = cpfl_rx_hairpin_queue_setup, .tx_hairpin_queue_setup = cpfl_tx_hairpin_queue_setup, + .hairpin_get_peer_ports = cpfl_hairpin_get_peer_ports, }; static int
Signature · 1 line
2.26.2
PATCH v2 10/10 net/cpfl: support hairpin bind/unbind
In reply to [email protected]From: Beilei Xing <[email protected]>
This patch supports hairpin_bind/unbind ops.
--- drivers/net/cpfl/cpfl_ethdev.c | 137 +++++++++++++++++++++++++++++++++ drivers/net/cpfl/cpfl_rxtx.c | 28 +++++++ drivers/net/cpfl/cpfl_rxtx.h | 2 + 3 files changed, 167 insertions(+)
drivers/net/cpfl/cpfl_ethdev.c +137 -0
@@ -1106,6 +1106,141 @@ cpfl_hairpin_get_peer_ports(struct rte_eth_dev *dev, uint16_t *peer_ports,return j; } +static int +cpfl_hairpin_bind (struct rte_eth_dev *dev,uint16_t rx_port) +{ +struct cpfl_vport *cpfl_tx_vport = dev->data->dev_private; +struct idpf_vport *tx_vport = &cpfl_tx_vport->base; +struct cpfl_vport *cpfl_rx_vport; +struct cpfl_tx_queue *cpfl_txq; +struct cpfl_rx_queue *cpfl_rxq; +struct rte_eth_dev *peer_dev; +struct idpf_vport *rx_vport; +int err =0 ; +int i; + + err =cpfl_txq_hairpin_info_update (dev, rx_port); +if (err !=0 ) { +PMD_DRV_LOG (ERR ,"Fail to update Tx hairpin queue info." ); +return err; + } + +/* configure hairpin queues */ +for (i = cpfl_tx_vport->nb_data_txq; i < dev->data->nb_tx_queues; i++) { + cpfl_txq = dev->data->tx_queues[i]; + err =cpfl_hairpin_txq_config (tx_vport, cpfl_txq); +if (err !=0 ) { +PMD_DRV_LOG (ERR ,"Fail to configure hairpin Tx queue %u" , i); +return err; + } + } + + err =cpfl_hairpin_tx_complq_config (cpfl_tx_vport); +if (err !=0 ) { +PMD_DRV_LOG (ERR ,"Fail to config Tx completion queue" ); +return err; + } + + peer_dev = &rte_eth_devices[rx_port]; + cpfl_rx_vport = (struct cpfl_vport *)peer_dev->data->dev_private; + rx_vport = &cpfl_rx_vport->base; +cpfl_rxq_hairpin_mz_bind (peer_dev); + +for (i = cpfl_rx_vport->nb_data_rxq; i < peer_dev->data->nb_rx_queues; i++) { + cpfl_rxq = peer_dev->data->rx_queues[i]; + err =cpfl_hairpin_rxq_config (rx_vport, cpfl_rxq); +if (err !=0 ) { +PMD_DRV_LOG (ERR ,"Fail to configure hairpin Rx queue %u" , i); +return err; + } + err =cpfl_rx_queue_init (peer_dev, i); +if (err !=0 ) { +PMD_DRV_LOG (ERR ,"Fail to init hairpin Rx queue %u" , i); +return err; + } + } + + err =cpfl_hairpin_rx_bufq_config (cpfl_rx_vport); +if (err !=0 ) { +PMD_DRV_LOG (ERR ,"Fail to config Rx buffer queue" ); +return err; + } + +/* enable hairpin queues */ +for (i = cpfl_tx_vport->nb_data_txq; i < dev->data->nb_tx_queues; i++) { + cpfl_txq = dev->data->tx_queues[i]; + err =cpfl_switch_hairpin_rxtx_queue (cpfl_tx_vport, + i - cpfl_tx_vport->nb_data_txq, + false, true); +if (err !=0 ) { +PMD_DRV_LOG (ERR ,"Failed to switch hairpin TX queue %u on" , + i); +return err; + } + cpfl_txq->base.q_started = true; + } + + err =cpfl_switch_hairpin_complq (cpfl_tx_vport, true); +if (err !=0 ) { +PMD_DRV_LOG (ERR ,"Failed to switch hairpin Tx complq" ); +return err; + } + +for (i = cpfl_rx_vport->nb_data_rxq; i < peer_dev->data->nb_rx_queues; i++) { + cpfl_rxq = peer_dev->data->rx_queues[i]; + err =cpfl_switch_hairpin_rxtx_queue (cpfl_rx_vport, + i - cpfl_rx_vport->nb_data_rxq, + true, true); +if (err !=0 ) { +PMD_DRV_LOG (ERR ,"Failed to switch hairpin RX queue %u on" , + i); + } + cpfl_rxq->base.q_started = true; + } + + err =cpfl_switch_hairpin_bufq (cpfl_rx_vport, true); +if (err !=0 ) { +PMD_DRV_LOG (ERR ,"Failed to switch hairpin Rx buffer queue" ); +return err; + } + +return 0 ; +} + +static int +cpfl_hairpin_unbind (struct rte_eth_dev *dev,uint16_t rx_port) +{ +struct cpfl_vport *cpfl_tx_vport = dev->data->dev_private; +struct rte_eth_dev *peer_dev = &rte_eth_devices[rx_port]; +struct cpfl_vport *cpfl_rx_vport = peer_dev->data->dev_private; +struct cpfl_tx_queue *cpfl_txq; +struct cpfl_rx_queue *cpfl_rxq; +int i; + +/* disable hairpin queues */ +for (i = cpfl_tx_vport->nb_data_txq; i < dev->data->nb_tx_queues; i++) { + cpfl_txq = dev->data->tx_queues[i]; +cpfl_switch_hairpin_rxtx_queue (cpfl_tx_vport, + i - cpfl_tx_vport->nb_data_txq, + false, false); + cpfl_txq->base.q_started = false; + } + +cpfl_switch_hairpin_complq (cpfl_tx_vport, false); + +for (i = cpfl_rx_vport->nb_data_rxq; i < peer_dev->data->nb_rx_queues; i++) { + cpfl_rxq = peer_dev->data->rx_queues[i]; +cpfl_switch_hairpin_rxtx_queue (cpfl_rx_vport, + i - cpfl_rx_vport->nb_data_rxq, + true, false); + cpfl_rxq->base.q_started = false; + } + +cpfl_switch_hairpin_bufq (cpfl_rx_vport, false); + +return 0 ; +} +static const struct eth_dev_ops cpfl_eth_dev_ops = { .dev_configure = cpfl_dev_configure, .dev_close = cpfl_dev_close,
@@ -1136,6 +1271,8 @@ static const struct eth_dev_ops cpfl_eth_dev_ops = { .rx_hairpin_queue_setup = cpfl_rx_hairpin_queue_setup, .tx_hairpin_queue_setup = cpfl_tx_hairpin_queue_setup, .hairpin_get_peer_ports = cpfl_hairpin_get_peer_ports, + .hairpin_bind = cpfl_hairpin_bind, + .hairpin_unbind = cpfl_hairpin_unbind, }; static int
drivers/net/cpfl/cpfl_rxtx.c +28 -0
@@ -1030,6 +1030,34 @@ cpfl_switch_hairpin_bufq_complq(struct cpfl_vport *cpfl_vport, bool on)return err; } +int +cpfl_switch_hairpin_complq (struct cpfl_vport *cpfl_vport,bool on) +{ +struct idpf_vport *vport = &cpfl_vport->base; +uint32_t type; +int err, queue_id; + + type =VIRTCHNL2_QUEUE_TYPE_TX_COMPLETION ; + queue_id = cpfl_vport->p2p_tx_complq->queue_id; + err =idpf_vc_ena_dis_one_queue (vport, queue_id, type, on); + +return err; +} + +int +cpfl_switch_hairpin_bufq (struct cpfl_vport *cpfl_vport,bool on) +{ +struct idpf_vport *vport = &cpfl_vport->base; +uint32_t type; +int err, queue_id; + + type =VIRTCHNL2_QUEUE_TYPE_RX_BUFFER ; + queue_id = cpfl_vport->p2p_rx_bufq->queue_id; + err =idpf_vc_ena_dis_one_queue (vport, queue_id, type, on); + +return err; +} +int cpfl_switch_hairpin_rxtx_queue (struct cpfl_vport *cpfl_vport,uint16_t logic_qid,bool rx,bool on)
drivers/net/cpfl/cpfl_rxtx.h +2 -0
@@ -102,6 +102,8 @@ int cpfl_hairpin_txq_config(struct idpf_vport *vport, struct cpfl_tx_queue *cpflint cpfl_hairpin_rx_bufq_config (struct cpfl_vport *cpfl_vport);int cpfl_hairpin_rxq_config (struct idpf_vport *vport,struct cpfl_rx_queue *cpfl_rxq);int cpfl_switch_hairpin_bufq_complq (struct cpfl_vport *cpfl_vport,bool on); +int cpfl_switch_hairpin_complq (struct cpfl_vport *cpfl_vport,bool on); +int cpfl_switch_hairpin_bufq (struct cpfl_vport *cpfl_vport,bool on);int cpfl_switch_hairpin_rxtx_queue (struct cpfl_vport *cpfl_vport,uint16_t qid,bool rx,bool on);#endif /* _CPFL_RXTX_H_ */
Signature · 1 line
2.26.2
v3 cover net/cpfl: add hairpin queue support
In reply to [email protected]From: Beilei Xing <[email protected]>
This patchset adds hairpin queue support.
v2 changes:
- change hairpin rx queus configuration sequence.
- code refine.
v3 changes:
- Refine the patchset based on the latest code.
Beilei Xing (10):
net/cpfl: refine structures
net/cpfl: support hairpin queue capbility get common/idpf: support queue groups add/delete net/cpfl: add haipin queue group during vport init net/cpfl: support hairpin queue setup and release net/cpfl: support hairpin queue configuration net/cpfl: support hairpin queue start/stop net/cpfl: enable write back based on ITR expire net/cpfl: support peer ports get
net/cpfl: support hairpin bind/unbind
drivers/common/idpf/idpf_common_device.c | 75 ++ drivers/common/idpf/idpf_common_device.h | 4 + drivers/common/idpf/idpf_common_virtchnl.c | 138 +++- drivers/common/idpf/idpf_common_virtchnl.h | 18 + drivers/common/idpf/version.map | 6 + drivers/net/cpfl/cpfl_ethdev.c | 591 +++++++++++++-- drivers/net/cpfl/cpfl_ethdev.h | 36 +- drivers/net/cpfl/cpfl_rxtx.c | 807 +++++++++++++++++++-- drivers/net/cpfl/cpfl_rxtx.h | 65 ++ drivers/net/cpfl/cpfl_rxtx_vec_common.h | 21 +- 10 files changed, 1642 insertions(+), 119 deletions(-)
Signature · 1 line
2.26.2
PATCH v3 1/10 net/cpfl: refine structures
From: Beilei Xing <[email protected]>
This patch refines some structures to support hairpin queue, cpfl_rx_queue/cpfl_tx_queue/cpfl_vport.
--- drivers/net/cpfl/cpfl_ethdev.c | 85 +++++++----- drivers/net/cpfl/cpfl_ethdev.h | 6 +- drivers/net/cpfl/cpfl_rxtx.c | 175 +++++++++++++++++------- drivers/net/cpfl/cpfl_rxtx.h | 8 ++ drivers/net/cpfl/cpfl_rxtx_vec_common.h | 17 +-- 5 files changed, 196 insertions(+), 95 deletions(-)
drivers/net/cpfl/cpfl_ethdev.c +49 -36
@@ -124,7 +124,8 @@ static int cpfl_dev_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complete) { - struct idpf_vport *vport = dev->data->dev_private; + struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;struct rte_eth_link new_link;unsigned int i;
@@ -156,7 +157,8 @@ cpfl_dev_link_update(struct rte_eth_dev *dev,static int cpfl_dev_info_get (struct rte_eth_dev *dev,struct rte_eth_dev_info *dev_info) { -struct idpf_vport *vport = dev->data->dev_private; +struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;struct idpf_adapter *base = vport->adapter; dev_info->max_rx_queues = base->caps.max_rx_q;
@@ -216,7 +218,8 @@ cpfl_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)static int cpfl_dev_mtu_set (struct rte_eth_dev *dev,uint16_t mtu) { -struct idpf_vport *vport = dev->data->dev_private; +struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;/* mtu setting is forbidden if port is start */ if (dev->data->dev_started) {
@@ -256,12 +259,12 @@ static uint64_t cpfl_get_mbuf_alloc_failed_stats(struct rte_eth_dev *dev) {uint64_t mbuf_alloc_failed =0 ; -struct idpf_rx_queue *rxq; +struct cpfl_rx_queue *cpfl_rxq;int i =0 ;for (i =0 ; i < dev->data->nb_rx_queues; i++) { - rxq = dev->data->rx_queues[i]; - mbuf_alloc_failed +=__atomic_load_n (&rxq->rx_stats.mbuf_alloc_failed, + cpfl_rxq = dev->data->rx_queues[i]; + mbuf_alloc_failed +=__atomic_load_n (&cpfl_rxq->base.rx_stats.mbuf_alloc_failed, __ATOMIC_RELAXED); }
@@ -271,8 +274,8 @@ cpfl_get_mbuf_alloc_failed_stats(struct rte_eth_dev *dev)static int cpfl_dev_stats_get (struct rte_eth_dev *dev,struct rte_eth_stats *stats) { -struct idpf_vport *vport = - (struct idpf_vport *)dev->data->dev_private; +struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;struct virtchnl2_vport_stats *pstats =NULL ;int ret;
@@ -305,20 +308,20 @@ cpfl_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)static void cpfl_reset_mbuf_alloc_failed_stats (struct rte_eth_dev *dev) { -struct idpf_rx_queue *rxq; +struct cpfl_rx_queue *cpfl_rxq;int i;for (i =0 ; i < dev->data->nb_rx_queues; i++) { - rxq = dev->data->rx_queues[i]; -__atomic_store_n (&rxq->rx_stats.mbuf_alloc_failed,0 , __ATOMIC_RELAXED); + cpfl_rxq = dev->data->rx_queues[i]; +__atomic_store_n (&cpfl_rxq->base.rx_stats.mbuf_alloc_failed,0 , __ATOMIC_RELAXED); } }static int cpfl_dev_stats_reset (struct rte_eth_dev *dev) { -struct idpf_vport *vport = - (struct idpf_vport *)dev->data->dev_private; +struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;struct virtchnl2_vport_stats *pstats =NULL ;int ret;
@@ -343,8 +346,8 @@ static int cpfl_dev_xstats_reset(struct rte_eth_dev *dev)static int cpfl_dev_xstats_get (struct rte_eth_dev *dev,struct rte_eth_xstat *xstats,unsigned int n) { -struct idpf_vport *vport = - (struct idpf_vport *)dev->data->dev_private; +struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;struct virtchnl2_vport_stats *pstats =NULL ;unsigned int i;int ret;
@@ -459,7 +462,8 @@ cpfl_rss_reta_update(struct rte_eth_dev *dev, struct rte_eth_rss_reta_entry64 *reta_conf, uint16_t reta_size) { -struct idpf_vport *vport = dev->data->dev_private; +struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;struct idpf_adapter *base = vport->adapter;uint16_t idx, shift;int ret =0 ;
@@ -498,7 +502,8 @@ cpfl_rss_reta_query(struct rte_eth_dev *dev, struct rte_eth_rss_reta_entry64 *reta_conf, uint16_t reta_size) { -struct idpf_vport *vport = dev->data->dev_private; +struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;struct idpf_adapter *base = vport->adapter;uint16_t idx, shift;int ret =0 ;
@@ -536,7 +541,8 @@ static int cpfl_rss_hash_update(struct rte_eth_dev *dev, struct rte_eth_rss_conf *rss_conf) { - struct idpf_vport *vport = dev->data->dev_private; + struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;struct idpf_adapter *base = vport->adapter;int ret =0 ;
@@ -601,7 +607,8 @@ static int cpfl_rss_hash_conf_get(struct rte_eth_dev *dev, struct rte_eth_rss_conf *rss_conf) { - struct idpf_vport *vport = dev->data->dev_private; + struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;struct idpf_adapter *base = vport->adapter;int ret =0 ;
@@ -638,7 +645,8 @@ cpfl_rss_hash_conf_get(struct rte_eth_dev *dev,static int cpfl_dev_configure (struct rte_eth_dev *dev) { -struct idpf_vport *vport = dev->data->dev_private; +struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;struct rte_eth_conf *conf = &dev->data->dev_conf;struct idpf_adapter *base = vport->adapter;int ret;
@@ -710,7 +718,8 @@ cpfl_dev_configure(struct rte_eth_dev *dev)static int cpfl_config_rx_queues_irqs (struct rte_eth_dev *dev) { -struct idpf_vport *vport = dev->data->dev_private; +struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;uint16_t nb_rx_queues = dev->data->nb_rx_queues;return idpf_vport_irq_map_config (vport, nb_rx_queues);
@@ -719,14 +728,14 @@ cpfl_config_rx_queues_irqs(struct rte_eth_dev *dev)static int cpfl_start_queues (struct rte_eth_dev *dev) { -struct idpf_rx_queue *rxq; -struct idpf_tx_queue *txq; +struct cpfl_rx_queue *cpfl_rxq; +struct cpfl_tx_queue *cpfl_txq;int err =0 ;int i;for (i =0 ; i < dev->data->nb_tx_queues; i++) { - txq = dev->data->tx_queues[i]; -if (txq ==NULL || txq->tx_deferred_start) + cpfl_txq = dev->data->tx_queues[i]; +if (cpfl_txq ==NULL || cpfl_txq->base.tx_deferred_start)continue ; err =cpfl_tx_queue_start (dev, i);if (err !=0 ) {
@@ -736,8 +745,8 @@ cpfl_start_queues(struct rte_eth_dev *dev) }for (i =0 ; i < dev->data->nb_rx_queues; i++) { - rxq = dev->data->rx_queues[i]; -if (rxq ==NULL || rxq->rx_deferred_start) + cpfl_rxq = dev->data->rx_queues[i]; +if (cpfl_rxq ==NULL || cpfl_rxq->base.rx_deferred_start)continue ; err =cpfl_rx_queue_start (dev, i);if (err !=0 ) {
@@ -752,7 +761,8 @@ cpfl_start_queues(struct rte_eth_dev *dev)static int cpfl_dev_start (struct rte_eth_dev *dev) { -struct idpf_vport *vport = dev->data->dev_private; +struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;struct idpf_adapter *base = vport->adapter;struct cpfl_adapter_ext *adapter =CPFL_ADAPTER_TO_EXT (base);uint16_t num_allocated_vectors = base->caps.num_allocated_vectors;
@@ -813,7 +823,8 @@ cpfl_dev_start(struct rte_eth_dev *dev)static int cpfl_dev_stop (struct rte_eth_dev *dev) { -struct idpf_vport *vport = dev->data->dev_private; +struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;if (dev->data->dev_started ==0 )return 0 ;
@@ -832,7 +843,8 @@ cpfl_dev_stop(struct rte_eth_dev *dev)static int cpfl_dev_close (struct rte_eth_dev *dev) { -struct idpf_vport *vport = dev->data->dev_private; +struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;struct cpfl_adapter_ext *adapter =CPFL_ADAPTER_TO_EXT (vport->adapter);cpfl_dev_stop (dev);
@@ -842,7 +854,7 @@ cpfl_dev_close(struct rte_eth_dev *dev) adapter->cur_vport_nb--; dev->data->dev_private =NULL ; adapter->vports[vport->sw_idx] =NULL ; -rte_free (vport); +rte_free (cpfl_vport);return 0 ; }
@@ -1047,7 +1059,7 @@ cpfl_find_vport(struct cpfl_adapter_ext *adapter, uint32_t vport_id)int i;for (i =0 ; i < adapter->cur_vport_nb; i++) { - vport = adapter->vports[i]; + vport = &adapter->vports[i]->base;if (vport->vport_id != vport_id)continue ;else
@@ -1275,7 +1287,8 @@ cpfl_vport_idx_alloc(struct cpfl_adapter_ext *adapter)static int cpfl_dev_vport_init (struct rte_eth_dev *dev,void *init_params) { -struct idpf_vport *vport = dev->data->dev_private; +struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;struct cpfl_vport_param *param = init_params;struct cpfl_adapter_ext *adapter = param->adapter;/* for sending create vport virtchnl msg prepare */
@@ -1300,7 +1313,7 @@ cpfl_dev_vport_init(struct rte_eth_dev *dev, void *init_params) goto err; } - adapter->vports[param->idx] = vport; + adapter->vports[param->idx] = cpfl_vport; adapter->cur_vports |=RTE_BIT32 (param->devarg_id); adapter->cur_vport_nb++;
@@ -1415,7 +1428,7 @@ cpfl_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,snprintf (name,sizeof (name),"cpfl_%s_vport_0" , pci_dev->device.name); retval =rte_eth_dev_create (&pci_dev->device, name, -sizeof (struct idpf_vport ), +sizeof (struct cpfl_vport ),NULL ,NULL , cpfl_dev_vport_init, &vport_param);if (retval !=0 )
@@ -1433,7 +1446,7 @@ cpfl_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, pci_dev->device.name, devargs.req_vports[i]); retval =rte_eth_dev_create (&pci_dev->device, name, -sizeof (struct idpf_vport ), +sizeof (struct cpfl_vport ),NULL ,NULL , cpfl_dev_vport_init, &vport_param);if (retval !=0 )
drivers/net/cpfl/cpfl_ethdev.h +5 -1
@@ -69,13 +69,17 @@ struct cpfl_devargs {uint16_t req_vport_nb; }; +struct cpfl_vport { +struct idpf_vport base; +}; +struct cpfl_adapter_ext {TAILQ_ENTRY (cpfl_adapter_ext) next;struct idpf_adapter base;char name[CPFL_ADAPTER_NAME_LEN ]; -struct idpf_vport **vports; +struct cpfl_vport **vports;uint16_t max_vport_nb;uint16_t cur_vports;/* bit mask of created vport */
drivers/net/cpfl/cpfl_rxtx.c +125 -50
401 lines not on this page · raw message
drivers/net/cpfl/cpfl_rxtx.h +8 -0
@@ -23,6 +23,14 @@#define CPFL_SUPPORT_CHAIN_NUM 5 +struct cpfl_rx_queue { +struct idpf_rx_queue base; +}; + +struct cpfl_tx_queue { +struct idpf_tx_queue base; +}; +int cpfl_tx_queue_setup (struct rte_eth_dev *dev,uint16_t queue_idx,uint16_t nb_desc,unsigned int socket_id,const struct rte_eth_txconf *tx_conf);
drivers/net/cpfl/cpfl_rxtx_vec_common.h +9 -8
@@ -76,15 +76,16 @@ cpfl_rx_splitq_vec_default(struct idpf_rx_queue *rxq)static inline int cpfl_rx_vec_dev_check_default (struct rte_eth_dev *dev) { -struct idpf_vport *vport = dev->data->dev_private; -struct idpf_rx_queue *rxq; +struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base; +struct cpfl_rx_queue *cpfl_rxq;int i, default_ret, splitq_ret, ret =CPFL_SCALAR_PATH ;for (i =0 ; i < dev->data->nb_rx_queues; i++) { - rxq = dev->data->rx_queues[i]; - default_ret =cpfl_rx_vec_queue_default (rxq); + cpfl_rxq = dev->data->rx_queues[i]; + default_ret =cpfl_rx_vec_queue_default (&cpfl_rxq->base);if (vport->rxq_model ==VIRTCHNL2_QUEUE_MODEL_SPLIT ) { - splitq_ret =cpfl_rx_splitq_vec_default (rxq); + splitq_ret =cpfl_rx_splitq_vec_default (&cpfl_rxq->base); ret = splitq_ret && default_ret; }else { ret = default_ret;
@@ -100,12 +101,12 @@ static inline int cpfl_tx_vec_dev_check_default(struct rte_eth_dev *dev) {int i; -struct idpf_tx_queue *txq; +struct cpfl_tx_queue *cpfl_txq;int ret =0 ;for (i =0 ; i < dev->data->nb_tx_queues; i++) { - txq = dev->data->tx_queues[i]; - ret =cpfl_tx_vec_queue_default (txq); + cpfl_txq = dev->data->tx_queues[i]; + ret =cpfl_tx_vec_queue_default (&cpfl_txq->base);if (ret ==CPFL_SCALAR_PATH )return CPFL_SCALAR_PATH ; }
Signature · 1 line
2.26.2
PATCH v3 2/10 net/cpfl: support hairpin queue capbility get
In reply to [email protected]From: Beilei Xing <[email protected]>
This patch adds hairpin_cap_get ops support.
--- drivers/net/cpfl/cpfl_ethdev.c | 13 +++++++++++++ drivers/net/cpfl/cpfl_rxtx.h | 4 ++++ 2 files changed, 17 insertions(+)
drivers/net/cpfl/cpfl_ethdev.c +13 -0
@@ -154,6 +154,18 @@ cpfl_dev_link_update(struct rte_eth_dev *dev,return rte_eth_linkstatus_set (dev, &new_link); } +static int +cpfl_hairpin_cap_get(__rte_unused struct rte_eth_dev *dev, +struct rte_eth_hairpin_cap *cap) +{ + cap->max_nb_queues =CPFL_MAX_P2P_NB_QUEUES ; + cap->max_rx_2_tx =CPFL_MAX_HAIRPINQ_RX_2_TX ; + cap->max_tx_2_rx =CPFL_MAX_HAIRPINQ_TX_2_RX ; + cap->max_nb_desc =CPFL_MAX_HAIRPINQ_NB_DESC ; + +return 0 ; +} +static int cpfl_dev_info_get (struct rte_eth_dev *dev,struct rte_eth_dev_info *dev_info) {
@@ -885,6 +897,7 @@ static const struct eth_dev_ops cpfl_eth_dev_ops = { .xstats_get = cpfl_dev_xstats_get, .xstats_get_names = cpfl_dev_xstats_get_names, .xstats_reset = cpfl_dev_xstats_reset, + .hairpin_cap_get = cpfl_hairpin_cap_get, }; static int
drivers/net/cpfl/cpfl_rxtx.h +4 -0
@@ -13,6 +13,10 @@#define CPFL_MIN_RING_DESC 32#define CPFL_MAX_RING_DESC 4096#define CPFL_DMA_MEM_ALIGN 4096 +#define CPFL_MAX_HAIRPINQ_RX_2_TX 1 +#define CPFL_MAX_HAIRPINQ_TX_2_RX 1 +#define CPFL_MAX_HAIRPINQ_NB_DESC 1024 +#define CPFL_MAX_P2P_NB_QUEUES 16/* Base address of the HW descriptor ring should be 128B aligned. */ #define CPFL_RING_BASE_ALIGN 128
Signature · 1 line
2.26.2
RE: [PATCH v3 02/10] net/cpfl: support hairpin queue capbility get
Quoted 29 lines
-----Original Message-----
From: Xing, Beilei <[email protected]>
Sent: Friday, May 19, 2023 3:31 PM
To: Wu, Jingjing <[email protected]>
Cc: [email protected]; Liu, Mingxia <[email protected]>; Xing, Beilei <[email protected]>; Wang, Xiao W <[email protected]>
Subject: [PATCH v3 02/10] net/cpfl: support hairpin queue capbility getFrom: Beilei Xing <[email protected]>
This patch adds
hairpin_cap_getops support.Signed-off-by Xiao Wang <[email protected]>Signed-off-by Mingxia Liu <[email protected]>Signed-off-by Beilei Xing <[email protected]>--- drivers/net/cpfl/cpfl_ethdev.c | 13 +++++++++++++ drivers/net/cpfl/cpfl_rxtx.h | 4 ++++ 2 files changed, 17 insertions(+)drivers/net/cpfl/cpfl_ethdev.c +0
-0@@ -154,6 +154,18 @@ cpfl_dev_link_update(struct rte_eth_dev *dev,return rte_eth_linkstatus_set (dev, &new_link); }
drivers/net/cpfl/cpfl_ethdev.c cpfl_dev_link_update(struct rte_eth_dev *dev, · line 165
Quoted 10 lines
drivers/net/cpfl/cpfl_ethdev.c +9
-0+static int +cpfl_hairpin_cap_get(__rte_unused struct rte_eth_dev *dev, +struct rte_eth_hairpin_cap *cap) +{ + cap->max_nb_queues =CPFL_MAX_P2P_NB_QUEUES ; + cap->max_rx_2_tx =CPFL_MAX_HAIRPINQ_RX_2_TX ; + cap->max_tx_2_rx =CPFL_MAX_HAIRPINQ_TX_2_RX ; + cap->max_nb_desc =CPFL_MAX_HAIRPINQ_NB_DESC ; +
Is that better to check if p2p queue group is added successfully and then return success?
PATCH v3 3/10 common/idpf: support queue groups add/delete
In reply to [email protected]From: Beilei Xing <[email protected]>
This patch adds queue group add/delete virtual channel support.
--- drivers/common/idpf/idpf_common_virtchnl.c | 66 ++++++++++++++++++++++ drivers/common/idpf/idpf_common_virtchnl.h | 9 +++ drivers/common/idpf/version.map | 2 + 3 files changed, 77 insertions(+)
drivers/common/idpf/idpf_common_virtchnl.c +66 -0
@@ -359,6 +359,72 @@ idpf_vc_vport_destroy(struct idpf_vport *vport)return err; } +int +idpf_vc_queue_grps_add (struct idpf_vport *vport, +struct virtchnl2_add_queue_groups *p2p_queue_grps_info, +uint8_t *p2p_queue_grps_out) +{ +struct idpf_adapter *adapter = vport->adapter; +struct idpf_cmd_info args; +int size, qg_info_size; +int err =-1 ; + + size =sizeof (*p2p_queue_grps_info) + + (p2p_queue_grps_info->qg_info.num_queue_groups -1 ) * +sizeof (struct virtchnl2_queue_group_info ); + +memset (&args,0 ,sizeof (args)); + args.ops =VIRTCHNL2_OP_ADD_QUEUE_GROUPS ; + args.in_args = (uint8_t *)p2p_queue_grps_info; + args.in_args_size = size; + args.out_buffer = adapter->mbx_resp; + args.out_size =IDPF_DFLT_MBX_BUF_SIZE ; + + err =idpf_vc_cmd_execute (adapter, &args); +if (err !=0 ) { +DRV_LOG (ERR , +"Failed to execute command of VIRTCHNL2_OP_ADD_QUEUE_GROUPS" ); +return err; + } + +rte_memcpy (p2p_queue_grps_out, args.out_buffer,IDPF_DFLT_MBX_BUF_SIZE ); +return 0 ; +} + +int idpf_vc_queue_grps_del (struct idpf_vport *vport, +uint16_t num_q_grps, +struct virtchnl2_queue_group_id *qg_ids) +{ +struct idpf_adapter *adapter = vport->adapter; +struct virtchnl2_delete_queue_groups *vc_del_q_grps; +struct idpf_cmd_info args; +int size; +int err; + + size =sizeof (*vc_del_q_grps) + + (num_q_grps -1 ) *sizeof (struct virtchnl2_queue_group_id ); + vc_del_q_grps =rte_zmalloc ("vc_del_q_grps" , size,0 ); + + vc_del_q_grps->vport_id = vport->vport_id; + vc_del_q_grps->num_queue_groups = num_q_grps; +memcpy (vc_del_q_grps->qg_ids, qg_ids, + num_q_grps *sizeof (struct virtchnl2_queue_group_id )); + +memset (&args,0 ,sizeof (args)); + args.ops =VIRTCHNL2_OP_DEL_QUEUE_GROUPS ; + args.in_args = (uint8_t *)vc_del_q_grps; + args.in_args_size = size; + args.out_buffer = adapter->mbx_resp; + args.out_size =IDPF_DFLT_MBX_BUF_SIZE ; + + err =idpf_vc_cmd_execute (adapter, &args); +if (err !=0 ) +DRV_LOG (ERR ,"Failed to execute command of VIRTCHNL2_OP_DEL_QUEUE_GROUPS" ); + +rte_free (vc_del_q_grps); +return err; +} +int idpf_vc_rss_key_set (struct idpf_vport *vport) {
drivers/common/idpf/idpf_common_virtchnl.h +9 -0
@@ -64,4 +64,13 @@ int idpf_vc_ctlq_recv(struct idpf_ctlq_info *cq, u16 *num_q_msg,__rte_internal int idpf_vc_ctlq_post_rx_buffs(struct idpf_hw *hw, struct idpf_ctlq_info *cq,u16 *buff_count,struct idpf_dma_mem **buffs); +__rte_internal +int idpf_vc_queue_grps_del(struct idpf_vport *vport, +uint16_t num_q_grps, +struct virtchnl2_queue_group_id *qg_ids); +__rte_internal +int +idpf_vc_queue_grps_add (struct idpf_vport *vport, +struct virtchnl2_add_queue_groups *ptp_queue_grps_info, +uint8_t *ptp_queue_grps_out);#endif /* _IDPF_COMMON_VIRTCHNL_H_ */
drivers/common/idpf/version.map +2 -0
@@ -43,6 +43,8 @@ INTERNAL { idpf_vc_irq_map_unmap_config; idpf_vc_one_msg_read; idpf_vc_ptype_info_query; + idpf_vc_queue_grps_add; + idpf_vc_queue_grps_del; idpf_vc_queue_switch; idpf_vc_queues_ena_dis; idpf_vc_rss_hash_get;
Signature · 1 line
2.26.2
PATCH v3 4/10 net/cpfl: add haipin queue group during vport init
In reply to [email protected]From: Beilei Xing <[email protected]>
This patch adds haipin queue group during vport init.
--- drivers/net/cpfl/cpfl_ethdev.c | 130 +++++++++++++++++++++++++++++++++ drivers/net/cpfl/cpfl_ethdev.h | 18 +++++ drivers/net/cpfl/cpfl_rxtx.h | 4 + 3 files changed, 152 insertions(+)
drivers/net/cpfl/cpfl_ethdev.c +130 -0
@@ -852,6 +852,20 @@ cpfl_dev_stop(struct rte_eth_dev *dev)return 0 ; } +static int +cpfl_p2p_queue_grps_del (struct idpf_vport *vport) +{ +struct virtchnl2_queue_group_id qg_ids[CPFL_P2P_NB_QUEUE_GRPS ] = {0 }; +int ret =0 ; + + qg_ids[0 ].queue_group_id =CPFL_P2P_QUEUE_GRP_ID ; + qg_ids[0 ].queue_group_type =VIRTCHNL2_QUEUE_GROUP_P2P ; + ret =idpf_vc_queue_grps_del (vport,CPFL_P2P_NB_QUEUE_GRPS , qg_ids); +if (ret) +PMD_DRV_LOG (ERR ,"Failed to delete p2p queue groups" ); +return ret; +} +static int cpfl_dev_close (struct rte_eth_dev *dev) {
@@ -860,6 +874,10 @@ cpfl_dev_close(struct rte_eth_dev *dev)struct cpfl_adapter_ext *adapter =CPFL_ADAPTER_TO_EXT (vport->adapter);cpfl_dev_stop (dev); + +if (!adapter->base.is_rx_singleq && !adapter->base.is_tx_singleq) +cpfl_p2p_queue_grps_del (vport); +idpf_vport_deinit (vport); adapter->cur_vports &= ~RTE_BIT32 (vport->devarg_id);
@@ -1297,6 +1315,96 @@ cpfl_vport_idx_alloc(struct cpfl_adapter_ext *adapter)return vport_idx; } +static int +cpfl_p2p_q_grps_add (struct idpf_vport *vport, +struct virtchnl2_add_queue_groups *p2p_queue_grps_info, +uint8_t *p2p_q_vc_out_info) +{ +int ret; + + p2p_queue_grps_info->vport_id = vport->vport_id; + p2p_queue_grps_info->qg_info.num_queue_groups =CPFL_P2P_NB_QUEUE_GRPS ; + p2p_queue_grps_info->qg_info.groups[0 ].num_rx_q =CPFL_MAX_P2P_NB_QUEUES ; + p2p_queue_grps_info->qg_info.groups[0 ].num_rx_bufq =CPFL_P2P_NB_RX_BUFQ ; + p2p_queue_grps_info->qg_info.groups[0 ].num_tx_q =CPFL_MAX_P2P_NB_QUEUES ; + p2p_queue_grps_info->qg_info.groups[0 ].num_tx_complq =CPFL_P2P_NB_TX_COMPLQ ; + p2p_queue_grps_info->qg_info.groups[0 ].qg_id.queue_group_id =CPFL_P2P_QUEUE_GRP_ID ; + p2p_queue_grps_info->qg_info.groups[0 ].qg_id.queue_group_type =VIRTCHNL2_QUEUE_GROUP_P2P ; + p2p_queue_grps_info->qg_info.groups[0 ].rx_q_grp_info.rss_lut_size =0 ; + p2p_queue_grps_info->qg_info.groups[0 ].tx_q_grp_info.tx_tc =0 ; + p2p_queue_grps_info->qg_info.groups[0 ].tx_q_grp_info.priority =0 ; + p2p_queue_grps_info->qg_info.groups[0 ].tx_q_grp_info.is_sp =0 ; + p2p_queue_grps_info->qg_info.groups[0 ].tx_q_grp_info.pir_weight =0 ; + + ret =idpf_vc_queue_grps_add (vport, p2p_queue_grps_info, p2p_q_vc_out_info); +if (ret !=0 ) { +PMD_DRV_LOG (ERR ,"Failed to add p2p queue groups." ); +return ret; + } + +return ret; +} + +static int +cpfl_p2p_queue_info_init (struct cpfl_vport *cpfl_vport, +struct virtchnl2_add_queue_groups *p2p_q_vc_out_info) +{ +struct p2p_queue_chunks_info *p2p_q_chunks_info = &cpfl_vport->p2p_q_chunks_info; +struct virtchnl2_queue_reg_chunks *vc_chunks_out; +int i, type; + +if (p2p_q_vc_out_info->qg_info.groups[0 ].qg_id.queue_group_type != +VIRTCHNL2_QUEUE_GROUP_P2P ) { +PMD_DRV_LOG (ERR ,"Add queue group response mismatch." ); +return -EINVAL ; + } + + vc_chunks_out = &p2p_q_vc_out_info->qg_info.groups[0 ].chunks; + +for (i =0 ; i < vc_chunks_out->num_chunks; i++) { + type = vc_chunks_out->chunks[i].type; +switch (type) { +case VIRTCHNL2_QUEUE_TYPE_TX : + p2p_q_chunks_info->tx_start_qid = + vc_chunks_out->chunks[i].start_queue_id; + p2p_q_chunks_info->tx_qtail_start = + vc_chunks_out->chunks[i].qtail_reg_start; + p2p_q_chunks_info->tx_qtail_spacing = + vc_chunks_out->chunks[i].qtail_reg_spacing; +break ; +case VIRTCHNL2_QUEUE_TYPE_RX : + p2p_q_chunks_info->rx_start_qid = + vc_chunks_out->chunks[i].start_queue_id; + p2p_q_chunks_info->rx_qtail_start = + vc_chunks_out->chunks[i].qtail_reg_start; + p2p_q_chunks_info->rx_qtail_spacing = + vc_chunks_out->chunks[i].qtail_reg_spacing; +break ; +case VIRTCHNL2_QUEUE_TYPE_TX_COMPLETION : + p2p_q_chunks_info->tx_compl_start_qid = + vc_chunks_out->chunks[i].start_queue_id; + p2p_q_chunks_info->tx_compl_qtail_start = + vc_chunks_out->chunks[i].qtail_reg_start; + p2p_q_chunks_info->tx_compl_qtail_spacing = + vc_chunks_out->chunks[i].qtail_reg_spacing; +break ; +case VIRTCHNL2_QUEUE_TYPE_RX_BUFFER : + p2p_q_chunks_info->rx_buf_start_qid = + vc_chunks_out->chunks[i].start_queue_id; + p2p_q_chunks_info->rx_buf_qtail_start = + vc_chunks_out->chunks[i].qtail_reg_start; + p2p_q_chunks_info->rx_buf_qtail_spacing = + vc_chunks_out->chunks[i].qtail_reg_spacing; +break ; +default : +PMD_DRV_LOG (ERR ,"Unsupported queue type" ); +break ; + } + } + +return 0 ; +} +static int cpfl_dev_vport_init (struct rte_eth_dev *dev,void *init_params) {
@@ -1306,6 +1414,8 @@ cpfl_dev_vport_init(struct rte_eth_dev *dev, void *init_params)struct cpfl_adapter_ext *adapter = param->adapter;/* for sending create vport virtchnl msg prepare */ struct virtchnl2_create_vport create_vport_info; +struct virtchnl2_add_queue_groups p2p_queue_grps_info; +uint8_t p2p_q_vc_out_info[IDPF_DFLT_MBX_BUF_SIZE ] = {0 };int ret =0 ; dev->dev_ops = &cpfl_eth_dev_ops;
@@ -1340,8 +1450,28 @@ cpfl_dev_vport_init(struct rte_eth_dev *dev, void *init_params)rte_ether_addr_copy ((struct rte_ether_addr *)vport->default_mac_addr, &dev->data->mac_addrs[0 ]); +if (!adapter->base.is_rx_singleq && !adapter->base.is_tx_singleq) { +memset (&p2p_queue_grps_info,0 ,sizeof (p2p_queue_grps_info)); + ret =cpfl_p2p_q_grps_add (vport, &p2p_queue_grps_info, p2p_q_vc_out_info); +if (ret !=0 ) { +PMD_INIT_LOG (ERR ,"Failed to add p2p queue group." ); + goto err_q_grps_add; + } + ret =cpfl_p2p_queue_info_init (cpfl_vport, + (struct virtchnl2_add_queue_groups *)p2p_q_vc_out_info); +if (ret !=0 ) { +PMD_INIT_LOG (ERR ,"Failed to init p2p queue info." ); + goto err_p2p_qinfo_init; + } + } +return 0 ; +err_p2p_qinfo_init: +cpfl_p2p_queue_grps_del (vport); +err_q_grps_add: +rte_free (dev->data->mac_addrs); + dev->data->mac_addrs =NULL ; err_mac_addrs: adapter->vports[param->idx] =NULL ;/* reset */ idpf_vport_deinit (vport);
drivers/net/cpfl/cpfl_ethdev.h +18 -0
@@ -56,6 +56,7 @@/* Device IDs */ #define IDPF_DEV_ID_CPF 0x1453 +#define VIRTCHNL2_QUEUE_GROUP_P2P 0x100struct cpfl_vport_param {struct cpfl_adapter_ext *adapter;
@@ -69,8 +70,25 @@ struct cpfl_devargs {uint16_t req_vport_nb; }; +struct p2p_queue_chunks_info { +uint32_t tx_start_qid; +uint32_t rx_start_qid; +uint32_t tx_compl_start_qid; +uint32_t rx_buf_start_qid; + +uint64_t tx_qtail_start; +uint32_t tx_qtail_spacing; +uint64_t rx_qtail_start; +uint32_t rx_qtail_spacing; +uint64_t tx_compl_qtail_start; +uint32_t tx_compl_qtail_spacing; +uint64_t rx_buf_qtail_start; +uint32_t rx_buf_qtail_spacing; +}; +struct cpfl_vport {struct idpf_vport base; +struct p2p_queue_chunks_info p2p_q_chunks_info; };struct cpfl_adapter_ext {
drivers/net/cpfl/cpfl_rxtx.h +4 -0
@@ -17,6 +17,10 @@#define CPFL_MAX_HAIRPINQ_TX_2_RX 1#define CPFL_MAX_HAIRPINQ_NB_DESC 1024#define CPFL_MAX_P2P_NB_QUEUES 16 +#define CPFL_P2P_NB_RX_BUFQ 1 +#define CPFL_P2P_NB_TX_COMPLQ 1 +#define CPFL_P2P_NB_QUEUE_GRPS 1 +#define CPFL_P2P_QUEUE_GRP_ID 1/* Base address of the HW descriptor ring should be 128B aligned. */ #define CPFL_RING_BASE_ALIGN 128
Signature · 1 line
2.26.2
RE: [PATCH v3 04/10] net/cpfl: add haipin queue group during vport init
Quoted 21 lines
static int
cpfl_dev_vport_init(struct rte_eth_dev *dev, void *init_params){drivers/net/cpfl/cpfl_ethdev.c +5
-0@@ -1306,6 +1414,8 @@ cpfl_dev_vport_init(struct rte_eth_dev *dev, void *init_params)struct cpfl_adapter_ext *adapter = param->adapter;/* for sending create vport virtchnl msg prepare */ struct virtchnl2_create_vport create_vport_info; +struct virtchnl2_add_queue_groups p2p_queue_grps_info; +uint8_t p2p_q_vc_out_info[IDPF_DFLT_MBX_BUF_SIZE ] = {0 };int ret =0 ; dev->dev_ops = &cpfl_eth_dev_ops;@@ -1340,8 +1450,28 @@ cpfl_dev_vport_init(struct rte_eth_dev *dev, void *init_params)rte_ether_addr_copy ((struct rte_ether_addr *)vport->default_mac_addr, &dev->data->mac_addrs[0 ]); +if (!adapter->base.is_rx_singleq && !adapter->base.is_tx_singleq) { +memset (&p2p_queue_grps_info,0 ,sizeof (p2p_queue_grps_info)); + ret =cpfl_p2p_q_grps_add (vport, &p2p_queue_grps_info, p2p_q_vc_out_info);
drivers/net/cpfl/cpfl_ethdev.c cpfl_dev_vport_init(struct rte_eth_dev *dev, void · line 1467
Quoted 10 lines
drivers/net/cpfl/cpfl_ethdev.c +9
-0+if (ret !=0 ) { +PMD_INIT_LOG (ERR ,"Failed to add p2p queue group." ); + goto err_q_grps_add; + } + ret =cpfl_p2p_queue_info_init (cpfl_vport, + (struct virtchnl2_add_queue_groups *)p2p_q_vc_out_info); +if (ret !=0 ) { +PMD_INIT_LOG (ERR ,"Failed to init p2p queue info." ); + goto err_p2p_qinfo_init;
If it is failed to add p2p queue group, the device init will quit?
I think it should be better to continue initialization just without p2p capability.
Quoted 5 lines
drivers/net/cpfl/cpfl_ethdev.c +3
-0+ } + } +return 0 ;
PATCH v3 5/10 net/cpfl: support hairpin queue setup and release
In reply to [email protected]From: Beilei Xing <[email protected]>
Support hairpin Rx/Tx queue setup and release.
--- drivers/net/cpfl/cpfl_ethdev.c | 6 + drivers/net/cpfl/cpfl_ethdev.h | 12 + drivers/net/cpfl/cpfl_rxtx.c | 373 +++++++++++++++++++++++- drivers/net/cpfl/cpfl_rxtx.h | 26 ++ drivers/net/cpfl/cpfl_rxtx_vec_common.h | 4 + 5 files changed, 420 insertions(+), 1 deletion(-)
drivers/net/cpfl/cpfl_ethdev.c +6 -0
@@ -874,6 +874,10 @@ cpfl_dev_close(struct rte_eth_dev *dev)struct cpfl_adapter_ext *adapter =CPFL_ADAPTER_TO_EXT (vport->adapter);cpfl_dev_stop (dev); +if (cpfl_vport->p2p_mp) { +rte_mempool_free (cpfl_vport->p2p_mp); + cpfl_vport->p2p_mp =NULL ; + }if (!adapter->base.is_rx_singleq && !adapter->base.is_tx_singleq)cpfl_p2p_queue_grps_del (vport);
@@ -916,6 +920,8 @@ static const struct eth_dev_ops cpfl_eth_dev_ops = { .xstats_get_names = cpfl_dev_xstats_get_names, .xstats_reset = cpfl_dev_xstats_reset, .hairpin_cap_get = cpfl_hairpin_cap_get, + .rx_hairpin_queue_setup = cpfl_rx_hairpin_queue_setup, + .tx_hairpin_queue_setup = cpfl_tx_hairpin_queue_setup, }; static int
drivers/net/cpfl/cpfl_ethdev.h +12 -0
@@ -89,6 +89,18 @@ struct p2p_queue_chunks_info {struct cpfl_vport {struct idpf_vport base;struct p2p_queue_chunks_info p2p_q_chunks_info; + +struct rte_mempool *p2p_mp; + +uint16_t nb_data_rxq; +uint16_t nb_data_txq; +uint16_t nb_p2p_rxq; +uint16_t nb_p2p_txq; + +struct idpf_rx_queue *p2p_rx_bufq; +struct idpf_tx_queue *p2p_tx_complq; +bool p2p_manual_bind; + };struct cpfl_adapter_ext {
drivers/net/cpfl/cpfl_rxtx.c +372 -1
409 lines not on this page · raw message
drivers/net/cpfl/cpfl_rxtx.h +26 -0
@@ -13,6 +13,7 @@#define CPFL_MIN_RING_DESC 32#define CPFL_MAX_RING_DESC 4096#define CPFL_DMA_MEM_ALIGN 4096 +#define CPFL_P2P_DESC_LEN 16#define CPFL_MAX_HAIRPINQ_RX_2_TX 1#define CPFL_MAX_HAIRPINQ_TX_2_RX 1#define CPFL_MAX_HAIRPINQ_NB_DESC 1024
@@ -21,6 +22,10 @@#define CPFL_P2P_NB_TX_COMPLQ 1#define CPFL_P2P_NB_QUEUE_GRPS 1#define CPFL_P2P_QUEUE_GRP_ID 1 +#define CPFL_P2P_NB_MBUF 4096 +#define CPFL_P2P_CACHE_SIZE 250 +#define CPFL_P2P_MBUF_SIZE 2048 +#define CPFL_P2P_RING_BUF 128/* Base address of the HW descriptor ring should be 128B aligned. */ #define CPFL_RING_BASE_ALIGN 128
@@ -31,12 +36,26 @@#define CPFL_SUPPORT_CHAIN_NUM 5 +struct cpfl_rxq_hairpin_info { +bool hairpin_q;/* if rx queue is a hairpin queue */ +uint16_t peer_txp; +uint16_t peer_txq_id; +}; +struct cpfl_rx_queue {struct idpf_rx_queue base; +struct cpfl_rxq_hairpin_info hairpin_info; +}; + +struct cpfl_txq_hairpin_info { +bool hairpin_q;/* if tx queue is a hairpin queue */ +uint16_t peer_rxp; +uint16_t peer_rxq_id; };struct cpfl_tx_queue {struct idpf_tx_queue base; +struct cpfl_txq_hairpin_info hairpin_info; }; int cpfl_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
@@ -57,4 +76,11 @@ void cpfl_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid);void cpfl_dev_rx_queue_release (struct rte_eth_dev *dev,uint16_t qid);void cpfl_set_rx_function (struct rte_eth_dev *dev);void cpfl_set_tx_function (struct rte_eth_dev *dev); +uint16_t cpfl_hw_qid_get (uint16_t start_qid,uint16_t offset); +uint64_t cpfl_hw_qtail_get (uint64_t tail_start,uint16_t offset,uint64_t tail_spacing); +int cpfl_rx_hairpin_queue_setup (struct rte_eth_dev *dev,uint16_t queue_idx, +uint16_t nb_desc,const struct rte_eth_hairpin_conf *conf); +int cpfl_tx_hairpin_queue_setup (struct rte_eth_dev *dev,uint16_t queue_idx, +uint16_t nb_desc, +const struct rte_eth_hairpin_conf *conf);#endif /* _CPFL_RXTX_H_ */
drivers/net/cpfl/cpfl_rxtx_vec_common.h +4 -0
@@ -85,6 +85,8 @@ cpfl_rx_vec_dev_check_default(struct rte_eth_dev *dev) cpfl_rxq = dev->data->rx_queues[i]; default_ret =cpfl_rx_vec_queue_default (&cpfl_rxq->base);if (vport->rxq_model ==VIRTCHNL2_QUEUE_MODEL_SPLIT ) { +if (cpfl_rxq->hairpin_info.hairpin_q) +continue ; splitq_ret =cpfl_rx_splitq_vec_default (&cpfl_rxq->base); ret = splitq_ret && default_ret; }else {
@@ -106,6 +108,8 @@ cpfl_tx_vec_dev_check_default(struct rte_eth_dev *dev)for (i =0 ; i < dev->data->nb_tx_queues; i++) { cpfl_txq = dev->data->tx_queues[i]; +if (cpfl_txq->hairpin_info.hairpin_q) +continue ; ret =cpfl_tx_vec_queue_default (&cpfl_txq->base);if (ret ==CPFL_SCALAR_PATH )return CPFL_SCALAR_PATH ;
Signature · 1 line
2.26.2
RE: [PATCH v3 05/10] net/cpfl: support hairpin queue setup and release
Quoted 98 lines
drivers/net/cpfl/cpfl_rxtx.c +19
-0+cpfl_tx_hairpin_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx, + uint16_t nb_desc, + const struct rte_eth_hairpin_conf *conf) { + struct cpfl_vport *cpfl_vport = + (struct cpfl_vport *)dev->data->dev_private; + +struct idpf_vport *vport = &cpfl_vport->base; +struct idpf_adapter *adapter_base = vport->adapter; +uint16_t logic_qid = cpfl_vport->nb_p2p_txq; +struct cpfl_txq_hairpin_info *hairpin_info; +struct idpf_hw *hw = &adapter_base->hw; +struct cpfl_tx_queue *cpfl_txq; +struct idpf_tx_queue *txq, *cq; +const struct rte_memzone *mz; +uint32_t ring_size; +uint16_t peer_port, peer_q; + +if (vport->txq_model ==VIRTCHNL2_QUEUE_MODEL_SINGLE ) { + PMD_INIT_LOG(ERR, "Only spilt queue model supports hairpinqueue.");
drivers/net/cpfl/cpfl_rxtx.c +5
-0+return -EINVAL ; + } + +if (conf->peer_count !=1 ) { + PMD_INIT_LOG(ERR, "Can't support Tx hairpin queue peercount %d",
conf->peer_count);drivers/net/cpfl/cpfl_rxtx.c +10
-0+return -EINVAL ; + } + + peer_port = conf->peers[0 ].port; + peer_q = conf->peers[0 ].queue; + +if (nb_desc %CPFL_ALIGN_RING_DESC !=0 || + nb_desc >CPFL_MAX_RING_DESC || + nb_desc <CPFL_MIN_RING_DESC ) { + PMD_INIT_LOG(ERR, "Number (%u) of transmit descriptors isinvalid",
drivers/net/cpfl/cpfl_rxtx.c +17
-0+ nb_desc); +return -EINVAL ; + } + +/* Free memory if needed. */ +if (dev->data->tx_queues[queue_idx]) { +cpfl_tx_queue_release (dev->data->tx_queues[queue_idx]); + dev->data->tx_queues[queue_idx] =NULL ; + } + +/* Allocate the TX queue data structure. */ + cpfl_txq =rte_zmalloc_socket ("cpfl hairpin txq" , +sizeof (struct cpfl_tx_queue ), +RTE_CACHE_LINE_SIZE , +SOCKET_ID_ANY ); +if (!cpfl_txq) { + PMD_INIT_LOG(ERR, "Failed to allocate memory for tx queuestructure");
drivers/net/cpfl/cpfl_rxtx.c +8
-0+return -ENOMEM ; + } + + txq = &cpfl_txq->base; + hairpin_info = &cpfl_txq->hairpin_info; +/* Txq ring length should be 2 times of Tx completion queue size. */ + txq->nb_tx_desc = nb_desc *2 ; + txq->queue_id = cpfl_hw_qid_get(cpfl_vport-Quoted 1 line
p2p_q_chunks_info.tx_start_qid,
logic_qid);drivers/net/cpfl/cpfl_rxtx.c +31
-0+ txq->port_id = dev->data->port_id; + hairpin_info->hairpin_q = true; + hairpin_info->peer_rxp = peer_port; + hairpin_info->peer_rxq_id = peer_q; + +if (conf->manual_bind !=0 ) + cpfl_vport->p2p_manual_bind = true; +else + cpfl_vport->p2p_manual_bind = false; + +/* Always Tx hairpin queue allocates Tx HW ring */ + ring_size =RTE_ALIGN (txq->nb_tx_desc *CPFL_P2P_DESC_LEN , +CPFL_DMA_MEM_ALIGN ); + mz =rte_eth_dma_zone_reserve (dev,"hairpin_tx_ring" , logic_qid, + ring_size +CPFL_P2P_RING_BUF , +CPFL_RING_BASE_ALIGN , + dev->device->numa_node); +if (!mz) { +PMD_INIT_LOG (ERR ,"Failed to reserve DMA memory for TX" ); +rte_free (txq->sw_ring); +rte_free (txq); +return -ENOMEM ; + } + + txq->tx_ring_phys_addr = mz->iova; + txq->desc_ring = mz->addr; + txq->mz = mz; + +cpfl_tx_hairpin_descq_reset (txq); + txq->qtx_tail = hw->hw_addr + + cpfl_hw_qtail_get(cpfl_vport-Quoted 1 line
p2p_q_chunks_info.tx_qtail_start,
(quoted diff) +1
-0+ logic_qid, cpfl_vport-Quoted 1 line
p2p_q_chunks_info.tx_qtail_spacing);
drivers/net/cpfl/cpfl_rxtx.c cpfl_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx, · line 890
Quoted 3 lines
drivers/net/cpfl/cpfl_rxtx.c +3
-0+ txq->ops = &def_txq_ops; + +if (cpfl_vport->p2p_tx_complq ==NULL ) {
[Liu, Mingxia] In cpfl_rx_hairpin_queue_setup(), "logic_qid" is used to identify if it is the first time to allocate "p2p_rx_bufq" buffer, Can it be unified, using logic_qid == 0 or p2p_tx_complq/ p2p_rx_bufq == NULL ?
Quoted 443 lines
-----Original Message-----
From: Xing, Beilei <[email protected]>
Sent: Friday, May 19, 2023 3:31 PM
To: Wu, Jingjing <[email protected]>
Cc: [email protected]; Liu, Mingxia <[email protected]>; Xing, Beilei <[email protected]>; Wang, Xiao W <[email protected]>
Subject: [PATCH v3 05/10] net/cpfl: support hairpin queue setup and releaseFrom: Beilei Xing <[email protected]>
Support hairpin Rx/Tx queue setup and release.
Signed-off-by Xiao Wang <[email protected]>Signed-off-by Mingxia Liu <[email protected]>Signed-off-by Beilei Xing <[email protected]>--- drivers/net/cpfl/cpfl_ethdev.c | 6 + drivers/net/cpfl/cpfl_ethdev.h | 12 + drivers/net/cpfl/cpfl_rxtx.c | 373 +++++++++++++++++++++++- drivers/net/cpfl/cpfl_rxtx.h | 26 ++ drivers/net/cpfl/cpfl_rxtx_vec_common.h | 4 + 5 files changed, 420 insertions(+), 1 deletion(-)drivers/net/cpfl/cpfl_ethdev.c index renamed from drivers/net/cpfl/cpfl_ethdev.c +0
-0
8e471d2a9b..03813716ce100644drivers/net/cpfl/cpfl_ethdev.c +4
-0@@ -874,6 +874,10 @@ cpfl_dev_close(struct rte_eth_dev *dev)struct cpfl_adapter_ext *adapter =CPFL_ADAPTER_TO_EXT (vport- >adapter);cpfl_dev_stop (dev); +if (cpfl_vport->p2p_mp) { +rte_mempool_free (cpfl_vport->p2p_mp); + cpfl_vport->p2p_mp =NULL ; + }if (!adapter->base.is_rx_singleq && !adapter->base.is_tx_singleq)drivers/net/cpfl/cpfl_ethdev.c +2
-0cpfl_p2p_queue_grps_del (vport);@@ -916,6 +920,8 @@ static const struct eth_dev_ops cpfl_eth_dev_ops = { .xstats_get_names = cpfl_dev_xstats_get_names, .xstats_reset = cpfl_dev_xstats_reset, .hairpin_cap_get = cpfl_hairpin_cap_get, + .rx_hairpin_queue_setup = cpfl_rx_hairpin_queue_setup, + .tx_hairpin_queue_setup = cpfl_tx_hairpin_queue_setup, }; static intdrivers/net/cpfl/cpfl_ethdev.h index renamed from drivers/net/cpfl/cpfl_ethdev.h +0
-0
65c9a195b2..a48344299c100644drivers/net/cpfl/cpfl_ethdev.h +12
-0@@ -89,6 +89,18 @@ struct p2p_queue_chunks_info { struct cpfl_vport {struct idpf_vport base;struct p2p_queue_chunks_info p2p_q_chunks_info; + +struct rte_mempool *p2p_mp; + +uint16_t nb_data_rxq; +uint16_t nb_data_txq; +uint16_t nb_p2p_rxq; +uint16_t nb_p2p_txq; + +struct idpf_rx_queue *p2p_rx_bufq; +struct idpf_tx_queue *p2p_tx_complq; +bool p2p_manual_bind; + };struct cpfl_adapter_ext {drivers/net/cpfl/cpfl_rxtx.c index renamed from drivers/net/cpfl/cpfl_rxtx.c +0
-0
04a51b8d15..333a399e73100644drivers/net/cpfl/cpfl_rxtx.c +85
-1@@ -10,6 +10,79 @@#include "cpfl_rxtx.h" #include "cpfl_rxtx_vec_common.h" +uint16_t +cpfl_hw_qid_get (uint16_t start_qid,uint16_t offset) { +return start_qid + offset; +} + +uint64_t +cpfl_hw_qtail_get (uint64_t tail_start,uint16_t offset,uint64_t +tail_spacing) { +return tail_start + offset * tail_spacing; } + +static inline void +cpfl_tx_hairpin_descq_reset (struct idpf_tx_queue *txq) { +uint32_t i, size; + +if (!txq) { +PMD_DRV_LOG (DEBUG ,"Pointer to txq is NULL" ); +return ; + } + + size = txq->nb_tx_desc *CPFL_P2P_DESC_LEN ; +for (i =0 ; i < size; i++) + ((volatile char *)txq->desc_ring)[i] =0 ; } + +static inline void +cpfl_tx_hairpin_complq_reset (struct idpf_tx_queue *cq) { +uint32_t i, size; + +if (!cq) { +PMD_DRV_LOG (DEBUG ,"Pointer to complq is NULL" ); +return ; + } + + size = cq->nb_tx_desc *CPFL_P2P_DESC_LEN ; +for (i =0 ; i < size; i++) + ((volatile char *)cq->compl_ring)[i] =0 ; } + +static inline void +cpfl_rx_hairpin_descq_reset (struct idpf_rx_queue *rxq) { +uint16_t len; +uint32_t i; + +if (!rxq) +return ; + + len = rxq->nb_rx_desc; +for (i =0 ; i < len *CPFL_P2P_DESC_LEN ; i++) + ((volatile char *)rxq->rx_ring)[i] =0 ; } + +static inline void +cpfl_rx_hairpin_bufq_reset (struct idpf_rx_queue *rxbq) { +uint16_t len; +uint32_t i; + +if (!rxbq) +return ; + + len = rxbq->nb_rx_desc; +for (i =0 ; i < len *CPFL_P2P_DESC_LEN ; i++) + ((volatile char *)rxbq->rx_ring)[i] =0 ; + + rxbq->bufq1 =NULL ; + rxbq->bufq2 =NULL ; +} +static uint64_t cpfl_rx_offload_convert(uint64_t offload) { @@ -234,7 +307,10 @@ cpfl_rx_queue_release(void *rxq)/* Split queue */ if (!q->adapter->is_rx_singleq) { -if (q->bufq2) +/* the mz is shared between Tx/Rx hairpin, let Rx_release +* free the buf, q->bufq1->mz and q->mz. +*/ +if (!cpfl_rxq->hairpin_info.hairpin_q && q->bufq2)cpfl_rx_split_bufq_release (q->bufq2);if (q->bufq1)@@ -385,6 +461,7 @@ cpfl_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx, } } + cpfl_vport->nb_data_rxq++; rxq->q_set = true; dev->data->rx_queues[queue_idx] = cpfl_rxq;@@ -548,6 +625,7 @@ cpfl_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx, txq->qtx_tail = hw->hw_addr + (vport->chunks_info.tx_qtail_start + queue_idx * vport->chunks_info.tx_qtail_spacing); txq->ops = &def_txq_ops; + cpfl_vport->nb_data_txq++; txq->q_set = true; dev->data->tx_queues[queue_idx] = cpfl_txq;@@ -562,6 +640,297 @@ cpfl_tx_queue_setup(struct rte_eth_dev *dev,uint16_t queue_idx, return ret; } +static int +cpfl_rx_hairpin_bufq_setup (struct rte_eth_dev *dev,struct idpf_rx_queue *bufq, +uint16_t logic_qid,uint16_t nb_desc) { +struct cpfl_vport *cpfl_vport = + (struct cpfl_vport *)dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base; +struct idpf_adapter *adapter = vport->adapter; +struct rte_mempool *mp; +char pool_name[RTE_MEMPOOL_NAMESIZE ]; + + mp = cpfl_vport->p2p_mp; +if (!mp) { +snprintf (pool_name,RTE_MEMPOOL_NAMESIZE ,"p2p_mb_pool_%u" , + dev->data->port_id); + mp = rte_pktmbuf_pool_create(pool_name,
CPFL_P2P_NB_MBUF,CPFL_P2P_CACHE_SIZE,drivers/net/cpfl/cpfl_rxtx.c +1
-0+ 0, CPFL_P2P_MBUF_SIZE, dev-Quoted 1 line
device->numa_node);drivers/net/cpfl/cpfl_rxtx.c +2
-0+if (!mp) { + PMD_INIT_LOG(ERR, "Failed to allocate mbuf pool forp2p");
drivers/net/cpfl/cpfl_rxtx.c +8
-0+return -ENOMEM ; + } + cpfl_vport->p2p_mp = mp; + } + + bufq->mp = mp; + bufq->nb_rx_desc = nb_desc; + bufq->queue_id = cpfl_hw_qid_get(cpfl_vport-Quoted 1 line
p2p_q_chunks_info.rx_buf_start_qid,
logic_qid);drivers/net/cpfl/cpfl_rxtx.c +3
-0+ bufq->port_id = dev->data->port_id; + bufq->adapter = adapter; + bufq->rx_buf_len = CPFL_P2P_MBUF_SIZE -
RTE_PKTMBUF_HEADROOM;drivers/net/cpfl/cpfl_rxtx.c +20
-0+ + bufq->sw_ring =rte_zmalloc ("sw ring" , +sizeof (struct rte_mbuf *) * nb_desc, +RTE_CACHE_LINE_SIZE ); +if (!bufq->sw_ring) { +PMD_INIT_LOG (ERR ,"Failed to allocate memory for SW ring" ); +return -ENOMEM ; + } + + bufq->q_set = true; + bufq->ops = &def_rxq_ops; + +return 0 ; +} + +int +cpfl_rx_hairpin_queue_setup (struct rte_eth_dev *dev,uint16_t queue_idx, +uint16_t nb_desc, +const struct rte_eth_hairpin_conf *conf) { + struct cpfl_vport *cpfl_vport = (struct cpfl_vport *)dev->data-Quoted 1 line
dev_private;drivers/net/cpfl/cpfl_rxtx.c +13
-0+struct idpf_vport *vport = &cpfl_vport->base; +struct idpf_adapter *adapter_base = vport->adapter; +uint16_t logic_qid = cpfl_vport->nb_p2p_rxq; +struct cpfl_rxq_hairpin_info *hairpin_info; +struct cpfl_rx_queue *cpfl_rxq; +struct idpf_rx_queue *bufq1 =NULL ; +struct idpf_rx_queue *rxq; +uint16_t peer_port, peer_q; +uint16_t qid; +int ret; + +if (vport->rxq_model ==VIRTCHNL2_QUEUE_MODEL_SINGLE ) { + PMD_INIT_LOG(ERR, "Only spilt queue model supports hairpinqueue.");
drivers/net/cpfl/cpfl_rxtx.c +5
-0+return -EINVAL ; + } + +if (conf->peer_count !=1 ) { + PMD_INIT_LOG(ERR, "Can't support Rx hairpin queue peercount %d",
conf->peer_count);drivers/net/cpfl/cpfl_rxtx.c +10
-0+return -EINVAL ; + } + + peer_port = conf->peers[0 ].port; + peer_q = conf->peers[0 ].queue; + +if (nb_desc %CPFL_ALIGN_RING_DESC !=0 || + nb_desc >CPFL_MAX_RING_DESC || + nb_desc <CPFL_MIN_RING_DESC ) { + PMD_INIT_LOG(ERR, "Number (%u) of receive descriptors isinvalid",
nb_desc);drivers/net/cpfl/cpfl_rxtx.c +16
-0+return -EINVAL ; + } + +/* Free memory if needed */ +if (dev->data->rx_queues[queue_idx]) { +cpfl_rx_queue_release (dev->data->rx_queues[queue_idx]); + dev->data->rx_queues[queue_idx] =NULL ; + } + +/* Setup Rx description queue */ + cpfl_rxq =rte_zmalloc_socket ("cpfl hairpin rxq" , +sizeof (struct cpfl_rx_queue ), +RTE_CACHE_LINE_SIZE , +SOCKET_ID_ANY ); +if (!cpfl_rxq) { + PMD_INIT_LOG(ERR, "Failed to allocate memory for rx queuedata structure");
drivers/net/cpfl/cpfl_rxtx.c +7
-0+return -ENOMEM ; + } + + rxq = &cpfl_rxq->base; + hairpin_info = &cpfl_rxq->hairpin_info; + rxq->nb_rx_desc = nb_desc *2 ; + rxq->queue_id = cpfl_hw_qid_get(cpfl_vport-Quoted 1 line
p2p_q_chunks_info.rx_start_qid,
logic_qid);drivers/net/cpfl/cpfl_rxtx.c +20
-0+ rxq->port_id = dev->data->port_id; + rxq->adapter = adapter_base; + rxq->rx_buf_len =CPFL_P2P_MBUF_SIZE -RTE_PKTMBUF_HEADROOM ; + hairpin_info->hairpin_q = true; + hairpin_info->peer_txp = peer_port; + hairpin_info->peer_txq_id = peer_q; + +if (conf->manual_bind !=0 ) + cpfl_vport->p2p_manual_bind = true; +else + cpfl_vport->p2p_manual_bind = false; + +/* setup 1 Rx buffer queue for the 1st hairpin rxq */ +if (logic_qid ==0 ) { + bufq1 =rte_zmalloc_socket ("hairpin rx bufq1" , +sizeof (struct idpf_rx_queue ), +RTE_CACHE_LINE_SIZE , +SOCKET_ID_ANY ); +if (!bufq1) { + PMD_INIT_LOG(ERR, "Failed to allocate memory forhairpin Rx buffer queue 1.");
drivers/net/cpfl/cpfl_rxtx.c +7
-0+ ret = -ENOMEM ; + goto err_alloc_bufq1; + } + qid =2 * logic_qid; + ret =cpfl_rx_hairpin_bufq_setup (dev, bufq1, qid, nb_desc); +if (ret) { + PMD_INIT_LOG(ERR, "Failed to setup hairpin Rx bufferqueue 1");
drivers/net/cpfl/cpfl_rxtx.c +43
-0+ ret = -EINVAL ; + goto err_setup_bufq1; + } + cpfl_vport->p2p_rx_bufq = bufq1; + } + + rxq->bufq1 = cpfl_vport->p2p_rx_bufq; + rxq->bufq2 =NULL ; + + cpfl_vport->nb_p2p_rxq++; + rxq->q_set = true; + dev->data->rx_queues[queue_idx] = cpfl_rxq; + +return 0 ; + +err_setup_bufq1: +rte_free (bufq1); +err_alloc_bufq1: +rte_free (rxq); + +return ret; +} + +int +cpfl_tx_hairpin_queue_setup (struct rte_eth_dev *dev,uint16_t queue_idx, +uint16_t nb_desc, +const struct rte_eth_hairpin_conf *conf) { +struct cpfl_vport *cpfl_vport = + (struct cpfl_vport *)dev->data->dev_private; + +struct idpf_vport *vport = &cpfl_vport->base; +struct idpf_adapter *adapter_base = vport->adapter; +uint16_t logic_qid = cpfl_vport->nb_p2p_txq; +struct cpfl_txq_hairpin_info *hairpin_info; +struct idpf_hw *hw = &adapter_base->hw; +struct cpfl_tx_queue *cpfl_txq; +struct idpf_tx_queue *txq, *cq; +const struct rte_memzone *mz; +uint32_t ring_size; +uint16_t peer_port, peer_q; + +if (vport->txq_model ==VIRTCHNL2_QUEUE_MODEL_SINGLE ) { + PMD_INIT_LOG(ERR, "Only spilt queue model supports hairpinqueue.");
drivers/net/cpfl/cpfl_rxtx.c +5
-0+return -EINVAL ; + } + +if (conf->peer_count !=1 ) { + PMD_INIT_LOG(ERR, "Can't support Tx hairpin queue peercount %d",
conf->peer_count);drivers/net/cpfl/cpfl_rxtx.c +10
-0+return -EINVAL ; + } + + peer_port = conf->peers[0 ].port; + peer_q = conf->peers[0 ].queue; + +if (nb_desc %CPFL_ALIGN_RING_DESC !=0 || + nb_desc >CPFL_MAX_RING_DESC || + nb_desc <CPFL_MIN_RING_DESC ) { + PMD_INIT_LOG(ERR, "Number (%u) of transmit descriptors isinvalid",
drivers/net/cpfl/cpfl_rxtx.c +17
-0+ nb_desc); +return -EINVAL ; + } + +/* Free memory if needed. */ +if (dev->data->tx_queues[queue_idx]) { +cpfl_tx_queue_release (dev->data->tx_queues[queue_idx]); + dev->data->tx_queues[queue_idx] =NULL ; + } + +/* Allocate the TX queue data structure. */ + cpfl_txq =rte_zmalloc_socket ("cpfl hairpin txq" , +sizeof (struct cpfl_tx_queue ), +RTE_CACHE_LINE_SIZE , +SOCKET_ID_ANY ); +if (!cpfl_txq) { + PMD_INIT_LOG(ERR, "Failed to allocate memory for tx queuestructure");
drivers/net/cpfl/cpfl_rxtx.c +8
-0+return -ENOMEM ; + } + + txq = &cpfl_txq->base; + hairpin_info = &cpfl_txq->hairpin_info; +/* Txq ring length should be 2 times of Tx completion queue size. */ + txq->nb_tx_desc = nb_desc *2 ; + txq->queue_id = cpfl_hw_qid_get(cpfl_vport-Quoted 1 line
p2p_q_chunks_info.tx_start_qid,
logic_qid);drivers/net/cpfl/cpfl_rxtx.c +31
-0+ txq->port_id = dev->data->port_id; + hairpin_info->hairpin_q = true; + hairpin_info->peer_rxp = peer_port; + hairpin_info->peer_rxq_id = peer_q; + +if (conf->manual_bind !=0 ) + cpfl_vport->p2p_manual_bind = true; +else + cpfl_vport->p2p_manual_bind = false; + +/* Always Tx hairpin queue allocates Tx HW ring */ + ring_size =RTE_ALIGN (txq->nb_tx_desc *CPFL_P2P_DESC_LEN , +CPFL_DMA_MEM_ALIGN ); + mz =rte_eth_dma_zone_reserve (dev,"hairpin_tx_ring" , logic_qid, + ring_size +CPFL_P2P_RING_BUF , +CPFL_RING_BASE_ALIGN , + dev->device->numa_node); +if (!mz) { +PMD_INIT_LOG (ERR ,"Failed to reserve DMA memory for TX" ); +rte_free (txq->sw_ring); +rte_free (txq); +return -ENOMEM ; + } + + txq->tx_ring_phys_addr = mz->iova; + txq->desc_ring = mz->addr; + txq->mz = mz; + +cpfl_tx_hairpin_descq_reset (txq); + txq->qtx_tail = hw->hw_addr + + cpfl_hw_qtail_get(cpfl_vport-Quoted 1 line
p2p_q_chunks_info.tx_qtail_start,
drivers/net/cpfl/cpfl_rxtx.c +1
-0+ logic_qid, cpfl_vport-Quoted 1 line
p2p_q_chunks_info.tx_qtail_spacing);
drivers/net/cpfl/cpfl_rxtx.c cpfl_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx, · line 890
Quoted 3 lines
drivers/net/cpfl/cpfl_rxtx.c +3
-0+ txq->ops = &def_txq_ops; + +if (cpfl_vport->p2p_tx_complq ==NULL ) {
[Liu, Mingxia] In cpfl_rx_hairpin_queue_setup(), "logic_qid" is used to identify if it is the first time to allocate "p2p_rx_bufq" buffer, Can it be unified, using logic_qid == 0 or p2p_tx_complq/ p2p_rx_bufq == NULL ?
Quoted 148 lines
drivers/net/cpfl/cpfl_rxtx.c +6
-0+ cq =rte_zmalloc_socket ("cpfl hairpin cq" , +sizeof (struct idpf_tx_queue ), +RTE_CACHE_LINE_SIZE , + dev->device->numa_node); +if (!cq) { + PMD_INIT_LOG(ERR, "Failed to allocate memory for txqueue structure");
drivers/net/cpfl/cpfl_rxtx.c +5
-0+return -ENOMEM ; + } + + cq->nb_tx_desc = nb_desc; + cq->queue_id = cpfl_hw_qid_get(cpfl_vport-Quoted 1 line
p2p_q_chunks_info.tx_compl_start_qid, 0);
drivers/net/cpfl/cpfl_rxtx.c +6
-0+ cq->port_id = dev->data->port_id; + +/* Tx completion queue always allocates the HW ring */ + ring_size =RTE_ALIGN (cq->nb_tx_desc *CPFL_P2P_DESC_LEN , +CPFL_DMA_MEM_ALIGN ); + mz = rte_eth_dma_zone_reserve(dev, "hairpin_tx_compl_ring",
logic_qid,drivers/net/cpfl/cpfl_rxtx.c +5
-0+ ring_size +CPFL_P2P_RING_BUF , +CPFL_RING_BASE_ALIGN , + dev->device->numa_node); +if (!mz) { + PMD_INIT_LOG(ERR, "Failed to reserve DMA memoryfor TX completion queue");
drivers/net/cpfl/cpfl_rxtx.c +21
-0+rte_free (txq->sw_ring); +rte_free (txq); +return -ENOMEM ; + } + cq->tx_ring_phys_addr = mz->iova; + cq->compl_ring = mz->addr; + cq->mz = mz; + +cpfl_tx_hairpin_complq_reset (cq); + cpfl_vport->p2p_tx_complq = cq; + } + + txq->complq = cpfl_vport->p2p_tx_complq; + + cpfl_vport->nb_p2p_txq++; + txq->q_set = true; + dev->data->tx_queues[queue_idx] = cpfl_txq; + +return 0 ; +} +int cpfl_rx_queue_init(struct rte_eth_dev *dev, uint16_t rx_queue_id) { @@ -865,6 +1234,8 @@
cpfl_set_rx_function(struct rte_eth_dev *dev)drivers/net/cpfl/cpfl_rxtx.c +2
-0if (vport->rx_vec_allowed) {for (i =0 ; i < dev->data->nb_rx_queues; i++) { cpfl_rxq = dev->data->rx_queues[i]; +if (cpfl_rxq->hairpin_info.hairpin_q) +continue ; (void)idpf_qc_splitq_rx_vec_setup(&cpfl_rxq-Quoted 1 line
base);
drivers/net/cpfl/cpfl_rxtx.c +0
-0}#ifdef CC_AVX512_SUPPORT drivers/net/cpfl/cpfl_rxtx.h index renamed from drivers/net/cpfl/cpfl_rxtx.h +0
-0
3a87a1f4b3..5e9f2dada7100644drivers/net/cpfl/cpfl_rxtx.h +18
-0@@ -13,6 +13,7 @@#define CPFL_MIN_RING_DESC 32#define CPFL_MAX_RING_DESC 4096#define CPFL_DMA_MEM_ALIGN 4096 +#define CPFL_P2P_DESC_LEN 16#define CPFL_MAX_HAIRPINQ_RX_2_TX 1#define CPFL_MAX_HAIRPINQ_TX_2_RX 1#define CPFL_MAX_HAIRPINQ_NB_DESC 1024@@ -21,6 +22,10 @@#define CPFL_P2P_NB_TX_COMPLQ 1#define CPFL_P2P_NB_QUEUE_GRPS 1#define CPFL_P2P_QUEUE_GRP_ID 1 +#define CPFL_P2P_NB_MBUF 4096 +#define CPFL_P2P_CACHE_SIZE 250 +#define CPFL_P2P_MBUF_SIZE 2048 +#define CPFL_P2P_RING_BUF 128/* Base address of the HW descriptor ring should be 128B aligned. */ #define CPFL_RING_BASE_ALIGN 128@@ -31,12 +36,26 @@#define CPFL_SUPPORT_CHAIN_NUM 5 +struct cpfl_rxq_hairpin_info { +bool hairpin_q;/* if rx queue is a hairpin queue */ +uint16_t peer_txp; +uint16_t peer_txq_id; +}; +struct cpfl_rx_queue {struct idpf_rx_queue base; +struct cpfl_rxq_hairpin_info hairpin_info; }; + +struct cpfl_txq_hairpin_info { +bool hairpin_q;/* if tx queue is a hairpin queue */ +uint16_t peer_rxp; +uint16_t peer_rxq_id; };struct cpfl_tx_queue {struct idpf_tx_queue base; +struct cpfl_txq_hairpin_info hairpin_info; }; int cpfl_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx, @@ -57,4 +76,11 @@ void
cpfl_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid); voidcpfl_dev_rx_queue_release(struct rte_eth_dev *dev, uint16_t qid); voidcpfl_set_rx_function(struct rte_eth_dev *dev); voidcpfl_set_tx_function(struct rte_eth_dev *dev);drivers/net/cpfl/cpfl_rxtx.h +3
-0+uint16_t cpfl_hw_qid_get (uint16_t start_qid,uint16_t offset);uint64_t +cpfl_hw_qtail_get (uint64_t tail_start,uint16_t offset,uint64_t +tail_spacing); int cpfl_rx_hairpin_queue_setup(struct rte_eth_dev *dev,
uint16_tqueue_idx,drivers/net/cpfl/cpfl_rxtx.h +1
-0+ uint16_t nb_desc, const struct
rte_eth_hairpin_conf*conf); intdrivers/net/cpfl/cpfl_rxtx.h +3
-0+cpfl_tx_hairpin_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx, + uint16_t nb_desc, + const struct rte_eth_hairpin_conf *conf);#endif /* _CPFL_RXTX_H_ */ drivers/net/cpfl/cpfl_rxtx_vec_common.h +2
-0@@ -85,6 +85,8 @@ cpfl_rx_vec_dev_check_default(struct rte_eth_dev *dev) cpfl_rxq = dev->data->rx_queues[i]; default_ret =cpfl_rx_vec_queue_default (&cpfl_rxq->base);if (vport->rxq_model ==VIRTCHNL2_QUEUE_MODEL_SPLIT ) { +if (cpfl_rxq->hairpin_info.hairpin_q) +continue ; splitq_ret =cpfl_rx_splitq_vec_default (&cpfl_rxq- >base); ret = splitq_ret && default_ret;drivers/net/cpfl/cpfl_rxtx_vec_common.h +2
-1}else {@@ -106,6 +108,8 @@ cpfl_tx_vec_dev_check_default(struct rte_eth_dev *dev)for (i =0 ; i < dev->data->nb_tx_queues; i++) { cpfl_txq = dev->data->tx_queues[i]; +if (cpfl_txq->hairpin_info.hairpin_q) +continue ; ret =cpfl_tx_vec_queue_default (&cpfl_txq->base);if (ret ==CPFL_SCALAR_PATH )return CPFL_SCALAR_PATH ; --2.26.2
RE: [PATCH v3 05/10] net/cpfl: support hairpin queue setup and release
Quoted 106 lines
-----Original Message-----
From: Liu, Mingxia <[email protected]>
Sent: Wednesday, May 24, 2023 5:02 PM
To: Xing, Beilei <[email protected]>; Wu, Jingjing <[email protected]>
Cc: [email protected]; Wang, Xiao W <[email protected]>
Subject: RE: [PATCH v3 05/10] net/cpfl: support hairpin queue setup and releaseQuoted 96 lines
drivers/net/cpfl/cpfl_rxtx.c +19
-0+cpfl_tx_hairpin_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx, + uint16_t nb_desc, + const struct rte_eth_hairpin_conf *conf) { + struct cpfl_vport *cpfl_vport = + (struct cpfl_vport *)dev->data->dev_private; + +struct idpf_vport *vport = &cpfl_vport->base; +struct idpf_adapter *adapter_base = vport->adapter; +uint16_t logic_qid = cpfl_vport->nb_p2p_txq; +struct cpfl_txq_hairpin_info *hairpin_info; +struct idpf_hw *hw = &adapter_base->hw; +struct cpfl_tx_queue *cpfl_txq; +struct idpf_tx_queue *txq, *cq; +const struct rte_memzone *mz; +uint32_t ring_size; +uint16_t peer_port, peer_q; + +if (vport->txq_model ==VIRTCHNL2_QUEUE_MODEL_SINGLE ) { + PMD_INIT_LOG(ERR, "Only spilt queue model supports hairpinqueue.");
drivers/net/cpfl/cpfl_rxtx.c +5
-0+return -EINVAL ; + } + +if (conf->peer_count !=1 ) { + PMD_INIT_LOG(ERR, "Can't support Tx hairpin queue peercount %d",
conf->peer_count);drivers/net/cpfl/cpfl_rxtx.c +10
-0+return -EINVAL ; + } + + peer_port = conf->peers[0 ].port; + peer_q = conf->peers[0 ].queue; + +if (nb_desc %CPFL_ALIGN_RING_DESC !=0 || + nb_desc >CPFL_MAX_RING_DESC || + nb_desc <CPFL_MIN_RING_DESC ) { + PMD_INIT_LOG(ERR, "Number (%u) of transmit descriptors isinvalid",
drivers/net/cpfl/cpfl_rxtx.c +17
-0+ nb_desc); +return -EINVAL ; + } + +/* Free memory if needed. */ +if (dev->data->tx_queues[queue_idx]) { +cpfl_tx_queue_release (dev->data->tx_queues[queue_idx]); + dev->data->tx_queues[queue_idx] =NULL ; + } + +/* Allocate the TX queue data structure. */ + cpfl_txq =rte_zmalloc_socket ("cpfl hairpin txq" , +sizeof (struct cpfl_tx_queue ), +RTE_CACHE_LINE_SIZE , +SOCKET_ID_ANY ); +if (!cpfl_txq) { + PMD_INIT_LOG(ERR, "Failed to allocate memory for tx queuestructure");
drivers/net/cpfl/cpfl_rxtx.c +8
-0+return -ENOMEM ; + } + + txq = &cpfl_txq->base; + hairpin_info = &cpfl_txq->hairpin_info; +/* Txq ring length should be 2 times of Tx completion queue size. */ + txq->nb_tx_desc = nb_desc *2 ; + txq->queue_id = cpfl_hw_qid_get(cpfl_vport-Quoted 1 line
p2p_q_chunks_info.tx_start_qid,
logic_qid);drivers/net/cpfl/cpfl_rxtx.c +31
-0+ txq->port_id = dev->data->port_id; + hairpin_info->hairpin_q = true; + hairpin_info->peer_rxp = peer_port; + hairpin_info->peer_rxq_id = peer_q; + +if (conf->manual_bind !=0 ) + cpfl_vport->p2p_manual_bind = true; +else + cpfl_vport->p2p_manual_bind = false; + +/* Always Tx hairpin queue allocates Tx HW ring */ + ring_size =RTE_ALIGN (txq->nb_tx_desc *CPFL_P2P_DESC_LEN , +CPFL_DMA_MEM_ALIGN ); + mz =rte_eth_dma_zone_reserve (dev,"hairpin_tx_ring" , logic_qid, + ring_size +CPFL_P2P_RING_BUF , +CPFL_RING_BASE_ALIGN , + dev->device->numa_node); +if (!mz) { +PMD_INIT_LOG (ERR ,"Failed to reserve DMA memory for TX" ); +rte_free (txq->sw_ring); +rte_free (txq); +return -ENOMEM ; + } + + txq->tx_ring_phys_addr = mz->iova; + txq->desc_ring = mz->addr; + txq->mz = mz; + +cpfl_tx_hairpin_descq_reset (txq); + txq->qtx_tail = hw->hw_addr + + cpfl_hw_qtail_get(cpfl_vport-Quoted 1 line
p2p_q_chunks_info.tx_qtail_start,
Quoted 10 lines
drivers/net/cpfl/cpfl_rxtx.c cpfl_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx, · line 890
Quoted 5 lines
(quoted diff) +1
-0+ logic_qid, cpfl_vport-Quoted 1 line
p2p_q_chunks_info.tx_qtail_spacing);
drivers/net/cpfl/cpfl_rxtx.c +3
-0+ txq->ops = &def_txq_ops; + +if (cpfl_vport->p2p_tx_complq ==NULL ) {[Liu, Mingxia] In
cpfl_rx_hairpin_queue_setup(), "logic_qid" is used to identify if it is the first time to allocate "p2p_rx_bufq" buffer, Can it be unified, usinglogic_qid== 0 or p2p_tx_complq/p2p_rx_bufq== NULL ?
Yes, thanks for the catch.
Quoted 608 lines
drivers/net/cpfl/cpfl_ethdev.c
Quoted 25 lines
-----Original Message-----
From: Xing, Beilei <[email protected]>
Sent: Friday, May 19, 2023 3:31 PM
To: Wu, Jingjing <[email protected]>
Cc: [email protected]; Liu, Mingxia <[email protected]>; Xing, Beilei <[email protected]>; Wang, Xiao W <[email protected]>
Subject: [PATCH v3 05/10] net/cpfl: support hairpin queue setup and releaseFrom: Beilei Xing <[email protected]>
Support hairpin Rx/Tx queue setup and release.
Signed-off-by Xiao Wang <[email protected]>Signed-off-by Mingxia Liu <[email protected]>Signed-off-by Beilei Xing <[email protected]>--- drivers/net/cpfl/cpfl_ethdev.c | 6 + drivers/net/cpfl/cpfl_ethdev.h | 12 + drivers/net/cpfl/cpfl_rxtx.c | 373 +++++++++++++++++++++++- drivers/net/cpfl/cpfl_rxtx.h | 26 ++ drivers/net/cpfl/cpfl_rxtx_vec_common.h | 4 + 5 files changed, 420 insertions(+), 1 deletion(-)drivers/net/cpfl/cpfl_ethdev.c +0
-0index
Quoted 16 lines
8e471d2a9b..03813716ce100644drivers/net/cpfl/cpfl_ethdev.c +4
-0@@ -874,6 +874,10 @@ cpfl_dev_close(struct rte_eth_dev *dev)struct cpfl_adapter_ext *adapter =CPFL_ADAPTER_TO_EXT (vport- >adapter);cpfl_dev_stop (dev); +if (cpfl_vport->p2p_mp) { +rte_mempool_free (cpfl_vport->p2p_mp); + cpfl_vport->p2p_mp =NULL ; + }if (!adapter->base.is_rx_singleq && !adapter->base.is_tx_singleq)drivers/net/cpfl/cpfl_ethdev.c +0
-0cpfl_p2p_queue_grps_del (vport);drivers/net/cpfl/cpfl_ethdev.c static const struct eth_dev_ops cpfl_eth_dev_ops = { · line 923
Quoted 4 lines
drivers/net/cpfl/cpfl_ethdev.c +1
-0@@ -916,6 +920,8 @@ static const struct eth_dev_ops cpfl_eth_dev_ops = { .xstats_get_names = cpfl_dev_xstats_get_names, .xstats_reset = cpfl_dev_xstats_reset, .hairpin_cap_get = cpfl_hairpin_cap_get, + .rx_hairpin_queue_setup =
cpfl_rx_hairpin_queue_setup,drivers/net/cpfl/cpfl_ethdev.c static const struct eth_dev_ops cpfl_eth_dev_ops = { · line 924
Quoted 1 line
drivers/net/cpfl/cpfl_ethdev.c +1
-0+ .tx_hairpin_queue_setup =
cpfl_tx_hairpin_queue_setup,drivers/net/cpfl/cpfl_ethdev.h
Quoted 4 lines
drivers/net/cpfl/cpfl_ethdev.c +0
-0}; static intdrivers/net/cpfl/cpfl_ethdev.h +0
-0index
drivers/net/cpfl/cpfl_rxtx.c cpfl_rx_queue_setup(struct rte_eth_dev *dev,
Quoted 108 lines
65c9a195b2..a48344299c100644drivers/net/cpfl/cpfl_ethdev.h +12
-0@@ -89,6 +89,18 @@ struct p2p_queue_chunks_info { struct cpfl_vport {struct idpf_vport base;struct p2p_queue_chunks_info p2p_q_chunks_info; + +struct rte_mempool *p2p_mp; + +uint16_t nb_data_rxq; +uint16_t nb_data_txq; +uint16_t nb_p2p_rxq; +uint16_t nb_p2p_txq; + +struct idpf_rx_queue *p2p_rx_bufq; +struct idpf_tx_queue *p2p_tx_complq; +bool p2p_manual_bind; + };struct cpfl_adapter_ext {drivers/net/cpfl/cpfl_rxtx.c index renamed from drivers/net/cpfl/cpfl_rxtx.c +0
-0
04a51b8d15..333a399e73100644drivers/net/cpfl/cpfl_rxtx.c +68
-1@@ -10,6 +10,79 @@#include "cpfl_rxtx.h" #include "cpfl_rxtx_vec_common.h" +uint16_t +cpfl_hw_qid_get (uint16_t start_qid,uint16_t offset) { +return start_qid + offset; +} + +uint64_t +cpfl_hw_qtail_get (uint64_t tail_start,uint16_t offset,uint64_t +tail_spacing) { +return tail_start + offset * tail_spacing; } + +static inline void +cpfl_tx_hairpin_descq_reset (struct idpf_tx_queue *txq) { +uint32_t i, size; + +if (!txq) { +PMD_DRV_LOG (DEBUG ,"Pointer to txq is NULL" ); +return ; + } + + size = txq->nb_tx_desc *CPFL_P2P_DESC_LEN ; +for (i =0 ; i < size; i++) + ((volatile char *)txq->desc_ring)[i] =0 ; } + +static inline void +cpfl_tx_hairpin_complq_reset (struct idpf_tx_queue *cq) { +uint32_t i, size; + +if (!cq) { +PMD_DRV_LOG (DEBUG ,"Pointer to complq is NULL" ); +return ; + } + + size = cq->nb_tx_desc *CPFL_P2P_DESC_LEN ; +for (i =0 ; i < size; i++) + ((volatile char *)cq->compl_ring)[i] =0 ; } + +static inline void +cpfl_rx_hairpin_descq_reset (struct idpf_rx_queue *rxq) { +uint16_t len; +uint32_t i; + +if (!rxq) +return ; + + len = rxq->nb_rx_desc; +for (i =0 ; i < len *CPFL_P2P_DESC_LEN ; i++) + ((volatile char *)rxq->rx_ring)[i] =0 ; } + +static inline void +cpfl_rx_hairpin_bufq_reset (struct idpf_rx_queue *rxbq) { +uint16_t len; +uint32_t i; + +if (!rxbq) +return ; + + len = rxbq->nb_rx_desc; +for (i =0 ; i < len *CPFL_P2P_DESC_LEN ; i++) + ((volatile char *)rxbq->rx_ring)[i] =0 ; + + rxbq->bufq1 =NULL ; + rxbq->bufq2 =NULL ; +} +static uint64_t cpfl_rx_offload_convert(uint64_t offload) { @@ -234,7 +307,10 @@ cpfl_rx_queue_release(void *rxq)/* Split queue */ if (!q->adapter->is_rx_singleq) { -if (q->bufq2) +/* the mz is shared between Tx/Rx hairpin, let Rx_release +* free the buf, q->bufq1->mz and q->mz. +*/ +if (!cpfl_rxq->hairpin_info.hairpin_q && q->bufq2)cpfl_rx_split_bufq_release (q->bufq2);if (q->bufq1)@@ -385,6 +461,7 @@ cpfl_rx_queue_setup(struct rte_eth_dev *dev,
uint16_tdrivers/net/cpfl/cpfl_rxtx.c cpfl_tx_queue_setup(struct rte_eth_dev *dev,
Quoted 9 lines
drivers/net/cpfl/cpfl_rxtx.c +1
-0queue_idx, } } + cpfl_vport->nb_data_rxq++; rxq->q_set = true; dev->data->rx_queues[queue_idx] = cpfl_rxq;@@ -548,6 +625,7 @@ cpfl_tx_queue_setup(struct rte_eth_dev *dev,
uint16_tQuoted 126 lines
drivers/net/cpfl/cpfl_rxtx.c +16
-0queue_idx, txq->qtx_tail = hw->hw_addr + (vport->chunks_info.tx_qtail_start + queue_idx * vport->chunks_info.tx_qtail_spacing); txq->ops = &def_txq_ops; + cpfl_vport->nb_data_txq++; txq->q_set = true; dev->data->tx_queues[queue_idx] = cpfl_txq;@@ -562,6 +640,297 @@ cpfl_tx_queue_setup(struct rte_eth_dev *dev,uint16_t queue_idx, return ret; } +static int +cpfl_rx_hairpin_bufq_setup (struct rte_eth_dev *dev,struct idpf_rx_queue *bufq, +uint16_t logic_qid,uint16_t nb_desc) { +struct cpfl_vport *cpfl_vport = + (struct cpfl_vport *)dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base; +struct idpf_adapter *adapter = vport->adapter; +struct rte_mempool *mp; +char pool_name[RTE_MEMPOOL_NAMESIZE ]; + + mp = cpfl_vport->p2p_mp; +if (!mp) { +snprintf (pool_name,RTE_MEMPOOL_NAMESIZE ,"p2p_mb_pool_%u" , + dev->data->port_id); + mp = rte_pktmbuf_pool_create(pool_name,
CPFL_P2P_NB_MBUF,CPFL_P2P_CACHE_SIZE,drivers/net/cpfl/cpfl_rxtx.c +1
-0+ 0, CPFL_P2P_MBUF_SIZE, dev-Quoted 1 line
device->numa_node);drivers/net/cpfl/cpfl_rxtx.c +2
-0+if (!mp) { + PMD_INIT_LOG(ERR, "Failed to allocate mbuf pool forp2p");
drivers/net/cpfl/cpfl_rxtx.c +8
-0+return -ENOMEM ; + } + cpfl_vport->p2p_mp = mp; + } + + bufq->mp = mp; + bufq->nb_rx_desc = nb_desc; + bufq->queue_id = cpfl_hw_qid_get(cpfl_vport-Quoted 1 line
p2p_q_chunks_info.rx_buf_start_qid,
logic_qid);drivers/net/cpfl/cpfl_rxtx.c +3
-0+ bufq->port_id = dev->data->port_id; + bufq->adapter = adapter; + bufq->rx_buf_len = CPFL_P2P_MBUF_SIZE -
RTE_PKTMBUF_HEADROOM;drivers/net/cpfl/cpfl_rxtx.c +20
-0+ + bufq->sw_ring =rte_zmalloc ("sw ring" , +sizeof (struct rte_mbuf *) * nb_desc, +RTE_CACHE_LINE_SIZE ); +if (!bufq->sw_ring) { +PMD_INIT_LOG (ERR ,"Failed to allocate memory for SW ring" ); +return -ENOMEM ; + } + + bufq->q_set = true; + bufq->ops = &def_rxq_ops; + +return 0 ; +} + +int +cpfl_rx_hairpin_queue_setup (struct rte_eth_dev *dev,uint16_t queue_idx, +uint16_t nb_desc, +const struct rte_eth_hairpin_conf *conf) { + struct cpfl_vport *cpfl_vport = (struct cpfl_vport *)dev->data-Quoted 1 line
dev_private;drivers/net/cpfl/cpfl_rxtx.c +13
-0+struct idpf_vport *vport = &cpfl_vport->base; +struct idpf_adapter *adapter_base = vport->adapter; +uint16_t logic_qid = cpfl_vport->nb_p2p_rxq; +struct cpfl_rxq_hairpin_info *hairpin_info; +struct cpfl_rx_queue *cpfl_rxq; +struct idpf_rx_queue *bufq1 =NULL ; +struct idpf_rx_queue *rxq; +uint16_t peer_port, peer_q; +uint16_t qid; +int ret; + +if (vport->rxq_model ==VIRTCHNL2_QUEUE_MODEL_SINGLE ) { + PMD_INIT_LOG(ERR, "Only spilt queue model supports hairpinqueue.");
drivers/net/cpfl/cpfl_rxtx.c +5
-0+return -EINVAL ; + } + +if (conf->peer_count !=1 ) { + PMD_INIT_LOG(ERR, "Can't support Rx hairpin queue peercount %d",
conf->peer_count);drivers/net/cpfl/cpfl_rxtx.c +10
-0+return -EINVAL ; + } + + peer_port = conf->peers[0 ].port; + peer_q = conf->peers[0 ].queue; + +if (nb_desc %CPFL_ALIGN_RING_DESC !=0 || + nb_desc >CPFL_MAX_RING_DESC || + nb_desc <CPFL_MIN_RING_DESC ) { + PMD_INIT_LOG(ERR, "Number (%u) of receive descriptors isinvalid",
nb_desc);drivers/net/cpfl/cpfl_rxtx.c +16
-0+return -EINVAL ; + } + +/* Free memory if needed */ +if (dev->data->rx_queues[queue_idx]) { +cpfl_rx_queue_release (dev->data->rx_queues[queue_idx]); + dev->data->rx_queues[queue_idx] =NULL ; + } + +/* Setup Rx description queue */ + cpfl_rxq =rte_zmalloc_socket ("cpfl hairpin rxq" , +sizeof (struct cpfl_rx_queue ), +RTE_CACHE_LINE_SIZE , +SOCKET_ID_ANY ); +if (!cpfl_rxq) { + PMD_INIT_LOG(ERR, "Failed to allocate memory for rx queuedata structure");
drivers/net/cpfl/cpfl_rxtx.c +7
-0+return -ENOMEM ; + } + + rxq = &cpfl_rxq->base; + hairpin_info = &cpfl_rxq->hairpin_info; + rxq->nb_rx_desc = nb_desc *2 ; + rxq->queue_id = cpfl_hw_qid_get(cpfl_vport-Quoted 1 line
p2p_q_chunks_info.rx_start_qid,
logic_qid);drivers/net/cpfl/cpfl_rxtx.c cpfl_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
Quoted 3 lines
drivers/net/cpfl/cpfl_rxtx.c +3
-0+ rxq->port_id = dev->data->port_id; + rxq->adapter = adapter_base; + rxq->rx_buf_len = CPFL_P2P_MBUF_SIZE -
RTE_PKTMBUF_HEADROOM;Quoted 148 lines
drivers/net/cpfl/cpfl_rxtx.c +17
-0+ hairpin_info->hairpin_q = true; + hairpin_info->peer_txp = peer_port; + hairpin_info->peer_txq_id = peer_q; + +if (conf->manual_bind !=0 ) + cpfl_vport->p2p_manual_bind = true; +else + cpfl_vport->p2p_manual_bind = false; + +/* setup 1 Rx buffer queue for the 1st hairpin rxq */ +if (logic_qid ==0 ) { + bufq1 =rte_zmalloc_socket ("hairpin rx bufq1" , +sizeof (struct idpf_rx_queue ), +RTE_CACHE_LINE_SIZE , +SOCKET_ID_ANY ); +if (!bufq1) { + PMD_INIT_LOG(ERR, "Failed to allocate memory forhairpin Rx buffer queue 1.");
drivers/net/cpfl/cpfl_rxtx.c +7
-0+ ret = -ENOMEM ; + goto err_alloc_bufq1; + } + qid =2 * logic_qid; + ret =cpfl_rx_hairpin_bufq_setup (dev, bufq1, qid, nb_desc); +if (ret) { + PMD_INIT_LOG(ERR, "Failed to setup hairpin Rx bufferqueue 1");
drivers/net/cpfl/cpfl_rxtx.c +43
-0+ ret = -EINVAL ; + goto err_setup_bufq1; + } + cpfl_vport->p2p_rx_bufq = bufq1; + } + + rxq->bufq1 = cpfl_vport->p2p_rx_bufq; + rxq->bufq2 =NULL ; + + cpfl_vport->nb_p2p_rxq++; + rxq->q_set = true; + dev->data->rx_queues[queue_idx] = cpfl_rxq; + +return 0 ; + +err_setup_bufq1: +rte_free (bufq1); +err_alloc_bufq1: +rte_free (rxq); + +return ret; +} + +int +cpfl_tx_hairpin_queue_setup (struct rte_eth_dev *dev,uint16_t queue_idx, +uint16_t nb_desc, +const struct rte_eth_hairpin_conf *conf) { +struct cpfl_vport *cpfl_vport = + (struct cpfl_vport *)dev->data->dev_private; + +struct idpf_vport *vport = &cpfl_vport->base; +struct idpf_adapter *adapter_base = vport->adapter; +uint16_t logic_qid = cpfl_vport->nb_p2p_txq; +struct cpfl_txq_hairpin_info *hairpin_info; +struct idpf_hw *hw = &adapter_base->hw; +struct cpfl_tx_queue *cpfl_txq; +struct idpf_tx_queue *txq, *cq; +const struct rte_memzone *mz; +uint32_t ring_size; +uint16_t peer_port, peer_q; + +if (vport->txq_model ==VIRTCHNL2_QUEUE_MODEL_SINGLE ) { + PMD_INIT_LOG(ERR, "Only spilt queue model supports hairpinqueue.");
drivers/net/cpfl/cpfl_rxtx.c +5
-0+return -EINVAL ; + } + +if (conf->peer_count !=1 ) { + PMD_INIT_LOG(ERR, "Can't support Tx hairpin queue peercount %d",
conf->peer_count);drivers/net/cpfl/cpfl_rxtx.c +10
-0+return -EINVAL ; + } + + peer_port = conf->peers[0 ].port; + peer_q = conf->peers[0 ].queue; + +if (nb_desc %CPFL_ALIGN_RING_DESC !=0 || + nb_desc >CPFL_MAX_RING_DESC || + nb_desc <CPFL_MIN_RING_DESC ) { + PMD_INIT_LOG(ERR, "Number (%u) of transmit descriptors isinvalid",
drivers/net/cpfl/cpfl_rxtx.c +17
-0+ nb_desc); +return -EINVAL ; + } + +/* Free memory if needed. */ +if (dev->data->tx_queues[queue_idx]) { +cpfl_tx_queue_release (dev->data->tx_queues[queue_idx]); + dev->data->tx_queues[queue_idx] =NULL ; + } + +/* Allocate the TX queue data structure. */ + cpfl_txq =rte_zmalloc_socket ("cpfl hairpin txq" , +sizeof (struct cpfl_tx_queue ), +RTE_CACHE_LINE_SIZE , +SOCKET_ID_ANY ); +if (!cpfl_txq) { + PMD_INIT_LOG(ERR, "Failed to allocate memory for tx queuestructure");
drivers/net/cpfl/cpfl_rxtx.c +8
-0+return -ENOMEM ; + } + + txq = &cpfl_txq->base; + hairpin_info = &cpfl_txq->hairpin_info; +/* Txq ring length should be 2 times of Tx completion queue size. */ + txq->nb_tx_desc = nb_desc *2 ; + txq->queue_id = cpfl_hw_qid_get(cpfl_vport-Quoted 1 line
p2p_q_chunks_info.tx_start_qid,
logic_qid);drivers/net/cpfl/cpfl_rxtx.c +31
-0+ txq->port_id = dev->data->port_id; + hairpin_info->hairpin_q = true; + hairpin_info->peer_rxp = peer_port; + hairpin_info->peer_rxq_id = peer_q; + +if (conf->manual_bind !=0 ) + cpfl_vport->p2p_manual_bind = true; +else + cpfl_vport->p2p_manual_bind = false; + +/* Always Tx hairpin queue allocates Tx HW ring */ + ring_size =RTE_ALIGN (txq->nb_tx_desc *CPFL_P2P_DESC_LEN , +CPFL_DMA_MEM_ALIGN ); + mz =rte_eth_dma_zone_reserve (dev,"hairpin_tx_ring" , logic_qid, + ring_size +CPFL_P2P_RING_BUF , +CPFL_RING_BASE_ALIGN , + dev->device->numa_node); +if (!mz) { +PMD_INIT_LOG (ERR ,"Failed to reserve DMA memory for TX" ); +rte_free (txq->sw_ring); +rte_free (txq); +return -ENOMEM ; + } + + txq->tx_ring_phys_addr = mz->iova; + txq->desc_ring = mz->addr; + txq->mz = mz; + +cpfl_tx_hairpin_descq_reset (txq); + txq->qtx_tail = hw->hw_addr + + cpfl_hw_qtail_get(cpfl_vport-Quoted 1 line
p2p_q_chunks_info.tx_qtail_start,
drivers/net/cpfl/cpfl_rxtx.c +1
-0+ logic_qid, cpfl_vport-Quoted 1 line
p2p_q_chunks_info.tx_qtail_spacing);
drivers/net/cpfl/cpfl_rxtx.c cpfl_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx, · line 890
Quoted 3 lines
drivers/net/cpfl/cpfl_rxtx.c +3
-0+ txq->ops = &def_txq_ops; + +if (cpfl_vport->p2p_tx_complq ==NULL ) {[Liu, Mingxia] In
cpfl_rx_hairpin_queue_setup(), "logic_qid" is used to identify if it is the first time to allocate "p2p_rx_bufq" buffer,
Can it be unified, usinglogic_qid== 0 or p2p_tx_complq/p2p_rx_bufq== NULL ?drivers/net/cpfl/cpfl_rxtx_vec_common.h cpfl_rx_vec_dev_check_default(struct rte_eth_dev
Quoted 128 lines
drivers/net/cpfl/cpfl_rxtx.c +6
-0+ cq =rte_zmalloc_socket ("cpfl hairpin cq" , +sizeof (struct idpf_tx_queue ), +RTE_CACHE_LINE_SIZE , + dev->device->numa_node); +if (!cq) { + PMD_INIT_LOG(ERR, "Failed to allocate memory for txqueue structure");
drivers/net/cpfl/cpfl_rxtx.c +5
-0+return -ENOMEM ; + } + + cq->nb_tx_desc = nb_desc; + cq->queue_id = cpfl_hw_qid_get(cpfl_vport-Quoted 1 line
p2p_q_chunks_info.tx_compl_start_qid, 0);
drivers/net/cpfl/cpfl_rxtx.c +6
-0+ cq->port_id = dev->data->port_id; + +/* Tx completion queue always allocates the HW ring */ + ring_size =RTE_ALIGN (cq->nb_tx_desc *CPFL_P2P_DESC_LEN , +CPFL_DMA_MEM_ALIGN ); + mz = rte_eth_dma_zone_reserve(dev, "hairpin_tx_compl_ring",
logic_qid,drivers/net/cpfl/cpfl_rxtx.c +5
-0+ ring_size +CPFL_P2P_RING_BUF , +CPFL_RING_BASE_ALIGN , + dev->device->numa_node); +if (!mz) { + PMD_INIT_LOG(ERR, "Failed to reserve DMA memoryfor TX completion queue");
drivers/net/cpfl/cpfl_rxtx.c +21
-0+rte_free (txq->sw_ring); +rte_free (txq); +return -ENOMEM ; + } + cq->tx_ring_phys_addr = mz->iova; + cq->compl_ring = mz->addr; + cq->mz = mz; + +cpfl_tx_hairpin_complq_reset (cq); + cpfl_vport->p2p_tx_complq = cq; + } + + txq->complq = cpfl_vport->p2p_tx_complq; + + cpfl_vport->nb_p2p_txq++; + txq->q_set = true; + dev->data->tx_queues[queue_idx] = cpfl_txq; + +return 0 ; +} +int cpfl_rx_queue_init(struct rte_eth_dev *dev, uint16_t rx_queue_id) { @@ -865,6 +1234,8 @@
cpfl_set_rx_function(struct rte_eth_dev *dev)drivers/net/cpfl/cpfl_rxtx.c +2
-0if (vport->rx_vec_allowed) {for (i =0 ; i < dev->data->nb_rx_queues; i++) { cpfl_rxq = dev->data->rx_queues[i]; +if (cpfl_rxq->hairpin_info.hairpin_q) +continue ; (void)idpf_qc_splitq_rx_vec_setup(&cpfl_rxq-Quoted 1 line
base);
drivers/net/cpfl/cpfl_rxtx.c +0
-0}#ifdef CC_AVX512_SUPPORT drivers/net/cpfl/cpfl_rxtx.h index renamed from drivers/net/cpfl/cpfl_rxtx.h +0
-0
3a87a1f4b3..5e9f2dada7100644drivers/net/cpfl/cpfl_rxtx.h +18
-0@@ -13,6 +13,7 @@#define CPFL_MIN_RING_DESC 32#define CPFL_MAX_RING_DESC 4096#define CPFL_DMA_MEM_ALIGN 4096 +#define CPFL_P2P_DESC_LEN 16#define CPFL_MAX_HAIRPINQ_RX_2_TX 1#define CPFL_MAX_HAIRPINQ_TX_2_RX 1#define CPFL_MAX_HAIRPINQ_NB_DESC 1024@@ -21,6 +22,10 @@#define CPFL_P2P_NB_TX_COMPLQ 1#define CPFL_P2P_NB_QUEUE_GRPS 1#define CPFL_P2P_QUEUE_GRP_ID 1 +#define CPFL_P2P_NB_MBUF 4096 +#define CPFL_P2P_CACHE_SIZE 250 +#define CPFL_P2P_MBUF_SIZE 2048 +#define CPFL_P2P_RING_BUF 128/* Base address of the HW descriptor ring should be 128B aligned. */ #define CPFL_RING_BASE_ALIGN 128@@ -31,12 +36,26 @@#define CPFL_SUPPORT_CHAIN_NUM 5 +struct cpfl_rxq_hairpin_info { +bool hairpin_q;/* if rx queue is a hairpin queue */ +uint16_t peer_txp; +uint16_t peer_txq_id; +}; +struct cpfl_rx_queue {struct idpf_rx_queue base; +struct cpfl_rxq_hairpin_info hairpin_info; }; + +struct cpfl_txq_hairpin_info { +bool hairpin_q;/* if tx queue is a hairpin queue */ +uint16_t peer_rxp; +uint16_t peer_rxq_id; };struct cpfl_tx_queue {struct idpf_tx_queue base; +struct cpfl_txq_hairpin_info hairpin_info; }; int cpfl_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx, @@ -57,4 +76,11 @@ void
cpfl_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid); voidcpfl_dev_rx_queue_release(struct rte_eth_dev *dev, uint16_t qid); voidcpfl_set_rx_function(struct rte_eth_dev *dev); voidcpfl_set_tx_function(struct rte_eth_dev *dev);drivers/net/cpfl/cpfl_rxtx.h +3
-0+uint16_t cpfl_hw_qid_get (uint16_t start_qid,uint16_t offset);uint64_t +cpfl_hw_qtail_get (uint64_t tail_start,uint16_t offset,uint64_t +tail_spacing); int cpfl_rx_hairpin_queue_setup(struct rte_eth_dev *dev,
uint16_tqueue_idx,drivers/net/cpfl/cpfl_rxtx.h +1
-0+ uint16_t nb_desc, const struct
rte_eth_hairpin_conf*conf); intdrivers/net/cpfl/cpfl_rxtx.h +3
-0+cpfl_tx_hairpin_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx, + uint16_t nb_desc, + const struct rte_eth_hairpin_conf *conf);#endif /* _CPFL_RXTX_H_ */ drivers/net/cpfl/cpfl_rxtx_vec_common.h +0
-0@@ -85,6 +85,8 @@ cpfl_rx_vec_dev_check_default(struct rte_eth_dev*dev)
drivers/net/cpfl/cpfl_rxtx_vec_common.h cpfl_tx_vec_dev_check_default(struct rte_eth_dev
Quoted 10 lines
drivers/net/cpfl/cpfl_rxtx_vec_common.h +2
-0cpfl_rxq = dev->data->rx_queues[i]; default_ret =cpfl_rx_vec_queue_default (&cpfl_rxq->base);if (vport->rxq_model ==VIRTCHNL2_QUEUE_MODEL_SPLIT ) { +if (cpfl_rxq->hairpin_info.hairpin_q) +continue ; splitq_ret =cpfl_rx_splitq_vec_default (&cpfl_rxq- >base); ret = splitq_ret && default_ret;drivers/net/cpfl/cpfl_rxtx_vec_common.h +0
-0}else {@@ -106,6 +108,8 @@ cpfl_tx_vec_dev_check_default(struct rte_eth_dev*dev)
Quoted 10 lines
drivers/net/cpfl/cpfl_rxtx_vec_common.h +2
-1for (i =0 ; i < dev->data->nb_tx_queues; i++) { cpfl_txq = dev->data->tx_queues[i]; +if (cpfl_txq->hairpin_info.hairpin_q) +continue ; ret =cpfl_tx_vec_queue_default (&cpfl_txq->base);if (ret ==CPFL_SCALAR_PATH )return CPFL_SCALAR_PATH ; --2.26.2
RE: [PATCH v3 05/10] net/cpfl: support hairpin queue setup and release
In reply to [email protected]Quoted 31 lines
drivers/net/cpfl/cpfl_rxtx.c +16
-0+static int +cpfl_rx_hairpin_bufq_setup (struct rte_eth_dev *dev,struct idpf_rx_queue *bufq, +uint16_t logic_qid,uint16_t nb_desc) +{ +struct cpfl_vport *cpfl_vport = + (struct cpfl_vport *)dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base; +struct idpf_adapter *adapter = vport->adapter; +struct rte_mempool *mp; +char pool_name[RTE_MEMPOOL_NAMESIZE ]; + + mp = cpfl_vport->p2p_mp; +if (!mp) { +snprintf (pool_name,RTE_MEMPOOL_NAMESIZE ,"p2p_mb_pool_%u" , + dev->data->port_id); + mp = rte_pktmbuf_pool_create(pool_name, CPFL_P2P_NB_MBUF,
CPFL_P2P_CACHE_SIZE,(quoted diff) +1
-0+ 0, CPFL_P2P_MBUF_SIZE, dev->device-Quoted 1 line
numa_node);drivers/net/cpfl/cpfl_rxtx.c +10
-0+if (!mp) { +PMD_INIT_LOG (ERR ,"Failed to allocate mbuf pool for p2p" ); +return -ENOMEM ; + } + cpfl_vport->p2p_mp = mp; + } + + bufq->mp = mp; + bufq->nb_rx_desc = nb_desc; + bufq->queue_id = cpfl_hw_qid_get(cpfl_vport-Quoted 1 line
p2p_q_chunks_info.rx_buf_start_qid,
logic_qid);
drivers/net/cpfl/cpfl_rxtx.c cpfl_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx, · line 676
Quoted 7 lines
drivers/net/cpfl/cpfl_rxtx.c +7
-0+ bufq->port_id = dev->data->port_id; + bufq->adapter = adapter; + bufq->rx_buf_len =CPFL_P2P_MBUF_SIZE -RTE_PKTMBUF_HEADROOM ; + + bufq->sw_ring =rte_zmalloc ("sw ring" , +sizeof (struct rte_mbuf *) * nb_desc, +RTE_CACHE_LINE_SIZE );
Is sw_ring required in p2p case? It has been never used right? Please also check the sw_ring in tx queue.
Quoted 93 lines
drivers/net/cpfl/cpfl_rxtx.c +35
-0+if (!bufq->sw_ring) { +PMD_INIT_LOG (ERR ,"Failed to allocate memory for SW ring" ); +return -ENOMEM ; + } + + bufq->q_set = true; + bufq->ops = &def_rxq_ops; + +return 0 ; +} + +int +cpfl_rx_hairpin_queue_setup (struct rte_eth_dev *dev,uint16_t queue_idx, +uint16_t nb_desc, +const struct rte_eth_hairpin_conf *conf) +{ +struct cpfl_vport *cpfl_vport = (struct cpfl_vport *)dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base; +struct idpf_adapter *adapter_base = vport->adapter; +uint16_t logic_qid = cpfl_vport->nb_p2p_rxq; +struct cpfl_rxq_hairpin_info *hairpin_info; +struct cpfl_rx_queue *cpfl_rxq; +struct idpf_rx_queue *bufq1 =NULL ; +struct idpf_rx_queue *rxq; +uint16_t peer_port, peer_q; +uint16_t qid; +int ret; + +if (vport->rxq_model ==VIRTCHNL2_QUEUE_MODEL_SINGLE ) { +PMD_INIT_LOG (ERR ,"Only spilt queue model supports hairpin queue." ); +return -EINVAL ; + } + +if (conf->peer_count !=1 ) { + PMD_INIT_LOG(ERR, "Can't support Rx hairpin queue peer count %d",
conf->peer_count);drivers/net/cpfl/cpfl_rxtx.c +10
-0+return -EINVAL ; + } + + peer_port = conf->peers[0 ].port; + peer_q = conf->peers[0 ].queue; + +if (nb_desc %CPFL_ALIGN_RING_DESC !=0 || + nb_desc >CPFL_MAX_RING_DESC || + nb_desc <CPFL_MIN_RING_DESC ) { + PMD_INIT_LOG(ERR, "Number (%u) of receive descriptors is invalid",
nb_desc);drivers/net/cpfl/cpfl_rxtx.c +16
-0+return -EINVAL ; + } + +/* Free memory if needed */ +if (dev->data->rx_queues[queue_idx]) { +cpfl_rx_queue_release (dev->data->rx_queues[queue_idx]); + dev->data->rx_queues[queue_idx] =NULL ; + } + +/* Setup Rx description queue */ + cpfl_rxq =rte_zmalloc_socket ("cpfl hairpin rxq" , +sizeof (struct cpfl_rx_queue ), +RTE_CACHE_LINE_SIZE , +SOCKET_ID_ANY ); +if (!cpfl_rxq) { + PMD_INIT_LOG(ERR, "Failed to allocate memory for rx queue datastructure");
drivers/net/cpfl/cpfl_rxtx.c +7
-0+return -ENOMEM ; + } + + rxq = &cpfl_rxq->base; + hairpin_info = &cpfl_rxq->hairpin_info; + rxq->nb_rx_desc = nb_desc *2 ; + rxq->queue_id = cpfl_hw_qid_get(cpfl_vport->p2p_q_chunks_info.rx_start_qid,
logic_qid);drivers/net/cpfl/cpfl_rxtx.c +20
-0+ rxq->port_id = dev->data->port_id; + rxq->adapter = adapter_base; + rxq->rx_buf_len =CPFL_P2P_MBUF_SIZE -RTE_PKTMBUF_HEADROOM ; + hairpin_info->hairpin_q = true; + hairpin_info->peer_txp = peer_port; + hairpin_info->peer_txq_id = peer_q; + +if (conf->manual_bind !=0 ) + cpfl_vport->p2p_manual_bind = true; +else + cpfl_vport->p2p_manual_bind = false; + +/* setup 1 Rx buffer queue for the 1st hairpin rxq */ +if (logic_qid ==0 ) { + bufq1 =rte_zmalloc_socket ("hairpin rx bufq1" , +sizeof (struct idpf_rx_queue ), +RTE_CACHE_LINE_SIZE , +SOCKET_ID_ANY ); +if (!bufq1) { + PMD_INIT_LOG(ERR, "Failed to allocate memory for hairpin Rxbuffer queue 1.");
drivers/net/cpfl/cpfl_rxtx.c cpfl_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx, · line 768
Quoted 4 lines
drivers/net/cpfl/cpfl_rxtx.c +4
-0+ ret = -ENOMEM ; + goto err_alloc_bufq1; + } + qid =2 * logic_qid;
Inside the brace ( if (logic_qid=0) {} ), the logic_qid should be zero, right? What is the purpose of doing qid = 2* logic_qid?
drivers/net/cpfl/cpfl_rxtx.c cpfl_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx, · line 780
Quoted 12 lines
drivers/net/cpfl/cpfl_rxtx.c +12
-0+ ret =cpfl_rx_hairpin_bufq_setup (dev, bufq1, qid, nb_desc); +if (ret) { +PMD_INIT_LOG (ERR ,"Failed to setup hairpin Rx buffer queue 1" ); + ret = -EINVAL ; + goto err_setup_bufq1; + } + cpfl_vport->p2p_rx_bufq = bufq1; + } + + rxq->bufq1 = cpfl_vport->p2p_rx_bufq; + rxq->bufq2 =NULL ; +
cpfl_vport->p2p_rx_bufq is allocated in this function. But haven't seen where it will be released. And in cpfl_rx_hairpin_bufq_reset the rxq->bufq1 will be assigned to NULL. Will queue release miss this?
Quoted 14 lines
drivers/net/cpfl/cpfl_rxtx.c +14
-0+ cpfl_vport->nb_p2p_rxq++; + rxq->q_set = true; + dev->data->rx_queues[queue_idx] = cpfl_rxq; + +return 0 ; + +err_setup_bufq1: +rte_free (bufq1); +err_alloc_bufq1: +rte_free (rxq); + +return ret; +} +
RE: [PATCH v3 05/10] net/cpfl: support hairpin queue setup and release
Quoted 50 lines
-----Original Message-----
From: Wu, Jingjing <[email protected]>
Sent: Thursday, May 25, 2023 11:59 AM
To: Xing, Beilei <[email protected]>
Cc: [email protected]; Liu, Mingxia <[email protected]>; Wang, Xiao W <[email protected]>
Subject: RE: [PATCH v3 05/10] net/cpfl: support hairpin queue setup and releaseReview
Quoted 3 lines
(quoted diff) +2
-0+static int +cpfl_rx_hairpin_bufq_setup(struct rte_eth_dev *dev, struct idpf_rx_queue*bufq,
drivers/net/cpfl/cpfl_rxtx.c cpfl_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
Quoted 11 lines
drivers/net/cpfl/cpfl_rxtx.c +11
-0+ uint16_t logic_qid, uint16_t nb_desc) { +struct cpfl_vport *cpfl_vport = + (struct cpfl_vport *)dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base; +struct idpf_adapter *adapter = vport->adapter; +struct rte_mempool *mp; +char pool_name[RTE_MEMPOOL_NAMESIZE ]; + + mp = cpfl_vport->p2p_mp; +if (!mp) { + snprintf(pool_name, RTE_MEMPOOL_NAMESIZE,"p2p_mb_pool_%u",
Review
Quoted 2 lines
(quoted diff) +2
-0+ dev->data->port_id); + mp = rte_pktmbuf_pool_create(pool_name,
CPFL_P2P_NB_MBUF,Review
Quoted 6 lines
CPFL_P2P_CACHE_SIZE,(quoted diff) +1
-0+ 0, CPFL_P2P_MBUF_SIZE, dev-device-
Quoted 1 line
numa_node);(quoted diff) +2
-0+ if (!mp) { + PMD_INIT_LOG(ERR, "Failed to allocate mbuf pool forp2p");
drivers/net/cpfl/cpfl_rxtx.c cpfl_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
Quoted 12 lines
drivers/net/cpfl/cpfl_rxtx.c +8
-0+return -ENOMEM ; + } + cpfl_vport->p2p_mp = mp; + } + + bufq->mp = mp; + bufq->nb_rx_desc = nb_desc; + bufq->queue_id = cpfl_hw_qid_get(cpfl_vport-Quoted 1 line
p2p_q_chunks_info.rx_buf_start_qid,
logic_qid);drivers/net/cpfl/cpfl_rxtx.c +3
-0+ bufq->port_id = dev->data->port_id; + bufq->adapter = adapter; + bufq->rx_buf_len = CPFL_P2P_MBUF_SIZE -
RTE_PKTMBUF_HEADROOM;
Quoted 7 lines
drivers/net/cpfl/cpfl_rxtx.c cpfl_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx, · line 676
Quoted 4 lines
drivers/net/cpfl/cpfl_rxtx.c +4
-0+ + bufq->sw_ring =rte_zmalloc ("sw ring" , +sizeof (struct rte_mbuf *) * nb_desc, +RTE_CACHE_LINE_SIZE );Is
sw_ringrequired in p2p case? It has been never used right? Please also check thesw_ringin tx queue.
Yes, it should be removed.
Quoted 100 lines
Quoted 21 lines
drivers/net/cpfl/cpfl_rxtx.c +16
-0+if (!bufq->sw_ring) { +PMD_INIT_LOG (ERR ,"Failed to allocate memory for SW ring" ); +return -ENOMEM ; + } + + bufq->q_set = true; + bufq->ops = &def_rxq_ops; + +return 0 ; +} + +int +cpfl_rx_hairpin_queue_setup (struct rte_eth_dev *dev,uint16_t queue_idx, +uint16_t nb_desc, +const struct rte_eth_hairpin_conf *conf) { + struct cpfl_vport *cpfl_vport = (struct cpfl_vport *)dev->data-
dev_private;drivers/net/cpfl/cpfl_rxtx.c +3
-0+struct idpf_vport *vport = &cpfl_vport->base; +struct idpf_adapter *adapter_base = vport->adapter; +uint16_t logic_qid = cpfl_vport->nb_p2p_rxq;drivers/net/cpfl/cpfl_rxtx.c cpfl_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
Quoted 10 lines
drivers/net/cpfl/cpfl_rxtx.c +10
-0+struct cpfl_rxq_hairpin_info *hairpin_info; +struct cpfl_rx_queue *cpfl_rxq; +struct idpf_rx_queue *bufq1 =NULL ; +struct idpf_rx_queue *rxq; +uint16_t peer_port, peer_q; +uint16_t qid; +int ret; + +if (vport->rxq_model ==VIRTCHNL2_QUEUE_MODEL_SINGLE ) { + PMD_INIT_LOG(ERR, "Only spilt queue model supports hairpinqueue.");
drivers/net/cpfl/cpfl_rxtx.c cpfl_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
Quoted 5 lines
drivers/net/cpfl/cpfl_rxtx.c +5
-0+return -EINVAL ; + } + +if (conf->peer_count !=1 ) { + PMD_INIT_LOG(ERR, "Can't support Rx hairpin queue peercount %d",
drivers/net/cpfl/cpfl_rxtx.c cpfl_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
Quoted 11 lines
conf->peer_count);drivers/net/cpfl/cpfl_rxtx.c +10
-0+return -EINVAL ; + } + + peer_port = conf->peers[0 ].port; + peer_q = conf->peers[0 ].queue; + +if (nb_desc %CPFL_ALIGN_RING_DESC !=0 || + nb_desc >CPFL_MAX_RING_DESC || + nb_desc <CPFL_MIN_RING_DESC ) { + PMD_INIT_LOG(ERR, "Number (%u) of receive descriptors isinvalid",
Quoted 7 lines
nb_desc);drivers/net/cpfl/cpfl_rxtx.c +6
-0+return -EINVAL ; + } + +/* Free memory if needed */ +if (dev->data->rx_queues[queue_idx]) { +cpfl_rx_queue_release (dev->data->rx_queues[queue_idx]);drivers/net/cpfl/cpfl_rxtx.c cpfl_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
Quoted 10 lines
drivers/net/cpfl/cpfl_rxtx.c +10
-0+ dev->data->rx_queues[queue_idx] =NULL ; + } + +/* Setup Rx description queue */ + cpfl_rxq =rte_zmalloc_socket ("cpfl hairpin rxq" , +sizeof (struct cpfl_rx_queue ), +RTE_CACHE_LINE_SIZE , +SOCKET_ID_ANY ); +if (!cpfl_rxq) { + PMD_INIT_LOG(ERR, "Failed to allocate memory for rx queuedata
drivers/net/cpfl/cpfl_rxtx.c cpfl_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
Quoted 13 lines
structure");
drivers/net/cpfl/cpfl_rxtx.c +8
-0+return -ENOMEM ; + } + + rxq = &cpfl_rxq->base; + hairpin_info = &cpfl_rxq->hairpin_info; + rxq->nb_rx_desc = nb_desc *2 ; + rxq->queue_id = +cpfl_hw_qid_get(cpfl_vport->p2p_q_chunks_info.rx_start_qid,
logic_qid);drivers/net/cpfl/cpfl_rxtx.c +3
-0+ rxq->port_id = dev->data->port_id; + rxq->adapter = adapter_base; + rxq->rx_buf_len = CPFL_P2P_MBUF_SIZE -
RTE_PKTMBUF_HEADROOM;Quoted 7 lines
drivers/net/cpfl/cpfl_rxtx.c +7
-0+ hairpin_info->hairpin_q = true; + hairpin_info->peer_txp = peer_port; + hairpin_info->peer_txq_id = peer_q; + +if (conf->manual_bind !=0 ) + cpfl_vport->p2p_manual_bind = true; +else drivers/net/cpfl/cpfl_rxtx.c cpfl_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
Quoted 10 lines
drivers/net/cpfl/cpfl_rxtx.c +10
-0+ cpfl_vport->p2p_manual_bind = false; + +/* setup 1 Rx buffer queue for the 1st hairpin rxq */ +if (logic_qid ==0 ) { + bufq1 =rte_zmalloc_socket ("hairpin rx bufq1" , +sizeof (struct idpf_rx_queue ), +RTE_CACHE_LINE_SIZE , +SOCKET_ID_ANY ); +if (!bufq1) { + PMD_INIT_LOG(ERR, "Failed to allocate memory forhairpin Rx
Quoted 8 lines
drivers/net/cpfl/cpfl_rxtx.c cpfl_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx, · line 768
Quoted 5 lines
buffer queue 1.");
drivers/net/cpfl/cpfl_rxtx.c +4
-0+ ret = -ENOMEM ; + goto err_alloc_bufq1; + } + qid =2 * logic_qid;Inside the brace ( if (logic_qid=0) {} ), the
logic_qidshould be zero, right? What is the purpose of doing qid = 2*logic_qid?
The if condition should be refined.
Quoted 5 lines
drivers/net/cpfl/cpfl_rxtx.c cpfl_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
Quoted 4 lines
drivers/net/cpfl/cpfl_rxtx.c +3
-0+ ret =cpfl_rx_hairpin_bufq_setup (dev, bufq1, qid, nb_desc); +if (ret) { + PMD_INIT_LOG(ERR, "Failed to setup hairpin Rx bufferqueue 1");
Quoted 12 lines
drivers/net/cpfl/cpfl_rxtx.c cpfl_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx, · line 780
Quoted 9 lines
drivers/net/cpfl/cpfl_rxtx.c +9
-0+ ret = -EINVAL ; + goto err_setup_bufq1; + } + cpfl_vport->p2p_rx_bufq = bufq1; + } + + rxq->bufq1 = cpfl_vport->p2p_rx_bufq; + rxq->bufq2 =NULL ; +
cpfl_vport->p2p_rx_bufqis allocated in this function. But haven't seen where it will be released.
It will be released in cpfl_rx_queue_release function.
Quoted 17 lines
And in
cpfl_rx_hairpin_bufq_resettherxq->bufq1will be assigned to NULL. Will queue release miss this?Quoted 14 lines
drivers/net/cpfl/cpfl_rxtx.c +14
-0+ cpfl_vport->nb_p2p_rxq++; + rxq->q_set = true; + dev->data->rx_queues[queue_idx] = cpfl_rxq; + +return 0 ; + +err_setup_bufq1: +rte_free (bufq1); +err_alloc_bufq1: +rte_free (rxq); + +return ret; +} +
PATCH v3 6/10 net/cpfl: support hairpin queue configuration
In reply to [email protected]From: Beilei Xing <[email protected]>
This patch supports Rx/Tx hairpin queue configuration.
--- drivers/common/idpf/idpf_common_virtchnl.c | 70 +++++++++++ drivers/common/idpf/idpf_common_virtchnl.h | 6 + drivers/common/idpf/version.map | 2 + drivers/net/cpfl/cpfl_ethdev.c | 136 ++++++++++++++++++++- drivers/net/cpfl/cpfl_rxtx.c | 80 ++++++++++++ drivers/net/cpfl/cpfl_rxtx.h | 7 ++ 6 files changed, 295 insertions(+), 6 deletions(-)
drivers/common/idpf/idpf_common_virtchnl.c +70 -0
@@ -1050,6 +1050,41 @@ idpf_vc_rxq_config(struct idpf_vport *vport, struct idpf_rx_queue *rxq)return err; } +int idpf_vc_rxq_config_by_info (struct idpf_vport *vport,struct virtchnl2_rxq_info *rxq_info, +uint16_t num_qs) +{ +struct idpf_adapter *adapter = vport->adapter; +struct virtchnl2_config_rx_queues *vc_rxqs =NULL ; +struct idpf_cmd_info args; +int size, err, i; + + size =sizeof (*vc_rxqs) + (num_qs -1 ) * +sizeof (struct virtchnl2_rxq_info ); + vc_rxqs =rte_zmalloc ("cfg_rxqs" , size,0 ); +if (vc_rxqs ==NULL ) { +DRV_LOG (ERR ,"Failed to allocate virtchnl2_config_rx_queues" ); + err = -ENOMEM ; +return err; + } + vc_rxqs->vport_id = vport->vport_id; + vc_rxqs->num_qinfo = num_qs; +memcpy (vc_rxqs->qinfo, rxq_info, num_qs *sizeof (struct virtchnl2_rxq_info )); + +memset (&args,0 ,sizeof (args)); + args.ops =VIRTCHNL2_OP_CONFIG_RX_QUEUES ; + args.in_args = (uint8_t *)vc_rxqs; + args.in_args_size = size; + args.out_buffer = adapter->mbx_resp; + args.out_size =IDPF_DFLT_MBX_BUF_SIZE ; + + err =idpf_vc_cmd_execute (adapter, &args); +rte_free (vc_rxqs); +if (err !=0 ) +DRV_LOG (ERR ,"Failed to execute command of VIRTCHNL2_OP_CONFIG_RX_QUEUES" ); + +return err; +} +int idpf_vc_txq_config (struct idpf_vport *vport,struct idpf_tx_queue *txq) {
@@ -1121,6 +1156,41 @@ idpf_vc_txq_config(struct idpf_vport *vport, struct idpf_tx_queue *txq)return err; } +int +idpf_vc_txq_config_by_info (struct idpf_vport *vport,struct virtchnl2_txq_info *txq_info, +uint16_t num_qs) +{ +struct idpf_adapter *adapter = vport->adapter; +struct virtchnl2_config_tx_queues *vc_txqs =NULL ; +struct idpf_cmd_info args; +int size, err; + + size =sizeof (*vc_txqs) + (num_qs -1 ) *sizeof (struct virtchnl2_txq_info ); + vc_txqs =rte_zmalloc ("cfg_txqs" , size,0 ); +if (vc_txqs ==NULL ) { +DRV_LOG (ERR ,"Failed to allocate virtchnl2_config_tx_queues" ); + err = -ENOMEM ; +return err; + } + vc_txqs->vport_id = vport->vport_id; + vc_txqs->num_qinfo = num_qs; +memcpy (vc_txqs->qinfo, txq_info, num_qs *sizeof (struct virtchnl2_txq_info )); + +memset (&args,0 ,sizeof (args)); + args.ops =VIRTCHNL2_OP_CONFIG_TX_QUEUES ; + args.in_args = (uint8_t *)vc_txqs; + args.in_args_size = size; + args.out_buffer = adapter->mbx_resp; + args.out_size =IDPF_DFLT_MBX_BUF_SIZE ; + + err =idpf_vc_cmd_execute (adapter, &args); +rte_free (vc_txqs); +if (err !=0 ) +DRV_LOG (ERR ,"Failed to execute command of VIRTCHNL2_OP_CONFIG_TX_QUEUES" ); + +return err; +} +int idpf_vc_ctlq_recv (struct idpf_ctlq_info *cq,u16 *num_q_msg,struct idpf_ctlq_msg *q_msg)
drivers/common/idpf/idpf_common_virtchnl.h +6 -0
@@ -65,6 +65,12 @@ __rte_internalint idpf_vc_ctlq_post_rx_buffs (struct idpf_hw *hw,struct idpf_ctlq_info *cq,u16 *buff_count,struct idpf_dma_mem **buffs);__rte_internal +int idpf_vc_rxq_config_by_info(struct idpf_vport *vport, struct virtchnl2_rxq_info *rxq_info, +uint16_t num_qs); +__rte_internal +int idpf_vc_txq_config_by_info(struct idpf_vport *vport, struct virtchnl2_txq_info *txq_info, +uint16_t num_qs); +__rte_internal int idpf_vc_queue_grps_del(struct idpf_vport *vport,uint16_t num_q_grps,struct virtchnl2_queue_group_id *qg_ids);
drivers/common/idpf/version.map +2 -0
@@ -54,8 +54,10 @@ INTERNAL { idpf_vc_rss_lut_get; idpf_vc_rss_lut_set; idpf_vc_rxq_config; + idpf_vc_rxq_config_by_info; idpf_vc_stats_query; idpf_vc_txq_config; + idpf_vc_txq_config_by_info; idpf_vc_vectors_alloc; idpf_vc_vectors_dealloc; idpf_vc_vport_create;
drivers/net/cpfl/cpfl_ethdev.c +130 -6
163 lines not on this page · raw message
drivers/net/cpfl/cpfl_rxtx.c +80 -0
86 lines not on this page · raw message
drivers/net/cpfl/cpfl_rxtx.h +7 -0
@@ -30,12 +30,15 @@#define CPFL_RING_BASE_ALIGN 128#define CPFL_DEFAULT_RX_FREE_THRESH 32 +#define CPFL_RXBUF_LOW_WATERMARK 64#define CPFL_DEFAULT_TX_RS_THRESH 32#define CPFL_DEFAULT_TX_FREE_THRESH 32#define CPFL_SUPPORT_CHAIN_NUM 5 +#define CPFL_RX_BUF_STRIDE 64 +struct cpfl_rxq_hairpin_info {bool hairpin_q;/* if rx queue is a hairpin queue */ uint16_t peer_txp;
@@ -83,4 +86,8 @@ int cpfl_rx_hairpin_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,int cpfl_tx_hairpin_queue_setup (struct rte_eth_dev *dev,uint16_t queue_idx,uint16_t nb_desc,const struct rte_eth_hairpin_conf *conf); +int cpfl_hairpin_tx_complq_config (struct cpfl_vport *cpfl_vport); +int cpfl_hairpin_txq_config (struct idpf_vport *vport,struct cpfl_tx_queue *cpfl_txq); +int cpfl_hairpin_rx_bufq_config (struct cpfl_vport *cpfl_vport); +int cpfl_hairpin_rxq_config (struct idpf_vport *vport,struct cpfl_rx_queue *cpfl_rxq);#endif /* _CPFL_RXTX_H_ */
Signature · 1 line
2.26.2
PATCH v3 7/10 net/cpfl: support hairpin queue start/stop
In reply to [email protected]From: Beilei Xing <[email protected]>
This patch supports Rx/Tx hairpin queue start/stop.
--- drivers/common/idpf/idpf_common_virtchnl.c | 2 +- drivers/common/idpf/idpf_common_virtchnl.h | 3 + drivers/common/idpf/version.map | 1 + drivers/net/cpfl/cpfl_ethdev.c | 41 ++++++ drivers/net/cpfl/cpfl_rxtx.c | 153 ++++++++++++++++++--- drivers/net/cpfl/cpfl_rxtx.h | 14 ++ 6 files changed, 195 insertions(+), 19 deletions(-)
drivers/common/idpf/idpf_common_virtchnl.c +1 -1
@@ -733,7 +733,7 @@ idpf_vc_vectors_dealloc(struct idpf_vport *vport)return err; } -static int +int idpf_vc_ena_dis_one_queue (struct idpf_vport *vport,uint16_t qid,uint32_t type,bool on) {
drivers/common/idpf/idpf_common_virtchnl.h +3 -0
@@ -71,6 +71,9 @@ __rte_internalint idpf_vc_txq_config_by_info (struct idpf_vport *vport,struct virtchnl2_txq_info *txq_info,uint16_t num_qs);__rte_internal +int idpf_vc_ena_dis_one_queue(struct idpf_vport *vport, uint16_t qid, +uint32_t type,bool on); +__rte_internal int idpf_vc_queue_grps_del(struct idpf_vport *vport,uint16_t num_q_grps,struct virtchnl2_queue_group_id *qg_ids);
drivers/common/idpf/version.map +1 -0
@@ -40,6 +40,7 @@ INTERNAL { idpf_vc_cmd_execute; idpf_vc_ctlq_post_rx_buffs; idpf_vc_ctlq_recv; + idpf_vc_ena_dis_one_queue; idpf_vc_irq_map_unmap_config; idpf_vc_one_msg_read; idpf_vc_ptype_info_query;
drivers/net/cpfl/cpfl_ethdev.c +41 -0
47 lines not on this page · raw message
drivers/net/cpfl/cpfl_rxtx.c +135 -18
207 lines not on this page · raw message
drivers/net/cpfl/cpfl_rxtx.h +14 -0
@@ -39,6 +39,17 @@#define CPFL_RX_BUF_STRIDE 64 +/* The value written in the RX buffer queue tail register, +* and in WritePTR field in the TX completion queue context, +* must be a multiple of 8. +*/ +#define CPFL_HAIRPIN_Q_TAIL_AUX_VALUE 8 + +struct virtchnl2_p2p_rx_buf_desc { +__le64 reserve0; +__le64 pkt_addr;/* Packet buffer address */ +}; +struct cpfl_rxq_hairpin_info {bool hairpin_q;/* if rx queue is a hairpin queue */ uint16_t peer_txp;
@@ -90,4 +101,7 @@ int cpfl_hairpin_tx_complq_config(struct cpfl_vport *cpfl_vport);int cpfl_hairpin_txq_config (struct idpf_vport *vport,struct cpfl_tx_queue *cpfl_txq);int cpfl_hairpin_rx_bufq_config (struct cpfl_vport *cpfl_vport);int cpfl_hairpin_rxq_config (struct idpf_vport *vport,struct cpfl_rx_queue *cpfl_rxq); +int cpfl_switch_hairpin_bufq_complq (struct cpfl_vport *cpfl_vport,bool on); +int cpfl_switch_hairpin_rxtx_queue (struct cpfl_vport *cpfl_vport,uint16_t qid, +bool rx,bool on);#endif /* _CPFL_RXTX_H_ */
Signature · 1 line
2.26.2
RE: [PATCH v3 07/10] net/cpfl: support hairpin queue start/stop
Quoted 61 lines
-----Original Message-----
From: Xing, Beilei <[email protected]>
Sent: Friday, May 19, 2023 3:31 PM
To: Wu, Jingjing <[email protected]>
Cc: [email protected]; Liu, Mingxia <[email protected]>; Xing, Beilei <[email protected]>; Wang, Xiao W <[email protected]>
Subject: [PATCH v3 07/10] net/cpfl: support hairpin queue start/stopFrom: Beilei Xing <[email protected]>
This patch supports Rx/Tx hairpin queue start/stop.
Signed-off-by Xiao Wang <[email protected]>Signed-off-by Mingxia Liu <[email protected]>Signed-off-by Beilei Xing <[email protected]>--- drivers/common/idpf/idpf_common_virtchnl.c | 2 +- drivers/common/idpf/idpf_common_virtchnl.h | 3 + drivers/common/idpf/version.map | 1 + drivers/net/cpfl/cpfl_ethdev.c | 41 ++++++ drivers/net/cpfl/cpfl_rxtx.c | 153 ++++++++++++++++++--- drivers/net/cpfl/cpfl_rxtx.h | 14 ++ 6 files changed, 195 insertions(+), 19 deletions(-)drivers/common/idpf/idpf_common_virtchnl.c +1
-1@@ -733,7 +733,7 @@ idpf_vc_vectors_dealloc(struct idpf_vport *vport)return err; } -static int +int idpf_vc_ena_dis_one_queue (struct idpf_vport *vport,uint16_t qid,uint32_t type,bool on) {drivers/common/idpf/idpf_common_virtchnl.h +3
-0@@ -71,6 +71,9 @@ __rte_internalint idpf_vc_txq_config_by_info (struct idpf_vport *vport,struct virtchnl2_txq_info *txq_info,uint16_t num_qs);__rte_internal +int idpf_vc_ena_dis_one_queue(struct idpf_vport *vport, uint16_t qid, +uint32_t type,bool on); +__rte_internal int idpf_vc_queue_grps_del(struct idpf_vport *vport, uint16_t num_q_grps,drivers/common/idpf/idpf_common_virtchnl.h +0
-0struct virtchnl2_queue_group_id *qg_ids);drivers/common/idpf/version.map +0
-0
drivers/common/idpf/version.map INTERNAL { · line 46
Quoted 7 lines
drivers/common/idpf/version.map +1
-0@@ -40,6 +40,7 @@ INTERNAL { idpf_vc_cmd_execute; idpf_vc_ctlq_post_rx_buffs; idpf_vc_ctlq_recv; + idpf_vc_ena_dis_one_queue; idpf_vc_irq_map_unmap_config; idpf_vc_one_msg_read; idpf_vc_ptype_info_query;
This change is in common, better to split this patch to two.
PATCH v3 8/10 net/cpfl: enable write back based on ITR expire
In reply to [email protected]From: Beilei Xing <[email protected]>
This patch enabls write back based on ITR expire
(WR_ON_ITR) for hairpin queue.
--- drivers/common/idpf/idpf_common_device.c | 75 ++++++++++++++++++++++++ drivers/common/idpf/idpf_common_device.h | 4 ++ drivers/common/idpf/version.map | 1 + drivers/net/cpfl/cpfl_ethdev.c | 13 +++- 4 files changed, 92 insertions(+), 1 deletion(-)
drivers/common/idpf/idpf_common_device.c +75 -0
@@ -667,6 +667,81 @@ idpf_vport_irq_map_config(struct idpf_vport *vport, uint16_t nb_rx_queues)return ret; } +int +idpf_vport_irq_map_config_by_qids (struct idpf_vport *vport,uint32_t *qids,uint16_t nb_rx_queues) +{ +struct idpf_adapter *adapter = vport->adapter; +struct virtchnl2_queue_vector *qv_map; +struct idpf_hw *hw = &adapter->hw; +uint32_t dynctl_val, itrn_val; +uint32_t dynctl_reg_start; +uint32_t itrn_reg_start; +uint16_t i; +int ret; + + qv_map =rte_zmalloc ("qv_map" , + nb_rx_queues * +sizeof (struct virtchnl2_queue_vector ),0 ); +if (qv_map ==NULL ) { +DRV_LOG (ERR ,"Failed to allocate %d queue-vector map" , + nb_rx_queues); + ret = -ENOMEM ; + goto qv_map_alloc_err; + } + +/* Rx interrupt disabled, Map interrupt only for writeback */ + +/* The capability flags adapter->caps.other_caps should be +* compared with bit VIRTCHNL2_CAP_WB_ON_ITR here. The if +* condition should be updated when the FW can return the +* correct flag bits. +*/ + dynctl_reg_start = + vport->recv_vectors->vchunks.vchunks->dynctl_reg_start; + itrn_reg_start = + vport->recv_vectors->vchunks.vchunks->itrn_reg_start; + dynctl_val =IDPF_READ_REG (hw, dynctl_reg_start); +DRV_LOG (DEBUG ,"Value of dynctl_reg_start is 0x%x" , dynctl_val); + itrn_val =IDPF_READ_REG (hw, itrn_reg_start); +DRV_LOG (DEBUG ,"Value of itrn_reg_start is 0x%x" , itrn_val); +/* Force write-backs by setting WB_ON_ITR bit in DYN_CTL +* register. WB_ON_ITR and INTENA are mutually exclusive +* bits. Setting WB_ON_ITR bits means TX and RX Descs +* are written back based on ITR expiration irrespective +* of INTENA setting. +*/ +/* TBD: need to tune INTERVAL value for better performance. */ + itrn_val = (itrn_val ==0 ) ?IDPF_DFLT_INTERVAL : itrn_val; + dynctl_val =VIRTCHNL2_ITR_IDX_0 << +PF_GLINT_DYN_CTL_ITR_INDX_S | +PF_GLINT_DYN_CTL_WB_ON_ITR_M | + itrn_val <<PF_GLINT_DYN_CTL_INTERVAL_S ; +IDPF_WRITE_REG (hw, dynctl_reg_start, dynctl_val); + +for (i =0 ; i < nb_rx_queues; i++) { +/* map all queues to the same vector */ + qv_map[i].queue_id = qids[i]; + qv_map[i].vector_id = + vport->recv_vectors->vchunks.vchunks->start_vector_id; + } + vport->qv_map = qv_map; + + ret =idpf_vc_irq_map_unmap_config (vport, nb_rx_queues, true); +if (ret !=0 ) { +DRV_LOG (ERR ,"config interrupt mapping failed" ); + goto config_irq_map_err; + } + +return 0 ; + +config_irq_map_err: +rte_free (vport->qv_map); + vport->qv_map =NULL ; + +qv_map_alloc_err: +return ret; +} +int idpf_vport_irq_unmap_config (struct idpf_vport *vport,uint16_t nb_rx_queues) {
drivers/common/idpf/idpf_common_device.h +4 -0
@@ -200,5 +200,9 @@ int idpf_vport_info_init(struct idpf_vport *vport, struct virtchnl2_create_vport *vport_info);__rte_internal void idpf_vport_stats_update(struct virtchnl2_vport_stats *oes, struct virtchnl2_vport_stats *nes); +__rte_internal +int idpf_vport_irq_map_config_by_qids(struct idpf_vport *vport, +uint32_t *qids, +uint16_t nb_rx_queues);#endif /* _IDPF_COMMON_DEVICE_H_ */
drivers/common/idpf/version.map +1 -0
@@ -69,6 +69,7 @@ INTERNAL { idpf_vport_info_init; idpf_vport_init; idpf_vport_irq_map_config; + idpf_vport_irq_map_config_by_qids; idpf_vport_irq_unmap_config; idpf_vport_rss_config; idpf_vport_stats_update;
drivers/net/cpfl/cpfl_ethdev.c +12 -1
@@ -730,11 +730,22 @@ cpfl_dev_configure(struct rte_eth_dev *dev)static int cpfl_config_rx_queues_irqs (struct rte_eth_dev *dev) { +uint32_t qids[CPFL_MAX_P2P_NB_QUEUES +IDPF_DEFAULT_RXQ_NUM ] = {0 };struct cpfl_vport *cpfl_vport = dev->data->dev_private;struct idpf_vport *vport = &cpfl_vport->base;uint16_t nb_rx_queues = dev->data->nb_rx_queues; +struct cpfl_rx_queue *cpfl_rxq; +int i; -return idpf_vport_irq_map_config (vport, nb_rx_queues); +for (i =0 ; i < nb_rx_queues; i++) { + cpfl_rxq = dev->data->rx_queues[i]; +if (cpfl_rxq->hairpin_info.hairpin_q) + qids[i] =cpfl_hw_qid_get (cpfl_vport->p2p_q_chunks_info.rx_start_qid, + (i - cpfl_vport->nb_data_rxq)); +else + qids[i] =cpfl_hw_qid_get (vport->chunks_info.rx_start_qid, i); + } +return idpf_vport_irq_map_config_by_qids (vport, qids, nb_rx_queues); }/* Update hairpin_info for dev's tx hairpin queue */
Signature · 1 line
2.26.2
RE: [PATCH v3 08/10] net/cpfl: enable write back based on ITR expire
Quoted 23 lines
idpf_vport_irq_unmap_config(struct idpf_vport *vport, uint16_t nb_rx_queues){drivers/common/idpf/idpf_common_device.h +4
-0@@ -200,5 +200,9 @@ int idpf_vport_info_init(struct idpf_vport *vport, struct virtchnl2_create_vport *vport_info);__rte_internal void idpf_vport_stats_update(struct virtchnl2_vport_stats *oes, structvirtchnl2_vport_stats *nes); +__rte_internal +int idpf_vport_irq_map_config_by_qids(struct idpf_vport *vport, +uint32_t *qids, +uint16_t nb_rx_queues);#endif /* _IDPF_COMMON_DEVICE_H_ */
drivers/common/idpf/version.map +0
-0
drivers/common/idpf/version.map INTERNAL { · line 75
Quoted 7 lines
drivers/common/idpf/version.map +1
-0@@ -69,6 +69,7 @@ INTERNAL { idpf_vport_info_init; idpf_vport_init; idpf_vport_irq_map_config; + idpf_vport_irq_map_config_by_qids; idpf_vport_irq_unmap_config; idpf_vport_rss_config; idpf_vport_stats_update;
The same, split common change with net one?
Quoted 14 lines
drivers/net/cpfl/cpfl_ethdev.c +3
-0@@ -730,11 +730,22 @@ cpfl_dev_configure(struct rte_eth_dev *dev)static int cpfl_config_rx_queues_irqs (struct rte_eth_dev *dev) { +uint32_t qids[CPFL_MAX_P2P_NB_QUEUES +IDPF_DEFAULT_RXQ_NUM ] = {0 };struct cpfl_vport *cpfl_vport = dev->data->dev_private;struct idpf_vport *vport = &cpfl_vport->base;uint16_t nb_rx_queues = dev->data->nb_rx_queues; +struct cpfl_rx_queue *cpfl_rxq; +int i;
drivers/net/cpfl/cpfl_ethdev.c cpfl_dev_configure(struct rte_eth_dev *dev) · line 747
Quoted 10 lines
drivers/net/cpfl/cpfl_ethdev.c +7
-1-return idpf_vport_irq_map_config (vport, nb_rx_queues); +for (i =0 ; i < nb_rx_queues; i++) { + cpfl_rxq = dev->data->rx_queues[i]; +if (cpfl_rxq->hairpin_info.hairpin_q) + qids[i] =cpfl_hw_qid_get (cpfl_vport- >p2p_q_chunks_info.rx_start_qid, + (i - cpfl_vport->nb_data_rxq)); +else + qids[i] =cpfl_hw_qid_get (vport->chunks_info.rx_start_qid, i);
Looks like cpfl_hw_qid_get and is used cross files, how about defined it as inline or Macro in header file?
Quoted 7 lines
drivers/net/cpfl/cpfl_ethdev.c +2
-0+ } +return idpf_vport_irq_map_config_by_qids (vport, qids, nb_rx_queues); }/* Update
hairpin_infofor dev's tx hairpin queue */
--
2.26.2
PATCH v3 9/10 net/cpfl: support peer ports get
In reply to [email protected]From: Beilei Xing <[email protected]>
This patch supports get hairpin peer ports.
--- drivers/net/cpfl/cpfl_ethdev.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+)
drivers/net/cpfl/cpfl_ethdev.c +34 -0
@@ -1069,6 +1069,39 @@ cpfl_dev_close(struct rte_eth_dev *dev)return 0 ; } +static int +cpfl_hairpin_get_peer_ports (struct rte_eth_dev *dev,uint16_t *peer_ports, + __rte_unused size_t len, uint32_t tx) +{ +struct cpfl_vport *cpfl_vport = + (struct cpfl_vport *)dev->data->dev_private; +struct idpf_tx_queue *txq; +struct idpf_rx_queue *rxq; +struct cpfl_tx_queue *cpfl_txq; +struct cpfl_rx_queue *cpfl_rxq; +int i, j; + +if (tx >0 ) { +for (i = cpfl_vport->nb_data_txq, j =0 ; i < dev->data->nb_tx_queues; i++, j++) { + txq = dev->data->tx_queues[i]; +if (txq ==NULL ) +return -EINVAL ; + cpfl_txq = (struct cpfl_tx_queue *)txq; + peer_ports[j] = cpfl_txq->hairpin_info.peer_rxp; + } + }else if (tx ==0 ) { +for (i = cpfl_vport->nb_data_rxq, j =0 ; i < dev->data->nb_rx_queues; i++, j++) { + rxq = dev->data->rx_queues[i]; +if (rxq ==NULL ) +return -EINVAL ; + cpfl_rxq = (struct cpfl_rx_queue *)rxq; + peer_ports[j] = cpfl_rxq->hairpin_info.peer_txp; + } + } + +return j; +} +static const struct eth_dev_ops cpfl_eth_dev_ops = { .dev_configure = cpfl_dev_configure, .dev_close = cpfl_dev_close,
@@ -1098,6 +1131,7 @@ static const struct eth_dev_ops cpfl_eth_dev_ops = { .hairpin_cap_get = cpfl_hairpin_cap_get, .rx_hairpin_queue_setup = cpfl_rx_hairpin_queue_setup, .tx_hairpin_queue_setup = cpfl_tx_hairpin_queue_setup, + .hairpin_get_peer_ports = cpfl_hairpin_get_peer_ports, }; static int
Signature · 1 line
2.26.2
RE: [PATCH v3 09/10] net/cpfl: support peer ports get
Quoted 25 lines
-----Original Message-----
From: Xing, Beilei <[email protected]>
Sent: Friday, May 19, 2023 3:31 PM
To: Wu, Jingjing <[email protected]>
Cc: [email protected]; Liu, Mingxia <[email protected]>; Xing, Beilei <[email protected]>; Wang, Xiao W <[email protected]>
Subject: [PATCH v3 09/10] net/cpfl: support peer ports getFrom: Beilei Xing <[email protected]>
This patch supports get hairpin peer ports.
Signed-off-by Xiao Wang <[email protected]>Signed-off-by Beilei Xing <[email protected]>--- drivers/net/cpfl/cpfl_ethdev.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+)drivers/net/cpfl/cpfl_ethdev.c +0
-0
drivers/net/cpfl/cpfl_ethdev.c cpfl_dev_close(struct rte_eth_dev *dev) · line 1075
Quoted 7 lines
drivers/net/cpfl/cpfl_ethdev.c +4
-0@@ -1069,6 +1069,39 @@ cpfl_dev_close(struct rte_eth_dev *dev)return 0 ; } +static int +cpfl_hairpin_get_peer_ports (struct rte_eth_dev *dev,uint16_t *peer_ports, + __rte_unused size_t len, uint32_t tx) +{
Param len is used to identify the size of the peer ports array.
You should use it, and check if peer_ports is null. Otherwise will cause invalid access.
* array length
Quoted 44 lines
drivers/net/cpfl/cpfl_ethdev.c +29
-0+struct cpfl_vport *cpfl_vport = + (struct cpfl_vport *)dev->data->dev_private; +struct idpf_tx_queue *txq; +struct idpf_rx_queue *rxq; +struct cpfl_tx_queue *cpfl_txq; +struct cpfl_rx_queue *cpfl_rxq; +int i, j; + +if (tx >0 ) { +for (i = cpfl_vport->nb_data_txq, j =0 ; i < dev->data->nb_tx_queues; i++, j++) { + txq = dev->data->tx_queues[i]; +if (txq ==NULL ) +return -EINVAL ; + cpfl_txq = (struct cpfl_tx_queue *)txq; + peer_ports[j] = cpfl_txq->hairpin_info.peer_rxp; + } + }else if (tx ==0 ) { +for (i = cpfl_vport->nb_data_rxq, j =0 ; i < dev->data->nb_rx_queues; i++, j++) { + rxq = dev->data->rx_queues[i]; +if (rxq ==NULL ) +return -EINVAL ; + cpfl_rxq = (struct cpfl_rx_queue *)rxq; + peer_ports[j] = cpfl_rxq->hairpin_info.peer_txp; + } + } + +return j; +} +static const struct eth_dev_ops cpfl_eth_dev_ops = {drivers/net/cpfl/cpfl_ethdev.c +1
-1.dev_configure = cpfl_dev_configure, .dev_close = cpfl_dev_close,@@ -1098,6 +1131,7 @@ static const struct eth_dev_ops cpfl_eth_dev_ops = { .hairpin_cap_get = cpfl_hairpin_cap_get, .rx_hairpin_queue_setup = cpfl_rx_hairpin_queue_setup, .tx_hairpin_queue_setup = cpfl_tx_hairpin_queue_setup, + .hairpin_get_peer_ports = cpfl_hairpin_get_peer_ports, }; static int --2.26.2
PATCH v3 10/10 net/cpfl: support hairpin bind/unbind
In reply to [email protected]From: Beilei Xing <[email protected]>
This patch supports hairpin_bind/unbind ops.
--- drivers/net/cpfl/cpfl_ethdev.c | 137 +++++++++++++++++++++++++++++++++ drivers/net/cpfl/cpfl_rxtx.c | 28 +++++++ drivers/net/cpfl/cpfl_rxtx.h | 2 + 3 files changed, 167 insertions(+)
drivers/net/cpfl/cpfl_ethdev.c +137 -0
@@ -1102,6 +1102,141 @@ cpfl_hairpin_get_peer_ports(struct rte_eth_dev *dev, uint16_t *peer_ports,return j; } +static int +cpfl_hairpin_bind (struct rte_eth_dev *dev,uint16_t rx_port) +{ +struct cpfl_vport *cpfl_tx_vport = dev->data->dev_private; +struct idpf_vport *tx_vport = &cpfl_tx_vport->base; +struct cpfl_vport *cpfl_rx_vport; +struct cpfl_tx_queue *cpfl_txq; +struct cpfl_rx_queue *cpfl_rxq; +struct rte_eth_dev *peer_dev; +struct idpf_vport *rx_vport; +int err =0 ; +int i; + + err =cpfl_txq_hairpin_info_update (dev, rx_port); +if (err !=0 ) { +PMD_DRV_LOG (ERR ,"Fail to update Tx hairpin queue info." ); +return err; + } + +/* configure hairpin queues */ +for (i = cpfl_tx_vport->nb_data_txq; i < dev->data->nb_tx_queues; i++) { + cpfl_txq = dev->data->tx_queues[i]; + err =cpfl_hairpin_txq_config (tx_vport, cpfl_txq); +if (err !=0 ) { +PMD_DRV_LOG (ERR ,"Fail to configure hairpin Tx queue %u" , i); +return err; + } + } + + err =cpfl_hairpin_tx_complq_config (cpfl_tx_vport); +if (err !=0 ) { +PMD_DRV_LOG (ERR ,"Fail to config Tx completion queue" ); +return err; + } + + peer_dev = &rte_eth_devices[rx_port]; + cpfl_rx_vport = (struct cpfl_vport *)peer_dev->data->dev_private; + rx_vport = &cpfl_rx_vport->base; +cpfl_rxq_hairpin_mz_bind (peer_dev); + +for (i = cpfl_rx_vport->nb_data_rxq; i < peer_dev->data->nb_rx_queues; i++) { + cpfl_rxq = peer_dev->data->rx_queues[i]; + err =cpfl_hairpin_rxq_config (rx_vport, cpfl_rxq); +if (err !=0 ) { +PMD_DRV_LOG (ERR ,"Fail to configure hairpin Rx queue %u" , i); +return err; + } + err =cpfl_rx_queue_init (peer_dev, i); +if (err !=0 ) { +PMD_DRV_LOG (ERR ,"Fail to init hairpin Rx queue %u" , i); +return err; + } + } + + err =cpfl_hairpin_rx_bufq_config (cpfl_rx_vport); +if (err !=0 ) { +PMD_DRV_LOG (ERR ,"Fail to config Rx buffer queue" ); +return err; + } + +/* enable hairpin queues */ +for (i = cpfl_tx_vport->nb_data_txq; i < dev->data->nb_tx_queues; i++) { + cpfl_txq = dev->data->tx_queues[i]; + err =cpfl_switch_hairpin_rxtx_queue (cpfl_tx_vport, + i - cpfl_tx_vport->nb_data_txq, + false, true); +if (err !=0 ) { +PMD_DRV_LOG (ERR ,"Failed to switch hairpin TX queue %u on" , + i); +return err; + } + cpfl_txq->base.q_started = true; + } + + err =cpfl_switch_hairpin_complq (cpfl_tx_vport, true); +if (err !=0 ) { +PMD_DRV_LOG (ERR ,"Failed to switch hairpin Tx complq" ); +return err; + } + +for (i = cpfl_rx_vport->nb_data_rxq; i < peer_dev->data->nb_rx_queues; i++) { + cpfl_rxq = peer_dev->data->rx_queues[i]; + err =cpfl_switch_hairpin_rxtx_queue (cpfl_rx_vport, + i - cpfl_rx_vport->nb_data_rxq, + true, true); +if (err !=0 ) { +PMD_DRV_LOG (ERR ,"Failed to switch hairpin RX queue %u on" , + i); + } + cpfl_rxq->base.q_started = true; + } + + err =cpfl_switch_hairpin_bufq (cpfl_rx_vport, true); +if (err !=0 ) { +PMD_DRV_LOG (ERR ,"Failed to switch hairpin Rx buffer queue" ); +return err; + } + +return 0 ; +} + +static int +cpfl_hairpin_unbind (struct rte_eth_dev *dev,uint16_t rx_port) +{ +struct cpfl_vport *cpfl_tx_vport = dev->data->dev_private; +struct rte_eth_dev *peer_dev = &rte_eth_devices[rx_port]; +struct cpfl_vport *cpfl_rx_vport = peer_dev->data->dev_private; +struct cpfl_tx_queue *cpfl_txq; +struct cpfl_rx_queue *cpfl_rxq; +int i; + +/* disable hairpin queues */ +for (i = cpfl_tx_vport->nb_data_txq; i < dev->data->nb_tx_queues; i++) { + cpfl_txq = dev->data->tx_queues[i]; +cpfl_switch_hairpin_rxtx_queue (cpfl_tx_vport, + i - cpfl_tx_vport->nb_data_txq, + false, false); + cpfl_txq->base.q_started = false; + } + +cpfl_switch_hairpin_complq (cpfl_tx_vport, false); + +for (i = cpfl_rx_vport->nb_data_rxq; i < peer_dev->data->nb_rx_queues; i++) { + cpfl_rxq = peer_dev->data->rx_queues[i]; +cpfl_switch_hairpin_rxtx_queue (cpfl_rx_vport, + i - cpfl_rx_vport->nb_data_rxq, + true, false); + cpfl_rxq->base.q_started = false; + } + +cpfl_switch_hairpin_bufq (cpfl_rx_vport, false); + +return 0 ; +} +static const struct eth_dev_ops cpfl_eth_dev_ops = { .dev_configure = cpfl_dev_configure, .dev_close = cpfl_dev_close,
@@ -1132,6 +1267,8 @@ static const struct eth_dev_ops cpfl_eth_dev_ops = { .rx_hairpin_queue_setup = cpfl_rx_hairpin_queue_setup, .tx_hairpin_queue_setup = cpfl_tx_hairpin_queue_setup, .hairpin_get_peer_ports = cpfl_hairpin_get_peer_ports, + .hairpin_bind = cpfl_hairpin_bind, + .hairpin_unbind = cpfl_hairpin_unbind, }; static int
drivers/net/cpfl/cpfl_rxtx.c +28 -0
@@ -1031,6 +1031,34 @@ cpfl_switch_hairpin_bufq_complq(struct cpfl_vport *cpfl_vport, bool on)return err; } +int +cpfl_switch_hairpin_complq (struct cpfl_vport *cpfl_vport,bool on) +{ +struct idpf_vport *vport = &cpfl_vport->base; +uint32_t type; +int err, queue_id; + + type =VIRTCHNL2_QUEUE_TYPE_TX_COMPLETION ; + queue_id = cpfl_vport->p2p_tx_complq->queue_id; + err =idpf_vc_ena_dis_one_queue (vport, queue_id, type, on); + +return err; +} + +int +cpfl_switch_hairpin_bufq (struct cpfl_vport *cpfl_vport,bool on) +{ +struct idpf_vport *vport = &cpfl_vport->base; +uint32_t type; +int err, queue_id; + + type =VIRTCHNL2_QUEUE_TYPE_RX_BUFFER ; + queue_id = cpfl_vport->p2p_rx_bufq->queue_id; + err =idpf_vc_ena_dis_one_queue (vport, queue_id, type, on); + +return err; +} +int cpfl_switch_hairpin_rxtx_queue (struct cpfl_vport *cpfl_vport,uint16_t logic_qid,bool rx,bool on)
drivers/net/cpfl/cpfl_rxtx.h +2 -0
@@ -102,6 +102,8 @@ int cpfl_hairpin_txq_config(struct idpf_vport *vport, struct cpfl_tx_queue *cpflint cpfl_hairpin_rx_bufq_config (struct cpfl_vport *cpfl_vport);int cpfl_hairpin_rxq_config (struct idpf_vport *vport,struct cpfl_rx_queue *cpfl_rxq);int cpfl_switch_hairpin_bufq_complq (struct cpfl_vport *cpfl_vport,bool on); +int cpfl_switch_hairpin_complq (struct cpfl_vport *cpfl_vport,bool on); +int cpfl_switch_hairpin_bufq (struct cpfl_vport *cpfl_vport,bool on);int cpfl_switch_hairpin_rxtx_queue (struct cpfl_vport *cpfl_vport,uint16_t qid,bool rx,bool on);#endif /* _CPFL_RXTX_H_ */
Signature · 1 line
2.26.2
v4 cover net/cpfl: add hairpin queue support
In reply to [email protected]From: Beilei Xing <[email protected]>
This patchset adds hairpin queue support.
v2 changes:
- change hairpin rx queus configuration sequence.
- code refine.
v3 changes:
- Refine the patchset based on the latest code.
v4 change:
- Remove hairpin rx buffer queue's sw_ring.
- Change hairpin rx queus configuration sequence in cpfl_hairpin_bind function.
- Refind hairpin queue setup and release.
Beilei Xing (13):
net/cpfl: refine structures
common/idpf: support queue groups add/delete net/cpfl: add haipin queue group during vport init net/cpfl: support hairpin queue capbility get net/cpfl: support hairpin queue setup and release common/idpf: add queue config API net/cpfl: support hairpin queue configuration common/idpf: add switch queue API net/cpfl: support hairpin queue start/stop common/idpf: add irq map config API net/cpfl: enable write back based on ITR expire net/cpfl: support peer ports get
net/cpfl: support hairpin bind/unbind
drivers/common/idpf/idpf_common_device.c | 75 ++ drivers/common/idpf/idpf_common_device.h | 4 + drivers/common/idpf/idpf_common_virtchnl.c | 138 +++- drivers/common/idpf/idpf_common_virtchnl.h | 18 + drivers/common/idpf/version.map | 6 + drivers/net/cpfl/cpfl_ethdev.c | 605 ++++++++++++++-- drivers/net/cpfl/cpfl_ethdev.h | 35 +- drivers/net/cpfl/cpfl_rxtx.c | 785 +++++++++++++++++++-- drivers/net/cpfl/cpfl_rxtx.h | 77 ++ drivers/net/cpfl/cpfl_rxtx_vec_common.h | 21 +- 10 files changed, 1645 insertions(+), 119 deletions(-)
Signature · 1 line
2.26.2
PATCH v4 1/13 net/cpfl: refine structures
From: Beilei Xing <[email protected]>
This patch refines some structures to support hairpin queue, cpfl_rx_queue/cpfl_tx_queue/cpfl_vport.
--- drivers/net/cpfl/cpfl_ethdev.c | 85 +++++++----- drivers/net/cpfl/cpfl_ethdev.h | 6 +- drivers/net/cpfl/cpfl_rxtx.c | 175 +++++++++++++++++------- drivers/net/cpfl/cpfl_rxtx.h | 8 ++ drivers/net/cpfl/cpfl_rxtx_vec_common.h | 17 +-- 5 files changed, 196 insertions(+), 95 deletions(-)
drivers/net/cpfl/cpfl_ethdev.c +49 -36
@@ -124,7 +124,8 @@ static int cpfl_dev_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complete) { - struct idpf_vport *vport = dev->data->dev_private; + struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;struct rte_eth_link new_link;unsigned int i;
@@ -156,7 +157,8 @@ cpfl_dev_link_update(struct rte_eth_dev *dev,static int cpfl_dev_info_get (struct rte_eth_dev *dev,struct rte_eth_dev_info *dev_info) { -struct idpf_vport *vport = dev->data->dev_private; +struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;struct idpf_adapter *base = vport->adapter; dev_info->max_rx_queues = base->caps.max_rx_q;
@@ -216,7 +218,8 @@ cpfl_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)static int cpfl_dev_mtu_set (struct rte_eth_dev *dev,uint16_t mtu) { -struct idpf_vport *vport = dev->data->dev_private; +struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;/* mtu setting is forbidden if port is start */ if (dev->data->dev_started) {
@@ -256,12 +259,12 @@ static uint64_t cpfl_get_mbuf_alloc_failed_stats(struct rte_eth_dev *dev) {uint64_t mbuf_alloc_failed =0 ; -struct idpf_rx_queue *rxq; +struct cpfl_rx_queue *cpfl_rxq;int i =0 ;for (i =0 ; i < dev->data->nb_rx_queues; i++) { - rxq = dev->data->rx_queues[i]; - mbuf_alloc_failed +=__atomic_load_n (&rxq->rx_stats.mbuf_alloc_failed, + cpfl_rxq = dev->data->rx_queues[i]; + mbuf_alloc_failed +=__atomic_load_n (&cpfl_rxq->base.rx_stats.mbuf_alloc_failed, __ATOMIC_RELAXED); }
@@ -271,8 +274,8 @@ cpfl_get_mbuf_alloc_failed_stats(struct rte_eth_dev *dev)static int cpfl_dev_stats_get (struct rte_eth_dev *dev,struct rte_eth_stats *stats) { -struct idpf_vport *vport = - (struct idpf_vport *)dev->data->dev_private; +struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;struct virtchnl2_vport_stats *pstats =NULL ;int ret;
@@ -305,20 +308,20 @@ cpfl_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)static void cpfl_reset_mbuf_alloc_failed_stats (struct rte_eth_dev *dev) { -struct idpf_rx_queue *rxq; +struct cpfl_rx_queue *cpfl_rxq;int i;for (i =0 ; i < dev->data->nb_rx_queues; i++) { - rxq = dev->data->rx_queues[i]; -__atomic_store_n (&rxq->rx_stats.mbuf_alloc_failed,0 , __ATOMIC_RELAXED); + cpfl_rxq = dev->data->rx_queues[i]; +__atomic_store_n (&cpfl_rxq->base.rx_stats.mbuf_alloc_failed,0 , __ATOMIC_RELAXED); } }static int cpfl_dev_stats_reset (struct rte_eth_dev *dev) { -struct idpf_vport *vport = - (struct idpf_vport *)dev->data->dev_private; +struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;struct virtchnl2_vport_stats *pstats =NULL ;int ret;
@@ -343,8 +346,8 @@ static int cpfl_dev_xstats_reset(struct rte_eth_dev *dev)static int cpfl_dev_xstats_get (struct rte_eth_dev *dev,struct rte_eth_xstat *xstats,unsigned int n) { -struct idpf_vport *vport = - (struct idpf_vport *)dev->data->dev_private; +struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;struct virtchnl2_vport_stats *pstats =NULL ;unsigned int i;int ret;
@@ -459,7 +462,8 @@ cpfl_rss_reta_update(struct rte_eth_dev *dev, struct rte_eth_rss_reta_entry64 *reta_conf, uint16_t reta_size) { -struct idpf_vport *vport = dev->data->dev_private; +struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;struct idpf_adapter *base = vport->adapter;uint16_t idx, shift;int ret =0 ;
@@ -498,7 +502,8 @@ cpfl_rss_reta_query(struct rte_eth_dev *dev, struct rte_eth_rss_reta_entry64 *reta_conf, uint16_t reta_size) { -struct idpf_vport *vport = dev->data->dev_private; +struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;struct idpf_adapter *base = vport->adapter;uint16_t idx, shift;int ret =0 ;
@@ -536,7 +541,8 @@ static int cpfl_rss_hash_update(struct rte_eth_dev *dev, struct rte_eth_rss_conf *rss_conf) { - struct idpf_vport *vport = dev->data->dev_private; + struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;struct idpf_adapter *base = vport->adapter;int ret =0 ;
@@ -601,7 +607,8 @@ static int cpfl_rss_hash_conf_get(struct rte_eth_dev *dev, struct rte_eth_rss_conf *rss_conf) { - struct idpf_vport *vport = dev->data->dev_private; + struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;struct idpf_adapter *base = vport->adapter;int ret =0 ;
@@ -638,7 +645,8 @@ cpfl_rss_hash_conf_get(struct rte_eth_dev *dev,static int cpfl_dev_configure (struct rte_eth_dev *dev) { -struct idpf_vport *vport = dev->data->dev_private; +struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;struct rte_eth_conf *conf = &dev->data->dev_conf;struct idpf_adapter *base = vport->adapter;int ret;
@@ -710,7 +718,8 @@ cpfl_dev_configure(struct rte_eth_dev *dev)static int cpfl_config_rx_queues_irqs (struct rte_eth_dev *dev) { -struct idpf_vport *vport = dev->data->dev_private; +struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;uint16_t nb_rx_queues = dev->data->nb_rx_queues;return idpf_vport_irq_map_config (vport, nb_rx_queues);
@@ -719,14 +728,14 @@ cpfl_config_rx_queues_irqs(struct rte_eth_dev *dev)static int cpfl_start_queues (struct rte_eth_dev *dev) { -struct idpf_rx_queue *rxq; -struct idpf_tx_queue *txq; +struct cpfl_rx_queue *cpfl_rxq; +struct cpfl_tx_queue *cpfl_txq;int err =0 ;int i;for (i =0 ; i < dev->data->nb_tx_queues; i++) { - txq = dev->data->tx_queues[i]; -if (txq ==NULL || txq->tx_deferred_start) + cpfl_txq = dev->data->tx_queues[i]; +if (cpfl_txq ==NULL || cpfl_txq->base.tx_deferred_start)continue ; err =cpfl_tx_queue_start (dev, i);if (err !=0 ) {
@@ -736,8 +745,8 @@ cpfl_start_queues(struct rte_eth_dev *dev) }for (i =0 ; i < dev->data->nb_rx_queues; i++) { - rxq = dev->data->rx_queues[i]; -if (rxq ==NULL || rxq->rx_deferred_start) + cpfl_rxq = dev->data->rx_queues[i]; +if (cpfl_rxq ==NULL || cpfl_rxq->base.rx_deferred_start)continue ; err =cpfl_rx_queue_start (dev, i);if (err !=0 ) {
@@ -752,7 +761,8 @@ cpfl_start_queues(struct rte_eth_dev *dev)static int cpfl_dev_start (struct rte_eth_dev *dev) { -struct idpf_vport *vport = dev->data->dev_private; +struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;struct idpf_adapter *base = vport->adapter;struct cpfl_adapter_ext *adapter =CPFL_ADAPTER_TO_EXT (base);uint16_t num_allocated_vectors = base->caps.num_allocated_vectors;
@@ -813,7 +823,8 @@ cpfl_dev_start(struct rte_eth_dev *dev)static int cpfl_dev_stop (struct rte_eth_dev *dev) { -struct idpf_vport *vport = dev->data->dev_private; +struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;if (dev->data->dev_started ==0 )return 0 ;
@@ -832,7 +843,8 @@ cpfl_dev_stop(struct rte_eth_dev *dev)static int cpfl_dev_close (struct rte_eth_dev *dev) { -struct idpf_vport *vport = dev->data->dev_private; +struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;struct cpfl_adapter_ext *adapter =CPFL_ADAPTER_TO_EXT (vport->adapter);cpfl_dev_stop (dev);
@@ -842,7 +854,7 @@ cpfl_dev_close(struct rte_eth_dev *dev) adapter->cur_vport_nb--; dev->data->dev_private =NULL ; adapter->vports[vport->sw_idx] =NULL ; -rte_free (vport); +rte_free (cpfl_vport);return 0 ; }
@@ -1047,7 +1059,7 @@ cpfl_find_vport(struct cpfl_adapter_ext *adapter, uint32_t vport_id)int i;for (i =0 ; i < adapter->cur_vport_nb; i++) { - vport = adapter->vports[i]; + vport = &adapter->vports[i]->base;if (vport->vport_id != vport_id)continue ;else
@@ -1275,7 +1287,8 @@ cpfl_vport_idx_alloc(struct cpfl_adapter_ext *adapter)static int cpfl_dev_vport_init (struct rte_eth_dev *dev,void *init_params) { -struct idpf_vport *vport = dev->data->dev_private; +struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;struct cpfl_vport_param *param = init_params;struct cpfl_adapter_ext *adapter = param->adapter;/* for sending create vport virtchnl msg prepare */
@@ -1300,7 +1313,7 @@ cpfl_dev_vport_init(struct rte_eth_dev *dev, void *init_params) goto err; } - adapter->vports[param->idx] = vport; + adapter->vports[param->idx] = cpfl_vport; adapter->cur_vports |=RTE_BIT32 (param->devarg_id); adapter->cur_vport_nb++;
@@ -1415,7 +1428,7 @@ cpfl_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,snprintf (name,sizeof (name),"cpfl_%s_vport_0" , pci_dev->device.name); retval =rte_eth_dev_create (&pci_dev->device, name, -sizeof (struct idpf_vport ), +sizeof (struct cpfl_vport ),NULL ,NULL , cpfl_dev_vport_init, &vport_param);if (retval !=0 )
@@ -1433,7 +1446,7 @@ cpfl_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, pci_dev->device.name, devargs.req_vports[i]); retval =rte_eth_dev_create (&pci_dev->device, name, -sizeof (struct idpf_vport ), +sizeof (struct cpfl_vport ),NULL ,NULL , cpfl_dev_vport_init, &vport_param);if (retval !=0 )
drivers/net/cpfl/cpfl_ethdev.h +5 -1
@@ -69,13 +69,17 @@ struct cpfl_devargs {uint16_t req_vport_nb; }; +struct cpfl_vport { +struct idpf_vport base; +}; +struct cpfl_adapter_ext {TAILQ_ENTRY (cpfl_adapter_ext) next;struct idpf_adapter base;char name[CPFL_ADAPTER_NAME_LEN ]; -struct idpf_vport **vports; +struct cpfl_vport **vports;uint16_t max_vport_nb;uint16_t cur_vports;/* bit mask of created vport */
drivers/net/cpfl/cpfl_rxtx.c +125 -50
401 lines not on this page · raw message
drivers/net/cpfl/cpfl_rxtx.h +8 -0
@@ -23,6 +23,14 @@#define CPFL_SUPPORT_CHAIN_NUM 5 +struct cpfl_rx_queue { +struct idpf_rx_queue base; +}; + +struct cpfl_tx_queue { +struct idpf_tx_queue base; +}; +int cpfl_tx_queue_setup (struct rte_eth_dev *dev,uint16_t queue_idx,uint16_t nb_desc,unsigned int socket_id,const struct rte_eth_txconf *tx_conf);
drivers/net/cpfl/cpfl_rxtx_vec_common.h +9 -8
@@ -76,15 +76,16 @@ cpfl_rx_splitq_vec_default(struct idpf_rx_queue *rxq)static inline int cpfl_rx_vec_dev_check_default (struct rte_eth_dev *dev) { -struct idpf_vport *vport = dev->data->dev_private; -struct idpf_rx_queue *rxq; +struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base; +struct cpfl_rx_queue *cpfl_rxq;int i, default_ret, splitq_ret, ret =CPFL_SCALAR_PATH ;for (i =0 ; i < dev->data->nb_rx_queues; i++) { - rxq = dev->data->rx_queues[i]; - default_ret =cpfl_rx_vec_queue_default (rxq); + cpfl_rxq = dev->data->rx_queues[i]; + default_ret =cpfl_rx_vec_queue_default (&cpfl_rxq->base);if (vport->rxq_model ==VIRTCHNL2_QUEUE_MODEL_SPLIT ) { - splitq_ret =cpfl_rx_splitq_vec_default (rxq); + splitq_ret =cpfl_rx_splitq_vec_default (&cpfl_rxq->base); ret = splitq_ret && default_ret; }else { ret = default_ret;
@@ -100,12 +101,12 @@ static inline int cpfl_tx_vec_dev_check_default(struct rte_eth_dev *dev) {int i; -struct idpf_tx_queue *txq; +struct cpfl_tx_queue *cpfl_txq;int ret =0 ;for (i =0 ; i < dev->data->nb_tx_queues; i++) { - txq = dev->data->tx_queues[i]; - ret =cpfl_tx_vec_queue_default (txq); + cpfl_txq = dev->data->tx_queues[i]; + ret =cpfl_tx_vec_queue_default (&cpfl_txq->base);if (ret ==CPFL_SCALAR_PATH )return CPFL_SCALAR_PATH ; }
Signature · 1 line
2.26.2
PATCH v4 2/13 common/idpf: support queue groups add/delete
In reply to [email protected]From: Beilei Xing <[email protected]>
This patch adds queue group add/delete virtual channel support.
--- drivers/common/idpf/idpf_common_virtchnl.c | 66 ++++++++++++++++++++++ drivers/common/idpf/idpf_common_virtchnl.h | 9 +++ drivers/common/idpf/version.map | 2 + 3 files changed, 77 insertions(+)
drivers/common/idpf/idpf_common_virtchnl.c +66 -0
@@ -359,6 +359,72 @@ idpf_vc_vport_destroy(struct idpf_vport *vport)return err; } +int +idpf_vc_queue_grps_add (struct idpf_vport *vport, +struct virtchnl2_add_queue_groups *p2p_queue_grps_info, +uint8_t *p2p_queue_grps_out) +{ +struct idpf_adapter *adapter = vport->adapter; +struct idpf_cmd_info args; +int size, qg_info_size; +int err =-1 ; + + size =sizeof (*p2p_queue_grps_info) + + (p2p_queue_grps_info->qg_info.num_queue_groups -1 ) * +sizeof (struct virtchnl2_queue_group_info ); + +memset (&args,0 ,sizeof (args)); + args.ops =VIRTCHNL2_OP_ADD_QUEUE_GROUPS ; + args.in_args = (uint8_t *)p2p_queue_grps_info; + args.in_args_size = size; + args.out_buffer = adapter->mbx_resp; + args.out_size =IDPF_DFLT_MBX_BUF_SIZE ; + + err =idpf_vc_cmd_execute (adapter, &args); +if (err !=0 ) { +DRV_LOG (ERR , +"Failed to execute command of VIRTCHNL2_OP_ADD_QUEUE_GROUPS" ); +return err; + } + +rte_memcpy (p2p_queue_grps_out, args.out_buffer,IDPF_DFLT_MBX_BUF_SIZE ); +return 0 ; +} + +int idpf_vc_queue_grps_del (struct idpf_vport *vport, +uint16_t num_q_grps, +struct virtchnl2_queue_group_id *qg_ids) +{ +struct idpf_adapter *adapter = vport->adapter; +struct virtchnl2_delete_queue_groups *vc_del_q_grps; +struct idpf_cmd_info args; +int size; +int err; + + size =sizeof (*vc_del_q_grps) + + (num_q_grps -1 ) *sizeof (struct virtchnl2_queue_group_id ); + vc_del_q_grps =rte_zmalloc ("vc_del_q_grps" , size,0 ); + + vc_del_q_grps->vport_id = vport->vport_id; + vc_del_q_grps->num_queue_groups = num_q_grps; +memcpy (vc_del_q_grps->qg_ids, qg_ids, + num_q_grps *sizeof (struct virtchnl2_queue_group_id )); + +memset (&args,0 ,sizeof (args)); + args.ops =VIRTCHNL2_OP_DEL_QUEUE_GROUPS ; + args.in_args = (uint8_t *)vc_del_q_grps; + args.in_args_size = size; + args.out_buffer = adapter->mbx_resp; + args.out_size =IDPF_DFLT_MBX_BUF_SIZE ; + + err =idpf_vc_cmd_execute (adapter, &args); +if (err !=0 ) +DRV_LOG (ERR ,"Failed to execute command of VIRTCHNL2_OP_DEL_QUEUE_GROUPS" ); + +rte_free (vc_del_q_grps); +return err; +} +int idpf_vc_rss_key_set (struct idpf_vport *vport) {
drivers/common/idpf/idpf_common_virtchnl.h +9 -0
@@ -64,4 +64,13 @@ int idpf_vc_ctlq_recv(struct idpf_ctlq_info *cq, u16 *num_q_msg,__rte_internal int idpf_vc_ctlq_post_rx_buffs(struct idpf_hw *hw, struct idpf_ctlq_info *cq,u16 *buff_count,struct idpf_dma_mem **buffs); +__rte_internal +int idpf_vc_queue_grps_del(struct idpf_vport *vport, +uint16_t num_q_grps, +struct virtchnl2_queue_group_id *qg_ids); +__rte_internal +int +idpf_vc_queue_grps_add (struct idpf_vport *vport, +struct virtchnl2_add_queue_groups *ptp_queue_grps_info, +uint8_t *ptp_queue_grps_out);#endif /* _IDPF_COMMON_VIRTCHNL_H_ */
drivers/common/idpf/version.map +2 -0
@@ -43,6 +43,8 @@ INTERNAL { idpf_vc_irq_map_unmap_config; idpf_vc_one_msg_read; idpf_vc_ptype_info_query; + idpf_vc_queue_grps_add; + idpf_vc_queue_grps_del; idpf_vc_queue_switch; idpf_vc_queues_ena_dis; idpf_vc_rss_hash_get;
Signature · 1 line
2.26.2
PATCH v4 3/13 net/cpfl: add haipin queue group during vport init
In reply to [email protected]From: Beilei Xing <[email protected]>
This patch adds haipin queue group during vport init.
--- drivers/net/cpfl/cpfl_ethdev.c | 133 +++++++++++++++++++++++++++++++++ drivers/net/cpfl/cpfl_ethdev.h | 18 +++++ drivers/net/cpfl/cpfl_rxtx.h | 7 ++ 3 files changed, 158 insertions(+)
drivers/net/cpfl/cpfl_ethdev.c +133 -0
@@ -840,6 +840,20 @@ cpfl_dev_stop(struct rte_eth_dev *dev)return 0 ; } +static int +cpfl_p2p_queue_grps_del (struct idpf_vport *vport) +{ +struct virtchnl2_queue_group_id qg_ids[CPFL_P2P_NB_QUEUE_GRPS ] = {0 }; +int ret =0 ; + + qg_ids[0 ].queue_group_id =CPFL_P2P_QUEUE_GRP_ID ; + qg_ids[0 ].queue_group_type =VIRTCHNL2_QUEUE_GROUP_P2P ; + ret =idpf_vc_queue_grps_del (vport,CPFL_P2P_NB_QUEUE_GRPS , qg_ids); +if (ret) +PMD_DRV_LOG (ERR ,"Failed to delete p2p queue groups" ); +return ret; +} +static int cpfl_dev_close (struct rte_eth_dev *dev) {
@@ -848,7 +862,12 @@ cpfl_dev_close(struct rte_eth_dev *dev)struct cpfl_adapter_ext *adapter =CPFL_ADAPTER_TO_EXT (vport->adapter);cpfl_dev_stop (dev); + +if (!adapter->base.is_rx_singleq && !adapter->base.is_tx_singleq) +cpfl_p2p_queue_grps_del (vport); +idpf_vport_deinit (vport); +rte_free (cpfl_vport->p2p_q_chunks_info); adapter->cur_vports &= ~RTE_BIT32 (vport->devarg_id); adapter->cur_vport_nb--;
@@ -1284,6 +1303,96 @@ cpfl_vport_idx_alloc(struct cpfl_adapter_ext *adapter)return vport_idx; } +static int +cpfl_p2p_q_grps_add (struct idpf_vport *vport, +struct virtchnl2_add_queue_groups *p2p_queue_grps_info, +uint8_t *p2p_q_vc_out_info) +{ +int ret; + + p2p_queue_grps_info->vport_id = vport->vport_id; + p2p_queue_grps_info->qg_info.num_queue_groups =CPFL_P2P_NB_QUEUE_GRPS ; + p2p_queue_grps_info->qg_info.groups[0 ].num_rx_q =CPFL_MAX_P2P_NB_QUEUES ; + p2p_queue_grps_info->qg_info.groups[0 ].num_rx_bufq =CPFL_P2P_NB_RX_BUFQ ; + p2p_queue_grps_info->qg_info.groups[0 ].num_tx_q =CPFL_MAX_P2P_NB_QUEUES ; + p2p_queue_grps_info->qg_info.groups[0 ].num_tx_complq =CPFL_P2P_NB_TX_COMPLQ ; + p2p_queue_grps_info->qg_info.groups[0 ].qg_id.queue_group_id =CPFL_P2P_QUEUE_GRP_ID ; + p2p_queue_grps_info->qg_info.groups[0 ].qg_id.queue_group_type =VIRTCHNL2_QUEUE_GROUP_P2P ; + p2p_queue_grps_info->qg_info.groups[0 ].rx_q_grp_info.rss_lut_size =0 ; + p2p_queue_grps_info->qg_info.groups[0 ].tx_q_grp_info.tx_tc =0 ; + p2p_queue_grps_info->qg_info.groups[0 ].tx_q_grp_info.priority =0 ; + p2p_queue_grps_info->qg_info.groups[0 ].tx_q_grp_info.is_sp =0 ; + p2p_queue_grps_info->qg_info.groups[0 ].tx_q_grp_info.pir_weight =0 ; + + ret =idpf_vc_queue_grps_add (vport, p2p_queue_grps_info, p2p_q_vc_out_info); +if (ret !=0 ) { +PMD_DRV_LOG (ERR ,"Failed to add p2p queue groups." ); +return ret; + } + +return ret; +} + +static int +cpfl_p2p_queue_info_init (struct cpfl_vport *cpfl_vport, +struct virtchnl2_add_queue_groups *p2p_q_vc_out_info) +{ +struct p2p_queue_chunks_info *p2p_q_chunks_info = cpfl_vport->p2p_q_chunks_info; +struct virtchnl2_queue_reg_chunks *vc_chunks_out; +int i, type; + +if (p2p_q_vc_out_info->qg_info.groups[0 ].qg_id.queue_group_type != +VIRTCHNL2_QUEUE_GROUP_P2P ) { +PMD_DRV_LOG (ERR ,"Add queue group response mismatch." ); +return -EINVAL ; + } + + vc_chunks_out = &p2p_q_vc_out_info->qg_info.groups[0 ].chunks; + +for (i =0 ; i < vc_chunks_out->num_chunks; i++) { + type = vc_chunks_out->chunks[i].type; +switch (type) { +case VIRTCHNL2_QUEUE_TYPE_TX : + p2p_q_chunks_info->tx_start_qid = + vc_chunks_out->chunks[i].start_queue_id; + p2p_q_chunks_info->tx_qtail_start = + vc_chunks_out->chunks[i].qtail_reg_start; + p2p_q_chunks_info->tx_qtail_spacing = + vc_chunks_out->chunks[i].qtail_reg_spacing; +break ; +case VIRTCHNL2_QUEUE_TYPE_RX : + p2p_q_chunks_info->rx_start_qid = + vc_chunks_out->chunks[i].start_queue_id; + p2p_q_chunks_info->rx_qtail_start = + vc_chunks_out->chunks[i].qtail_reg_start; + p2p_q_chunks_info->rx_qtail_spacing = + vc_chunks_out->chunks[i].qtail_reg_spacing; +break ; +case VIRTCHNL2_QUEUE_TYPE_TX_COMPLETION : + p2p_q_chunks_info->tx_compl_start_qid = + vc_chunks_out->chunks[i].start_queue_id; + p2p_q_chunks_info->tx_compl_qtail_start = + vc_chunks_out->chunks[i].qtail_reg_start; + p2p_q_chunks_info->tx_compl_qtail_spacing = + vc_chunks_out->chunks[i].qtail_reg_spacing; +break ; +case VIRTCHNL2_QUEUE_TYPE_RX_BUFFER : + p2p_q_chunks_info->rx_buf_start_qid = + vc_chunks_out->chunks[i].start_queue_id; + p2p_q_chunks_info->rx_buf_qtail_start = + vc_chunks_out->chunks[i].qtail_reg_start; + p2p_q_chunks_info->rx_buf_qtail_spacing = + vc_chunks_out->chunks[i].qtail_reg_spacing; +break ; +default : +PMD_DRV_LOG (ERR ,"Unsupported queue type" ); +break ; + } + } + +return 0 ; +} +static int cpfl_dev_vport_init (struct rte_eth_dev *dev,void *init_params) {
@@ -1293,6 +1402,8 @@ cpfl_dev_vport_init(struct rte_eth_dev *dev, void *init_params)struct cpfl_adapter_ext *adapter = param->adapter;/* for sending create vport virtchnl msg prepare */ struct virtchnl2_create_vport create_vport_info; +struct virtchnl2_add_queue_groups p2p_queue_grps_info; +uint8_t p2p_q_vc_out_info[IDPF_DFLT_MBX_BUF_SIZE ] = {0 };int ret =0 ; dev->dev_ops = &cpfl_eth_dev_ops;
@@ -1327,6 +1438,28 @@ cpfl_dev_vport_init(struct rte_eth_dev *dev, void *init_params)rte_ether_addr_copy ((struct rte_ether_addr *)vport->default_mac_addr, &dev->data->mac_addrs[0 ]); +if (!adapter->base.is_rx_singleq && !adapter->base.is_tx_singleq) { +memset (&p2p_queue_grps_info,0 ,sizeof (p2p_queue_grps_info)); + ret =cpfl_p2p_q_grps_add (vport, &p2p_queue_grps_info, p2p_q_vc_out_info); +if (ret !=0 ) { +PMD_INIT_LOG (ERR ,"Failed to add p2p queue group." ); +return 0 ; + } + cpfl_vport->p2p_q_chunks_info =rte_zmalloc (NULL , +sizeof (struct p2p_queue_chunks_info ),0 ); +if (cpfl_vport->p2p_q_chunks_info ==NULL ) { +PMD_INIT_LOG (ERR ,"Failed to allocate p2p queue info." ); +cpfl_p2p_queue_grps_del (vport); +return 0 ; + } + ret =cpfl_p2p_queue_info_init (cpfl_vport, + (struct virtchnl2_add_queue_groups *)p2p_q_vc_out_info); +if (ret !=0 ) { +PMD_INIT_LOG (ERR ,"Failed to init p2p queue info." ); +cpfl_p2p_queue_grps_del (vport); + } + } +return 0 ; err_mac_addrs:
drivers/net/cpfl/cpfl_ethdev.h +18 -0
@@ -56,6 +56,7 @@/* Device IDs */ #define IDPF_DEV_ID_CPF 0x1453 +#define VIRTCHNL2_QUEUE_GROUP_P2P 0x100struct cpfl_vport_param {struct cpfl_adapter_ext *adapter;
@@ -69,8 +70,25 @@ struct cpfl_devargs {uint16_t req_vport_nb; }; +struct p2p_queue_chunks_info { +uint32_t tx_start_qid; +uint32_t rx_start_qid; +uint32_t tx_compl_start_qid; +uint32_t rx_buf_start_qid; + +uint64_t tx_qtail_start; +uint32_t tx_qtail_spacing; +uint64_t rx_qtail_start; +uint32_t rx_qtail_spacing; +uint64_t tx_compl_qtail_start; +uint32_t tx_compl_qtail_spacing; +uint64_t rx_buf_qtail_start; +uint32_t rx_buf_qtail_spacing; +}; +struct cpfl_vport {struct idpf_vport base; +struct p2p_queue_chunks_info *p2p_q_chunks_info; };struct cpfl_adapter_ext {
drivers/net/cpfl/cpfl_rxtx.h +7 -0
@@ -13,6 +13,13 @@#define CPFL_MIN_RING_DESC 32#define CPFL_MAX_RING_DESC 4096#define CPFL_DMA_MEM_ALIGN 4096 + +#define CPFL_MAX_P2P_NB_QUEUES 16 +#define CPFL_P2P_NB_RX_BUFQ 1 +#define CPFL_P2P_NB_TX_COMPLQ 1 +#define CPFL_P2P_NB_QUEUE_GRPS 1 +#define CPFL_P2P_QUEUE_GRP_ID 1 +/* Base address of the HW descriptor ring should be 128B aligned. */ #define CPFL_RING_BASE_ALIGN 128
Signature · 1 line
2.26.2
PATCH v4 4/13 net/cpfl: support hairpin queue capbility get
In reply to [email protected]From: Beilei Xing <[email protected]>
This patch adds hairpin_cap_get ops support.
--- drivers/net/cpfl/cpfl_ethdev.c | 18 ++++++++++++++++++ drivers/net/cpfl/cpfl_rxtx.h | 3 +++ 2 files changed, 21 insertions(+)
drivers/net/cpfl/cpfl_ethdev.c +18 -0
@@ -154,6 +154,23 @@ cpfl_dev_link_update(struct rte_eth_dev *dev,return rte_eth_linkstatus_set (dev, &new_link); } +static int +cpfl_hairpin_cap_get (struct rte_eth_dev *dev, +struct rte_eth_hairpin_cap *cap) +{ +struct cpfl_vport *cpfl_vport = dev->data->dev_private; + +if (cpfl_vport->p2p_q_chunks_info ==NULL ) +return -ENOTSUP ; + + cap->max_nb_queues =CPFL_MAX_P2P_NB_QUEUES ; + cap->max_rx_2_tx =CPFL_MAX_HAIRPINQ_RX_2_TX ; + cap->max_tx_2_rx =CPFL_MAX_HAIRPINQ_TX_2_RX ; + cap->max_nb_desc =CPFL_MAX_HAIRPINQ_NB_DESC ; + +return 0 ; +} +static int cpfl_dev_info_get (struct rte_eth_dev *dev,struct rte_eth_dev_info *dev_info) {
@@ -904,6 +921,7 @@ static const struct eth_dev_ops cpfl_eth_dev_ops = { .xstats_get = cpfl_dev_xstats_get, .xstats_get_names = cpfl_dev_xstats_get_names, .xstats_reset = cpfl_dev_xstats_reset, + .hairpin_cap_get = cpfl_hairpin_cap_get, }; static int
drivers/net/cpfl/cpfl_rxtx.h +3 -0
@@ -14,6 +14,9 @@#define CPFL_MAX_RING_DESC 4096#define CPFL_DMA_MEM_ALIGN 4096 +#define CPFL_MAX_HAIRPINQ_RX_2_TX 1 +#define CPFL_MAX_HAIRPINQ_TX_2_RX 1 +#define CPFL_MAX_HAIRPINQ_NB_DESC 1024#define CPFL_MAX_P2P_NB_QUEUES 16#define CPFL_P2P_NB_RX_BUFQ 1#define CPFL_P2P_NB_TX_COMPLQ 1
Signature · 1 line
2.26.2
PATCH v4 5/13 net/cpfl: support hairpin queue setup and release
In reply to [email protected]From: Beilei Xing <[email protected]>
Support hairpin Rx/Tx queue setup and release.
--- drivers/net/cpfl/cpfl_ethdev.c | 6 + drivers/net/cpfl/cpfl_ethdev.h | 11 + drivers/net/cpfl/cpfl_rxtx.c | 353 +++++++++++++++++++++++- drivers/net/cpfl/cpfl_rxtx.h | 36 +++ drivers/net/cpfl/cpfl_rxtx_vec_common.h | 4 + 5 files changed, 409 insertions(+), 1 deletion(-)
drivers/net/cpfl/cpfl_ethdev.c +6 -0
@@ -879,6 +879,10 @@ cpfl_dev_close(struct rte_eth_dev *dev)struct cpfl_adapter_ext *adapter =CPFL_ADAPTER_TO_EXT (vport->adapter);cpfl_dev_stop (dev); +if (cpfl_vport->p2p_mp) { +rte_mempool_free (cpfl_vport->p2p_mp); + cpfl_vport->p2p_mp =NULL ; + }if (!adapter->base.is_rx_singleq && !adapter->base.is_tx_singleq)cpfl_p2p_queue_grps_del (vport);
@@ -922,6 +926,8 @@ static const struct eth_dev_ops cpfl_eth_dev_ops = { .xstats_get_names = cpfl_dev_xstats_get_names, .xstats_reset = cpfl_dev_xstats_reset, .hairpin_cap_get = cpfl_hairpin_cap_get, + .rx_hairpin_queue_setup = cpfl_rx_hairpin_queue_setup, + .tx_hairpin_queue_setup = cpfl_tx_hairpin_queue_setup, }; static int
drivers/net/cpfl/cpfl_ethdev.h +11 -0
@@ -89,6 +89,17 @@ struct p2p_queue_chunks_info {struct cpfl_vport {struct idpf_vport base;struct p2p_queue_chunks_info *p2p_q_chunks_info; + +struct rte_mempool *p2p_mp; + +uint16_t nb_data_rxq; +uint16_t nb_data_txq; +uint16_t nb_p2p_rxq; +uint16_t nb_p2p_txq; + +struct idpf_rx_queue *p2p_rx_bufq; +struct idpf_tx_queue *p2p_tx_complq; +bool p2p_manual_bind; };struct cpfl_adapter_ext {
drivers/net/cpfl/cpfl_rxtx.c +352 -1
389 lines not on this page · raw message
drivers/net/cpfl/cpfl_rxtx.h +36 -0
@@ -22,6 +22,11 @@#define CPFL_P2P_NB_TX_COMPLQ 1#define CPFL_P2P_NB_QUEUE_GRPS 1#define CPFL_P2P_QUEUE_GRP_ID 1 +#define CPFL_P2P_DESC_LEN 16 +#define CPFL_P2P_NB_MBUF 4096 +#define CPFL_P2P_CACHE_SIZE 250 +#define CPFL_P2P_MBUF_SIZE 2048 +#define CPFL_P2P_RING_BUF 128/* Base address of the HW descriptor ring should be 128B aligned. */ #define CPFL_RING_BASE_ALIGN 128
@@ -33,14 +38,40 @@#define CPFL_SUPPORT_CHAIN_NUM 5 +struct cpfl_rxq_hairpin_info { +bool hairpin_q;/* if rx queue is a hairpin queue */ +uint16_t peer_txp; +uint16_t peer_txq_id; +}; +struct cpfl_rx_queue {struct idpf_rx_queue base; +struct cpfl_rxq_hairpin_info hairpin_info; +}; + +struct cpfl_txq_hairpin_info { +bool hairpin_q;/* if tx queue is a hairpin queue */ +uint16_t peer_rxp; +uint16_t peer_rxq_id; };struct cpfl_tx_queue {struct idpf_tx_queue base; +struct cpfl_txq_hairpin_info hairpin_info; }; +static inline uint16_t +cpfl_hw_qid_get (uint16_t start_qid,uint16_t offset) +{ +return start_qid + offset; +} + +static inline uint64_t +cpfl_hw_qtail_get (uint64_t tail_start,uint16_t offset,uint64_t tail_spacing) +{ +return tail_start + offset * tail_spacing; +} +int cpfl_tx_queue_setup (struct rte_eth_dev *dev,uint16_t queue_idx,uint16_t nb_desc,unsigned int socket_id,const struct rte_eth_txconf *tx_conf);
@@ -59,4 +90,9 @@ void cpfl_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid);void cpfl_dev_rx_queue_release (struct rte_eth_dev *dev,uint16_t qid);void cpfl_set_rx_function (struct rte_eth_dev *dev);void cpfl_set_tx_function (struct rte_eth_dev *dev); +int cpfl_rx_hairpin_queue_setup (struct rte_eth_dev *dev,uint16_t queue_idx, +uint16_t nb_desc,const struct rte_eth_hairpin_conf *conf); +int cpfl_tx_hairpin_queue_setup (struct rte_eth_dev *dev,uint16_t queue_idx, +uint16_t nb_desc, +const struct rte_eth_hairpin_conf *conf);#endif /* _CPFL_RXTX_H_ */
drivers/net/cpfl/cpfl_rxtx_vec_common.h +4 -0
@@ -85,6 +85,8 @@ cpfl_rx_vec_dev_check_default(struct rte_eth_dev *dev) cpfl_rxq = dev->data->rx_queues[i]; default_ret =cpfl_rx_vec_queue_default (&cpfl_rxq->base);if (vport->rxq_model ==VIRTCHNL2_QUEUE_MODEL_SPLIT ) { +if (cpfl_rxq->hairpin_info.hairpin_q) +continue ; splitq_ret =cpfl_rx_splitq_vec_default (&cpfl_rxq->base); ret = splitq_ret && default_ret; }else {
@@ -106,6 +108,8 @@ cpfl_tx_vec_dev_check_default(struct rte_eth_dev *dev)for (i =0 ; i < dev->data->nb_tx_queues; i++) { cpfl_txq = dev->data->tx_queues[i]; +if (cpfl_txq->hairpin_info.hairpin_q) +continue ; ret =cpfl_tx_vec_queue_default (&cpfl_txq->base);if (ret ==CPFL_SCALAR_PATH )return CPFL_SCALAR_PATH ;
Signature · 1 line
2.26.2
RE: [PATCH v4 05/13] net/cpfl: support hairpin queue setup and release
Quoted 148 lines
-----Original Message-----
From: Xing, Beilei <[email protected]>
Sent: Friday, May 26, 2023 3:39 PM
To: Wu, Jingjing <[email protected]>
Cc: [email protected]; Liu, Mingxia <[email protected]>; Xing, Beilei <[email protected]>; Wang, Xiao W <[email protected]>
Subject: [PATCH v4 05/13] net/cpfl: support hairpin queue setup and releaseFrom: Beilei Xing <[email protected]>
Support hairpin Rx/Tx queue setup and release.
Signed-off-by Xiao Wang <[email protected]>Signed-off-by Mingxia Liu <[email protected]>Signed-off-by Beilei Xing <[email protected]>--- drivers/net/cpfl/cpfl_ethdev.c | 6 + drivers/net/cpfl/cpfl_ethdev.h | 11 + drivers/net/cpfl/cpfl_rxtx.c | 353 +++++++++++++++++++++++- drivers/net/cpfl/cpfl_rxtx.h | 36 +++ drivers/net/cpfl/cpfl_rxtx_vec_common.h | 4 + 5 files changed, 409 insertions(+), 1 deletion(-)drivers/net/cpfl/cpfl_ethdev.c index renamed from drivers/net/cpfl/cpfl_ethdev.c +0
-0
40b4515539..b17c538ec2100644drivers/net/cpfl/cpfl_ethdev.c +4
-0@@ -879,6 +879,10 @@ cpfl_dev_close(struct rte_eth_dev *dev)struct cpfl_adapter_ext *adapter =CPFL_ADAPTER_TO_EXT (vport- >adapter);cpfl_dev_stop (dev); +if (cpfl_vport->p2p_mp) { +rte_mempool_free (cpfl_vport->p2p_mp); + cpfl_vport->p2p_mp =NULL ; + }if (!adapter->base.is_rx_singleq && !adapter->base.is_tx_singleq)drivers/net/cpfl/cpfl_ethdev.c +7
-0cpfl_p2p_queue_grps_del (vport);@@ -922,6 +926,8 @@ static const struct eth_dev_ops cpfl_eth_dev_ops = { .xstats_get_names = cpfl_dev_xstats_get_names, .xstats_reset = cpfl_dev_xstats_reset, .hairpin_cap_get = cpfl_hairpin_cap_get, + .rx_hairpin_queue_setup = cpfl_rx_hairpin_queue_setup, + .tx_hairpin_queue_setup = cpfl_tx_hairpin_queue_setup, }; +int +cpfl_rx_hairpin_queue_setup (struct rte_eth_dev *dev,uint16_t queue_idx, +uint16_t nb_desc, +const struct rte_eth_hairpin_conf *conf) { + struct cpfl_vport *cpfl_vport = (struct cpfl_vport *)dev->data-Quoted 1 line
dev_private;drivers/net/cpfl/cpfl_ethdev.c +13
-0+struct idpf_vport *vport = &cpfl_vport->base; +struct idpf_adapter *adapter_base = vport->adapter; +uint16_t logic_qid = cpfl_vport->nb_p2p_rxq; +struct cpfl_rxq_hairpin_info *hairpin_info; +struct cpfl_rx_queue *cpfl_rxq; +struct idpf_rx_queue *bufq1 =NULL ; +struct idpf_rx_queue *rxq; +uint16_t peer_port, peer_q; +uint16_t qid; +int ret; + +if (vport->rxq_model ==VIRTCHNL2_QUEUE_MODEL_SINGLE ) { + PMD_INIT_LOG(ERR, "Only spilt queue model supports hairpinqueue.");
drivers/net/cpfl/cpfl_ethdev.c +5
-0+return -EINVAL ; + } + +if (conf->peer_count !=1 ) { + PMD_INIT_LOG(ERR, "Can't support Rx hairpin queue peercount %d",
conf->peer_count);drivers/net/cpfl/cpfl_ethdev.c +10
-0+return -EINVAL ; + } + + peer_port = conf->peers[0 ].port; + peer_q = conf->peers[0 ].queue; + +if (nb_desc %CPFL_ALIGN_RING_DESC !=0 || + nb_desc >CPFL_MAX_RING_DESC || + nb_desc <CPFL_MIN_RING_DESC ) { + PMD_INIT_LOG(ERR, "Number (%u) of receive descriptors isinvalid",
nb_desc);drivers/net/cpfl/cpfl_ethdev.c +16
-0+return -EINVAL ; + } + +/* Free memory if needed */ +if (dev->data->rx_queues[queue_idx]) { +cpfl_rx_queue_release (dev->data->rx_queues[queue_idx]); + dev->data->rx_queues[queue_idx] =NULL ; + } + +/* Setup Rx description queue */ + cpfl_rxq =rte_zmalloc_socket ("cpfl hairpin rxq" , +sizeof (struct cpfl_rx_queue ), +RTE_CACHE_LINE_SIZE , +SOCKET_ID_ANY ); +if (!cpfl_rxq) { + PMD_INIT_LOG(ERR, "Failed to allocate memory for rx queuedata structure");
drivers/net/cpfl/cpfl_ethdev.c +7
-0+return -ENOMEM ; + } + + rxq = &cpfl_rxq->base; + hairpin_info = &cpfl_rxq->hairpin_info; + rxq->nb_rx_desc = nb_desc *2 ; + rxq->queue_id = cpfl_hw_qid_get(cpfl_vport->p2p_q_chunks_info-Quoted 1 line
rx_start_qid,logic_qid);drivers/net/cpfl/cpfl_ethdev.c +19
-0+ rxq->port_id = dev->data->port_id; + rxq->adapter = adapter_base; + rxq->rx_buf_len =CPFL_P2P_MBUF_SIZE -RTE_PKTMBUF_HEADROOM ; + hairpin_info->hairpin_q = true; + hairpin_info->peer_txp = peer_port; + hairpin_info->peer_txq_id = peer_q; + +if (conf->manual_bind !=0 ) + cpfl_vport->p2p_manual_bind = true; +else + cpfl_vport->p2p_manual_bind = false; + +if (cpfl_vport->p2p_rx_bufq ==NULL ) { + bufq1 =rte_zmalloc_socket ("hairpin rx bufq1" , +sizeof (struct idpf_rx_queue ), +RTE_CACHE_LINE_SIZE , +SOCKET_ID_ANY ); +if (!bufq1) { + PMD_INIT_LOG(ERR, "Failed to allocate memory forhairpin Rx buffer queue 1.");
drivers/net/cpfl/cpfl_ethdev.c +7
-0+ ret = -ENOMEM ; + goto err_alloc_bufq1; + } + qid =2 * logic_qid; + ret =cpfl_rx_hairpin_bufq_setup (dev, bufq1, qid, nb_desc); +if (ret) { + PMD_INIT_LOG(ERR, "Failed to setup hairpin Rx bufferqueue 1");
drivers/net/cpfl/cpfl_ethdev.c +9
-0+ ret = -EINVAL ; + goto err_setup_bufq1; + } + cpfl_vport->p2p_rx_bufq = bufq1; + } + + rxq->bufq1 = cpfl_vport->p2p_rx_bufq; + rxq->bufq2 =NULL ; +
drivers/net/cpfl/cpfl_ethdev.c
Quoted 10 lines
drivers/net/cpfl/cpfl_ethdev.c +10
-0+ cpfl_vport->nb_p2p_rxq++; + rxq->q_set = true; + dev->data->rx_queues[queue_idx] = cpfl_rxq; + +return 0 ; + +err_setup_bufq1: +rte_free (bufq1); +err_alloc_bufq1: +rte_free (rxq);
[Liu, Mingxia] Here should free cpfl_rxq, right?
Quoted 79 lines
drivers/net/cpfl/cpfl_ethdev.c +24
-0+ +return ret; +} + +int +cpfl_tx_hairpin_queue_setup (struct rte_eth_dev *dev,uint16_t queue_idx, +uint16_t nb_desc, +const struct rte_eth_hairpin_conf *conf) { +struct cpfl_vport *cpfl_vport = + (struct cpfl_vport *)dev->data->dev_private; + +struct idpf_vport *vport = &cpfl_vport->base; +struct idpf_adapter *adapter_base = vport->adapter; +uint16_t logic_qid = cpfl_vport->nb_p2p_txq; +struct cpfl_txq_hairpin_info *hairpin_info; +struct idpf_hw *hw = &adapter_base->hw; +struct cpfl_tx_queue *cpfl_txq; +struct idpf_tx_queue *txq, *cq; +const struct rte_memzone *mz; +uint32_t ring_size; +uint16_t peer_port, peer_q; + +if (vport->txq_model ==VIRTCHNL2_QUEUE_MODEL_SINGLE ) { + PMD_INIT_LOG(ERR, "Only spilt queue model supports hairpinqueue.");
drivers/net/cpfl/cpfl_ethdev.c +5
-0+return -EINVAL ; + } + +if (conf->peer_count !=1 ) { + PMD_INIT_LOG(ERR, "Can't support Tx hairpin queue peercount %d",
conf->peer_count);drivers/net/cpfl/cpfl_ethdev.c +10
-0+return -EINVAL ; + } + + peer_port = conf->peers[0 ].port; + peer_q = conf->peers[0 ].queue; + +if (nb_desc %CPFL_ALIGN_RING_DESC !=0 || + nb_desc >CPFL_MAX_RING_DESC || + nb_desc <CPFL_MIN_RING_DESC ) { + PMD_INIT_LOG(ERR, "Number (%u) of transmit descriptors isinvalid",
drivers/net/cpfl/cpfl_ethdev.c +17
-0+ nb_desc); +return -EINVAL ; + } + +/* Free memory if needed. */ +if (dev->data->tx_queues[queue_idx]) { +cpfl_tx_queue_release (dev->data->tx_queues[queue_idx]); + dev->data->tx_queues[queue_idx] =NULL ; + } + +/* Allocate the TX queue data structure. */ + cpfl_txq =rte_zmalloc_socket ("cpfl hairpin txq" , +sizeof (struct cpfl_tx_queue ), +RTE_CACHE_LINE_SIZE , +SOCKET_ID_ANY ); +if (!cpfl_txq) { + PMD_INIT_LOG(ERR, "Failed to allocate memory for tx queuestructure");
drivers/net/cpfl/cpfl_ethdev.c +8
-0+return -ENOMEM ; + } + + txq = &cpfl_txq->base; + hairpin_info = &cpfl_txq->hairpin_info; +/* Txq ring length should be 2 times of Tx completion queue size. */ + txq->nb_tx_desc = nb_desc *2 ; + txq->queue_id = cpfl_hw_qid_get(cpfl_vport->p2p_q_chunks_info-Quoted 1 line
tx_start_qid,logic_qid);drivers/net/cpfl/cpfl_ethdev.c +10
-0+ txq->port_id = dev->data->port_id; + hairpin_info->hairpin_q = true; + hairpin_info->peer_rxp = peer_port; + hairpin_info->peer_rxq_id = peer_q; + +if (conf->manual_bind !=0 ) + cpfl_vport->p2p_manual_bind = true; +else + cpfl_vport->p2p_manual_bind = false; +
drivers/net/cpfl/cpfl_ethdev.c
Quoted 10 lines
drivers/net/cpfl/cpfl_ethdev.c +10
-0+/* Always Tx hairpin queue allocates Tx HW ring */ + ring_size =RTE_ALIGN (txq->nb_tx_desc *CPFL_P2P_DESC_LEN , +CPFL_DMA_MEM_ALIGN ); + mz =rte_eth_dma_zone_reserve (dev,"hairpin_tx_ring" , logic_qid, + ring_size +CPFL_P2P_RING_BUF , +CPFL_RING_BASE_ALIGN , + dev->device->numa_node); +if (!mz) { +PMD_INIT_LOG (ERR ,"Failed to reserve DMA memory for TX" ); +rte_free (txq);
[Liu, Mingxia] Here should free cpfl_txq, right?
Quoted 22 lines
drivers/net/cpfl/cpfl_ethdev.c +10
-0+return -ENOMEM ; + } + + txq->tx_ring_phys_addr = mz->iova; + txq->desc_ring = mz->addr; + txq->mz = mz; + +cpfl_tx_hairpin_descq_reset (txq); + txq->qtx_tail = hw->hw_addr + + cpfl_hw_qtail_get(cpfl_vport->p2p_q_chunks_info-Quoted 1 line
tx_qtail_start,drivers/net/cpfl/cpfl_ethdev.c +1
-0+ logic_qid, cpfl_vport->p2p_q_chunks_info-Quoted 1 line
tx_qtail_spacing);drivers/net/cpfl/cpfl_ethdev.c +9
-0+ txq->ops = &def_txq_ops; + +if (cpfl_vport->p2p_tx_complq ==NULL ) { + cq =rte_zmalloc_socket ("cpfl hairpin cq" , +sizeof (struct idpf_tx_queue ), +RTE_CACHE_LINE_SIZE , + dev->device->numa_node); +if (!cq) { + PMD_INIT_LOG(ERR, "Failed to allocate memory for tx
Quoted 1 line
queue structure");
[Liu, Mingxia] Before returning, should free some resource, such as free cpfl_txq, right?
Quoted 20 lines
drivers/net/cpfl/cpfl_ethdev.c +5
-0+return -ENOMEM ; + } + + cq->nb_tx_desc = nb_desc; + cq->queue_id = cpfl_hw_qid_get(cpfl_vport-Quoted 1 line
p2p_q_chunks_info->tx_compl_start_qid,drivers/net/cpfl/cpfl_ethdev.c +7
-0+ 0); + cq->port_id = dev->data->port_id; + +/* Tx completion queue always allocates the HW ring */ + ring_size =RTE_ALIGN (cq->nb_tx_desc *CPFL_P2P_DESC_LEN , +CPFL_DMA_MEM_ALIGN ); + mz = rte_eth_dma_zone_reserve(dev, "hairpin_tx_compl_ring",
logic_qid,drivers/net/cpfl/cpfl_ethdev.c +5
-0+ ring_size +CPFL_P2P_RING_BUF , +CPFL_RING_BASE_ALIGN , + dev->device->numa_node); +if (!mz) { + PMD_INIT_LOG(ERR, "Failed to reserve DMA memoryfor TX completion queue");
drivers/net/cpfl/cpfl_ethdev.c
Quoted 1 line
drivers/net/cpfl/cpfl_ethdev.c +1
-0+rte_free (txq);
[Liu, Mingxia]Here should free cpfl_txq, right?In addition, should cq resource be released?
RE: [PATCH v4 05/13] net/cpfl: support hairpin queue setup and release
Quoted 273 lines
-----Original Message-----
From: Liu, Mingxia
Sent: Tuesday, May 30, 2023 10:27 AM
To: Xing, Beilei <[email protected]>; Wu, Jingjing <[email protected]>
Cc: [email protected]; Wang, Xiao W <[email protected]>
Subject: RE: [PATCH v4 05/13] net/cpfl: support hairpin queue setup and releaseQuoted 148 lines
-----Original Message-----
From: Xing, Beilei <[email protected]>
Sent: Friday, May 26, 2023 3:39 PM
To: Wu, Jingjing <[email protected]>
Cc: [email protected]; Liu, Mingxia <[email protected]>; Xing, Beilei <[email protected]>; Wang, Xiao W <[email protected]>
Subject: [PATCH v4 05/13] net/cpfl: support hairpin queue setup and releaseFrom: Beilei Xing <[email protected]>
Support hairpin Rx/Tx queue setup and release.
Signed-off-by Xiao Wang <[email protected]>Signed-off-by Mingxia Liu <[email protected]>Signed-off-by Beilei Xing <[email protected]>--- drivers/net/cpfl/cpfl_ethdev.c | 6 + drivers/net/cpfl/cpfl_ethdev.h | 11 + drivers/net/cpfl/cpfl_rxtx.c | 353 +++++++++++++++++++++++- drivers/net/cpfl/cpfl_rxtx.h | 36 +++ drivers/net/cpfl/cpfl_rxtx_vec_common.h | 4 + 5 files changed, 409 insertions(+), 1 deletion(-)(quoted diff) +0
-0
b/drivers/net/cpfl/cpfl_ethdev.cindex40b4515539..b17c538ec2100644drivers/net/cpfl/cpfl_ethdev.c +4
-0@@ -879,6 +879,10 @@ cpfl_dev_close(struct rte_eth_dev *dev)struct cpfl_adapter_ext *adapter =CPFL_ADAPTER_TO_EXT (vport- >adapter);cpfl_dev_stop (dev); +if (cpfl_vport->p2p_mp) { +rte_mempool_free (cpfl_vport->p2p_mp); + cpfl_vport->p2p_mp =NULL ; + }if (!adapter->base.is_rx_singleq && !adapter->base.is_tx_singleq)drivers/net/cpfl/cpfl_ethdev.c +7
-0cpfl_p2p_queue_grps_del (vport);@@ -922,6 +926,8 @@ static const struct eth_dev_ops cpfl_eth_dev_ops = { .xstats_get_names = cpfl_dev_xstats_get_names, .xstats_reset = cpfl_dev_xstats_reset, .hairpin_cap_get = cpfl_hairpin_cap_get, + .rx_hairpin_queue_setup = cpfl_rx_hairpin_queue_setup, + .tx_hairpin_queue_setup = cpfl_tx_hairpin_queue_setup, }; +int +cpfl_rx_hairpin_queue_setup (struct rte_eth_dev *dev,uint16_t queue_idx, +uint16_t nb_desc, +const struct rte_eth_hairpin_conf *conf) { + struct cpfl_vport *cpfl_vport = (struct cpfl_vport *)dev->data-Quoted 1 line
dev_private;drivers/net/cpfl/cpfl_ethdev.c +13
-0+struct idpf_vport *vport = &cpfl_vport->base; +struct idpf_adapter *adapter_base = vport->adapter; +uint16_t logic_qid = cpfl_vport->nb_p2p_rxq; +struct cpfl_rxq_hairpin_info *hairpin_info; +struct cpfl_rx_queue *cpfl_rxq; +struct idpf_rx_queue *bufq1 =NULL ; +struct idpf_rx_queue *rxq; +uint16_t peer_port, peer_q; +uint16_t qid; +int ret; + +if (vport->rxq_model ==VIRTCHNL2_QUEUE_MODEL_SINGLE ) { + PMD_INIT_LOG(ERR, "Only spilt queue model supports hairpinqueue.");
drivers/net/cpfl/cpfl_ethdev.c +5
-0+return -EINVAL ; + } + +if (conf->peer_count !=1 ) { + PMD_INIT_LOG(ERR, "Can't support Rx hairpin queue peercount %d",
conf->peer_count);drivers/net/cpfl/cpfl_ethdev.c +10
-0+return -EINVAL ; + } + + peer_port = conf->peers[0 ].port; + peer_q = conf->peers[0 ].queue; + +if (nb_desc %CPFL_ALIGN_RING_DESC !=0 || + nb_desc >CPFL_MAX_RING_DESC || + nb_desc <CPFL_MIN_RING_DESC ) { + PMD_INIT_LOG(ERR, "Number (%u) of receive descriptors isinvalid",
nb_desc);drivers/net/cpfl/cpfl_ethdev.c +16
-0+return -EINVAL ; + } + +/* Free memory if needed */ +if (dev->data->rx_queues[queue_idx]) { +cpfl_rx_queue_release (dev->data->rx_queues[queue_idx]); + dev->data->rx_queues[queue_idx] =NULL ; + } + +/* Setup Rx description queue */ + cpfl_rxq =rte_zmalloc_socket ("cpfl hairpin rxq" , +sizeof (struct cpfl_rx_queue ), +RTE_CACHE_LINE_SIZE , +SOCKET_ID_ANY ); +if (!cpfl_rxq) { + PMD_INIT_LOG(ERR, "Failed to allocate memory for rx queuedata structure");
drivers/net/cpfl/cpfl_ethdev.c +7
-0+return -ENOMEM ; + } + + rxq = &cpfl_rxq->base; + hairpin_info = &cpfl_rxq->hairpin_info; + rxq->nb_rx_desc = nb_desc *2 ; + rxq->queue_id = cpfl_hw_qid_get(cpfl_vport->p2p_q_chunks_info-Quoted 1 line
rx_start_qid,logic_qid);drivers/net/cpfl/cpfl_ethdev.c +19
-0+ rxq->port_id = dev->data->port_id; + rxq->adapter = adapter_base; + rxq->rx_buf_len =CPFL_P2P_MBUF_SIZE -RTE_PKTMBUF_HEADROOM ; + hairpin_info->hairpin_q = true; + hairpin_info->peer_txp = peer_port; + hairpin_info->peer_txq_id = peer_q; + +if (conf->manual_bind !=0 ) + cpfl_vport->p2p_manual_bind = true; +else + cpfl_vport->p2p_manual_bind = false; + +if (cpfl_vport->p2p_rx_bufq ==NULL ) { + bufq1 =rte_zmalloc_socket ("hairpin rx bufq1" , +sizeof (struct idpf_rx_queue ), +RTE_CACHE_LINE_SIZE , +SOCKET_ID_ANY ); +if (!bufq1) { + PMD_INIT_LOG(ERR, "Failed to allocate memory forhairpin Rx buffer queue 1.");
drivers/net/cpfl/cpfl_ethdev.c +7
-0+ ret = -ENOMEM ; + goto err_alloc_bufq1; + } + qid =2 * logic_qid; + ret =cpfl_rx_hairpin_bufq_setup (dev, bufq1, qid, nb_desc); +if (ret) { + PMD_INIT_LOG(ERR, "Failed to setup hairpin Rx bufferqueue 1");
drivers/net/cpfl/cpfl_ethdev.c +9
-0+ ret = -EINVAL ; + goto err_setup_bufq1; + } + cpfl_vport->p2p_rx_bufq = bufq1; + } + + rxq->bufq1 = cpfl_vport->p2p_rx_bufq; + rxq->bufq2 =NULL ; +drivers/net/cpfl/cpfl_ethdev.c
Quoted 10 lines
drivers/net/cpfl/cpfl_ethdev.c +10
-0+ cpfl_vport->nb_p2p_rxq++; + rxq->q_set = true; + dev->data->rx_queues[queue_idx] = cpfl_rxq; + +return 0 ; + +err_setup_bufq1: +rte_free (bufq1); +err_alloc_bufq1: +rte_free (rxq);[Liu, Mingxia] Here should free
cpfl_rxq, right?Quoted 79 lines
drivers/net/cpfl/cpfl_ethdev.c +24
-0+ +return ret; +} + +int +cpfl_tx_hairpin_queue_setup (struct rte_eth_dev *dev,uint16_t queue_idx, +uint16_t nb_desc, +const struct rte_eth_hairpin_conf *conf) { +struct cpfl_vport *cpfl_vport = + (struct cpfl_vport *)dev->data->dev_private; + +struct idpf_vport *vport = &cpfl_vport->base; +struct idpf_adapter *adapter_base = vport->adapter; +uint16_t logic_qid = cpfl_vport->nb_p2p_txq; +struct cpfl_txq_hairpin_info *hairpin_info; +struct idpf_hw *hw = &adapter_base->hw; +struct cpfl_tx_queue *cpfl_txq; +struct idpf_tx_queue *txq, *cq; +const struct rte_memzone *mz; +uint32_t ring_size; +uint16_t peer_port, peer_q; + +if (vport->txq_model ==VIRTCHNL2_QUEUE_MODEL_SINGLE ) { + PMD_INIT_LOG(ERR, "Only spilt queue model supports hairpinqueue.");
drivers/net/cpfl/cpfl_ethdev.c +5
-0+return -EINVAL ; + } + +if (conf->peer_count !=1 ) { + PMD_INIT_LOG(ERR, "Can't support Tx hairpin queue peercount %d",
conf->peer_count);drivers/net/cpfl/cpfl_ethdev.c +10
-0+return -EINVAL ; + } + + peer_port = conf->peers[0 ].port; + peer_q = conf->peers[0 ].queue; + +if (nb_desc %CPFL_ALIGN_RING_DESC !=0 || + nb_desc >CPFL_MAX_RING_DESC || + nb_desc <CPFL_MIN_RING_DESC ) { + PMD_INIT_LOG(ERR, "Number (%u) of transmit descriptors isinvalid",
drivers/net/cpfl/cpfl_ethdev.c +17
-0+ nb_desc); +return -EINVAL ; + } + +/* Free memory if needed. */ +if (dev->data->tx_queues[queue_idx]) { +cpfl_tx_queue_release (dev->data->tx_queues[queue_idx]); + dev->data->tx_queues[queue_idx] =NULL ; + } + +/* Allocate the TX queue data structure. */ + cpfl_txq =rte_zmalloc_socket ("cpfl hairpin txq" , +sizeof (struct cpfl_tx_queue ), +RTE_CACHE_LINE_SIZE , +SOCKET_ID_ANY ); +if (!cpfl_txq) { + PMD_INIT_LOG(ERR, "Failed to allocate memory for tx queuestructure");
drivers/net/cpfl/cpfl_ethdev.c +8
-0+return -ENOMEM ; + } + + txq = &cpfl_txq->base; + hairpin_info = &cpfl_txq->hairpin_info; +/* Txq ring length should be 2 times of Tx completion queue size. */ + txq->nb_tx_desc = nb_desc *2 ; + txq->queue_id = cpfl_hw_qid_get(cpfl_vport->p2p_q_chunks_info-Quoted 1 line
tx_start_qid,logic_qid);drivers/net/cpfl/cpfl_ethdev.c +10
-0+ txq->port_id = dev->data->port_id; + hairpin_info->hairpin_q = true; + hairpin_info->peer_rxp = peer_port; + hairpin_info->peer_rxq_id = peer_q; + +if (conf->manual_bind !=0 ) + cpfl_vport->p2p_manual_bind = true; +else + cpfl_vport->p2p_manual_bind = false; +drivers/net/cpfl/cpfl_ethdev.c
Quoted 10 lines
drivers/net/cpfl/cpfl_ethdev.c +10
-0+/* Always Tx hairpin queue allocates Tx HW ring */ + ring_size =RTE_ALIGN (txq->nb_tx_desc *CPFL_P2P_DESC_LEN , +CPFL_DMA_MEM_ALIGN ); + mz =rte_eth_dma_zone_reserve (dev,"hairpin_tx_ring" , logic_qid, + ring_size +CPFL_P2P_RING_BUF , +CPFL_RING_BASE_ALIGN , + dev->device->numa_node); +if (!mz) { +PMD_INIT_LOG (ERR ,"Failed to reserve DMA memory for TX" ); +rte_free (txq);[Liu, Mingxia] Here should free
cpfl_txq, right?Quoted 13 lines
drivers/net/cpfl/cpfl_ethdev.c +10
-0+return -ENOMEM ; + } + + txq->tx_ring_phys_addr = mz->iova; + txq->desc_ring = mz->addr; + txq->mz = mz; + +cpfl_tx_hairpin_descq_reset (txq); + txq->qtx_tail = hw->hw_addr + + cpfl_hw_qtail_get(cpfl_vport->p2p_q_chunks_info-Quoted 1 line
tx_qtail_start,drivers/net/cpfl/cpfl_ethdev.c +1
-0+ logic_qid, cpfl_vport->p2p_q_chunks_info-Quoted 1 line
tx_qtail_spacing);
Quoted 12 lines
Quoted 10 lines
drivers/net/cpfl/cpfl_ethdev.c +9
-0+ txq->ops = &def_txq_ops; + +if (cpfl_vport->p2p_tx_complq ==NULL ) { + cq =rte_zmalloc_socket ("cpfl hairpin cq" , +sizeof (struct idpf_tx_queue ), +RTE_CACHE_LINE_SIZE , + dev->device->numa_node); +if (!cq) { + PMD_INIT_LOG(ERR, "Failed to allocate memory for txqueue structure");
[Liu, Mingxia] Before returning, should free some resource, such as free
cpfl_txq, right?
[Liu, Mingxia] In addition, should txq->mz be freed before release cpfl_txq ?
Quoted 16 lines
Quoted 16 lines
drivers/net/cpfl/cpfl_ethdev.c +5
-0+return -ENOMEM ; + } + + cq->nb_tx_desc = nb_desc; + cq->queue_id = cpfl_hw_qid_get(cpfl_vport-Quoted 1 line
p2p_q_chunks_info->tx_compl_start_qid,drivers/net/cpfl/cpfl_ethdev.c +7
-0+ 0); + cq->port_id = dev->data->port_id; + +/* Tx completion queue always allocates the HW ring */ + ring_size =RTE_ALIGN (cq->nb_tx_desc *CPFL_P2P_DESC_LEN , +CPFL_DMA_MEM_ALIGN ); + mz = rte_eth_dma_zone_reserve(dev, "hairpin_tx_compl_ring",
logic_qid,drivers/net/cpfl/cpfl_ethdev.c +2
-0+ ring_size +CPFL_P2P_RING_BUF , + CPFL_RING_BASE_ALIGN,
Quoted 8 lines
drivers/net/cpfl/cpfl_ethdev.c
Quoted 5 lines
drivers/net/cpfl/cpfl_ethdev.c +3
-0+ dev->device->numa_node); +if (!mz) { + PMD_INIT_LOG(ERR, "Failed to reserve DMA memoryfor TX completion queue");
drivers/net/cpfl/cpfl_ethdev.c +1
-0+rte_free (txq);[Liu, Mingxia]Here should free
cpfl_txq, right?In addition, should cq resource be released?
[Liu, Mingxia] In addition, should txq->mz be freed before release cpfl_txq ?
Quoted 2 lines
RE: [PATCH v4 05/13] net/cpfl: support hairpin queue setup and release
Quoted 136 lines
-----Original Message-----
From: Liu, Mingxia <[email protected]>
Sent: Tuesday, May 30, 2023 10:50 AM
To: Xing, Beilei <[email protected]>; Wu, Jingjing <[email protected]>
Cc: [email protected]; Wang, Xiao W <[email protected]>
Subject: RE: [PATCH v4 05/13] net/cpfl: support hairpin queue setup and releaseQuoted 50 lines
-----Original Message-----
From: Liu, Mingxia
Sent: Tuesday, May 30, 2023 10:27 AM
To: Xing, Beilei <[email protected]>; Wu, Jingjing <[email protected]>
Cc: [email protected]; Wang, Xiao W <[email protected]>
Subject: RE: [PATCH v4 05/13] net/cpfl: support hairpin queue setup and releaseQuoted 39 lines
-----Original Message-----
From: Xing, Beilei <[email protected]>
Sent: Friday, May 26, 2023 3:39 PM
To: Wu, Jingjing <[email protected]>
Cc: [email protected]; Liu, Mingxia <[email protected]>; Xing, Beilei <[email protected]>; Wang, Xiao W <[email protected]>
Subject: [PATCH v4 05/13] net/cpfl: support hairpin queue setup and releaseFrom: Beilei Xing <[email protected]>
Support hairpin Rx/Tx queue setup and release.
Signed-off-by Xiao Wang <[email protected]>Signed-off-by Mingxia Liu <[email protected]>Signed-off-by Beilei Xing <[email protected]>--- drivers/net/cpfl/cpfl_ethdev.c | 6 + drivers/net/cpfl/cpfl_ethdev.h | 11 + drivers/net/cpfl/cpfl_rxtx.c | 353 +++++++++++++++++++++++- drivers/net/cpfl/cpfl_rxtx.h | 36 +++ drivers/net/cpfl/cpfl_rxtx_vec_common.h | 4 + 5 files changed, 409 insertions(+), 1 deletion(-)(quoted diff) +0
-0
b/drivers/net/cpfl/cpfl_ethdev.cindex40b4515539..b17c538ec2100644drivers/net/cpfl/cpfl_ethdev.c +4
-0@@ -879,6 +879,10 @@ cpfl_dev_close(struct rte_eth_dev *dev)struct cpfl_adapter_ext *adapter =CPFL_ADAPTER_TO_EXT (vport- >adapter);cpfl_dev_stop (dev); +if (cpfl_vport->p2p_mp) { +rte_mempool_free (cpfl_vport->p2p_mp); + cpfl_vport->p2p_mp =NULL ; + }Quoted 3 lines
drivers/net/cpfl/cpfl_ethdev.c static const struct eth_dev_ops cpfl_eth_dev_ops =
Quoted 3 lines
drivers/net/cpfl/cpfl_ethdev.c +0
-0if (!adapter->base.is_rx_singleq && !adapter->base.is_tx_singleq)drivers/net/cpfl/cpfl_ethdev.c +0
-0cpfl_p2p_queue_grps_del (vport);@@ -922,6 +926,8 @@ static const struct eth_dev_ops cpfl_eth_dev_ops ={
Quoted 4 lines
drivers/net/cpfl/cpfl_ethdev.c static const struct eth_dev_ops cpfl_eth_dev_ops = {
Quoted 4 lines
drivers/net/cpfl/cpfl_ethdev.c +1
-0.xstats_get_names = cpfl_dev_xstats_get_names, .xstats_reset = cpfl_dev_xstats_reset, .hairpin_cap_get = cpfl_hairpin_cap_get, + .rx_hairpin_queue_setup =
cpfl_rx_hairpin_queue_setup,Quoted 1 line
drivers/net/cpfl/cpfl_ethdev.c static const struct eth_dev_ops cpfl_eth_dev_ops = · line 930
Quoted 1 line
drivers/net/cpfl/cpfl_ethdev.c +1
-0+ .tx_hairpin_queue_setup =
cpfl_tx_hairpin_queue_setup,Quoted 63 lines
Quoted 63 lines
drivers/net/cpfl/cpfl_ethdev.c +5
-0}; +int +cpfl_rx_hairpin_queue_setup (struct rte_eth_dev *dev,uint16_t queue_idx, +uint16_t nb_desc, +const struct rte_eth_hairpin_conf *conf) { + struct cpfl_vport *cpfl_vport = (struct cpfl_vport *)dev->data-Quoted 1 line
dev_private;drivers/net/cpfl/cpfl_ethdev.c +13
-0+struct idpf_vport *vport = &cpfl_vport->base; +struct idpf_adapter *adapter_base = vport->adapter; +uint16_t logic_qid = cpfl_vport->nb_p2p_rxq; +struct cpfl_rxq_hairpin_info *hairpin_info; +struct cpfl_rx_queue *cpfl_rxq; +struct idpf_rx_queue *bufq1 =NULL ; +struct idpf_rx_queue *rxq; +uint16_t peer_port, peer_q; +uint16_t qid; +int ret; + +if (vport->rxq_model ==VIRTCHNL2_QUEUE_MODEL_SINGLE ) { + PMD_INIT_LOG(ERR, "Only spilt queue model supports hairpinqueue.");
drivers/net/cpfl/cpfl_ethdev.c +5
-0+return -EINVAL ; + } + +if (conf->peer_count !=1 ) { + PMD_INIT_LOG(ERR, "Can't support Rx hairpin queue peercount %d",
conf->peer_count);drivers/net/cpfl/cpfl_ethdev.c +10
-0+return -EINVAL ; + } + + peer_port = conf->peers[0 ].port; + peer_q = conf->peers[0 ].queue; + +if (nb_desc %CPFL_ALIGN_RING_DESC !=0 || + nb_desc >CPFL_MAX_RING_DESC || + nb_desc <CPFL_MIN_RING_DESC ) { + PMD_INIT_LOG(ERR, "Number (%u) of receive descriptors isinvalid",
nb_desc);drivers/net/cpfl/cpfl_ethdev.c +16
-0+return -EINVAL ; + } + +/* Free memory if needed */ +if (dev->data->rx_queues[queue_idx]) { +cpfl_rx_queue_release (dev->data->rx_queues[queue_idx]); + dev->data->rx_queues[queue_idx] =NULL ; + } + +/* Setup Rx description queue */ + cpfl_rxq =rte_zmalloc_socket ("cpfl hairpin rxq" , +sizeof (struct cpfl_rx_queue ), +RTE_CACHE_LINE_SIZE , +SOCKET_ID_ANY ); +if (!cpfl_rxq) { + PMD_INIT_LOG(ERR, "Failed to allocate memory for rx queuedata structure");
drivers/net/cpfl/cpfl_ethdev.c +7
-0+return -ENOMEM ; + } + + rxq = &cpfl_rxq->base; + hairpin_info = &cpfl_rxq->hairpin_info; + rxq->nb_rx_desc = nb_desc *2 ; + rxq->queue_id = cpfl_hw_qid_get(cpfl_vport->p2p_q_chunks_info-
Quoted 50 lines
Quoted 4 lines
drivers/net/cpfl/cpfl_ethdev.c
Quoted 4 lines
Quoted 1 line
rx_start_qid,logic_qid);drivers/net/cpfl/cpfl_ethdev.c +3
-0+ rxq->port_id = dev->data->port_id; + rxq->adapter = adapter_base; + rxq->rx_buf_len = CPFL_P2P_MBUF_SIZE -
RTE_PKTMBUF_HEADROOM;Quoted 45 lines
Quoted 34 lines
drivers/net/cpfl/cpfl_ethdev.c +16
-0+ hairpin_info->hairpin_q = true; + hairpin_info->peer_txp = peer_port; + hairpin_info->peer_txq_id = peer_q; + +if (conf->manual_bind !=0 ) + cpfl_vport->p2p_manual_bind = true; +else + cpfl_vport->p2p_manual_bind = false; + +if (cpfl_vport->p2p_rx_bufq ==NULL ) { + bufq1 =rte_zmalloc_socket ("hairpin rx bufq1" , +sizeof (struct idpf_rx_queue ), +RTE_CACHE_LINE_SIZE , +SOCKET_ID_ANY ); +if (!bufq1) { + PMD_INIT_LOG(ERR, "Failed to allocate memory forhairpin Rx buffer queue 1.");
drivers/net/cpfl/cpfl_ethdev.c +7
-0+ ret = -ENOMEM ; + goto err_alloc_bufq1; + } + qid =2 * logic_qid; + ret =cpfl_rx_hairpin_bufq_setup (dev, bufq1, qid, nb_desc); +if (ret) { + PMD_INIT_LOG(ERR, "Failed to setup hairpin Rx bufferqueue 1");
drivers/net/cpfl/cpfl_ethdev.c +9
-0+ ret = -EINVAL ; + goto err_setup_bufq1; + } + cpfl_vport->p2p_rx_bufq = bufq1; + } + + rxq->bufq1 = cpfl_vport->p2p_rx_bufq; + rxq->bufq2 =NULL ; +drivers/net/cpfl/cpfl_ethdev.c
Quoted 10 lines
drivers/net/cpfl/cpfl_ethdev.c +10
-0+ cpfl_vport->nb_p2p_rxq++; + rxq->q_set = true; + dev->data->rx_queues[queue_idx] = cpfl_rxq; + +return 0 ; + +err_setup_bufq1: +rte_free (bufq1); +err_alloc_bufq1: +rte_free (rxq);[Liu, Mingxia] Here should free
cpfl_rxq, right?
Thanks for the comments, all err process are refined in new version.
PATCH v4 6/13 common/idpf: add queue config API
In reply to [email protected]From: Beilei Xing <[email protected]>
This patch supports Rx/Tx queue configuration APIs.
--- drivers/common/idpf/idpf_common_virtchnl.c | 70 ++++++++++++++++++++++ drivers/common/idpf/idpf_common_virtchnl.h | 6 ++ drivers/common/idpf/version.map | 2 + 3 files changed, 78 insertions(+)
drivers/common/idpf/idpf_common_virtchnl.c +70 -0
@@ -1050,6 +1050,41 @@ idpf_vc_rxq_config(struct idpf_vport *vport, struct idpf_rx_queue *rxq)return err; } +int idpf_vc_rxq_config_by_info (struct idpf_vport *vport,struct virtchnl2_rxq_info *rxq_info, +uint16_t num_qs) +{ +struct idpf_adapter *adapter = vport->adapter; +struct virtchnl2_config_rx_queues *vc_rxqs =NULL ; +struct idpf_cmd_info args; +int size, err, i; + + size =sizeof (*vc_rxqs) + (num_qs -1 ) * +sizeof (struct virtchnl2_rxq_info ); + vc_rxqs =rte_zmalloc ("cfg_rxqs" , size,0 ); +if (vc_rxqs ==NULL ) { +DRV_LOG (ERR ,"Failed to allocate virtchnl2_config_rx_queues" ); + err = -ENOMEM ; +return err; + } + vc_rxqs->vport_id = vport->vport_id; + vc_rxqs->num_qinfo = num_qs; +memcpy (vc_rxqs->qinfo, rxq_info, num_qs *sizeof (struct virtchnl2_rxq_info )); + +memset (&args,0 ,sizeof (args)); + args.ops =VIRTCHNL2_OP_CONFIG_RX_QUEUES ; + args.in_args = (uint8_t *)vc_rxqs; + args.in_args_size = size; + args.out_buffer = adapter->mbx_resp; + args.out_size =IDPF_DFLT_MBX_BUF_SIZE ; + + err =idpf_vc_cmd_execute (adapter, &args); +rte_free (vc_rxqs); +if (err !=0 ) +DRV_LOG (ERR ,"Failed to execute command of VIRTCHNL2_OP_CONFIG_RX_QUEUES" ); + +return err; +} +int idpf_vc_txq_config (struct idpf_vport *vport,struct idpf_tx_queue *txq) {
@@ -1121,6 +1156,41 @@ idpf_vc_txq_config(struct idpf_vport *vport, struct idpf_tx_queue *txq)return err; } +int +idpf_vc_txq_config_by_info (struct idpf_vport *vport,struct virtchnl2_txq_info *txq_info, +uint16_t num_qs) +{ +struct idpf_adapter *adapter = vport->adapter; +struct virtchnl2_config_tx_queues *vc_txqs =NULL ; +struct idpf_cmd_info args; +int size, err; + + size =sizeof (*vc_txqs) + (num_qs -1 ) *sizeof (struct virtchnl2_txq_info ); + vc_txqs =rte_zmalloc ("cfg_txqs" , size,0 ); +if (vc_txqs ==NULL ) { +DRV_LOG (ERR ,"Failed to allocate virtchnl2_config_tx_queues" ); + err = -ENOMEM ; +return err; + } + vc_txqs->vport_id = vport->vport_id; + vc_txqs->num_qinfo = num_qs; +memcpy (vc_txqs->qinfo, txq_info, num_qs *sizeof (struct virtchnl2_txq_info )); + +memset (&args,0 ,sizeof (args)); + args.ops =VIRTCHNL2_OP_CONFIG_TX_QUEUES ; + args.in_args = (uint8_t *)vc_txqs; + args.in_args_size = size; + args.out_buffer = adapter->mbx_resp; + args.out_size =IDPF_DFLT_MBX_BUF_SIZE ; + + err =idpf_vc_cmd_execute (adapter, &args); +rte_free (vc_txqs); +if (err !=0 ) +DRV_LOG (ERR ,"Failed to execute command of VIRTCHNL2_OP_CONFIG_TX_QUEUES" ); + +return err; +} +int idpf_vc_ctlq_recv (struct idpf_ctlq_info *cq,u16 *num_q_msg,struct idpf_ctlq_msg *q_msg)
drivers/common/idpf/idpf_common_virtchnl.h +6 -0
@@ -65,6 +65,12 @@ __rte_internalint idpf_vc_ctlq_post_rx_buffs (struct idpf_hw *hw,struct idpf_ctlq_info *cq,u16 *buff_count,struct idpf_dma_mem **buffs);__rte_internal +int idpf_vc_rxq_config_by_info(struct idpf_vport *vport, struct virtchnl2_rxq_info *rxq_info, +uint16_t num_qs); +__rte_internal +int idpf_vc_txq_config_by_info(struct idpf_vport *vport, struct virtchnl2_txq_info *txq_info, +uint16_t num_qs); +__rte_internal int idpf_vc_queue_grps_del(struct idpf_vport *vport,uint16_t num_q_grps,struct virtchnl2_queue_group_id *qg_ids);
drivers/common/idpf/version.map +2 -0
@@ -54,8 +54,10 @@ INTERNAL { idpf_vc_rss_lut_get; idpf_vc_rss_lut_set; idpf_vc_rxq_config; + idpf_vc_rxq_config_by_info; idpf_vc_stats_query; idpf_vc_txq_config; + idpf_vc_txq_config_by_info; idpf_vc_vectors_alloc; idpf_vc_vectors_dealloc; idpf_vc_vport_create;
Signature · 1 line
2.26.2
PATCH v4 7/13 net/cpfl: support hairpin queue configuration
In reply to [email protected]From: Beilei Xing <[email protected]>
This patch supports Rx/Tx hairpin queue configuration.
--- drivers/net/cpfl/cpfl_ethdev.c | 136 +++++++++++++++++++++++++++++++-- drivers/net/cpfl/cpfl_rxtx.c | 80 +++++++++++++++++++ drivers/net/cpfl/cpfl_rxtx.h | 7 ++ 3 files changed, 217 insertions(+), 6 deletions(-)
drivers/net/cpfl/cpfl_ethdev.c +130 -6
@@ -742,33 +742,157 @@ cpfl_config_rx_queues_irqs(struct rte_eth_dev *dev)return idpf_vport_irq_map_config (vport, nb_rx_queues); } +/* Update hairpin_info for dev's tx hairpin queue */ +static int +cpfl_txq_hairpin_info_update (struct rte_eth_dev *dev,uint16_t rx_port) +{ +struct cpfl_vport *cpfl_tx_vport = dev->data->dev_private; +struct rte_eth_dev *peer_dev = &rte_eth_devices[rx_port]; +struct cpfl_vport *cpfl_rx_vport = peer_dev->data->dev_private; +struct cpfl_txq_hairpin_info *hairpin_info; +struct cpfl_tx_queue *cpfl_txq; +int i; + +for (i = cpfl_tx_vport->nb_data_txq; i < dev->data->nb_tx_queues; i++) { + cpfl_txq = dev->data->tx_queues[i]; + hairpin_info = &cpfl_txq->hairpin_info; +if (hairpin_info->peer_rxp != rx_port) { +PMD_DRV_LOG (ERR ,"port %d is not the peer port" , rx_port); +return -EINVAL ; + } + hairpin_info->peer_rxq_id = +cpfl_hw_qid_get (cpfl_rx_vport->p2p_q_chunks_info->rx_start_qid, + hairpin_info->peer_rxq_id - cpfl_rx_vport->nb_data_rxq); + } + +return 0 ; +} + +/* Bind Rx hairpin queue's memory zone to peer Tx hairpin queue's memory zone */ +static void +cpfl_rxq_hairpin_mz_bind (struct rte_eth_dev *dev) +{ +struct cpfl_vport *cpfl_rx_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_rx_vport->base; +struct idpf_adapter *adapter = vport->adapter; +struct idpf_hw *hw = &adapter->hw; +struct cpfl_rx_queue *cpfl_rxq; +struct cpfl_tx_queue *cpfl_txq; +struct rte_eth_dev *peer_dev; +const struct rte_memzone *mz; +uint16_t peer_tx_port; +uint16_t peer_tx_qid; +int i; + +for (i = cpfl_rx_vport->nb_data_rxq; i < dev->data->nb_rx_queues; i++) { + cpfl_rxq = dev->data->rx_queues[i]; + peer_tx_port = cpfl_rxq->hairpin_info.peer_txp; + peer_tx_qid = cpfl_rxq->hairpin_info.peer_txq_id; + peer_dev = &rte_eth_devices[peer_tx_port]; + cpfl_txq = peer_dev->data->tx_queues[peer_tx_qid]; + +/* bind rx queue */ + mz = cpfl_txq->base.mz; + cpfl_rxq->base.rx_ring_phys_addr = mz->iova; + cpfl_rxq->base.rx_ring = mz->addr; + cpfl_rxq->base.mz = mz; + +/* bind rx buffer queue */ + mz = cpfl_txq->base.complq->mz; + cpfl_rxq->base.bufq1->rx_ring_phys_addr = mz->iova; + cpfl_rxq->base.bufq1->rx_ring = mz->addr; + cpfl_rxq->base.bufq1->mz = mz; + cpfl_rxq->base.bufq1->qrx_tail = hw->hw_addr + +cpfl_hw_qtail_get (cpfl_rx_vport->p2p_q_chunks_info->rx_buf_qtail_start, +0 , cpfl_rx_vport->p2p_q_chunks_info->rx_buf_qtail_spacing); + } +} +static int cpfl_start_queues (struct rte_eth_dev *dev) { +struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;struct cpfl_rx_queue *cpfl_rxq;struct cpfl_tx_queue *cpfl_txq; +int update_flag =0 ;int err =0 ;int i; +/* For normal data queues, configure, init and enale Txq. +* For non-manual bind hairpin queues, configure Txq. +*/ for (i =0 ; i < dev->data->nb_tx_queues; i++) { cpfl_txq = dev->data->tx_queues[i];if (cpfl_txq ==NULL || cpfl_txq->base.tx_deferred_start)continue ; - err =cpfl_tx_queue_start (dev, i); +if (!cpfl_txq->hairpin_info.hairpin_q) { + err =cpfl_tx_queue_start (dev, i); +if (err !=0 ) { +PMD_DRV_LOG (ERR ,"Fail to start Tx queue %u" , i); +return err; + } + }else if (!cpfl_vport->p2p_manual_bind) { +if (update_flag ==0 ) { + err =cpfl_txq_hairpin_info_update (dev, + cpfl_txq->hairpin_info.peer_rxp); +if (err !=0 ) { +PMD_DRV_LOG (ERR ,"Fail to update Tx hairpin queue info" ); +return err; + } + update_flag =1 ; + } + err =cpfl_hairpin_txq_config (vport, cpfl_txq); +if (err !=0 ) { +PMD_DRV_LOG (ERR ,"Fail to configure hairpin Tx queue %u" , i); +return err; + } + } + } + +/* For non-manual bind hairpin queues, configure Tx completion queue first.*/ +if (!cpfl_vport->p2p_manual_bind && cpfl_vport->p2p_tx_complq !=NULL ) { + err =cpfl_hairpin_tx_complq_config (cpfl_vport);if (err !=0 ) { -PMD_DRV_LOG (ERR ,"Fail to start Tx queue %u" , i); +PMD_DRV_LOG (ERR ,"Fail to config Tx completion queue" );return err; } } +/* For non-manual bind hairpin queues, configure Rx buffer queue.*/ +if (!cpfl_vport->p2p_manual_bind && cpfl_vport->p2p_rx_bufq !=NULL ) { +cpfl_rxq_hairpin_mz_bind (dev); + err =cpfl_hairpin_rx_bufq_config (cpfl_vport); +if (err !=0 ) { +PMD_DRV_LOG (ERR ,"Fail to config Rx buffer queue" ); +return err; + } + } + +/* For normal data queues, configure, init and enale Rxq. +* For non-manual bind hairpin queues, configure Rxq, and then init Rxq. +*/ for (i =0 ; i < dev->data->nb_rx_queues; i++) { cpfl_rxq = dev->data->rx_queues[i];if (cpfl_rxq ==NULL || cpfl_rxq->base.rx_deferred_start)continue ; - err =cpfl_rx_queue_start (dev, i); -if (err !=0 ) { -PMD_DRV_LOG (ERR ,"Fail to start Rx queue %u" , i); -return err; +if (!cpfl_rxq->hairpin_info.hairpin_q) { + err =cpfl_rx_queue_start (dev, i); +if (err !=0 ) { +PMD_DRV_LOG (ERR ,"Fail to start Rx queue %u" , i); +return err; + } + }else if (!cpfl_vport->p2p_manual_bind) { + err =cpfl_hairpin_rxq_config (vport, cpfl_rxq); +if (err !=0 ) { +PMD_DRV_LOG (ERR ,"Fail to configure hairpin Rx queue %u" , i); +return err; + } + err =cpfl_rx_queue_init (dev, i); +if (err !=0 ) { +PMD_DRV_LOG (ERR ,"Fail to init hairpin Rx queue %u" , i); +return err; + } } }
drivers/net/cpfl/cpfl_rxtx.c +80 -0
86 lines not on this page · raw message
drivers/net/cpfl/cpfl_rxtx.h +7 -0
@@ -32,12 +32,15 @@#define CPFL_RING_BASE_ALIGN 128#define CPFL_DEFAULT_RX_FREE_THRESH 32 +#define CPFL_RXBUF_LOW_WATERMARK 64#define CPFL_DEFAULT_TX_RS_THRESH 32#define CPFL_DEFAULT_TX_FREE_THRESH 32#define CPFL_SUPPORT_CHAIN_NUM 5 +#define CPFL_RX_BUF_STRIDE 64 +struct cpfl_rxq_hairpin_info {bool hairpin_q;/* if rx queue is a hairpin queue */ uint16_t peer_txp;
@@ -95,4 +98,8 @@ int cpfl_rx_hairpin_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,int cpfl_tx_hairpin_queue_setup (struct rte_eth_dev *dev,uint16_t queue_idx,uint16_t nb_desc,const struct rte_eth_hairpin_conf *conf); +int cpfl_hairpin_tx_complq_config (struct cpfl_vport *cpfl_vport); +int cpfl_hairpin_txq_config (struct idpf_vport *vport,struct cpfl_tx_queue *cpfl_txq); +int cpfl_hairpin_rx_bufq_config (struct cpfl_vport *cpfl_vport); +int cpfl_hairpin_rxq_config (struct idpf_vport *vport,struct cpfl_rx_queue *cpfl_rxq);#endif /* _CPFL_RXTX_H_ */
Signature · 1 line
2.26.2
PATCH v4 8/13 common/idpf: add switch queue API
In reply to [email protected]From: Beilei Xing <[email protected]>
This patch adds idpf_vc_ena_dis_one_queue API.
--- drivers/common/idpf/idpf_common_virtchnl.c | 2 +- drivers/common/idpf/idpf_common_virtchnl.h | 3 +++ drivers/common/idpf/version.map | 1 + 3 files changed, 5 insertions(+), 1 deletion(-)
drivers/common/idpf/idpf_common_virtchnl.c +1 -1
@@ -733,7 +733,7 @@ idpf_vc_vectors_dealloc(struct idpf_vport *vport)return err; } -static int +int idpf_vc_ena_dis_one_queue (struct idpf_vport *vport,uint16_t qid,uint32_t type,bool on) {
drivers/common/idpf/idpf_common_virtchnl.h +3 -0
@@ -71,6 +71,9 @@ __rte_internalint idpf_vc_txq_config_by_info (struct idpf_vport *vport,struct virtchnl2_txq_info *txq_info,uint16_t num_qs);__rte_internal +int idpf_vc_ena_dis_one_queue(struct idpf_vport *vport, uint16_t qid, +uint32_t type,bool on); +__rte_internal int idpf_vc_queue_grps_del(struct idpf_vport *vport,uint16_t num_q_grps,struct virtchnl2_queue_group_id *qg_ids);
drivers/common/idpf/version.map +1 -0
@@ -40,6 +40,7 @@ INTERNAL { idpf_vc_cmd_execute; idpf_vc_ctlq_post_rx_buffs; idpf_vc_ctlq_recv; + idpf_vc_ena_dis_one_queue; idpf_vc_irq_map_unmap_config; idpf_vc_one_msg_read; idpf_vc_ptype_info_query;
Signature · 1 line
2.26.2
PATCH v4 9/13 net/cpfl: support hairpin queue start/stop
In reply to [email protected]From: Beilei Xing <[email protected]>
This patch supports Rx/Tx hairpin queue start/stop.
--- drivers/net/cpfl/cpfl_ethdev.c | 41 +++++++++ drivers/net/cpfl/cpfl_rxtx.c | 151 +++++++++++++++++++++++++++++---- drivers/net/cpfl/cpfl_rxtx.h | 14 +++ 3 files changed, 188 insertions(+), 18 deletions(-)
drivers/net/cpfl/cpfl_ethdev.c +41 -0
@@ -896,6 +896,47 @@ cpfl_start_queues(struct rte_eth_dev *dev) } } +/* For non-manual bind hairpin queues, enable Tx queue and Rx queue, +* then enable Tx completion queue and Rx buffer queue. +*/ +for (i =0 ; i < dev->data->nb_tx_queues; i++) { + cpfl_txq = dev->data->tx_queues[i]; +if (cpfl_txq->hairpin_info.hairpin_q && !cpfl_vport->p2p_manual_bind) { + err =cpfl_switch_hairpin_rxtx_queue (cpfl_vport, + i - cpfl_vport->nb_data_txq, + false, true); +if (err) +PMD_DRV_LOG (ERR ,"Failed to switch hairpin TX queue %u on" , + i); +else + cpfl_txq->base.q_started = true; + } + } + +for (i =0 ; i < dev->data->nb_rx_queues; i++) { + cpfl_rxq = dev->data->rx_queues[i]; +if (cpfl_rxq->hairpin_info.hairpin_q && !cpfl_vport->p2p_manual_bind) { + err =cpfl_switch_hairpin_rxtx_queue (cpfl_vport, + i - cpfl_vport->nb_data_rxq, + true, true); +if (err) +PMD_DRV_LOG (ERR ,"Failed to switch hairpin RX queue %u on" , + i); +else + cpfl_rxq->base.q_started = true; + } + } + +if (!cpfl_vport->p2p_manual_bind && + cpfl_vport->p2p_tx_complq !=NULL && + cpfl_vport->p2p_rx_bufq !=NULL ) { + err =cpfl_switch_hairpin_bufq_complq (cpfl_vport, true); +if (err !=0 ) { +PMD_DRV_LOG (ERR ,"Failed to switch hairpin Tx complq and Rx bufq" ); +return err; + } + } +return err; }
drivers/net/cpfl/cpfl_rxtx.c +133 -18
205 lines not on this page · raw message
drivers/net/cpfl/cpfl_rxtx.h +14 -0
@@ -41,6 +41,17 @@#define CPFL_RX_BUF_STRIDE 64 +/* The value written in the RX buffer queue tail register, +* and in WritePTR field in the TX completion queue context, +* must be a multiple of 8. +*/ +#define CPFL_HAIRPIN_Q_TAIL_AUX_VALUE 8 + +struct virtchnl2_p2p_rx_buf_desc { +__le64 reserve0; +__le64 pkt_addr;/* Packet buffer address */ +}; +struct cpfl_rxq_hairpin_info {bool hairpin_q;/* if rx queue is a hairpin queue */ uint16_t peer_txp;
@@ -102,4 +113,7 @@ int cpfl_hairpin_tx_complq_config(struct cpfl_vport *cpfl_vport);int cpfl_hairpin_txq_config (struct idpf_vport *vport,struct cpfl_tx_queue *cpfl_txq);int cpfl_hairpin_rx_bufq_config (struct cpfl_vport *cpfl_vport);int cpfl_hairpin_rxq_config (struct idpf_vport *vport,struct cpfl_rx_queue *cpfl_rxq); +int cpfl_switch_hairpin_bufq_complq (struct cpfl_vport *cpfl_vport,bool on); +int cpfl_switch_hairpin_rxtx_queue (struct cpfl_vport *cpfl_vport,uint16_t qid, +bool rx,bool on);#endif /* _CPFL_RXTX_H_ */
Signature · 1 line
2.26.2
RE: [PATCH v4 09/13] net/cpfl: support hairpin queue start/stop
Quoted 28 lines
-----Original Message-----
From: Xing, Beilei <[email protected]>
Sent: Friday, May 26, 2023 3:39 PM
To: Wu, Jingjing <[email protected]>
Cc: [email protected]; Liu, Mingxia <[email protected]>; Xing, Beilei <[email protected]>; Wang, Xiao W <[email protected]>
Subject: [PATCH v4 09/13] net/cpfl: support hairpin queue start/stopFrom: Beilei Xing <[email protected]>
This patch supports Rx/Tx hairpin queue start/stop.
Signed-off-by Xiao Wang <[email protected]>Signed-off-by Mingxia Liu <[email protected]>Signed-off-by Beilei Xing <[email protected]>--- drivers/net/cpfl/cpfl_ethdev.c | 41 +++++++++ drivers/net/cpfl/cpfl_rxtx.c | 151 +++++++++++++++++++++++++++++---- drivers/net/cpfl/cpfl_rxtx.h | 14 +++ 3 files changed, 188 insertions(+), 18 deletions(-)drivers/net/cpfl/cpfl_ethdev.c index renamed from drivers/net/cpfl/cpfl_ethdev.c +0
-0a06def06d0..8035878602 100644
drivers/net/cpfl/cpfl_ethdev.c cpfl_start_queues(struct rte_eth_dev *dev) · line 902
Quoted 7 lines
drivers/net/cpfl/cpfl_ethdev.c +4
-0@@ -896,6 +896,47 @@ cpfl_start_queues(struct rte_eth_dev *dev) } } +/* For non-manual bind hairpin queues, enable Tx queue and Rx queue, +* then enable Tx completion queue and Rx buffer queue. +*/ +for (i =0 ; i < dev->data->nb_tx_queues; i++) {
[Liu, Mingxia] Better to use for (i = cpfl_tx_vport->nb_data_txq; i < dev->data->nb_tx_queues; i++), because when i < cpfl_tx_vport->nb_data_txq, (cpfl_txq->hairpin_info.hairpin_q && !cpfl_vport-
Quoted 12 lines
Quoted 1 line
p2p_manual_bind) must be false, or (i -cpfl_vport->nb_data_txq) will < 0.drivers/net/cpfl/cpfl_ethdev.c +2
-0+ cpfl_txq = dev->data->tx_queues[i]; + if (cpfl_txq->hairpin_info.hairpin_q && !cpfl_vport-Quoted 1 line
p2p_manual_bind) {drivers/net/cpfl/cpfl_ethdev.c +2
-0+ err = cpfl_switch_hairpin_rxtx_queue(cpfl_vport, + i - cpfl_vport-Quoted 1 line
nb_data_txq,drivers/net/cpfl/cpfl_ethdev.c +3
-0+ false, true); +if (err) + PMD_DRV_LOG(ERR, "Failed to switch hairpinTX queue %u on",
drivers/net/cpfl/cpfl_ethdev.c cpfl_start_queues(struct rte_eth_dev *dev) · line 916
Quoted 7 lines
drivers/net/cpfl/cpfl_ethdev.c +7
-0+ i); + else + cpfl_txq->base.q_started = true; + } + } + +for (i =0 ; i < dev->data->nb_rx_queues; i++) {
[Liu, Mingxia] Better to use for (i = cpfl_rx_vport->nb_data_rxq; i < dev->data->nb_rx_queues; i++), because when i < cpfl_rx_vport->nb_data_rxq, (cpfl_txq->hairpin_info.hairpin_q && !cpfl_vport-
Quoted 304 lines
Quoted 1 line
p2p_manual_bind) must be false, or (i -cpfl_vport->nb_data_rxq) will < 0.drivers/net/cpfl/cpfl_ethdev.c +2
-0+ cpfl_rxq = dev->data->rx_queues[i]; + if (cpfl_rxq->hairpin_info.hairpin_q && !cpfl_vport-Quoted 1 line
p2p_manual_bind) {drivers/net/cpfl/cpfl_ethdev.c +2
-0+ err = cpfl_switch_hairpin_rxtx_queue(cpfl_vport, + i - cpfl_vport-Quoted 1 line
nb_data_rxq,drivers/net/cpfl/cpfl_ethdev.c +3
-0+ true, true); +if (err) + PMD_DRV_LOG(ERR, "Failed to switch hairpinRX queue %u on",
drivers/net/cpfl/cpfl_ethdev.c +12
-0+ i); + else + cpfl_rxq->base.q_started = true; + } + } + +if (!cpfl_vport->p2p_manual_bind && + cpfl_vport->p2p_tx_complq !=NULL && + cpfl_vport->p2p_rx_bufq !=NULL ) { + err =cpfl_switch_hairpin_bufq_complq (cpfl_vport, true); +if (err !=0 ) { + PMD_DRV_LOG(ERR, "Failed to switch hairpin Txcomplq and Rx bufq");
drivers/net/cpfl/cpfl_ethdev.c +4
-0+return err; + } + } +return err; }drivers/net/cpfl/cpfl_rxtx.c index renamed from drivers/net/cpfl/cpfl_rxtx.c +0
-0
702054d1c5..38c48ad8c7100644drivers/net/cpfl/cpfl_rxtx.c +0
-0@@ -991,6 +991,81 @@ cpfl_hairpin_txq_config(struct idpf_vport *vport,struct
cpfl_tx_queue*cpfl_txqdrivers/net/cpfl/cpfl_rxtx.c +22
-0return idpf_vc_txq_config_by_info (vport, txq_info,1 ); } +int +cpfl_switch_hairpin_bufq_complq (struct cpfl_vport *cpfl_vport,bool on) +{ +struct idpf_vport *vport = &cpfl_vport->base; +uint32_t type; +int err, queue_id; + + type =VIRTCHNL2_QUEUE_TYPE_TX_COMPLETION ; + queue_id = cpfl_vport->p2p_tx_complq->queue_id; + err =idpf_vc_ena_dis_one_queue (vport, queue_id, type, on); +if (err) +return err; + + type =VIRTCHNL2_QUEUE_TYPE_RX_BUFFER ; + queue_id = cpfl_vport->p2p_rx_bufq->queue_id; + err =idpf_vc_ena_dis_one_queue (vport, queue_id, type, on); + +return err; +} + +int +cpfl_switch_hairpin_rxtx_queue(struct cpfl_vport *cpfl_vport, uint16_t
logic_qid,drivers/net/cpfl/cpfl_rxtx.c +7
-0+ bool rx, bool on) +{ +struct idpf_vport *vport = &cpfl_vport->base; +uint32_t type; +int err, queue_id; + + type = rx ? VIRTCHNL2_QUEUE_TYPE_RX :
VIRTCHNL2_QUEUE_TYPE_TX;drivers/net/cpfl/cpfl_rxtx.c +3
-0+ +if (type ==VIRTCHNL2_QUEUE_TYPE_RX ) + queue_id = cpfl_hw_qid_get(cpfl_vport->p2p_q_chunks_info-Quoted 1 line
rx_start_qid,logic_qid);drivers/net/cpfl/cpfl_rxtx.c +2
-0+else + queue_id = cpfl_hw_qid_get(cpfl_vport->p2p_q_chunks_info-Quoted 1 line
tx_start_qid,logic_qid);drivers/net/cpfl/cpfl_rxtx.c +27
-0+ err =idpf_vc_ena_dis_one_queue (vport, queue_id, type, on); +if (err) +return err; + +return err; +} + +static int +cpfl_alloc_split_p2p_rxq_mbufs (struct idpf_rx_queue *rxq) { +volatile struct virtchnl2_p2p_rx_buf_desc *rxd; +struct rte_mbuf *mbuf =NULL ; +uint64_t dma_addr; +uint16_t i; + +for (i =0 ; i < rxq->nb_rx_desc; i++) { + mbuf =rte_mbuf_raw_alloc (rxq->mp); +if (unlikely (!mbuf)) { +PMD_DRV_LOG (ERR ,"Failed to allocate mbuf for RX" ); +return -ENOMEM ; + } + +rte_mbuf_refcnt_set (mbuf,1 ); + mbuf->next =NULL ; + mbuf->data_off =RTE_PKTMBUF_HEADROOM ; + mbuf->nb_segs =1 ; + mbuf->port = rxq->port_id; + dma_addr =rte_cpu_to_le_64(rte_mbuf_data_iova_default(mbuf));
drivers/net/cpfl/cpfl_rxtx.c +2
-0+ + rxd = &((volatile struct virtchnl2_p2p_rx_buf_desc *)(rxq-Quoted 1 line
rx_ring))[i];
drivers/net/cpfl/cpfl_rxtx.c +6
-0+ rxd->reserve0 =0 ; + rxd->pkt_addr = dma_addr; + } + + rxq->nb_rx_hold =0 ; +/* The value written in the RX buffer queue tail register, must be a multiple of 8.*/
drivers/net/cpfl/cpfl_rxtx.c +5
-0+ rxq->rx_tail = rxq->nb_rx_desc -CPFL_HAIRPIN_Q_TAIL_AUX_VALUE ; + +return 0 ; +} +int cpfl_rx_queue_init(struct rte_eth_dev *dev, uint16_t rx_queue_id) { @@ -1044,22 +1119,31 @@
cpfl_rx_queue_init(struct rte_eth_dev *dev, uint16_t rx_queue_id)drivers/net/cpfl/cpfl_rxtx.c +0
-3IDPF_PCI_REG_WRITE (rxq->qrx_tail, rxq->nb_rx_desc -1 ); }else {/* Split queue */ - err =idpf_qc_split_rxq_mbufs_alloc (rxq->bufq1); -if (err !=0 ) { - PMD_DRV_LOG(ERR, "Failed to allocate RX bufferqueue mbuf");
drivers/net/cpfl/cpfl_rxtx.c +0
-5-return err; - } - err =idpf_qc_split_rxq_mbufs_alloc (rxq->bufq2); -if (err !=0 ) { - PMD_DRV_LOG(ERR, "Failed to allocate RX bufferqueue mbuf");
drivers/net/cpfl/cpfl_rxtx.c +4
-1-return err; +if (cpfl_rxq->hairpin_info.hairpin_q) { + err =cpfl_alloc_split_p2p_rxq_mbufs (rxq->bufq1); +if (err !=0 ) { + PMD_DRV_LOG(ERR, "Failed to allocate p2p RXbuffer queue mbuf");
drivers/net/cpfl/cpfl_rxtx.c +6
-0+return err; + } + }else { + err =idpf_qc_split_rxq_mbufs_alloc (rxq->bufq1); +if (err !=0 ) { + PMD_DRV_LOG(ERR, "Failed to allocate RXbuffer queue mbuf");
drivers/net/cpfl/cpfl_rxtx.c +5
-0+return err; + } + err =idpf_qc_split_rxq_mbufs_alloc (rxq->bufq2); +if (err !=0 ) { + PMD_DRV_LOG(ERR, "Failed to allocate RXbuffer queue mbuf");
drivers/net/cpfl/cpfl_rxtx.c +2
-0+return err; + } }rte_wmb ();/* Init the RX tail register. */ IDPF_PCI_REG_WRITE(rxq->bufq1->qrx_tail, rxq->bufq1-Quoted 1 line
rx_tail);drivers/net/cpfl/cpfl_rxtx.c +0
-1- IDPF_PCI_REG_WRITE(rxq->bufq2->qrx_tail, rxq->bufq2-Quoted 1 line
rx_tail);drivers/net/cpfl/cpfl_rxtx.c +2
-0+if (rxq->bufq2) + IDPF_PCI_REG_WRITE(rxq->bufq2->qrx_tail, rxq-Quoted 1 line
bufq2->rx_tail);drivers/net/cpfl/cpfl_rxtx.c +6
-1}return err;@@ -1166,7 +1250,12 @@ cpfl_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id)return -EINVAL ; cpfl_rxq = dev->data->rx_queues[rx_queue_id]; - err =idpf_vc_queue_switch (vport, rx_queue_id, true, false); +if (cpfl_rxq->hairpin_info.hairpin_q) + err =cpfl_switch_hairpin_rxtx_queue (cpfl_vport, + rx_queue_id - cpfl_vport- >nb_data_txq, + true, false); +else + err =idpf_vc_queue_switch (vport, rx_queue_id, true, false);if (err !=0 ) {drivers/net/cpfl/cpfl_rxtx.c +10
-3PMD_DRV_LOG (ERR ,"Failed to switch RX queue %u off" , rx_queue_id);@@ -1180,10 +1269,17 @@ cpfl_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id)idpf_qc_single_rx_queue_reset (rxq ); }else { rxq->bufq1->ops->release_mbufs (rxq->bufq1); - rxq->bufq2->ops->release_mbufs (rxq->bufq2); -idpf_qc_split_rx_queue_reset (rxq); +if (rxq->bufq2) + rxq->bufq2->ops->release_mbufs (rxq->bufq2); +if (cpfl_rxq->hairpin_info.hairpin_q) { +cpfl_rx_hairpin_descq_reset (rxq); +cpfl_rx_hairpin_bufq_reset (rxq->bufq1); + }else { +idpf_qc_split_rx_queue_reset (rxq); + } } - dev->data->rx_queue_state[rx_queue_id] =RTE_ETH_QUEUE_STATE_STOPPED ; +if (!cpfl_rxq->hairpin_info.hairpin_q) + dev->data->rx_queue_state[rx_queue_id] =RTE_ETH_QUEUE_STATE_STOPPED ;drivers/net/cpfl/cpfl_rxtx.c +6
-1return 0 ; }@@ -1202,7 +1298,12 @@ cpfl_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id) cpfl_txq = dev->data->tx_queues[tx_queue_id]; - err =idpf_vc_queue_switch (vport, tx_queue_id, false, false); +if (cpfl_txq->hairpin_info.hairpin_q) + err =cpfl_switch_hairpin_rxtx_queue (cpfl_vport, + tx_queue_id - cpfl_vport- >nb_data_txq, + false, false); +else + err =idpf_vc_queue_switch (vport, tx_queue_id, false, false);if (err !=0 ) {drivers/net/cpfl/cpfl_rxtx.c +10
-3PMD_DRV_LOG (ERR ,"Failed to switch TX queue %u off" , tx_queue_id);@@ -1215,10 +1316,17 @@ cpfl_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id)if (vport->txq_model ==VIRTCHNL2_QUEUE_MODEL_SINGLE ) {idpf_qc_single_tx_queue_reset (txq); }else { -idpf_qc_split_tx_descq_reset (txq); -idpf_qc_split_tx_complq_reset (txq->complq); +if (cpfl_txq->hairpin_info.hairpin_q) { +cpfl_tx_hairpin_descq_reset (txq); +cpfl_tx_hairpin_complq_reset (txq->complq); + }else { +idpf_qc_split_tx_descq_reset (txq); +idpf_qc_split_tx_complq_reset (txq->complq); + } } - dev->data->tx_queue_state[tx_queue_id] =RTE_ETH_QUEUE_STATE_STOPPED ; + +if (!cpfl_txq->hairpin_info.hairpin_q) + dev->data->tx_queue_state[tx_queue_id] =RTE_ETH_QUEUE_STATE_STOPPED ;drivers/net/cpfl/cpfl_rxtx.c +7
-0return 0 ; }@@ -1238,10 +1346,17 @@ cpfl_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid) void cpfl_stop_queues(struct rte_eth_dev *dev) { +struct cpfl_vport *cpfl_vport = + (struct cpfl_vport *)dev->data->dev_private;struct cpfl_rx_queue *cpfl_rxq;struct cpfl_tx_queue *cpfl_txq;int i; +if (cpfl_vport->p2p_rx_bufq !=NULL ) { + if (cpfl_switch_hairpin_bufq_complq(cpfl_vport, false) != 0) + PMD_DRV_LOG(ERR, "Failed to stop hairpin Tx complq and Rx bufq"); + } + for (i = 0; i < dev->data->nb_rx_queues; i++) { cpfl_rxq = dev->data->rx_queues[i]; if (cpfl_rxq == NULL)drivers/net/cpfl/cpfl_rxtx.h index renamed from drivers/net/cpfl/cpfl_rxtx.h +0
-0
872ebc1bfd..42dfd07155100644drivers/net/cpfl/cpfl_rxtx.h +10
-0@@ -41,6 +41,17 @@#define CPFL_RX_BUF_STRIDE 64 +/* The value written in the RX buffer queue tail register, +* and in WritePTR field in the TX completion queue context, +* must be a multiple of 8. +*/ +#define CPFL_HAIRPIN_Q_TAIL_AUX_VALUE 8 + +struct virtchnl2_p2p_rx_buf_desc { +__le64 reserve0; +__le64 pkt_addr;/* Packet buffer address */ }; +struct cpfl_rxq_hairpin_info {bool hairpin_q;/* if rx queue is a hairpin queue */ uint16_t peer_txp;@@ -102,4 +113,7 @@ int cpfl_hairpin_tx_complq_config(struct cpfl_vport *cpfl_vport); int cpfl_hairpin_txq_config(struct idpf_vport *vport, struct
cpfl_tx_queue*cpfl_txq); intcpfl_hairpin_rx_bufq_config(struct cpfl_vport *cpfl_vport); intcpfl_hairpin_rxq_config(struct idpf_vport *vport, struct cpfl_rx_queue *cpfl_rxq);drivers/net/cpfl/cpfl_rxtx.h +2
-0+int cpfl_switch_hairpin_bufq_complq (struct cpfl_vport *cpfl_vport,bool +on); int cpfl_switch_hairpin_rxtx_queue(struct cpfl_vport *cpfl_vport, uint16_tqid,
drivers/net/cpfl/cpfl_rxtx.h +1
-1+ bool rx, bool on);#endif /* _CPFL_RXTX_H_ */ --2.26.2
RE: [PATCH v4 09/13] net/cpfl: support hairpin queue start/stop
Quoted 56 lines
-----Original Message-----
From: Liu, Mingxia <[email protected]>
Sent: Tuesday, May 30, 2023 11:31 AM
To: Xing, Beilei <[email protected]>; Wu, Jingjing <[email protected]>
Cc: [email protected]; Wang, Xiao W <[email protected]>
Subject: RE: [PATCH v4 09/13] net/cpfl: support hairpin queue start/stopQuoted 27 lines
-----Original Message-----
From: Xing, Beilei <[email protected]>
Sent: Friday, May 26, 2023 3:39 PM
To: Wu, Jingjing <[email protected]>
Cc: [email protected]; Liu, Mingxia <[email protected]>; Xing, Beilei <[email protected]>; Wang, Xiao W <[email protected]>
Subject: [PATCH v4 09/13] net/cpfl: support hairpin queue start/stopFrom: Beilei Xing <[email protected]>
This patch supports Rx/Tx hairpin queue start/stop.
Signed-off-by Xiao Wang <[email protected]>Signed-off-by Mingxia Liu <[email protected]>Signed-off-by Beilei Xing <[email protected]>--- drivers/net/cpfl/cpfl_ethdev.c | 41 +++++++++ drivers/net/cpfl/cpfl_rxtx.c | 151 +++++++++++++++++++++++++++++---- drivers/net/cpfl/cpfl_rxtx.h | 14 +++ 3 files changed, 188 insertions(+), 18 deletions(-)(quoted diff) +0
-0
b/drivers/net/cpfl/cpfl_ethdev.cindex
a06def06d0..8035878602 100644drivers/net/cpfl/cpfl_ethdev.c cpfl_start_queues(struct rte_eth_dev *dev) · line 902
Quoted 7 lines
drivers/net/cpfl/cpfl_ethdev.c +4
-0@@ -896,6 +896,47 @@ cpfl_start_queues(struct rte_eth_dev *dev) } } +/* For non-manual bind hairpin queues, enable Tx queue and Rx queue, +* then enable Tx completion queue and Rx buffer queue. +*/ +for (i =0 ; i < dev->data->nb_tx_queues; i++) {[Liu, Mingxia] Better to use for (i =
cpfl_tx_vport->nb_data_txq; i < dev->data-Quoted 10 lines
nb_tx_queues; i++), because when i <cpfl_tx_vport->nb_data_txq, (cpfl_txq- hairpin_info.hairpin_q && !cpfl_vport-Quoted 1 line
p2p_manual_bind) must be false, or (i -cpfl_vport->nb_data_txq) will < 0.drivers/net/cpfl/cpfl_ethdev.c +2
-0+ cpfl_txq = dev->data->tx_queues[i]; + if (cpfl_txq->hairpin_info.hairpin_q && !cpfl_vport-Quoted 1 line
p2p_manual_bind) {drivers/net/cpfl/cpfl_ethdev.c +2
-0+ err = cpfl_switch_hairpin_rxtx_queue(cpfl_vport, + i - cpfl_vport-Quoted 1 line
nb_data_txq,
Quoted 15 lines
drivers/net/cpfl/cpfl_ethdev.c cpfl_start_queues(struct rte_eth_dev *dev) · line 916
Quoted 11 lines
drivers/net/cpfl/cpfl_ethdev.c +3
-0+ false, true); +if (err) + PMD_DRV_LOG(ERR, "Failed to switch hairpinTX queue %u on",
drivers/net/cpfl/cpfl_ethdev.c +7
-0+ i); + else + cpfl_txq->base.q_started = true; + } + } + +for (i =0 ; i < dev->data->nb_rx_queues; i++) {[Liu, Mingxia] Better to use for (i =
cpfl_rx_vport->nb_data_rxq; i < dev->data-Quoted 3 lines
nb_rx_queues; i++), because when i <cpfl_rx_vport->nb_data_rxq, (cpfl_txq- hairpin_info.hairpin_q && !cpfl_vport-Quoted 1 line
p2p_manual_bind) must be false, or (i -cpfl_vport->nb_data_rxq) will < 0.
Make sense.
Quoted 312 lines
Quoted 141 lines
drivers/net/cpfl/cpfl_ethdev.c +2
-0+ cpfl_rxq = dev->data->rx_queues[i]; + if (cpfl_rxq->hairpin_info.hairpin_q && !cpfl_vport-Quoted 1 line
p2p_manual_bind) {drivers/net/cpfl/cpfl_ethdev.c +2
-0+ err = cpfl_switch_hairpin_rxtx_queue(cpfl_vport, + i - cpfl_vport-Quoted 1 line
nb_data_rxq,drivers/net/cpfl/cpfl_ethdev.c +3
-0+ true, true); +if (err) + PMD_DRV_LOG(ERR, "Failed to switch hairpinRX queue %u on",
drivers/net/cpfl/cpfl_ethdev.c +12
-0+ i); + else + cpfl_rxq->base.q_started = true; + } + } + +if (!cpfl_vport->p2p_manual_bind && + cpfl_vport->p2p_tx_complq !=NULL && + cpfl_vport->p2p_rx_bufq !=NULL ) { + err =cpfl_switch_hairpin_bufq_complq (cpfl_vport, true); +if (err !=0 ) { + PMD_DRV_LOG(ERR, "Failed to switch hairpin Txcomplq and Rx bufq");
drivers/net/cpfl/cpfl_ethdev.c +4
-0+return err; + } + } +return err; }(quoted diff) +0
-0
b/drivers/net/cpfl/cpfl_rxtx.cindex702054d1c5..38c48ad8c7100644drivers/net/cpfl/cpfl_rxtx.c +0
-0@@ -991,6 +991,81 @@ cpfl_hairpin_txq_config(struct idpf_vport *vport,struct
cpfl_tx_queue*cpfl_txqdrivers/net/cpfl/cpfl_rxtx.c +23
-0return idpf_vc_txq_config_by_info (vport, txq_info,1 ); } +int +cpfl_switch_hairpin_bufq_complq (struct cpfl_vport *cpfl_vport,bool +on) { +struct idpf_vport *vport = &cpfl_vport->base; +uint32_t type; +int err, queue_id; + + type =VIRTCHNL2_QUEUE_TYPE_TX_COMPLETION ; + queue_id = cpfl_vport->p2p_tx_complq->queue_id; + err =idpf_vc_ena_dis_one_queue (vport, queue_id, type, on); +if (err) +return err; + + type =VIRTCHNL2_QUEUE_TYPE_RX_BUFFER ; + queue_id = cpfl_vport->p2p_rx_bufq->queue_id; + err =idpf_vc_ena_dis_one_queue (vport, queue_id, type, on); + +return err; +} + +int +cpfl_switch_hairpin_rxtx_queue (struct cpfl_vport *cpfl_vport, +uint16_t
logic_qid,drivers/net/cpfl/cpfl_rxtx.c +7
-0+ bool rx, bool on) +{ +struct idpf_vport *vport = &cpfl_vport->base; +uint32_t type; +int err, queue_id; + + type = rx ? VIRTCHNL2_QUEUE_TYPE_RX :
VIRTCHNL2_QUEUE_TYPE_TX;drivers/net/cpfl/cpfl_rxtx.c +3
-0+ +if (type ==VIRTCHNL2_QUEUE_TYPE_RX ) + queue_id = cpfl_hw_qid_get(cpfl_vport->p2p_q_chunks_info-Quoted 1 line
rx_start_qid,logic_qid);drivers/net/cpfl/cpfl_rxtx.c +2
-0+else + queue_id = cpfl_hw_qid_get(cpfl_vport->p2p_q_chunks_info-Quoted 1 line
tx_start_qid,logic_qid);drivers/net/cpfl/cpfl_rxtx.c +27
-0+ err =idpf_vc_ena_dis_one_queue (vport, queue_id, type, on); +if (err) +return err; + +return err; +} + +static int +cpfl_alloc_split_p2p_rxq_mbufs (struct idpf_rx_queue *rxq) { +volatile struct virtchnl2_p2p_rx_buf_desc *rxd; +struct rte_mbuf *mbuf =NULL ; +uint64_t dma_addr; +uint16_t i; + +for (i =0 ; i < rxq->nb_rx_desc; i++) { + mbuf =rte_mbuf_raw_alloc (rxq->mp); +if (unlikely (!mbuf)) { +PMD_DRV_LOG (ERR ,"Failed to allocate mbuf for RX" ); +return -ENOMEM ; + } + +rte_mbuf_refcnt_set (mbuf,1 ); + mbuf->next =NULL ; + mbuf->data_off =RTE_PKTMBUF_HEADROOM ; + mbuf->nb_segs =1 ; + mbuf->port = rxq->port_id; + dma_addr =rte_cpu_to_le_64(rte_mbuf_data_iova_default(mbuf));
drivers/net/cpfl/cpfl_rxtx.c +2
-0+ + rxd = &((volatile struct virtchnl2_p2p_rx_buf_desc *)(rxq-Quoted 1 line
rx_ring))[i];
drivers/net/cpfl/cpfl_rxtx.c +6
-0+ rxd->reserve0 =0 ; + rxd->pkt_addr = dma_addr; + } + + rxq->nb_rx_hold =0 ; +/* The value written in the RX buffer queue tail register, must be a multiple of 8.*/
drivers/net/cpfl/cpfl_rxtx.c +5
-0+ rxq->rx_tail = rxq->nb_rx_desc -CPFL_HAIRPIN_Q_TAIL_AUX_VALUE ; + +return 0 ; +} +int cpfl_rx_queue_init (struct rte_eth_dev *dev,uint16_t rx_queue_id) {@@ -
1044,22 +1119,31 @@ cpfl_rx_queue_init(structrte_eth_dev*dev,uint16_trx_queue_id)drivers/net/cpfl/cpfl_rxtx.c +0
-3IDPF_PCI_REG_WRITE (rxq->qrx_tail, rxq->nb_rx_desc -1 ); }else {/* Split queue */ - err =idpf_qc_split_rxq_mbufs_alloc (rxq->bufq1); -if (err !=0 ) { - PMD_DRV_LOG(ERR, "Failed to allocate RX bufferqueue mbuf");
drivers/net/cpfl/cpfl_rxtx.c +0
-5-return err; - } - err =idpf_qc_split_rxq_mbufs_alloc (rxq->bufq2); -if (err !=0 ) { - PMD_DRV_LOG(ERR, "Failed to allocate RX bufferqueue mbuf");
drivers/net/cpfl/cpfl_rxtx.c cpfl_rx_queue_init(struct rte_eth_dev *dev, uint16_t rx_queue_id)
Quoted 5 lines
drivers/net/cpfl/cpfl_rxtx.c +4
-1-return err; +if (cpfl_rxq->hairpin_info.hairpin_q) { + err =cpfl_alloc_split_p2p_rxq_mbufs (rxq->bufq1); +if (err !=0 ) { + PMD_DRV_LOG(ERR, "Failed to allocate p2pRX
Quoted 165 lines
buffer queue mbuf");
drivers/net/cpfl/cpfl_rxtx.c +6
-0+return err; + } + }else { + err =idpf_qc_split_rxq_mbufs_alloc (rxq->bufq1); +if (err !=0 ) { + PMD_DRV_LOG(ERR, "Failed to allocate RXbuffer queue mbuf");
drivers/net/cpfl/cpfl_rxtx.c +5
-0+return err; + } + err =idpf_qc_split_rxq_mbufs_alloc (rxq->bufq2); +if (err !=0 ) { + PMD_DRV_LOG(ERR, "Failed to allocate RXbuffer queue mbuf");
drivers/net/cpfl/cpfl_rxtx.c +2
-0+return err; + } }rte_wmb ();/* Init the RX tail register. */ IDPF_PCI_REG_WRITE(rxq->bufq1->qrx_tail, rxq->bufq1-Quoted 1 line
rx_tail);drivers/net/cpfl/cpfl_rxtx.c +0
-1- IDPF_PCI_REG_WRITE(rxq->bufq2->qrx_tail, rxq->bufq2-Quoted 1 line
rx_tail);drivers/net/cpfl/cpfl_rxtx.c +2
-0+if (rxq->bufq2) + IDPF_PCI_REG_WRITE(rxq->bufq2->qrx_tail, rxq-Quoted 1 line
bufq2->rx_tail);drivers/net/cpfl/cpfl_rxtx.c +6
-1}return err;@@ -1166,7 +1250,12 @@ cpfl_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id)return -EINVAL ; cpfl_rxq = dev->data->rx_queues[rx_queue_id]; - err =idpf_vc_queue_switch (vport, rx_queue_id, true, false); +if (cpfl_rxq->hairpin_info.hairpin_q) + err =cpfl_switch_hairpin_rxtx_queue (cpfl_vport, + rx_queue_id - cpfl_vport- >nb_data_txq, + true, false); +else + err =idpf_vc_queue_switch (vport, rx_queue_id, true, false);if (err !=0 ) {drivers/net/cpfl/cpfl_rxtx.c +10
-3PMD_DRV_LOG (ERR ,"Failed to switch RX queue %u off" , rx_queue_id);@@ -1180,10 +1269,17 @@ cpfl_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id)idpf_qc_single_rx_queue_reset (rxq ); }else { rxq->bufq1->ops->release_mbufs (rxq->bufq1); - rxq->bufq2->ops->release_mbufs (rxq->bufq2); -idpf_qc_split_rx_queue_reset (rxq); +if (rxq->bufq2) + rxq->bufq2->ops->release_mbufs (rxq->bufq2); +if (cpfl_rxq->hairpin_info.hairpin_q) { +cpfl_rx_hairpin_descq_reset (rxq); +cpfl_rx_hairpin_bufq_reset (rxq->bufq1); + }else { +idpf_qc_split_rx_queue_reset (rxq); + } } - dev->data->rx_queue_state[rx_queue_id] =RTE_ETH_QUEUE_STATE_STOPPED ; +if (!cpfl_rxq->hairpin_info.hairpin_q) + dev->data->rx_queue_state[rx_queue_id] =RTE_ETH_QUEUE_STATE_STOPPED ;drivers/net/cpfl/cpfl_rxtx.c +6
-1return 0 ; }@@ -1202,7 +1298,12 @@ cpfl_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id) cpfl_txq = dev->data->tx_queues[tx_queue_id]; - err =idpf_vc_queue_switch (vport, tx_queue_id, false, false); +if (cpfl_txq->hairpin_info.hairpin_q) + err =cpfl_switch_hairpin_rxtx_queue (cpfl_vport, + tx_queue_id - cpfl_vport- >nb_data_txq, + false, false); +else + err =idpf_vc_queue_switch (vport, tx_queue_id, false, false);if (err !=0 ) {drivers/net/cpfl/cpfl_rxtx.c +10
-3PMD_DRV_LOG (ERR ,"Failed to switch TX queue %u off" , tx_queue_id);@@ -1215,10 +1316,17 @@ cpfl_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id)if (vport->txq_model ==VIRTCHNL2_QUEUE_MODEL_SINGLE ) {idpf_qc_single_tx_queue_reset (txq); }else { -idpf_qc_split_tx_descq_reset (txq); -idpf_qc_split_tx_complq_reset (txq->complq); +if (cpfl_txq->hairpin_info.hairpin_q) { +cpfl_tx_hairpin_descq_reset (txq); +cpfl_tx_hairpin_complq_reset (txq->complq); + }else { +idpf_qc_split_tx_descq_reset (txq); +idpf_qc_split_tx_complq_reset (txq->complq); + } } - dev->data->tx_queue_state[tx_queue_id] =RTE_ETH_QUEUE_STATE_STOPPED ; + +if (!cpfl_txq->hairpin_info.hairpin_q) + dev->data->tx_queue_state[tx_queue_id] =RTE_ETH_QUEUE_STATE_STOPPED ;drivers/net/cpfl/cpfl_rxtx.c +7
-0return 0 ; }@@ -1238,10 +1346,17 @@ cpfl_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid) void cpfl_stop_queues(struct rte_eth_dev *dev) { +struct cpfl_vport *cpfl_vport = + (struct cpfl_vport *)dev->data->dev_private;struct cpfl_rx_queue *cpfl_rxq;struct cpfl_tx_queue *cpfl_txq;int i; +if (cpfl_vport->p2p_rx_bufq !=NULL ) { + if (cpfl_switch_hairpin_bufq_complq(cpfl_vport, false) != 0) + PMD_DRV_LOG(ERR, "Failed to stop hairpin Tx complq and Rx bufq"); + } + for (i = 0; i < dev->data->nb_rx_queues; i++) { cpfl_rxq = dev->data->rx_queues[i]; if (cpfl_rxq == NULL)(quoted diff) +0
-0
b/drivers/net/cpfl/cpfl_rxtx.hindex872ebc1bfd..42dfd07155100644drivers/net/cpfl/cpfl_rxtx.h +10
-0@@ -41,6 +41,17 @@#define CPFL_RX_BUF_STRIDE 64 +/* The value written in the RX buffer queue tail register, +* and in WritePTR field in the TX completion queue context, +* must be a multiple of 8. +*/ +#define CPFL_HAIRPIN_Q_TAIL_AUX_VALUE 8 + +struct virtchnl2_p2p_rx_buf_desc { +__le64 reserve0; +__le64 pkt_addr;/* Packet buffer address */ }; +struct cpfl_rxq_hairpin_info {bool hairpin_q;/* if rx queue is a hairpin queue */ uint16_t peer_txp;@@ -102,4 +113,7 @@ int cpfl_hairpin_tx_complq_config(struct
cpfl_vport*cpfl_vport); intcpfl_hairpin_txq_config(struct idpf_vport *vport, struct cpfl_tx_queue *cpfl_txq); intcpfl_hairpin_rx_bufq_config(struct cpfl_vport *cpfl_vport); intcpfl_hairpin_rxq_config(struct idpf_vport *vport, struct cpfl_rx_queue *cpfl_rxq);drivers/net/cpfl/cpfl_rxtx.h +3
-0+int cpfl_switch_hairpin_bufq_complq (struct cpfl_vport *cpfl_vport, +bool on);int cpfl_switch_hairpin_rxtx_queue (struct cpfl_vport +*cpfl_vport, uint16_tqid,
drivers/net/cpfl/cpfl_rxtx.h +1
-1+ bool rx, bool on);#endif /* _CPFL_RXTX_H_ */ --2.26.2
PATCH v4 10/13 common/idpf: add irq map config API
In reply to [email protected]From: Beilei Xing <[email protected]>
This patch supports idpf_vport_irq_map_config_by_qids API.
--- drivers/common/idpf/idpf_common_device.c | 75 ++++++++++++++++++++++++ drivers/common/idpf/idpf_common_device.h | 4 ++ drivers/common/idpf/version.map | 1 + 3 files changed, 80 insertions(+)
drivers/common/idpf/idpf_common_device.c +75 -0
@@ -667,6 +667,81 @@ idpf_vport_irq_map_config(struct idpf_vport *vport, uint16_t nb_rx_queues)return ret; } +int +idpf_vport_irq_map_config_by_qids (struct idpf_vport *vport,uint32_t *qids,uint16_t nb_rx_queues) +{ +struct idpf_adapter *adapter = vport->adapter; +struct virtchnl2_queue_vector *qv_map; +struct idpf_hw *hw = &adapter->hw; +uint32_t dynctl_val, itrn_val; +uint32_t dynctl_reg_start; +uint32_t itrn_reg_start; +uint16_t i; +int ret; + + qv_map =rte_zmalloc ("qv_map" , + nb_rx_queues * +sizeof (struct virtchnl2_queue_vector ),0 ); +if (qv_map ==NULL ) { +DRV_LOG (ERR ,"Failed to allocate %d queue-vector map" , + nb_rx_queues); + ret = -ENOMEM ; + goto qv_map_alloc_err; + } + +/* Rx interrupt disabled, Map interrupt only for writeback */ + +/* The capability flags adapter->caps.other_caps should be +* compared with bit VIRTCHNL2_CAP_WB_ON_ITR here. The if +* condition should be updated when the FW can return the +* correct flag bits. +*/ + dynctl_reg_start = + vport->recv_vectors->vchunks.vchunks->dynctl_reg_start; + itrn_reg_start = + vport->recv_vectors->vchunks.vchunks->itrn_reg_start; + dynctl_val =IDPF_READ_REG (hw, dynctl_reg_start); +DRV_LOG (DEBUG ,"Value of dynctl_reg_start is 0x%x" , dynctl_val); + itrn_val =IDPF_READ_REG (hw, itrn_reg_start); +DRV_LOG (DEBUG ,"Value of itrn_reg_start is 0x%x" , itrn_val); +/* Force write-backs by setting WB_ON_ITR bit in DYN_CTL +* register. WB_ON_ITR and INTENA are mutually exclusive +* bits. Setting WB_ON_ITR bits means TX and RX Descs +* are written back based on ITR expiration irrespective +* of INTENA setting. +*/ +/* TBD: need to tune INTERVAL value for better performance. */ + itrn_val = (itrn_val ==0 ) ?IDPF_DFLT_INTERVAL : itrn_val; + dynctl_val =VIRTCHNL2_ITR_IDX_0 << +PF_GLINT_DYN_CTL_ITR_INDX_S | +PF_GLINT_DYN_CTL_WB_ON_ITR_M | + itrn_val <<PF_GLINT_DYN_CTL_INTERVAL_S ; +IDPF_WRITE_REG (hw, dynctl_reg_start, dynctl_val); + +for (i =0 ; i < nb_rx_queues; i++) { +/* map all queues to the same vector */ + qv_map[i].queue_id = qids[i]; + qv_map[i].vector_id = + vport->recv_vectors->vchunks.vchunks->start_vector_id; + } + vport->qv_map = qv_map; + + ret =idpf_vc_irq_map_unmap_config (vport, nb_rx_queues, true); +if (ret !=0 ) { +DRV_LOG (ERR ,"config interrupt mapping failed" ); + goto config_irq_map_err; + } + +return 0 ; + +config_irq_map_err: +rte_free (vport->qv_map); + vport->qv_map =NULL ; + +qv_map_alloc_err: +return ret; +} +int idpf_vport_irq_unmap_config (struct idpf_vport *vport,uint16_t nb_rx_queues) {
drivers/common/idpf/idpf_common_device.h +4 -0
@@ -200,5 +200,9 @@ int idpf_vport_info_init(struct idpf_vport *vport, struct virtchnl2_create_vport *vport_info);__rte_internal void idpf_vport_stats_update(struct virtchnl2_vport_stats *oes, struct virtchnl2_vport_stats *nes); +__rte_internal +int idpf_vport_irq_map_config_by_qids(struct idpf_vport *vport, +uint32_t *qids, +uint16_t nb_rx_queues);#endif /* _IDPF_COMMON_DEVICE_H_ */
drivers/common/idpf/version.map +1 -0
@@ -69,6 +69,7 @@ INTERNAL { idpf_vport_info_init; idpf_vport_init; idpf_vport_irq_map_config; + idpf_vport_irq_map_config_by_qids; idpf_vport_irq_unmap_config; idpf_vport_rss_config; idpf_vport_stats_update;
Signature · 1 line
2.26.2
PATCH v4 11/13 net/cpfl: enable write back based on ITR expire
In reply to [email protected]From: Beilei Xing <[email protected]>
This patch enables write back based on ITR expire
(WR_ON_ITR) for hairpin queues.
--- drivers/net/cpfl/cpfl_ethdev.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
drivers/net/cpfl/cpfl_ethdev.c +12 -1
@@ -735,11 +735,22 @@ cpfl_dev_configure(struct rte_eth_dev *dev)static int cpfl_config_rx_queues_irqs (struct rte_eth_dev *dev) { +uint32_t qids[CPFL_MAX_P2P_NB_QUEUES +IDPF_DEFAULT_RXQ_NUM ] = {0 };struct cpfl_vport *cpfl_vport = dev->data->dev_private;struct idpf_vport *vport = &cpfl_vport->base;uint16_t nb_rx_queues = dev->data->nb_rx_queues; +struct cpfl_rx_queue *cpfl_rxq; +int i; -return idpf_vport_irq_map_config (vport, nb_rx_queues); +for (i =0 ; i < nb_rx_queues; i++) { + cpfl_rxq = dev->data->rx_queues[i]; +if (cpfl_rxq->hairpin_info.hairpin_q) + qids[i] =cpfl_hw_qid_get (cpfl_vport->p2p_q_chunks_info->rx_start_qid, + (i - cpfl_vport->nb_data_rxq)); +else + qids[i] =cpfl_hw_qid_get (vport->chunks_info.rx_start_qid, i); + } +return idpf_vport_irq_map_config_by_qids (vport, qids, nb_rx_queues); }/* Update hairpin_info for dev's tx hairpin queue */
Signature · 1 line
2.26.2
PATCH v4 12/13 net/cpfl: support peer ports get
In reply to [email protected]From: Beilei Xing <[email protected]>
This patch supports get hairpin peer ports.
--- drivers/net/cpfl/cpfl_ethdev.c | 40 ++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+)
drivers/net/cpfl/cpfl_ethdev.c +40 -0
@@ -1075,6 +1075,45 @@ cpfl_dev_close(struct rte_eth_dev *dev)return 0 ; } +static int +cpfl_hairpin_get_peer_ports (struct rte_eth_dev *dev,uint16_t *peer_ports, +size_t len,uint32_t tx) +{ +struct cpfl_vport *cpfl_vport = + (struct cpfl_vport *)dev->data->dev_private; +struct idpf_tx_queue *txq; +struct idpf_rx_queue *rxq; +struct cpfl_tx_queue *cpfl_txq; +struct cpfl_rx_queue *cpfl_rxq; +int i, j; + +if (len <=0 ) +return -EINVAL ; + +if (cpfl_vport->p2p_q_chunks_info ==NULL ) +return -ENOTSUP ; + +if (tx >0 ) { +for (i = cpfl_vport->nb_data_txq, j =0 ; i < dev->data->nb_tx_queues; i++, j++) { + txq = dev->data->tx_queues[i]; +if (txq ==NULL ) +return -EINVAL ; + cpfl_txq = (struct cpfl_tx_queue *)txq; + peer_ports[j] = cpfl_txq->hairpin_info.peer_rxp; + } + }else if (tx ==0 ) { +for (i = cpfl_vport->nb_data_rxq, j =0 ; i < dev->data->nb_rx_queues; i++, j++) { + rxq = dev->data->rx_queues[i]; +if (rxq ==NULL ) +return -EINVAL ; + cpfl_rxq = (struct cpfl_rx_queue *)rxq; + peer_ports[j] = cpfl_rxq->hairpin_info.peer_txp; + } + } + +return j; +} +static const struct eth_dev_ops cpfl_eth_dev_ops = { .dev_configure = cpfl_dev_configure, .dev_close = cpfl_dev_close,
@@ -1104,6 +1143,7 @@ static const struct eth_dev_ops cpfl_eth_dev_ops = { .hairpin_cap_get = cpfl_hairpin_cap_get, .rx_hairpin_queue_setup = cpfl_rx_hairpin_queue_setup, .tx_hairpin_queue_setup = cpfl_tx_hairpin_queue_setup, + .hairpin_get_peer_ports = cpfl_hairpin_get_peer_ports, }; static int
Signature · 1 line
2.26.2
PATCH v4 13/13 net/cpfl: support hairpin bind/unbind
In reply to [email protected]From: Beilei Xing <[email protected]>
This patch supports hairpin_bind/unbind ops.
--- drivers/net/cpfl/cpfl_ethdev.c | 137 +++++++++++++++++++++++++++++++++ drivers/net/cpfl/cpfl_rxtx.c | 28 +++++++ drivers/net/cpfl/cpfl_rxtx.h | 2 + 3 files changed, 167 insertions(+)
drivers/net/cpfl/cpfl_ethdev.c +137 -0
@@ -1114,6 +1114,141 @@ cpfl_hairpin_get_peer_ports(struct rte_eth_dev *dev, uint16_t *peer_ports,return j; } +static int +cpfl_hairpin_bind (struct rte_eth_dev *dev,uint16_t rx_port) +{ +struct cpfl_vport *cpfl_tx_vport = dev->data->dev_private; +struct idpf_vport *tx_vport = &cpfl_tx_vport->base; +struct cpfl_vport *cpfl_rx_vport; +struct cpfl_tx_queue *cpfl_txq; +struct cpfl_rx_queue *cpfl_rxq; +struct rte_eth_dev *peer_dev; +struct idpf_vport *rx_vport; +int err =0 ; +int i; + + err =cpfl_txq_hairpin_info_update (dev, rx_port); +if (err !=0 ) { +PMD_DRV_LOG (ERR ,"Fail to update Tx hairpin queue info." ); +return err; + } + +/* configure hairpin queues */ +for (i = cpfl_tx_vport->nb_data_txq; i < dev->data->nb_tx_queues; i++) { + cpfl_txq = dev->data->tx_queues[i]; + err =cpfl_hairpin_txq_config (tx_vport, cpfl_txq); +if (err !=0 ) { +PMD_DRV_LOG (ERR ,"Fail to configure hairpin Tx queue %u" , i); +return err; + } + } + + err =cpfl_hairpin_tx_complq_config (cpfl_tx_vport); +if (err !=0 ) { +PMD_DRV_LOG (ERR ,"Fail to config Tx completion queue" ); +return err; + } + + peer_dev = &rte_eth_devices[rx_port]; + cpfl_rx_vport = (struct cpfl_vport *)peer_dev->data->dev_private; + rx_vport = &cpfl_rx_vport->base; +cpfl_rxq_hairpin_mz_bind (peer_dev); + + err =cpfl_hairpin_rx_bufq_config (cpfl_rx_vport); +if (err !=0 ) { +PMD_DRV_LOG (ERR ,"Fail to config Rx buffer queue" ); +return err; + } + +for (i = cpfl_rx_vport->nb_data_rxq; i < peer_dev->data->nb_rx_queues; i++) { + cpfl_rxq = peer_dev->data->rx_queues[i]; + err =cpfl_hairpin_rxq_config (rx_vport, cpfl_rxq); +if (err !=0 ) { +PMD_DRV_LOG (ERR ,"Fail to configure hairpin Rx queue %u" , i); +return err; + } + err =cpfl_rx_queue_init (peer_dev, i); +if (err !=0 ) { +PMD_DRV_LOG (ERR ,"Fail to init hairpin Rx queue %u" , i); +return err; + } + } + +/* enable hairpin queues */ +for (i = cpfl_tx_vport->nb_data_txq; i < dev->data->nb_tx_queues; i++) { + cpfl_txq = dev->data->tx_queues[i]; + err =cpfl_switch_hairpin_rxtx_queue (cpfl_tx_vport, + i - cpfl_tx_vport->nb_data_txq, + false, true); +if (err !=0 ) { +PMD_DRV_LOG (ERR ,"Failed to switch hairpin TX queue %u on" , + i); +return err; + } + cpfl_txq->base.q_started = true; + } + + err =cpfl_switch_hairpin_complq (cpfl_tx_vport, true); +if (err !=0 ) { +PMD_DRV_LOG (ERR ,"Failed to switch hairpin Tx complq" ); +return err; + } + +for (i = cpfl_rx_vport->nb_data_rxq; i < peer_dev->data->nb_rx_queues; i++) { + cpfl_rxq = peer_dev->data->rx_queues[i]; + err =cpfl_switch_hairpin_rxtx_queue (cpfl_rx_vport, + i - cpfl_rx_vport->nb_data_rxq, + true, true); +if (err !=0 ) { +PMD_DRV_LOG (ERR ,"Failed to switch hairpin RX queue %u on" , + i); + } + cpfl_rxq->base.q_started = true; + } + + err =cpfl_switch_hairpin_bufq (cpfl_rx_vport, true); +if (err !=0 ) { +PMD_DRV_LOG (ERR ,"Failed to switch hairpin Rx buffer queue" ); +return err; + } + +return 0 ; +} + +static int +cpfl_hairpin_unbind (struct rte_eth_dev *dev,uint16_t rx_port) +{ +struct cpfl_vport *cpfl_tx_vport = dev->data->dev_private; +struct rte_eth_dev *peer_dev = &rte_eth_devices[rx_port]; +struct cpfl_vport *cpfl_rx_vport = peer_dev->data->dev_private; +struct cpfl_tx_queue *cpfl_txq; +struct cpfl_rx_queue *cpfl_rxq; +int i; + +/* disable hairpin queues */ +for (i = cpfl_tx_vport->nb_data_txq; i < dev->data->nb_tx_queues; i++) { + cpfl_txq = dev->data->tx_queues[i]; +cpfl_switch_hairpin_rxtx_queue (cpfl_tx_vport, + i - cpfl_tx_vport->nb_data_txq, + false, false); + cpfl_txq->base.q_started = false; + } + +cpfl_switch_hairpin_complq (cpfl_tx_vport, false); + +for (i = cpfl_rx_vport->nb_data_rxq; i < peer_dev->data->nb_rx_queues; i++) { + cpfl_rxq = peer_dev->data->rx_queues[i]; +cpfl_switch_hairpin_rxtx_queue (cpfl_rx_vport, + i - cpfl_rx_vport->nb_data_rxq, + true, false); + cpfl_rxq->base.q_started = false; + } + +cpfl_switch_hairpin_bufq (cpfl_rx_vport, false); + +return 0 ; +} +static const struct eth_dev_ops cpfl_eth_dev_ops = { .dev_configure = cpfl_dev_configure, .dev_close = cpfl_dev_close,
@@ -1144,6 +1279,8 @@ static const struct eth_dev_ops cpfl_eth_dev_ops = { .rx_hairpin_queue_setup = cpfl_rx_hairpin_queue_setup, .tx_hairpin_queue_setup = cpfl_tx_hairpin_queue_setup, .hairpin_get_peer_ports = cpfl_hairpin_get_peer_ports, + .hairpin_bind = cpfl_hairpin_bind, + .hairpin_unbind = cpfl_hairpin_unbind, }; static int
drivers/net/cpfl/cpfl_rxtx.c +28 -0
@@ -1011,6 +1011,34 @@ cpfl_switch_hairpin_bufq_complq(struct cpfl_vport *cpfl_vport, bool on)return err; } +int +cpfl_switch_hairpin_complq (struct cpfl_vport *cpfl_vport,bool on) +{ +struct idpf_vport *vport = &cpfl_vport->base; +uint32_t type; +int err, queue_id; + + type =VIRTCHNL2_QUEUE_TYPE_TX_COMPLETION ; + queue_id = cpfl_vport->p2p_tx_complq->queue_id; + err =idpf_vc_ena_dis_one_queue (vport, queue_id, type, on); + +return err; +} + +int +cpfl_switch_hairpin_bufq (struct cpfl_vport *cpfl_vport,bool on) +{ +struct idpf_vport *vport = &cpfl_vport->base; +uint32_t type; +int err, queue_id; + + type =VIRTCHNL2_QUEUE_TYPE_RX_BUFFER ; + queue_id = cpfl_vport->p2p_rx_bufq->queue_id; + err =idpf_vc_ena_dis_one_queue (vport, queue_id, type, on); + +return err; +} +int cpfl_switch_hairpin_rxtx_queue (struct cpfl_vport *cpfl_vport,uint16_t logic_qid,bool rx,bool on)
drivers/net/cpfl/cpfl_rxtx.h +2 -0
@@ -114,6 +114,8 @@ int cpfl_hairpin_txq_config(struct idpf_vport *vport, struct cpfl_tx_queue *cpflint cpfl_hairpin_rx_bufq_config (struct cpfl_vport *cpfl_vport);int cpfl_hairpin_rxq_config (struct idpf_vport *vport,struct cpfl_rx_queue *cpfl_rxq);int cpfl_switch_hairpin_bufq_complq (struct cpfl_vport *cpfl_vport,bool on); +int cpfl_switch_hairpin_complq (struct cpfl_vport *cpfl_vport,bool on); +int cpfl_switch_hairpin_bufq (struct cpfl_vport *cpfl_vport,bool on);int cpfl_switch_hairpin_rxtx_queue (struct cpfl_vport *cpfl_vport,uint16_t qid,bool rx,bool on);#endif /* _CPFL_RXTX_H_ */
Signature · 1 line
2.26.2
RE: [PATCH v4 13/13] net/cpfl: support hairpin bind/unbind
Quoted 58 lines
-----Original Message-----
From: Xing, Beilei <[email protected]>
Sent: Friday, May 26, 2023 3:39 PM
To: Wu, Jingjing <[email protected]>
Cc: [email protected]; Liu, Mingxia <[email protected]>; Xing, Beilei <[email protected]>; Wang, Xiao W <[email protected]>
Subject: [PATCH v4 13/13] net/cpfl: support hairpin bind/unbindFrom: Beilei Xing <[email protected]>
This patch supports hairpin_bind/unbind ops.
Signed-off-by Xiao Wang <[email protected]>Signed-off-by Beilei Xing <[email protected]>--- drivers/net/cpfl/cpfl_ethdev.c | 137 +++++++++++++++++++++++++++++++++ drivers/net/cpfl/cpfl_rxtx.c | 28 +++++++ drivers/net/cpfl/cpfl_rxtx.h | 2 + 3 files changed, 167 insertions(+)drivers/net/cpfl/cpfl_ethdev.c index renamed from drivers/net/cpfl/cpfl_ethdev.c +0
-0
d6dc1672f1..4b70441e27100644drivers/net/cpfl/cpfl_ethdev.c +0
-0@@ -1114,6 +1114,141 @@ cpfl_hairpin_get_peer_ports(struct rte_eth_dev *dev, uint16_t *peer_ports, return j; } static intdrivers/net/cpfl/cpfl_rxtx.c index renamed from drivers/net/cpfl/cpfl_rxtx.c +0
-0
38c48ad8c7..ef83a03c2b100644drivers/net/cpfl/cpfl_rxtx.c +16
-0@@ -1011,6 +1011,34 @@ cpfl_switch_hairpin_bufq_complq(struct cpfl_vport *cpfl_vport, bool on)return err; } +int +cpfl_switch_hairpin_complq (struct cpfl_vport *cpfl_vport,bool on) { +struct idpf_vport *vport = &cpfl_vport->base; +uint32_t type; +int err, queue_id; + + type =VIRTCHNL2_QUEUE_TYPE_TX_COMPLETION ; + queue_id = cpfl_vport->p2p_tx_complq->queue_id; + err =idpf_vc_ena_dis_one_queue (vport, queue_id, type, on); + +return err; +} + +int +cpfl_switch_hairpin_bufq (struct cpfl_vport *cpfl_vport,bool on) { +struct idpf_vport *vport = &cpfl_vport->base;
drivers/net/cpfl/cpfl_rxtx.c cpfl_switch_hairpin_bufq_complq(struct cpfl_vport · line 1040
Quoted 10 lines
drivers/net/cpfl/cpfl_rxtx.c +10
-0+uint32_t type; +int err, queue_id; + + type =VIRTCHNL2_QUEUE_TYPE_RX_BUFFER ; + queue_id = cpfl_vport->p2p_rx_bufq->queue_id; + err =idpf_vc_ena_dis_one_queue (vport, queue_id, type, on); + +return err; +} +
[Liu, Mingxia] Can cpfl_switch_hairpin_bufq_complq() in patch 9/13 be optimized by calling cpfl_switch_hairpin_complq() and cpfl_switch_hairpin_bufq()?
Quoted 20 lines
drivers/net/cpfl/cpfl_rxtx.c +0
-0int cpfl_switch_hairpin_rxtx_queue(struct cpfl_vport *cpfl_vport, uint16_t
logic_qid,drivers/net/cpfl/cpfl_rxtx.c +0
-0bool rx, bool on)drivers/net/cpfl/cpfl_rxtx.h index renamed from drivers/net/cpfl/cpfl_rxtx.h +0
-0
42dfd07155..86e97541c4100644drivers/net/cpfl/cpfl_rxtx.h +0
-0@@ -114,6 +114,8 @@ int cpfl_hairpin_txq_config(struct idpf_vport *vport,struct
cpfl_tx_queue*cpfl intcpfl_hairpin_rx_bufq_config(struct cpfl_vport *cpfl_vport); intcpfl_hairpin_rxq_config(struct idpf_vport *vport, struct cpfl_rx_queue *cpfl_rxq); intcpfl_switch_hairpin_bufq_complq(struct cpfl_vport *cpfl_vport, bool on);drivers/net/cpfl/cpfl_rxtx.h +2
-1+int cpfl_switch_hairpin_complq (struct cpfl_vport *cpfl_vport,bool on); +int cpfl_switch_hairpin_bufq (struct cpfl_vport *cpfl_vport,bool on);int cpfl_switch_hairpin_rxtx_queue (struct cpfl_vport *cpfl_vport,uint16_t qid,bool rx,bool on);#endif /* _CPFL_RXTX_H_ */ --2.26.2
RE: [PATCH v4 13/13] net/cpfl: support hairpin bind/unbind
Quoted 74 lines
-----Original Message-----
From: Liu, Mingxia <[email protected]>
Sent: Tuesday, May 30, 2023 12:00 PM
To: Xing, Beilei <[email protected]>; Wu, Jingjing <[email protected]>
Cc: [email protected]; Wang, Xiao W <[email protected]>
Subject: RE: [PATCH v4 13/13] net/cpfl: support hairpin bind/unbinddrivers/net/cpfl/cpfl_ethdev.c cpfl_hairpin_get_peer_ports(struct
Quoted 26 lines
-----Original Message-----
From: Xing, Beilei <[email protected]>
Sent: Friday, May 26, 2023 3:39 PM
To: Wu, Jingjing <[email protected]>
Cc: [email protected]; Liu, Mingxia <[email protected]>; Xing, Beilei <[email protected]>; Wang, Xiao W <[email protected]>
Subject: [PATCH v4 13/13] net/cpfl: support hairpin bind/unbindFrom: Beilei Xing <[email protected]>
This patch supports hairpin_bind/unbind ops.
Signed-off-by Xiao Wang <[email protected]>Signed-off-by Beilei Xing <[email protected]>--- drivers/net/cpfl/cpfl_ethdev.c | 137 +++++++++++++++++++++++++++++++++ drivers/net/cpfl/cpfl_rxtx.c | 28 +++++++ drivers/net/cpfl/cpfl_rxtx.h | 2 + 3 files changed, 167 insertions(+)(quoted diff) +0
-0
b/drivers/net/cpfl/cpfl_ethdev.cindexd6dc1672f1..4b70441e27100644drivers/net/cpfl/cpfl_ethdev.c +0
-0@@ -1114,6 +1114,141 @@ cpfl_hairpin_get_peer_ports(struct
rte_eth_devQuoted 36 lines
drivers/net/cpfl/cpfl_ethdev.c +0
-0*dev, uint16_t *peer_ports, return j; } static int(quoted diff) +0
-0
b/drivers/net/cpfl/cpfl_rxtx.cindex38c48ad8c7..ef83a03c2b100644drivers/net/cpfl/cpfl_rxtx.c +21
-0@@ -1011,6 +1011,34 @@ cpfl_switch_hairpin_bufq_complq(struct cpfl_vport *cpfl_vport, bool on) return err; } +int +cpfl_switch_hairpin_complq (struct cpfl_vport *cpfl_vport,bool on) { +struct idpf_vport *vport = &cpfl_vport->base; +uint32_t type; +int err, queue_id; + + type =VIRTCHNL2_QUEUE_TYPE_TX_COMPLETION ; + queue_id = cpfl_vport->p2p_tx_complq->queue_id; + err =idpf_vc_ena_dis_one_queue (vport, queue_id, type, on); + +return err; +} + +int +cpfl_switch_hairpin_bufq (struct cpfl_vport *cpfl_vport,bool on) { +struct idpf_vport *vport = &cpfl_vport->base; +uint32_t type; +int err, queue_id; + + type =VIRTCHNL2_QUEUE_TYPE_RX_BUFFER ; + queue_id = cpfl_vport->p2p_rx_bufq->queue_id;
Quoted 8 lines
drivers/net/cpfl/cpfl_rxtx.c cpfl_switch_hairpin_bufq_complq(struct cpfl_vport *cpfl_vport, bool on) · line 1027
Quoted 5 lines
drivers/net/cpfl/cpfl_rxtx.c +5
-0+ err =idpf_vc_ena_dis_one_queue (vport, queue_id, type, on); + +return err; +} +[Liu, Mingxia] Can
cpfl_switch_hairpin_bufq_complq()in patch 9/13 be optimized by callingcpfl_switch_hairpin_complq()andcpfl_switch_hairpin_bufq()?
Yes, the functions are duplicated. Refined in next version.
Quoted 24 lines
Quoted 15 lines
drivers/net/cpfl/cpfl_rxtx.c +0
-0int cpfl_switch_hairpin_rxtx_queue(struct cpfl_vport *cpfl_vport,
uint16_tlogic_qid,drivers/net/cpfl/cpfl_rxtx.c +0
-0bool rx, bool on)(quoted diff) +0
-0
b/drivers/net/cpfl/cpfl_rxtx.hindex42dfd07155..86e97541c4100644drivers/net/cpfl/cpfl_rxtx.h +0
-0@@ -114,6 +114,8 @@ int cpfl_hairpin_txq_config(struct idpf_vport *vport, struct cpfl_tx_queue *cpfl int
cpfl_hairpin_rx_bufq_config(struct cpfl_vport *cpfl_vport); intcpfl_hairpin_rxq_config(struct idpf_vport *vport, struct cpfl_rx_queue *cpfl_rxq); intcpfl_switch_hairpin_bufq_complq(struct cpfl_vport *cpfl_vport, bool on);drivers/net/cpfl/cpfl_rxtx.h
Quoted 4 lines
drivers/net/cpfl/cpfl_rxtx.h +3
-0+int cpfl_switch_hairpin_complq (struct cpfl_vport *cpfl_vport,bool +on);int cpfl_switch_hairpin_bufq (struct cpfl_vport *cpfl_vport,bool +on); int cpfl_switch_hairpin_rxtx_queue(struct cpfl_vport *cpfl_vport, uint16_tqid,
Quoted 4 lines
bool rx, bool on);
#endif /* _CPFL_RXTX_H_ */
--
2.26.2
v5 cover net/cpfl: add hairpin queue support
In reply to [email protected]From: Beilei Xing <[email protected]>
This patchset adds hairpin queue support.
v2 changes:
- change hairpin rx queus configuration sequence.
- code refine.
v3 changes:
- Refine the patchset based on the latest code.
v4 change:
- Remove hairpin rx buffer queue's sw_ring.
- Change hairpin rx queus configuration sequence in cpfl_hairpin_bind function.
- Refind hairpin queue setup and release.
v5 change:
- Fix memory leak during queue setup.
- Refine hairpin Rxq/Txq start/stop.
Beilei Xing (13):
net/cpfl: refine structures
common/idpf: support queue groups add/delete net/cpfl: add haipin queue group during vport init net/cpfl: support hairpin queue capbility get net/cpfl: support hairpin queue setup and release common/idpf: add queue config API net/cpfl: support hairpin queue configuration common/idpf: add switch queue API net/cpfl: support hairpin queue start/stop common/idpf: add irq map config API net/cpfl: enable write back based on ITR expire net/cpfl: support peer ports get
net/cpfl: support hairpin bind/unbind
drivers/common/idpf/idpf_common_device.c | 75 ++ drivers/common/idpf/idpf_common_device.h | 4 + drivers/common/idpf/idpf_common_virtchnl.c | 138 +++- drivers/common/idpf/idpf_common_virtchnl.h | 18 + drivers/common/idpf/version.map | 6 + drivers/net/cpfl/cpfl_ethdev.c | 610 ++++++++++++++-- drivers/net/cpfl/cpfl_ethdev.h | 35 +- drivers/net/cpfl/cpfl_rxtx.c | 781 +++++++++++++++++++-- drivers/net/cpfl/cpfl_rxtx.h | 76 ++ drivers/net/cpfl/cpfl_rxtx_vec_common.h | 21 +- 10 files changed, 1645 insertions(+), 119 deletions(-)
Signature · 1 line
2.26.2
PATCH v5 1/13 net/cpfl: refine structures
From: Beilei Xing <[email protected]>
This patch refines some structures to support hairpin queue, cpfl_rx_queue/cpfl_tx_queue/cpfl_vport.
--- drivers/net/cpfl/cpfl_ethdev.c | 85 +++++++----- drivers/net/cpfl/cpfl_ethdev.h | 6 +- drivers/net/cpfl/cpfl_rxtx.c | 175 +++++++++++++++++------- drivers/net/cpfl/cpfl_rxtx.h | 8 ++ drivers/net/cpfl/cpfl_rxtx_vec_common.h | 17 +-- 5 files changed, 196 insertions(+), 95 deletions(-)
drivers/net/cpfl/cpfl_ethdev.c +49 -36
@@ -124,7 +124,8 @@ static int cpfl_dev_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complete) { - struct idpf_vport *vport = dev->data->dev_private; + struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;struct rte_eth_link new_link;unsigned int i;
@@ -156,7 +157,8 @@ cpfl_dev_link_update(struct rte_eth_dev *dev,static int cpfl_dev_info_get (struct rte_eth_dev *dev,struct rte_eth_dev_info *dev_info) { -struct idpf_vport *vport = dev->data->dev_private; +struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;struct idpf_adapter *base = vport->adapter; dev_info->max_rx_queues = base->caps.max_rx_q;
@@ -216,7 +218,8 @@ cpfl_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)static int cpfl_dev_mtu_set (struct rte_eth_dev *dev,uint16_t mtu) { -struct idpf_vport *vport = dev->data->dev_private; +struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;/* mtu setting is forbidden if port is start */ if (dev->data->dev_started) {
@@ -256,12 +259,12 @@ static uint64_t cpfl_get_mbuf_alloc_failed_stats(struct rte_eth_dev *dev) {uint64_t mbuf_alloc_failed =0 ; -struct idpf_rx_queue *rxq; +struct cpfl_rx_queue *cpfl_rxq;int i =0 ;for (i =0 ; i < dev->data->nb_rx_queues; i++) { - rxq = dev->data->rx_queues[i]; - mbuf_alloc_failed +=__atomic_load_n (&rxq->rx_stats.mbuf_alloc_failed, + cpfl_rxq = dev->data->rx_queues[i]; + mbuf_alloc_failed +=__atomic_load_n (&cpfl_rxq->base.rx_stats.mbuf_alloc_failed, __ATOMIC_RELAXED); }
@@ -271,8 +274,8 @@ cpfl_get_mbuf_alloc_failed_stats(struct rte_eth_dev *dev)static int cpfl_dev_stats_get (struct rte_eth_dev *dev,struct rte_eth_stats *stats) { -struct idpf_vport *vport = - (struct idpf_vport *)dev->data->dev_private; +struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;struct virtchnl2_vport_stats *pstats =NULL ;int ret;
@@ -305,20 +308,20 @@ cpfl_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)static void cpfl_reset_mbuf_alloc_failed_stats (struct rte_eth_dev *dev) { -struct idpf_rx_queue *rxq; +struct cpfl_rx_queue *cpfl_rxq;int i;for (i =0 ; i < dev->data->nb_rx_queues; i++) { - rxq = dev->data->rx_queues[i]; -__atomic_store_n (&rxq->rx_stats.mbuf_alloc_failed,0 , __ATOMIC_RELAXED); + cpfl_rxq = dev->data->rx_queues[i]; +__atomic_store_n (&cpfl_rxq->base.rx_stats.mbuf_alloc_failed,0 , __ATOMIC_RELAXED); } }static int cpfl_dev_stats_reset (struct rte_eth_dev *dev) { -struct idpf_vport *vport = - (struct idpf_vport *)dev->data->dev_private; +struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;struct virtchnl2_vport_stats *pstats =NULL ;int ret;
@@ -343,8 +346,8 @@ static int cpfl_dev_xstats_reset(struct rte_eth_dev *dev)static int cpfl_dev_xstats_get (struct rte_eth_dev *dev,struct rte_eth_xstat *xstats,unsigned int n) { -struct idpf_vport *vport = - (struct idpf_vport *)dev->data->dev_private; +struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;struct virtchnl2_vport_stats *pstats =NULL ;unsigned int i;int ret;
@@ -459,7 +462,8 @@ cpfl_rss_reta_update(struct rte_eth_dev *dev, struct rte_eth_rss_reta_entry64 *reta_conf, uint16_t reta_size) { -struct idpf_vport *vport = dev->data->dev_private; +struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;struct idpf_adapter *base = vport->adapter;uint16_t idx, shift;int ret =0 ;
@@ -498,7 +502,8 @@ cpfl_rss_reta_query(struct rte_eth_dev *dev, struct rte_eth_rss_reta_entry64 *reta_conf, uint16_t reta_size) { -struct idpf_vport *vport = dev->data->dev_private; +struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;struct idpf_adapter *base = vport->adapter;uint16_t idx, shift;int ret =0 ;
@@ -536,7 +541,8 @@ static int cpfl_rss_hash_update(struct rte_eth_dev *dev, struct rte_eth_rss_conf *rss_conf) { - struct idpf_vport *vport = dev->data->dev_private; + struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;struct idpf_adapter *base = vport->adapter;int ret =0 ;
@@ -601,7 +607,8 @@ static int cpfl_rss_hash_conf_get(struct rte_eth_dev *dev, struct rte_eth_rss_conf *rss_conf) { - struct idpf_vport *vport = dev->data->dev_private; + struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;struct idpf_adapter *base = vport->adapter;int ret =0 ;
@@ -638,7 +645,8 @@ cpfl_rss_hash_conf_get(struct rte_eth_dev *dev,static int cpfl_dev_configure (struct rte_eth_dev *dev) { -struct idpf_vport *vport = dev->data->dev_private; +struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;struct rte_eth_conf *conf = &dev->data->dev_conf;struct idpf_adapter *base = vport->adapter;int ret;
@@ -710,7 +718,8 @@ cpfl_dev_configure(struct rte_eth_dev *dev)static int cpfl_config_rx_queues_irqs (struct rte_eth_dev *dev) { -struct idpf_vport *vport = dev->data->dev_private; +struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;uint16_t nb_rx_queues = dev->data->nb_rx_queues;return idpf_vport_irq_map_config (vport, nb_rx_queues);
@@ -719,14 +728,14 @@ cpfl_config_rx_queues_irqs(struct rte_eth_dev *dev)static int cpfl_start_queues (struct rte_eth_dev *dev) { -struct idpf_rx_queue *rxq; -struct idpf_tx_queue *txq; +struct cpfl_rx_queue *cpfl_rxq; +struct cpfl_tx_queue *cpfl_txq;int err =0 ;int i;for (i =0 ; i < dev->data->nb_tx_queues; i++) { - txq = dev->data->tx_queues[i]; -if (txq ==NULL || txq->tx_deferred_start) + cpfl_txq = dev->data->tx_queues[i]; +if (cpfl_txq ==NULL || cpfl_txq->base.tx_deferred_start)continue ; err =cpfl_tx_queue_start (dev, i);if (err !=0 ) {
@@ -736,8 +745,8 @@ cpfl_start_queues(struct rte_eth_dev *dev) }for (i =0 ; i < dev->data->nb_rx_queues; i++) { - rxq = dev->data->rx_queues[i]; -if (rxq ==NULL || rxq->rx_deferred_start) + cpfl_rxq = dev->data->rx_queues[i]; +if (cpfl_rxq ==NULL || cpfl_rxq->base.rx_deferred_start)continue ; err =cpfl_rx_queue_start (dev, i);if (err !=0 ) {
@@ -752,7 +761,8 @@ cpfl_start_queues(struct rte_eth_dev *dev)static int cpfl_dev_start (struct rte_eth_dev *dev) { -struct idpf_vport *vport = dev->data->dev_private; +struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;struct idpf_adapter *base = vport->adapter;struct cpfl_adapter_ext *adapter =CPFL_ADAPTER_TO_EXT (base);uint16_t num_allocated_vectors = base->caps.num_allocated_vectors;
@@ -813,7 +823,8 @@ cpfl_dev_start(struct rte_eth_dev *dev)static int cpfl_dev_stop (struct rte_eth_dev *dev) { -struct idpf_vport *vport = dev->data->dev_private; +struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;if (dev->data->dev_started ==0 )return 0 ;
@@ -832,7 +843,8 @@ cpfl_dev_stop(struct rte_eth_dev *dev)static int cpfl_dev_close (struct rte_eth_dev *dev) { -struct idpf_vport *vport = dev->data->dev_private; +struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;struct cpfl_adapter_ext *adapter =CPFL_ADAPTER_TO_EXT (vport->adapter);cpfl_dev_stop (dev);
@@ -842,7 +854,7 @@ cpfl_dev_close(struct rte_eth_dev *dev) adapter->cur_vport_nb--; dev->data->dev_private =NULL ; adapter->vports[vport->sw_idx] =NULL ; -rte_free (vport); +rte_free (cpfl_vport);return 0 ; }
@@ -1047,7 +1059,7 @@ cpfl_find_vport(struct cpfl_adapter_ext *adapter, uint32_t vport_id)int i;for (i =0 ; i < adapter->cur_vport_nb; i++) { - vport = adapter->vports[i]; + vport = &adapter->vports[i]->base;if (vport->vport_id != vport_id)continue ;else
@@ -1275,7 +1287,8 @@ cpfl_vport_idx_alloc(struct cpfl_adapter_ext *adapter)static int cpfl_dev_vport_init (struct rte_eth_dev *dev,void *init_params) { -struct idpf_vport *vport = dev->data->dev_private; +struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base;struct cpfl_vport_param *param = init_params;struct cpfl_adapter_ext *adapter = param->adapter;/* for sending create vport virtchnl msg prepare */
@@ -1300,7 +1313,7 @@ cpfl_dev_vport_init(struct rte_eth_dev *dev, void *init_params) goto err; } - adapter->vports[param->idx] = vport; + adapter->vports[param->idx] = cpfl_vport; adapter->cur_vports |=RTE_BIT32 (param->devarg_id); adapter->cur_vport_nb++;
@@ -1415,7 +1428,7 @@ cpfl_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,snprintf (name,sizeof (name),"cpfl_%s_vport_0" , pci_dev->device.name); retval =rte_eth_dev_create (&pci_dev->device, name, -sizeof (struct idpf_vport ), +sizeof (struct cpfl_vport ),NULL ,NULL , cpfl_dev_vport_init, &vport_param);if (retval !=0 )
@@ -1433,7 +1446,7 @@ cpfl_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, pci_dev->device.name, devargs.req_vports[i]); retval =rte_eth_dev_create (&pci_dev->device, name, -sizeof (struct idpf_vport ), +sizeof (struct cpfl_vport ),NULL ,NULL , cpfl_dev_vport_init, &vport_param);if (retval !=0 )
drivers/net/cpfl/cpfl_ethdev.h +5 -1
@@ -69,13 +69,17 @@ struct cpfl_devargs {uint16_t req_vport_nb; }; +struct cpfl_vport { +struct idpf_vport base; +}; +struct cpfl_adapter_ext {TAILQ_ENTRY (cpfl_adapter_ext) next;struct idpf_adapter base;char name[CPFL_ADAPTER_NAME_LEN ]; -struct idpf_vport **vports; +struct cpfl_vport **vports;uint16_t max_vport_nb;uint16_t cur_vports;/* bit mask of created vport */
drivers/net/cpfl/cpfl_rxtx.c +125 -50
401 lines not on this page · raw message
drivers/net/cpfl/cpfl_rxtx.h +8 -0
@@ -23,6 +23,14 @@#define CPFL_SUPPORT_CHAIN_NUM 5 +struct cpfl_rx_queue { +struct idpf_rx_queue base; +}; + +struct cpfl_tx_queue { +struct idpf_tx_queue base; +}; +int cpfl_tx_queue_setup (struct rte_eth_dev *dev,uint16_t queue_idx,uint16_t nb_desc,unsigned int socket_id,const struct rte_eth_txconf *tx_conf);
drivers/net/cpfl/cpfl_rxtx_vec_common.h +9 -8
@@ -76,15 +76,16 @@ cpfl_rx_splitq_vec_default(struct idpf_rx_queue *rxq)static inline int cpfl_rx_vec_dev_check_default (struct rte_eth_dev *dev) { -struct idpf_vport *vport = dev->data->dev_private; -struct idpf_rx_queue *rxq; +struct cpfl_vport *cpfl_vport = dev->data->dev_private; +struct idpf_vport *vport = &cpfl_vport->base; +struct cpfl_rx_queue *cpfl_rxq;int i, default_ret, splitq_ret, ret =CPFL_SCALAR_PATH ;for (i =0 ; i < dev->data->nb_rx_queues; i++) { - rxq = dev->data->rx_queues[i]; - default_ret =cpfl_rx_vec_queue_default (rxq); + cpfl_rxq = dev->data->rx_queues[i]; + default_ret =cpfl_rx_vec_queue_default (&cpfl_rxq->base);if (vport->rxq_model ==VIRTCHNL2_QUEUE_MODEL_SPLIT ) { - splitq_ret =cpfl_rx_splitq_vec_default (rxq); + splitq_ret =cpfl_rx_splitq_vec_default (&cpfl_rxq->base); ret = splitq_ret && default_ret; }else { ret = default_ret;
@@ -100,12 +101,12 @@ static inline int cpfl_tx_vec_dev_check_default(struct rte_eth_dev *dev) {int i; -struct idpf_tx_queue *txq; +struct cpfl_tx_queue *cpfl_txq;int ret =0 ;for (i =0 ; i < dev->data->nb_tx_queues; i++) { - txq = dev->data->tx_queues[i]; - ret =cpfl_tx_vec_queue_default (txq); + cpfl_txq = dev->data->tx_queues[i]; + ret =cpfl_tx_vec_queue_default (&cpfl_txq->base);if (ret ==CPFL_SCALAR_PATH )return CPFL_SCALAR_PATH ; }
Signature · 1 line
2.26.2