net/idpf: refactor idpf pmd
Subsystems (2)
cover net/idpf: refactor idpf pmd
From: Beilei Xing <[email protected]>
Refactor idpf pmd by introducing idpf common module, which will be also consumed by a new PMD - CPFL (Control Plane Function Library) PMD.
The patchset depends on this following patchset:
https://patches.dpdk.org/project/dpdk/cover/[email protected]/
Beilei Xing (15):
common/idpf: add adapter structure
common/idpf: add vport structure
common/idpf: move vc functions to common module common/idpf: introduce adapter init and deinit common/idpf: add vport init/deinit
common/idpf: add config RSS
common/idpf: add irq map/unmap
common/idpf: move ptype table to adapter structure common/idpf: init create vport info
common/idpf: add vector flags in vport common/idpf: add rxq and txq struct
common/idpf: add help functions for queue setup and release common/idpf: add scalar data path
common/idpf: add vec queue setup
common/idpf: add avx512 for single queue model
drivers/common/idpf/base/meson.build | 2 +-
drivers/common/idpf/idpf_common_device.c | 675 ++++++
drivers/common/idpf/idpf_common_device.h | 192 ++
drivers/common/idpf/idpf_common_logs.h | 47 +
drivers/common/idpf/idpf_common_rxtx.c | 1456 ++++++++++++
drivers/common/idpf/idpf_common_rxtx.h | 278 +++
.../idpf/idpf_common_rxtx_avx512.c} | 12 +-
.../idpf/idpf_common_virtchnl.c} | 881 ++-----
drivers/common/idpf/idpf_common_virtchnl.h | 41 +
drivers/common/idpf/meson.build | 38 +
drivers/common/idpf/version.map | 40 +
drivers/net/idpf/idpf_ethdev.c | 530 +----
drivers/net/idpf/idpf_ethdev.h | 194 +-
drivers/net/idpf/idpf_logs.h | 24 -
drivers/net/idpf/idpf_rxtx.c | 2034 +++--------------
drivers/net/idpf/idpf_rxtx.h | 253 +-
drivers/net/idpf/meson.build | 18 -
17 files changed, 3344 insertions(+), 3371 deletions(-)
create mode 100644 drivers/common/idpf/idpf_common_device.c
create mode 100644 drivers/common/idpf/idpf_common_device.h
create mode 100644 drivers/common/idpf/idpf_common_logs.h
create mode 100644 drivers/common/idpf/idpf_common_rxtx.c
create mode 100644 drivers/common/idpf/idpf_common_rxtx.h
rename drivers/{net/idpf/idpf_rxtx_vec_avx512.c => common/idpf/idpf_common_rxtx_avx512.c} (98%)
rename drivers/{net/idpf/idpf_vchnl.c => common/idpf/idpf_common_virtchnl.c} (56%)
create mode 100644 drivers/common/idpf/idpf_common_virtchnl.hSignature · 1 line
2.26.2
PATCH 1/15 common/idpf: add adapter structure
From: Beilei Xing <[email protected]>
Add structure idpf_adapter in common module, the structure includes some basic fields.
Introduce structure idpf_adapter_ext in PMD, this structure includes extra fileds except idpf_adapter.
--- drivers/common/idpf/idpf_common_device.h | 20 ++++++ drivers/net/idpf/idpf_ethdev.c | 89 ++++++++++-------------- drivers/net/idpf/idpf_ethdev.h | 25 +++---- drivers/net/idpf/idpf_rxtx.c | 16 ++--- drivers/net/idpf/idpf_rxtx.h | 4 +- drivers/net/idpf/idpf_rxtx_vec_avx512.c | 3 +- drivers/net/idpf/idpf_vchnl.c | 30 ++++---- 7 files changed, 98 insertions(+), 89 deletions(-) create mode 100644 drivers/common/idpf/idpf_common_device.h
drivers/common/idpf/idpf_common_device.h new file +20 -0
@@ -0,0 +1,20 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2022 Intel Corporation +*/ + +#ifndef _IDPF_COMMON_DEVICE_H_ +#define _IDPF_COMMON_DEVICE_H_ + +#include <base/idpf_prototype.h> +#include <base/virtchnl2.h> + +struct idpf_adapter { +struct idpf_hw hw; +struct virtchnl2_version_info virtchnl_version; +struct virtchnl2_get_capabilities caps; +volatile uint32_t pend_cmd;/* pending command not finished */ +uint32_t cmd_retval;/* return value of the cmd response from cp */ +uint8_t *mbx_resp;/* buffer to store the mailbox response from cp */ +}; + +#endif /* _IDPF_COMMON_DEVICE_H_ */
drivers/net/idpf/idpf_ethdev.c +37 -52
231 lines not on this page · raw message
drivers/net/idpf/idpf_ethdev.h +11 -14
@@ -15,6 +15,7 @@#include "idpf_logs.h" +#include <idpf_common_device.h> #include <base/idpf_prototype.h> #include <base/virtchnl2.h>
@@ -90,7 +91,7 @@ struct idpf_chunks_info { };struct idpf_vport_param { -struct idpf_adapter *adapter; +struct idpf_adapter_ext *adapter;uint16_t devarg_id;/* arg id from user */ uint16_t idx;/* index in adapter->vports[]*/ };
@@ -143,17 +144,11 @@ struct idpf_devargs {uint16_t req_vport_nb; }; -struct idpf_adapter { -TAILQ_ENTRY (idpf_adapter) next; -struct idpf_hw hw; -char name[IDPF_ADAPTER_NAME_LEN ]; - -struct virtchnl2_version_info virtchnl_version; -struct virtchnl2_get_capabilities *caps; +struct idpf_adapter_ext { +TAILQ_ENTRY (idpf_adapter_ext) next; +struct idpf_adapter base; -volatile uint32_t pend_cmd;/* pending command not finished */ -uint32_t cmd_retval;/* return value of the cmd response from ipf */ -uint8_t *mbx_resp;/* buffer to store the mailbox response from ipf */ +char name[IDPF_ADAPTER_NAME_LEN ];uint32_t txq_model;/* 0 - split queue model, non-0 - single queue model */ uint32_t rxq_model;/* 0 - split queue model, non-0 - single queue model */
@@ -181,10 +176,12 @@ struct idpf_adapter {uint64_t time_hw; }; -TAILQ_HEAD (idpf_adapter_list, idpf_adapter); +TAILQ_HEAD (idpf_adapter_list, idpf_adapter_ext);#define IDPF_DEV_TO_PCI (eth_dev) \ RTE_DEV_TO_PCI((eth_dev)->device) +#define IDPF_ADAPTER_TO_EXT (p) \ + container_of((p), struct idpf_adapter_ext, base)/* structure used for sending and checking response of virtchnl ops */ struct idpf_cmd_info {
@@ -233,10 +230,10 @@ atomic_set_cmd(struct idpf_adapter *adapter, uint32_t ops)return !ret; } -struct idpf_adapter *idpf_find_adapter (struct rte_pci_device *pci_dev); +struct idpf_adapter_ext *idpf_find_adapter_ext (struct rte_pci_device *pci_dev);void idpf_handle_virtchnl_msg (struct rte_eth_dev *dev);int idpf_vc_check_api_version (struct idpf_adapter *adapter); -int idpf_get_pkt_type (struct idpf_adapter *adapter); +int idpf_get_pkt_type (struct idpf_adapter_ext *adapter);int idpf_vc_get_caps (struct idpf_adapter *adapter);int idpf_vc_create_vport (struct idpf_vport *vport,struct virtchnl2_create_vport *vport_info);
drivers/net/idpf/idpf_rxtx.c +8 -8
@@ -1384,7 +1384,7 @@ idpf_splitq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,struct idpf_rx_queue *rxq;const uint32_t *ptype_tbl;uint8_t status_err0_qw1; -struct idpf_adapter *ad; +struct idpf_adapter_ext *ad;struct rte_mbuf *rxm;uint16_t rx_id_bufq1;uint16_t rx_id_bufq2;
@@ -1398,7 +1398,7 @@ idpf_splitq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, nb_rx =0 ; rxq = rx_queue; - ad = rxq->adapter; + ad =IDPF_ADAPTER_TO_EXT (rxq->adapter);if (unlikely (rxq ==NULL ) ||unlikely (!rxq->q_started))return nb_rx;
@@ -1407,7 +1407,7 @@ idpf_splitq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, rx_id_bufq1 = rxq->bufq1->rx_next_avail; rx_id_bufq2 = rxq->bufq2->rx_next_avail; rx_desc_ring = rxq->rx_ring; - ptype_tbl = rxq->adapter->ptype_tbl; + ptype_tbl = ad->ptype_tbl;if ((rxq->offloads &RTE_ETH_RX_OFFLOAD_TIMESTAMP ) !=0 ) rxq->hw_register_set =1 ;
@@ -1791,7 +1791,7 @@ idpf_singleq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,const uint32_t *ptype_tbl;uint16_t rx_id, nb_hold;struct rte_eth_dev *dev; -struct idpf_adapter *ad; +struct idpf_adapter_ext *ad;uint16_t rx_packet_len;struct rte_mbuf *rxm;struct rte_mbuf *nmb;
@@ -1805,14 +1805,14 @@ idpf_singleq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, nb_hold =0 ; rxq = rx_queue; - ad = rxq->adapter; + ad =IDPF_ADAPTER_TO_EXT (rxq->adapter);if (unlikely (rxq ==NULL ) ||unlikely (!rxq->q_started))return nb_rx; rx_id = rxq->rx_tail; rx_ring = rxq->rx_ring; - ptype_tbl = rxq->adapter->ptype_tbl; + ptype_tbl = ad->ptype_tbl;if ((rxq->offloads &RTE_ETH_RX_OFFLOAD_TIMESTAMP ) !=0 ) rxq->hw_register_set =1 ;
@@ -2221,7 +2221,7 @@ idpf_set_rx_function(struct rte_eth_dev *dev) {struct idpf_vport *vport = dev->data->dev_private;#ifdef RTE_ARCH_X86 -struct idpf_adapter *ad = vport->adapter; +struct idpf_adapter_ext *ad =IDPF_ADAPTER_TO_EXT (vport->adapter);struct idpf_rx_queue *rxq;int i;
@@ -2275,7 +2275,7 @@ idpf_set_tx_function(struct rte_eth_dev *dev) {struct idpf_vport *vport = dev->data->dev_private;#ifdef RTE_ARCH_X86 -struct idpf_adapter *ad = vport->adapter; +struct idpf_adapter_ext *ad =IDPF_ADAPTER_TO_EXT (vport->adapter);#ifdef CC_AVX512_SUPPORT struct idpf_tx_queue *txq;int i;
drivers/net/idpf/idpf_rxtx.h +2 -2
@@ -247,11 +247,11 @@ void idpf_set_tx_function(struct rte_eth_dev *dev);/* Helper function to convert a 32b nanoseconds timestamp to 64b. */ static inline uint64_t -idpf_tstamp_convert_32b_64b (struct idpf_adapter *ad,uint32_t flag, +idpf_tstamp_convert_32b_64b (struct idpf_adapter_ext *ad,uint32_t flag,uint32_t in_timestamp) {#ifdef RTE_ARCH_X86_64 -struct idpf_hw *hw = &ad->hw; +struct idpf_hw *hw = &ad->base.hw;const uint64_t mask =0xFFFFFFFF ;uint32_t hi, lo, lo2, delta;uint64_t ns;
drivers/net/idpf/idpf_rxtx_vec_avx512.c +2 -1
@@ -245,7 +245,8 @@ _idpf_singleq_recv_raw_pkts_avx512(struct idpf_rx_queue *rxq, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) { -const uint32_t *type_table = rxq->adapter->ptype_tbl; +struct idpf_adapter_ext *adapter =IDPF_ADAPTER_TO_EXT (rxq->adapter); +const uint32_t *type_table = adapter->ptype_tbl;const __m256i mbuf_init =_mm256_set_epi64x (0 ,0 ,0 , rxq->mbuf_initializer);
drivers/net/idpf/idpf_vchnl.c +18 -12
@@ -311,13 +311,17 @@ idpf_vc_check_api_version(struct idpf_adapter *adapter) } int __rte_cold -idpf_get_pkt_type (struct idpf_adapter *adapter) +idpf_get_pkt_type (struct idpf_adapter_ext *adapter) {struct virtchnl2_get_ptype_info *ptype_info; -uint16_t ptype_recvd =0 , ptype_offset, i, j; +struct idpf_adapter *base; +uint16_t ptype_offset, i, j; +uint16_t ptype_recvd =0 ;int ret; - ret =idpf_vc_query_ptype_info (adapter); + base = &adapter->base; + + ret =idpf_vc_query_ptype_info (base);if (ret !=0 ) {PMD_DRV_LOG (ERR ,"Fail to query packet type information" );return ret;
@@ -328,7 +332,7 @@ idpf_get_pkt_type(struct idpf_adapter *adapter)return -ENOMEM ;while (ptype_recvd <IDPF_MAX_PKT_TYPE ) { - ret =idpf_read_one_msg (adapter,VIRTCHNL2_OP_GET_PTYPE_INFO , + ret =idpf_read_one_msg (base,VIRTCHNL2_OP_GET_PTYPE_INFO ,IDPF_DFLT_MBX_BUF_SIZE , (u8 *)ptype_info);if (ret !=0 ) {PMD_DRV_LOG (ERR ,"Fail to get packet type information" );
@@ -515,7 +519,7 @@ idpf_get_pkt_type(struct idpf_adapter *adapter) free_ptype_info:rte_free (ptype_info); -clear_cmd (adapter); +clear_cmd (base);return ret; }
@@ -577,7 +581,7 @@ idpf_vc_get_caps(struct idpf_adapter *adapter)return err; } -rte_memcpy (adapter->caps, args.out_buffer,sizeof (caps_msg)); +rte_memcpy (&adapter->caps, args.out_buffer,sizeof (caps_msg));return 0 ; }
@@ -740,7 +744,8 @@ idpf_vc_set_rss_hash(struct idpf_vport *vport)int idpf_vc_config_rxqs (struct idpf_vport *vport) { -struct idpf_adapter *adapter = vport->adapter; +struct idpf_adapter *base = vport->adapter; +struct idpf_adapter_ext *adapter =IDPF_ADAPTER_TO_EXT (base);struct idpf_rx_queue **rxq = (struct idpf_rx_queue **)vport->dev_data->rx_queues;struct virtchnl2_config_rx_queues *vc_rxqs =NULL ;
@@ -832,10 +837,10 @@ idpf_vc_config_rxqs(struct idpf_vport *vport) 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_buffer = base->mbx_resp; args.out_size =IDPF_DFLT_MBX_BUF_SIZE ; - err =idpf_execute_vc_cmd (adapter, &args); + err =idpf_execute_vc_cmd (base, &args);rte_free (vc_rxqs);if (err !=0 ) {PMD_DRV_LOG (ERR ,"Failed to execute command of VIRTCHNL2_OP_CONFIG_RX_QUEUES" );
@@ -940,7 +945,8 @@ idpf_vc_config_rxq(struct idpf_vport *vport, uint16_t rxq_id)int idpf_vc_config_txqs (struct idpf_vport *vport) { -struct idpf_adapter *adapter = vport->adapter; +struct idpf_adapter *base = vport->adapter; +struct idpf_adapter_ext *adapter =IDPF_ADAPTER_TO_EXT (base);struct idpf_tx_queue **txq = (struct idpf_tx_queue **)vport->dev_data->tx_queues;struct virtchnl2_config_tx_queues *vc_txqs =NULL ;
@@ -1010,10 +1016,10 @@ idpf_vc_config_txqs(struct idpf_vport *vport) 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_buffer = base->mbx_resp; args.out_size =IDPF_DFLT_MBX_BUF_SIZE ; - err =idpf_execute_vc_cmd (adapter, &args); + err =idpf_execute_vc_cmd (base, &args);rte_free (vc_txqs);if (err !=0 ) {PMD_DRV_LOG (ERR ,"Failed to execute command of VIRTCHNL2_OP_CONFIG_TX_QUEUES" );
Signature · 1 line
2.26.2
PATCH 2/15 common/idpf: add vport structure
In reply to [email protected]From: Beilei Xing <[email protected]>
Move idpf_vport structure to common module, remove ethdev dependency. Also remove unused functions.
--- drivers/common/idpf/idpf_common_device.h | 59 ++++++ drivers/net/idpf/idpf_ethdev.c | 10 +- drivers/net/idpf/idpf_ethdev.h | 66 +----- drivers/net/idpf/idpf_rxtx.c | 4 +- drivers/net/idpf/idpf_rxtx.h | 3 + drivers/net/idpf/idpf_vchnl.c | 252 +++-------------------- 6 files changed, 96 insertions(+), 298 deletions(-)
drivers/common/idpf/idpf_common_device.h +59 -0
@@ -17,4 +17,63 @@ struct idpf_adapter {uint8_t *mbx_resp;/* buffer to store the mailbox response from cp */ }; +struct idpf_chunks_info { +uint32_t tx_start_qid; +uint32_t rx_start_qid; +/* Valid only if split queue model */ +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 idpf_vport { +struct idpf_adapter *adapter;/* Backreference to associated adapter */ +struct virtchnl2_create_vport *vport_info;/* virtchnl response info handling */ +uint16_t sw_idx;/* SW index in adapter->vports[]*/ +uint16_t vport_id; +uint32_t txq_model; +uint32_t rxq_model; +uint16_t num_tx_q; +/* valid only if txq_model is split Q */ +uint16_t num_tx_complq; +uint16_t num_rx_q; +/* valid only if rxq_model is split Q */ +uint16_t num_rx_bufq; + +uint16_t max_mtu; +uint8_t default_mac_addr[VIRTCHNL_ETH_LENGTH_OF_ADDRESS ]; + +enum virtchnl_rss_algorithm rss_algorithm; +uint16_t rss_key_size; +uint16_t rss_lut_size; + +void *dev_data;/* Pointer to the device data */ +uint16_t max_pkt_len;/* Maximum packet length */ + +/* RSS info */ +uint32_t *rss_lut; +uint8_t *rss_key; +uint64_t rss_hf; + +/* MSIX info*/ +struct virtchnl2_queue_vector *qv_map;/* queue vector mapping */ +uint16_t max_vectors; +struct virtchnl2_alloc_vectors *recv_vectors; + +/* Chunk info */ +struct idpf_chunks_info chunks_info; + +uint16_t devarg_id; + +bool stopped; +}; +#endif /* _IDPF_COMMON_DEVICE_H_ */
drivers/net/idpf/idpf_ethdev.c +6 -4
@@ -266,11 +266,13 @@ static int idpf_init_rss(struct idpf_vport *vport) {struct rte_eth_rss_conf *rss_conf; +struct rte_eth_dev_data *dev_data;uint16_t i, nb_q, lut_size;int ret =0 ; - rss_conf = &vport->dev_data->dev_conf.rx_adv_conf.rss_conf; - nb_q = vport->dev_data->nb_rx_queues; + dev_data = vport->dev_data; + rss_conf = &dev_data->dev_conf.rx_adv_conf.rss_conf; + nb_q = dev_data->nb_rx_queues; vport->rss_key =rte_zmalloc ("rss_key" , vport->rss_key_size,0 );
@@ -453,7 +455,7 @@ idpf_config_rx_queues_irqs(struct rte_eth_dev *dev) } vport->qv_map = qv_map; -if (idpf_vc_config_irq_map_unmap (vport, true) !=0 ) { +if (idpf_vc_config_irq_map_unmap (vport, dev->data->nb_rx_queues, true) !=0 ) {PMD_DRV_LOG (ERR ,"config interrupt mapping failed" ); goto config_irq_map_err; }
@@ -577,7 +579,7 @@ idpf_dev_stop(struct rte_eth_dev *dev)idpf_stop_queues (dev); -idpf_vc_config_irq_map_unmap (vport, false); +idpf_vc_config_irq_map_unmap (vport, dev->data->nb_rx_queues, false);if (vport->recv_vectors !=NULL )idpf_vc_dealloc_vectors (vport);
drivers/net/idpf/idpf_ethdev.h +2 -64
88 lines not on this page · raw message
drivers/net/idpf/idpf_rxtx.c +2 -2
@@ -1066,7 +1066,7 @@ idpf_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id) dev->data->rx_queues[rx_queue_id];int err =0 ; - err =idpf_vc_config_rxq (vport, rx_queue_id); + err =idpf_vc_config_rxq (vport, rxq);if (err !=0 ) {PMD_DRV_LOG (ERR ,"Fail to configure Rx queue %u" , rx_queue_id);return err;
@@ -1117,7 +1117,7 @@ idpf_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id) dev->data->tx_queues[tx_queue_id];int err =0 ; - err =idpf_vc_config_txq (vport, tx_queue_id); + err =idpf_vc_config_txq (vport, txq);if (err !=0 ) {PMD_DRV_LOG (ERR ,"Fail to configure Tx queue %u" , tx_queue_id);return err;
drivers/net/idpf/idpf_rxtx.h +3 -0
@@ -243,6 +243,9 @@ void idpf_stop_queues(struct rte_eth_dev *dev);void idpf_set_rx_function (struct rte_eth_dev *dev);void idpf_set_tx_function (struct rte_eth_dev *dev); +int idpf_vc_config_rxq (struct idpf_vport *vport,struct idpf_rx_queue *rxq); +int idpf_vc_config_txq (struct idpf_vport *vport,struct idpf_tx_queue *txq); +#define IDPF_TIMESYNC_REG_WRAP_GUARD_BAND 10000/* Helper function to convert a 32b nanoseconds timestamp to 64b. */ static inline uint64_t
drivers/net/idpf/idpf_vchnl.c +24 -228
327 lines not on this page · raw message
Signature · 1 line
2.26.2
PATCH 3/15 common/idpf: move vc functions to common module
In reply to [email protected]From: Beilei Xing <[email protected]>
Move most of virtual channel functions to idpf common module.
--- drivers/common/idpf/base/meson.build | 2 +- drivers/common/idpf/idpf_common_device.c | 8 + drivers/common/idpf/idpf_common_device.h | 61 ++ drivers/common/idpf/idpf_common_logs.h | 23 + drivers/common/idpf/idpf_common_virtchnl.c | 815 +++++++++++++++++++++ drivers/common/idpf/idpf_common_virtchnl.h | 48 ++ drivers/common/idpf/meson.build | 5 + drivers/common/idpf/version.map | 16 + drivers/net/idpf/idpf_ethdev.c | 9 +- drivers/net/idpf/idpf_ethdev.h | 85 +-- drivers/net/idpf/idpf_vchnl.c | 815 +-------------------- 11 files changed, 981 insertions(+), 906 deletions(-) create mode 100644 drivers/common/idpf/idpf_common_device.c create mode 100644 drivers/common/idpf/idpf_common_logs.h create mode 100644 drivers/common/idpf/idpf_common_virtchnl.c create mode 100644 drivers/common/idpf/idpf_common_virtchnl.h
drivers/common/idpf/base/meson.build +1 -1
@@ -1,7 +1,7 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2022 Intel Corporation -sources = files( +sources += files( 'idpf_common.c', 'idpf_controlq.c', 'idpf_controlq_setup.c',
drivers/common/idpf/idpf_common_device.c new file +8 -0
@@ -0,0 +1,8 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2022 Intel Corporation +*/ + +#include <rte_log.h> +#include <idpf_common_device.h> + +RTE_LOG_REGISTER_SUFFIX (idpf_common_logtype, common,NOTICE );
drivers/common/idpf/idpf_common_device.h +61 -0
71 lines not on this page · raw message
drivers/common/idpf/idpf_common_logs.h new file +23 -0
@@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2022 Intel Corporation +*/ + +#ifndef _IDPF_COMMON_LOGS_H_ +#define _IDPF_COMMON_LOGS_H_ + +#include <rte_log.h> + +extern int idpf_common_logtype; + +#define DRV_LOG_RAW (level, ...) \ + rte_log(RTE_LOG_ ## level, \ + idpf_common_logtype, \ + RTE_FMT("%s(): " \ + RTE_FMT_HEAD(__VA_ARGS__,) "\n", \ + __func__, \ + RTE_FMT_TAIL(__VA_ARGS__,))) + +#define DRV_LOG(level, fmt, args...) \ + DRV_LOG_RAW(level, fmt "\n", ## args) + +#endif /* _IDPF_COMMON_LOGS_H_ */
drivers/common/idpf/idpf_common_virtchnl.c new file +815 -0
815 lines not on this page · raw message
drivers/common/idpf/idpf_common_virtchnl.h new file +48 -0
48 lines not on this page · raw message
drivers/common/idpf/meson.build +5 -0
@@ -1,4 +1,9 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2022 Intel Corporation +sources = files( + 'idpf_common_device.c', + 'idpf_common_virtchnl.c', +) + subdir('base')
drivers/common/idpf/version.map +16 -0
@@ -7,6 +7,22 @@ INTERNAL { idpf_ctlq_recv; idpf_ctlq_send; idpf_ctlq_post_rx_buffs; + idpf_vc_check_api_version; + idpf_vc_get_caps; + idpf_vc_create_vport; + idpf_vc_destroy_vport; + idpf_vc_set_rss_key; + idpf_vc_set_rss_lut; + idpf_vc_set_rss_hash; + idpf_switch_queue; + idpf_vc_ena_dis_queues; + idpf_vc_ena_dis_vport; + idpf_vc_config_irq_map_unmap; + idpf_vc_alloc_vectors; + idpf_vc_dealloc_vectors; + idpf_vc_query_ptype_info; + idpf_read_one_msg; + idpf_execute_vc_cmd; local: *; };
drivers/net/idpf/idpf_ethdev.c +1 -8
@@ -937,13 +937,6 @@ idpf_adapter_init(struct rte_pci_device *pci_dev, struct idpf_adapter_ext *adapt goto err_api; } - adapter->max_rxq_per_msg = (IDPF_DFLT_MBX_BUF_SIZE - -sizeof (struct virtchnl2_config_rx_queues )) / -sizeof (struct virtchnl2_rxq_info ); - adapter->max_txq_per_msg = (IDPF_DFLT_MBX_BUF_SIZE - -sizeof (struct virtchnl2_config_tx_queues )) / -sizeof (struct virtchnl2_txq_info ); - adapter->cur_vports =0 ; adapter->cur_vport_nb =0 ;
@@ -1070,7 +1063,7 @@ static const struct rte_pci_id pci_id_idpf_map[] = { { .vendor_id = 0, /* sentinel */ }, }; -struct idpf_adapter_ext * +static struct idpf_adapter_ext *idpf_find_adapter_ext (struct rte_pci_device *pci_dev) {struct idpf_adapter_ext *adapter;
drivers/net/idpf/idpf_ethdev.h +1 -84
121 lines not on this page · raw message
drivers/net/idpf/idpf_vchnl.c +2 -813
842 lines not on this page · raw message
Signature · 1 line
2.26.2
PATCH 4/15 common/idpf: introduce adapter init and deinit
In reply to [email protected]From: Beilei Xing <[email protected]>
Introduce base init and deinit in common module.
--- drivers/common/idpf/idpf_common_device.c | 153 ++++++++++++++++++++ drivers/common/idpf/idpf_common_device.h | 6 + drivers/common/idpf/idpf_common_virtchnl.h | 2 - drivers/common/idpf/version.map | 4 +- drivers/net/idpf/idpf_ethdev.c | 158 +++------------------ drivers/net/idpf/idpf_ethdev.h | 2 - 6 files changed, 178 insertions(+), 147 deletions(-)
drivers/common/idpf/idpf_common_device.c +153 -0
@@ -4,5 +4,158 @@#include <rte_log.h> #include <idpf_common_device.h> +#include <idpf_common_virtchnl.h> + +static void +idpf_reset_pf (struct idpf_hw *hw) +{ +uint32_t reg; + + reg =IDPF_READ_REG (hw,PFGEN_CTRL ); +IDPF_WRITE_REG (hw,PFGEN_CTRL , (reg |PFGEN_CTRL_PFSWR )); +} + +#define IDPF_RESET_WAIT_CNT 100 +static int +idpf_check_pf_reset_done (struct idpf_hw *hw) +{ +uint32_t reg; +int i; + +for (i =0 ; i <IDPF_RESET_WAIT_CNT ; i++) { + reg =IDPF_READ_REG (hw,PFGEN_RSTAT ); +if (reg !=0xFFFFFFFF && (reg &PFGEN_RSTAT_PFR_STATE_M )) +return 0 ; +rte_delay_ms (1000 ); + } + +DRV_LOG (ERR ,"IDPF reset timeout" ); +return -EBUSY ; +} + +#define CTLQ_NUM 2 +static int +idpf_init_mbx (struct idpf_hw *hw) +{ +struct idpf_ctlq_create_info ctlq_info[CTLQ_NUM ] = { + { + .type =IDPF_CTLQ_TYPE_MAILBOX_TX , + .id =IDPF_CTLQ_ID , + .len =IDPF_CTLQ_LEN , + .buf_size =IDPF_DFLT_MBX_BUF_SIZE , + .reg = { + .head =PF_FW_ATQH , + .tail =PF_FW_ATQT , + .len =PF_FW_ATQLEN , + .bah =PF_FW_ATQBAH , + .bal =PF_FW_ATQBAL , + .len_mask =PF_FW_ATQLEN_ATQLEN_M , + .len_ena_mask =PF_FW_ATQLEN_ATQENABLE_M , + .head_mask =PF_FW_ATQH_ATQH_M , + } + }, + { + .type =IDPF_CTLQ_TYPE_MAILBOX_RX , + .id =IDPF_CTLQ_ID , + .len =IDPF_CTLQ_LEN , + .buf_size =IDPF_DFLT_MBX_BUF_SIZE , + .reg = { + .head =PF_FW_ARQH , + .tail =PF_FW_ARQT , + .len =PF_FW_ARQLEN , + .bah =PF_FW_ARQBAH , + .bal =PF_FW_ARQBAL , + .len_mask =PF_FW_ARQLEN_ARQLEN_M , + .len_ena_mask =PF_FW_ARQLEN_ARQENABLE_M , + .head_mask =PF_FW_ARQH_ARQH_M , + } + } + }; +struct idpf_ctlq_info *ctlq; +int ret; + + ret =idpf_ctlq_init (hw,CTLQ_NUM , ctlq_info); +if (ret !=0 ) +return ret; + +LIST_FOR_EACH_ENTRY_SAFE (ctlq,NULL , &hw->cq_list_head, + struct idpf_ctlq_info, cq_list) { +if (ctlq->q_id ==IDPF_CTLQ_ID && + ctlq->cq_type ==IDPF_CTLQ_TYPE_MAILBOX_TX ) + hw->asq = ctlq; +if (ctlq->q_id ==IDPF_CTLQ_ID && + ctlq->cq_type ==IDPF_CTLQ_TYPE_MAILBOX_RX ) + hw->arq = ctlq; + } + +if (hw->asq ==NULL || hw->arq ==NULL ) { +idpf_ctlq_deinit (hw); + ret = -ENOENT ; + } + +return ret; +} + +int +idpf_adapter_init (struct idpf_adapter *adapter) +{ +struct idpf_hw *hw = &adapter->hw; +int ret; + +idpf_reset_pf (hw); + ret =idpf_check_pf_reset_done (hw); +if (ret !=0 ) { +DRV_LOG (ERR ,"IDPF is still resetting" ); + goto err_check_reset; + } + + ret =idpf_init_mbx (hw); +if (ret !=0 ) { +DRV_LOG (ERR ,"Failed to init mailbox" ); + goto err_check_reset; + } + + adapter->mbx_resp =rte_zmalloc ("idpf_adapter_mbx_resp" , +IDPF_DFLT_MBX_BUF_SIZE ,0 ); +if (adapter->mbx_resp ==NULL ) { +DRV_LOG (ERR ,"Failed to allocate idpf_adapter_mbx_resp memory" ); + ret = -ENOMEM ; + goto err_mbx_resp; + } + + ret =idpf_vc_check_api_version (adapter); +if (ret !=0 ) { +DRV_LOG (ERR ,"Failed to check api version" ); + goto err_check_api; + } + + ret =idpf_vc_get_caps (adapter); +if (ret !=0 ) { +DRV_LOG (ERR ,"Failed to get capabilities" ); + goto err_check_api; + } + +return 0 ; + +err_check_api: +rte_free (adapter->mbx_resp); + adapter->mbx_resp =NULL ; +err_mbx_resp: +idpf_ctlq_deinit (hw); +err_check_reset: +return ret; +} + +int +idpf_adapter_deinit (struct idpf_adapter *adapter) +{ +struct idpf_hw *hw = &adapter->hw; + +idpf_ctlq_deinit (hw); +rte_free (adapter->mbx_resp); + adapter->mbx_resp =NULL ; + +return 0 ; +}RTE_LOG_REGISTER_SUFFIX (idpf_common_logtype, common,NOTICE );
drivers/common/idpf/idpf_common_device.h +6 -0
@@ -9,6 +9,7 @@#include <base/virtchnl2.h> #include <idpf_common_logs.h> +#define IDPF_CTLQ_ID -1#define IDPF_CTLQ_LEN 64#define IDPF_DFLT_MBX_BUF_SIZE 4096
@@ -137,4 +138,9 @@ atomic_set_cmd(struct idpf_adapter *adapter, uint32_t ops)return !ret; } +__rte_internal +int idpf_adapter_init(struct idpf_adapter *adapter); +__rte_internal +int idpf_adapter_deinit(struct idpf_adapter *adapter); +#endif /* _IDPF_COMMON_DEVICE_H_ */
drivers/common/idpf/idpf_common_virtchnl.h +0 -2
@@ -7,9 +7,7 @@#include <idpf_common_device.h> -__rte_internal int idpf_vc_check_api_version (struct idpf_adapter *adapter); -__rte_internal int idpf_vc_get_caps (struct idpf_adapter *adapter); __rte_internal int idpf_vc_create_vport(struct idpf_vport *vport,
drivers/common/idpf/version.map +2 -2
@@ -7,8 +7,6 @@ INTERNAL { idpf_ctlq_recv; idpf_ctlq_send; idpf_ctlq_post_rx_buffs; - idpf_vc_check_api_version; - idpf_vc_get_caps; idpf_vc_create_vport; idpf_vc_destroy_vport; idpf_vc_set_rss_key;
@@ -23,6 +21,8 @@ INTERNAL { idpf_vc_query_ptype_info; idpf_read_one_msg; idpf_execute_vc_cmd; + idpf_adapter_init; + idpf_adapter_deinit; local: *; };
drivers/net/idpf/idpf_ethdev.c +17 -141
219 lines not on this page · raw message
drivers/net/idpf/idpf_ethdev.h +0 -2
@@ -31,8 +31,6 @@#define IDPF_RXQ_PER_GRP 1#define IDPF_RX_BUFQ_PER_GRP 2 -#define IDPF_CTLQ_ID -1 -#define IDPF_DFLT_Q_VEC_NUM 1#define IDPF_DFLT_INTERVAL 16
Signature · 1 line
2.26.2
PATCH 5/15 common/idpf: add vport init/deinit
In reply to [email protected]From: Beilei Xing <[email protected]>
Add vport init/deinit in common module.
--- drivers/common/idpf/idpf_common_device.c | 128 +++++++++++++++++++ drivers/common/idpf/idpf_common_device.h | 8 ++ drivers/common/idpf/idpf_common_virtchnl.c | 16 +-- drivers/common/idpf/idpf_common_virtchnl.h | 2 - drivers/common/idpf/version.map | 4 +- drivers/net/idpf/idpf_ethdev.c | 138 ++------------------- 6 files changed, 156 insertions(+), 140 deletions(-)
drivers/common/idpf/idpf_common_device.c +128 -0
@@ -158,4 +158,132 @@ idpf_adapter_deinit(struct idpf_adapter *adapter)return 0 ; } +int +idpf_vport_init (struct idpf_vport *vport, +struct virtchnl2_create_vport *create_vport_info, +void *dev_data) +{ +struct virtchnl2_create_vport *vport_info; +int i, type, ret; + + vport->vport_info =rte_zmalloc (NULL ,IDPF_DFLT_MBX_BUF_SIZE ,0 ); +if (vport->vport_info ==NULL ) { +DRV_LOG (ERR ,"Failed to allocate vport_info" ); + ret = -ENOMEM ; + goto err_vport_info; + } + + ret =idpf_vc_create_vport (vport, create_vport_info); +if (ret !=0 ) { +DRV_LOG (ERR ,"Failed to create vport." ); + goto err_create_vport; + } + + vport_info = vport->vport_info; + vport->vport_id = vport_info->vport_id; + vport->txq_model = vport_info->txq_model; + vport->rxq_model = vport_info->rxq_model; + vport->num_tx_q = vport_info->num_tx_q; + vport->num_tx_complq = vport_info->num_tx_complq; + vport->num_rx_q = vport_info->num_rx_q; + vport->num_rx_bufq = vport_info->num_rx_bufq; + vport->max_mtu = vport_info->max_mtu; +rte_memcpy (vport->default_mac_addr, + vport_info->default_mac_addr,ETH_ALEN ); + vport->rss_algorithm = vport_info->rss_algorithm; + vport->rss_key_size =RTE_MIN (IDPF_RSS_KEY_LEN , + vport_info->rss_key_size); + vport->rss_lut_size = vport_info->rss_lut_size; + +for (i =0 ; i < vport_info->chunks.num_chunks; i++) { + type = vport_info->chunks.chunks[i].type; +switch (type) { +case VIRTCHNL2_QUEUE_TYPE_TX : + vport->chunks_info.tx_start_qid = + vport_info->chunks.chunks[i].start_queue_id; + vport->chunks_info.tx_qtail_start = + vport_info->chunks.chunks[i].qtail_reg_start; + vport->chunks_info.tx_qtail_spacing = + vport_info->chunks.chunks[i].qtail_reg_spacing; +break ; +case VIRTCHNL2_QUEUE_TYPE_RX : + vport->chunks_info.rx_start_qid = + vport_info->chunks.chunks[i].start_queue_id; + vport->chunks_info.rx_qtail_start = + vport_info->chunks.chunks[i].qtail_reg_start; + vport->chunks_info.rx_qtail_spacing = + vport_info->chunks.chunks[i].qtail_reg_spacing; +break ; +case VIRTCHNL2_QUEUE_TYPE_TX_COMPLETION : + vport->chunks_info.tx_compl_start_qid = + vport_info->chunks.chunks[i].start_queue_id; + vport->chunks_info.tx_compl_qtail_start = + vport_info->chunks.chunks[i].qtail_reg_start; + vport->chunks_info.tx_compl_qtail_spacing = + vport_info->chunks.chunks[i].qtail_reg_spacing; +break ; +case VIRTCHNL2_QUEUE_TYPE_RX_BUFFER : + vport->chunks_info.rx_buf_start_qid = + vport_info->chunks.chunks[i].start_queue_id; + vport->chunks_info.rx_buf_qtail_start = + vport_info->chunks.chunks[i].qtail_reg_start; + vport->chunks_info.rx_buf_qtail_spacing = + vport_info->chunks.chunks[i].qtail_reg_spacing; +break ; +default : +DRV_LOG (ERR ,"Unsupported queue type" ); +break ; + } + } + + vport->dev_data = dev_data; + + vport->rss_key =rte_zmalloc ("rss_key" , + vport->rss_key_size,0 ); +if (vport->rss_key ==NULL ) { +DRV_LOG (ERR ,"Failed to allocate RSS key" ); + ret = -ENOMEM ; + goto err_rss_key; + } + + vport->rss_lut =rte_zmalloc ("rss_lut" , +sizeof (uint32_t ) * vport->rss_lut_size,0 ); +if (vport->rss_lut ==NULL ) { +DRV_LOG (ERR ,"Failed to allocate RSS lut" ); + ret = -ENOMEM ; + goto err_rss_lut; + } + +return 0 ; + +err_rss_lut: + vport->dev_data =NULL ; +rte_free (vport->rss_key); + vport->rss_key =NULL ; +err_rss_key: +idpf_vc_destroy_vport (vport); +err_create_vport: +rte_free (vport->vport_info); + vport->vport_info =NULL ; +err_vport_info: +return ret; +} +int +idpf_vport_deinit (struct idpf_vport *vport) +{ +rte_free (vport->rss_lut); + vport->rss_lut =NULL ; + +rte_free (vport->rss_key); + vport->rss_key =NULL ; + + vport->dev_data =NULL ; + +rte_free (vport->vport_info); + vport->vport_info =NULL ; + +idpf_vc_destroy_vport (vport); + +return 0 ; +}RTE_LOG_REGISTER_SUFFIX (idpf_common_logtype, common,NOTICE );
drivers/common/idpf/idpf_common_device.h +8 -0
@@ -9,6 +9,8 @@#include <base/virtchnl2.h> #include <idpf_common_logs.h> +#define IDPF_RSS_KEY_LEN 52 +#define IDPF_CTLQ_ID -1#define IDPF_CTLQ_LEN 64#define IDPF_DFLT_MBX_BUF_SIZE 4096
@@ -142,5 +144,11 @@ __rte_internalint idpf_adapter_init (struct idpf_adapter *adapter);__rte_internal int idpf_adapter_deinit(struct idpf_adapter *adapter); +__rte_internal +int idpf_vport_init(struct idpf_vport *vport, +struct virtchnl2_create_vport *vport_req_info, +void *dev_data); +__rte_internal +int idpf_vport_deinit(struct idpf_vport *vport);#endif /* _IDPF_COMMON_DEVICE_H_ */
drivers/common/idpf/idpf_common_virtchnl.c +8 -8
@@ -355,7 +355,7 @@ idpf_vc_get_caps(struct idpf_adapter *adapter)int idpf_vc_create_vport (struct idpf_vport *vport, -struct virtchnl2_create_vport *vport_req_info) +struct virtchnl2_create_vport *create_vport_info) {struct idpf_adapter *adapter = vport->adapter;struct virtchnl2_create_vport vport_msg;
@@ -363,13 +363,13 @@ idpf_vc_create_vport(struct idpf_vport *vport,int err =-1 ;memset (&vport_msg,0 ,sizeof (struct virtchnl2_create_vport )); - vport_msg.vport_type = vport_req_info->vport_type; - vport_msg.txq_model = vport_req_info->txq_model; - vport_msg.rxq_model = vport_req_info->rxq_model; - vport_msg.num_tx_q = vport_req_info->num_tx_q; - vport_msg.num_tx_complq = vport_req_info->num_tx_complq; - vport_msg.num_rx_q = vport_req_info->num_rx_q; - vport_msg.num_rx_bufq = vport_req_info->num_rx_bufq; + vport_msg.vport_type = create_vport_info->vport_type; + vport_msg.txq_model = create_vport_info->txq_model; + vport_msg.rxq_model = create_vport_info->rxq_model; + vport_msg.num_tx_q = create_vport_info->num_tx_q; + vport_msg.num_tx_complq = create_vport_info->num_tx_complq; + vport_msg.num_rx_q = create_vport_info->num_rx_q; + vport_msg.num_rx_bufq = create_vport_info->num_rx_bufq;memset (&args,0 ,sizeof (args)); args.ops =VIRTCHNL2_OP_CREATE_VPORT ;
drivers/common/idpf/idpf_common_virtchnl.h +0 -2
@@ -9,10 +9,8 @@int idpf_vc_check_api_version (struct idpf_adapter *adapter);int idpf_vc_get_caps (struct idpf_adapter *adapter); -__rte_internal int idpf_vc_create_vport (struct idpf_vport *vport,struct virtchnl2_create_vport *vport_info); -__rte_internal int idpf_vc_destroy_vport (struct idpf_vport *vport);__rte_internal int idpf_vc_set_rss_key(struct idpf_vport *vport);
drivers/common/idpf/version.map +2 -2
@@ -7,8 +7,6 @@ INTERNAL { idpf_ctlq_recv; idpf_ctlq_send; idpf_ctlq_post_rx_buffs; - idpf_vc_create_vport; - idpf_vc_destroy_vport; idpf_vc_set_rss_key; idpf_vc_set_rss_lut; idpf_vc_set_rss_hash;
@@ -23,6 +21,8 @@ INTERNAL { idpf_execute_vc_cmd; idpf_adapter_init; idpf_adapter_deinit; + idpf_vport_init; + idpf_vport_deinit; local: *; };
drivers/net/idpf/idpf_ethdev.c +10 -128
209 lines not on this page · raw message
Signature · 1 line
2.26.2
PATCH 6/15 common/idpf: add config RSS
In reply to [email protected]From: Beilei Xing <[email protected]>
Move configure RSS to common module.
--- drivers/common/idpf/idpf_common_device.c | 25 +++++++++++++++++++++ drivers/common/idpf/idpf_common_device.h | 2 ++ drivers/common/idpf/idpf_common_virtchnl.h | 3 --- drivers/common/idpf/version.map | 4 +--- drivers/net/idpf/idpf_ethdev.c | 26 ---------------------- 5 files changed, 28 insertions(+), 32 deletions(-)
drivers/common/idpf/idpf_common_device.c +25 -0
@@ -286,4 +286,29 @@ idpf_vport_deinit(struct idpf_vport *vport)return 0 ; } +int +idpf_config_rss (struct idpf_vport *vport) +{ +int ret; + + ret =idpf_vc_set_rss_key (vport); +if (ret !=0 ) { +DRV_LOG (ERR ,"Failed to configure RSS key" ); +return ret; + } + + ret =idpf_vc_set_rss_lut (vport); +if (ret !=0 ) { +DRV_LOG (ERR ,"Failed to configure RSS lut" ); +return ret; + } + + ret =idpf_vc_set_rss_hash (vport); +if (ret !=0 ) { +DRV_LOG (ERR ,"Failed to configure RSS hash" ); +return ret; + } + +return ret; +}RTE_LOG_REGISTER_SUFFIX (idpf_common_logtype, common,NOTICE );
drivers/common/idpf/idpf_common_device.h +2 -0
@@ -150,5 +150,7 @@ int idpf_vport_init(struct idpf_vport *vport, void *dev_data);__rte_internal int idpf_vport_deinit(struct idpf_vport *vport); +__rte_internal +int idpf_config_rss(struct idpf_vport *vport);#endif /* _IDPF_COMMON_DEVICE_H_ */
drivers/common/idpf/idpf_common_virtchnl.h +0 -3
@@ -12,11 +12,8 @@ int idpf_vc_get_caps(struct idpf_adapter *adapter);int idpf_vc_create_vport (struct idpf_vport *vport,struct virtchnl2_create_vport *vport_info);int idpf_vc_destroy_vport (struct idpf_vport *vport); -__rte_internal int idpf_vc_set_rss_key (struct idpf_vport *vport); -__rte_internal int idpf_vc_set_rss_lut (struct idpf_vport *vport); -__rte_internal int idpf_vc_set_rss_hash (struct idpf_vport *vport); __rte_internal int idpf_switch_queue(struct idpf_vport *vport, uint16_t qid,
drivers/common/idpf/version.map +1 -3
@@ -7,9 +7,6 @@ INTERNAL { idpf_ctlq_recv; idpf_ctlq_send; idpf_ctlq_post_rx_buffs; - idpf_vc_set_rss_key; - idpf_vc_set_rss_lut; - idpf_vc_set_rss_hash; idpf_switch_queue; idpf_vc_ena_dis_queues; idpf_vc_ena_dis_vport;
@@ -23,6 +20,7 @@ INTERNAL { idpf_adapter_deinit; idpf_vport_init; idpf_vport_deinit; + idpf_config_rss; local: *; };
drivers/net/idpf/idpf_ethdev.c +0 -26
@@ -169,32 +169,6 @@ idpf_init_vport_req_info(struct rte_eth_dev *dev,return 0 ; } -static int -idpf_config_rss (struct idpf_vport *vport) -{ -int ret; - - ret =idpf_vc_set_rss_key (vport); -if (ret !=0 ) { -PMD_INIT_LOG (ERR ,"Failed to configure RSS key" ); -return ret; - } - - ret =idpf_vc_set_rss_lut (vport); -if (ret !=0 ) { -PMD_INIT_LOG (ERR ,"Failed to configure RSS lut" ); -return ret; - } - - ret =idpf_vc_set_rss_hash (vport); -if (ret !=0 ) { -PMD_INIT_LOG (ERR ,"Failed to configure RSS hash" ); -return ret; - } - -return ret; -} -static int idpf_init_rss (struct idpf_vport *vport) {
Signature · 1 line
2.26.2
PATCH 7/15 common/idpf: add irq map/unmap
In reply to [email protected]From: Beilei Xing <[email protected]>
Add irq map/unmap functions in common module.
--- drivers/common/idpf/idpf_common_device.c | 110 +++++++++++++++++++++ drivers/common/idpf/idpf_common_device.h | 6 ++ drivers/common/idpf/idpf_common_virtchnl.c | 8 -- drivers/common/idpf/idpf_common_virtchnl.h | 5 +- drivers/common/idpf/version.map | 3 +- drivers/net/idpf/idpf_ethdev.c | 90 +---------------- drivers/net/idpf/idpf_ethdev.h | 1 - 7 files changed, 124 insertions(+), 99 deletions(-)
drivers/common/idpf/idpf_common_device.c +110 -0
@@ -254,8 +254,21 @@ idpf_vport_init(struct idpf_vport *vport, goto err_rss_lut; } +/* recv_vectors is used for VIRTCHNL2_OP_ALLOC_VECTORS response, +* reserve maximum size for it now, may need optimization in future. +*/ + vport->recv_vectors =rte_zmalloc ("recv_vectors" ,IDPF_DFLT_MBX_BUF_SIZE ,0 ); +if (vport->recv_vectors ==NULL ) { +DRV_LOG (ERR ,"Failed to allocate ecv_vectors" ); + ret = -ENOMEM ; + goto err_recv_vec; + } +return 0 ; +err_recv_vec: +rte_free (vport->rss_lut); + vport->rss_lut =NULL ; err_rss_lut: vport->dev_data =NULL ;rte_free (vport->rss_key);
@@ -271,6 +284,8 @@ idpf_vport_init(struct idpf_vport *vport,int idpf_vport_deinit (struct idpf_vport *vport) { +rte_free (vport->recv_vectors); + vport->recv_vectors =NULL ;rte_free (vport->rss_lut); vport->rss_lut =NULL ;
@@ -311,4 +326,99 @@ idpf_config_rss(struct idpf_vport *vport)return ret; } + +int +idpf_config_irq_map (struct idpf_vport *vport,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; + + 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); + 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. */ +if (itrn_val !=0 ) +IDPF_WRITE_REG (hw, + dynctl_reg_start, +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 ); +else +IDPF_WRITE_REG (hw, + dynctl_reg_start, +VIRTCHNL2_ITR_IDX_0 << +PF_GLINT_DYN_CTL_ITR_INDX_S | +PF_GLINT_DYN_CTL_WB_ON_ITR_M | +IDPF_DFLT_INTERVAL << +PF_GLINT_DYN_CTL_INTERVAL_S ); + +for (i =0 ; i < nb_rx_queues; i++) { +/* map all queues to the same vector */ + qv_map[i].queue_id = vport->chunks_info.rx_start_qid + i; + qv_map[i].vector_id = + vport->recv_vectors->vchunks.vchunks->start_vector_id; + } + vport->qv_map = qv_map; + +if (idpf_vc_config_irq_map_unmap (vport, nb_rx_queues, true) !=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 -1 ; +} + +int +idpf_config_irq_unmap (struct idpf_vport *vport,uint16_t nb_rx_queues) +{ +idpf_vc_config_irq_map_unmap (vport, nb_rx_queues, false); + +rte_free (vport->qv_map); + vport->qv_map =NULL ; + +return 0 ; +} +RTE_LOG_REGISTER_SUFFIX (idpf_common_logtype, common,NOTICE );
drivers/common/idpf/idpf_common_device.h +6 -0
@@ -17,6 +17,8 @@#define IDPF_MAX_PKT_TYPE 1024 +#define IDPF_DFLT_INTERVAL 16 +struct idpf_adapter {struct idpf_hw hw;struct virtchnl2_version_info virtchnl_version;
@@ -152,5 +154,9 @@ __rte_internalint idpf_vport_deinit (struct idpf_vport *vport);__rte_internal int idpf_config_rss(struct idpf_vport *vport); +__rte_internal +int idpf_config_irq_map(struct idpf_vport *vport, uint16_t nb_rx_queues); +__rte_internal +int idpf_config_irq_unmap(struct idpf_vport *vport, uint16_t nb_rx_queues);#endif /* _IDPF_COMMON_DEVICE_H_ */
drivers/common/idpf/idpf_common_virtchnl.c +0 -8
@@ -573,14 +573,6 @@ idpf_vc_alloc_vectors(struct idpf_vport *vport, uint16_t num_vectors)if (err !=0 )DRV_LOG (ERR ,"Failed to execute command VIRTCHNL2_OP_ALLOC_VECTORS" ); -if (vport->recv_vectors ==NULL ) { - vport->recv_vectors =rte_zmalloc ("recv_vectors" , len,0 ); -if (vport->recv_vectors ==NULL ) { -rte_free (alloc_vec); -return -ENOMEM ; - } - } -rte_memcpy (vport->recv_vectors, args.out_buffer, len);rte_free (alloc_vec);return err;
drivers/common/idpf/idpf_common_virtchnl.h +2 -3
@@ -15,6 +15,8 @@ int idpf_vc_destroy_vport(struct idpf_vport *vport);int idpf_vc_set_rss_key (struct idpf_vport *vport);int idpf_vc_set_rss_lut (struct idpf_vport *vport);int idpf_vc_set_rss_hash (struct idpf_vport *vport); +int idpf_vc_config_irq_map_unmap (struct idpf_vport *vport, +uint16_t nb_rxq,bool map);__rte_internal int idpf_switch_queue(struct idpf_vport *vport, uint16_t qid,bool rx,bool on);
@@ -23,9 +25,6 @@ int idpf_vc_ena_dis_queues(struct idpf_vport *vport, bool enable);__rte_internal int idpf_vc_ena_dis_vport(struct idpf_vport *vport, bool enable);__rte_internal -int idpf_vc_config_irq_map_unmap(struct idpf_vport *vport, -uint16_t nb_rxq,bool map); -__rte_internal int idpf_vc_alloc_vectors(struct idpf_vport *vport, uint16_t num_vectors);__rte_internal int idpf_vc_dealloc_vectors(struct idpf_vport *vport);
drivers/common/idpf/version.map +2 -1
@@ -10,7 +10,6 @@ INTERNAL { idpf_switch_queue; idpf_vc_ena_dis_queues; idpf_vc_ena_dis_vport; - idpf_vc_config_irq_map_unmap; idpf_vc_alloc_vectors; idpf_vc_dealloc_vectors; idpf_vc_query_ptype_info;
@@ -21,6 +20,8 @@ INTERNAL { idpf_vport_init; idpf_vport_deinit; idpf_config_rss; + idpf_config_irq_map; + idpf_config_irq_unmap; local: *; };
drivers/net/idpf/idpf_ethdev.c +4 -86
110 lines not on this page · raw message
drivers/net/idpf/idpf_ethdev.h +0 -1
@@ -32,7 +32,6 @@#define IDPF_RX_BUFQ_PER_GRP 2#define IDPF_DFLT_Q_VEC_NUM 1 -#define IDPF_DFLT_INTERVAL 16#define IDPF_MIN_BUF_SIZE 1024#define IDPF_MAX_FRAME_SIZE 9728
Signature · 1 line
2.26.2
PATCH 8/15 common/idpf: move ptype table to adapter structure
In reply to [email protected]From: Beilei Xing <[email protected]>
Move ptype_tbl field to idpf_adapter structure.
Move get_pkt_type to common module.
--- drivers/common/idpf/idpf_common_device.c | 216 +++++++++++++++++++++ drivers/common/idpf/idpf_common_device.h | 7 + drivers/common/idpf/idpf_common_virtchnl.h | 8 +- drivers/common/idpf/meson.build | 2 + drivers/common/idpf/version.map | 2 - drivers/net/idpf/idpf_ethdev.c | 6 - drivers/net/idpf/idpf_ethdev.h | 4 - drivers/net/idpf/idpf_rxtx.c | 4 +- drivers/net/idpf/idpf_rxtx.h | 4 - drivers/net/idpf/idpf_rxtx_vec_avx512.c | 3 +- drivers/net/idpf/idpf_vchnl.c | 213 -------------------- 11 files changed, 231 insertions(+), 238 deletions(-)
drivers/common/idpf/idpf_common_device.c +216 -0
@@ -96,6 +96,216 @@ idpf_init_mbx(struct idpf_hw *hw)return ret; } +static int +idpf_get_pkt_type (struct idpf_adapter *adapter) +{ +struct virtchnl2_get_ptype_info *ptype_info; +uint16_t ptype_offset, i, j; +uint16_t ptype_recvd =0 ; +int ret; + + ret =idpf_vc_query_ptype_info (adapter); +if (ret !=0 ) { +DRV_LOG (ERR ,"Fail to query packet type information" ); +return ret; + } + + ptype_info =rte_zmalloc ("ptype_info" ,IDPF_DFLT_MBX_BUF_SIZE ,0 ); +if (ptype_info ==NULL ) +return -ENOMEM ; + +while (ptype_recvd <IDPF_MAX_PKT_TYPE ) { + ret =idpf_read_one_msg (adapter,VIRTCHNL2_OP_GET_PTYPE_INFO , +IDPF_DFLT_MBX_BUF_SIZE , (uint8_t *)ptype_info); +if (ret !=0 ) { +DRV_LOG (ERR ,"Fail to get packet type information" ); + goto free_ptype_info; + } + + ptype_recvd += ptype_info->num_ptypes; + ptype_offset =sizeof (struct virtchnl2_get_ptype_info ) - +sizeof (struct virtchnl2_ptype ); + +for (i =0 ; i <rte_cpu_to_le_16 (ptype_info->num_ptypes); i++) { +bool is_inner = false, is_ip = false; +struct virtchnl2_ptype *ptype; +uint32_t proto_hdr =0 ; + + ptype = (struct virtchnl2_ptype *) + ((uint8_t *)ptype_info + ptype_offset); + ptype_offset +=IDPF_GET_PTYPE_SIZE (ptype); +if (ptype_offset >IDPF_DFLT_MBX_BUF_SIZE ) { + ret = -EINVAL ; + goto free_ptype_info; + } + +if (rte_cpu_to_le_16 (ptype->ptype_id_10) ==0xFFFF ) + goto free_ptype_info; + +for (j =0 ; j < ptype->proto_id_count; j++) { +switch (rte_cpu_to_le_16 (ptype->proto_id[j])) { +case VIRTCHNL2_PROTO_HDR_GRE : +case VIRTCHNL2_PROTO_HDR_VXLAN : + proto_hdr &= ~RTE_PTYPE_L4_MASK ; + proto_hdr |=RTE_PTYPE_TUNNEL_GRENAT ; + is_inner = true; +break ; +case VIRTCHNL2_PROTO_HDR_MAC : +if (is_inner) { + proto_hdr &= ~RTE_PTYPE_INNER_L2_MASK ; + proto_hdr |=RTE_PTYPE_INNER_L2_ETHER ; + }else { + proto_hdr &= ~RTE_PTYPE_L2_MASK ; + proto_hdr |=RTE_PTYPE_L2_ETHER ; + } +break ; +case VIRTCHNL2_PROTO_HDR_VLAN : +if (is_inner) { + proto_hdr &= ~RTE_PTYPE_INNER_L2_MASK ; + proto_hdr |=RTE_PTYPE_INNER_L2_ETHER_VLAN ; + } +break ; +case VIRTCHNL2_PROTO_HDR_PTP : + proto_hdr &= ~RTE_PTYPE_L2_MASK ; + proto_hdr |=RTE_PTYPE_L2_ETHER_TIMESYNC ; +break ; +case VIRTCHNL2_PROTO_HDR_LLDP : + proto_hdr &= ~RTE_PTYPE_L2_MASK ; + proto_hdr |=RTE_PTYPE_L2_ETHER_LLDP ; +break ; +case VIRTCHNL2_PROTO_HDR_ARP : + proto_hdr &= ~RTE_PTYPE_L2_MASK ; + proto_hdr |=RTE_PTYPE_L2_ETHER_ARP ; +break ; +case VIRTCHNL2_PROTO_HDR_PPPOE : + proto_hdr &= ~RTE_PTYPE_L2_MASK ; + proto_hdr |=RTE_PTYPE_L2_ETHER_PPPOE ; +break ; +case VIRTCHNL2_PROTO_HDR_IPV4 : +if (!is_ip) { + proto_hdr |=RTE_PTYPE_L3_IPV4_EXT_UNKNOWN ; + is_ip = true; + }else { + proto_hdr |=RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | +RTE_PTYPE_TUNNEL_IP ; + is_inner = true; + } +break ; +case VIRTCHNL2_PROTO_HDR_IPV6 : +if (!is_ip) { + proto_hdr |=RTE_PTYPE_L3_IPV6_EXT_UNKNOWN ; + is_ip = true; + }else { + proto_hdr |=RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | +RTE_PTYPE_TUNNEL_IP ; + is_inner = true; + } +break ; +case VIRTCHNL2_PROTO_HDR_IPV4_FRAG : +case VIRTCHNL2_PROTO_HDR_IPV6_FRAG : +if (is_inner) + proto_hdr |=RTE_PTYPE_INNER_L4_FRAG ; +else + proto_hdr |=RTE_PTYPE_L4_FRAG ; +break ; +case VIRTCHNL2_PROTO_HDR_UDP : +if (is_inner) + proto_hdr |=RTE_PTYPE_INNER_L4_UDP ; +else + proto_hdr |=RTE_PTYPE_L4_UDP ; +break ; +case VIRTCHNL2_PROTO_HDR_TCP : +if (is_inner) + proto_hdr |=RTE_PTYPE_INNER_L4_TCP ; +else + proto_hdr |=RTE_PTYPE_L4_TCP ; +break ; +case VIRTCHNL2_PROTO_HDR_SCTP : +if (is_inner) + proto_hdr |=RTE_PTYPE_INNER_L4_SCTP ; +else + proto_hdr |=RTE_PTYPE_L4_SCTP ; +break ; +case VIRTCHNL2_PROTO_HDR_ICMP : +if (is_inner) + proto_hdr |=RTE_PTYPE_INNER_L4_ICMP ; +else + proto_hdr |=RTE_PTYPE_L4_ICMP ; +break ; +case VIRTCHNL2_PROTO_HDR_ICMPV6 : +if (is_inner) + proto_hdr |=RTE_PTYPE_INNER_L4_ICMP ; +else + proto_hdr |=RTE_PTYPE_L4_ICMP ; +break ; +case VIRTCHNL2_PROTO_HDR_L2TPV2 : +case VIRTCHNL2_PROTO_HDR_L2TPV2_CONTROL : +case VIRTCHNL2_PROTO_HDR_L2TPV3 : + is_inner = true; + proto_hdr |=RTE_PTYPE_TUNNEL_L2TP ; +break ; +case VIRTCHNL2_PROTO_HDR_NVGRE : + is_inner = true; + proto_hdr |=RTE_PTYPE_TUNNEL_NVGRE ; +break ; +case VIRTCHNL2_PROTO_HDR_GTPC_TEID : + is_inner = true; + proto_hdr |=RTE_PTYPE_TUNNEL_GTPC ; +break ; +case VIRTCHNL2_PROTO_HDR_GTPU : +case VIRTCHNL2_PROTO_HDR_GTPU_UL : +case VIRTCHNL2_PROTO_HDR_GTPU_DL : + is_inner = true; + proto_hdr |=RTE_PTYPE_TUNNEL_GTPU ; +break ; +case VIRTCHNL2_PROTO_HDR_PAY : +case VIRTCHNL2_PROTO_HDR_IPV6_EH : +case VIRTCHNL2_PROTO_HDR_PRE_MAC : +case VIRTCHNL2_PROTO_HDR_POST_MAC : +case VIRTCHNL2_PROTO_HDR_ETHERTYPE : +case VIRTCHNL2_PROTO_HDR_SVLAN : +case VIRTCHNL2_PROTO_HDR_CVLAN : +case VIRTCHNL2_PROTO_HDR_MPLS : +case VIRTCHNL2_PROTO_HDR_MMPLS : +case VIRTCHNL2_PROTO_HDR_CTRL : +case VIRTCHNL2_PROTO_HDR_ECP : +case VIRTCHNL2_PROTO_HDR_EAPOL : +case VIRTCHNL2_PROTO_HDR_PPPOD : +case VIRTCHNL2_PROTO_HDR_IGMP : +case VIRTCHNL2_PROTO_HDR_AH : +case VIRTCHNL2_PROTO_HDR_ESP : +case VIRTCHNL2_PROTO_HDR_IKE : +case VIRTCHNL2_PROTO_HDR_NATT_KEEP : +case VIRTCHNL2_PROTO_HDR_GTP : +case VIRTCHNL2_PROTO_HDR_GTP_EH : +case VIRTCHNL2_PROTO_HDR_GTPCV2 : +case VIRTCHNL2_PROTO_HDR_ECPRI : +case VIRTCHNL2_PROTO_HDR_VRRP : +case VIRTCHNL2_PROTO_HDR_OSPF : +case VIRTCHNL2_PROTO_HDR_TUN : +case VIRTCHNL2_PROTO_HDR_VXLAN_GPE : +case VIRTCHNL2_PROTO_HDR_GENEVE : +case VIRTCHNL2_PROTO_HDR_NSH : +case VIRTCHNL2_PROTO_HDR_QUIC : +case VIRTCHNL2_PROTO_HDR_PFCP : +case VIRTCHNL2_PROTO_HDR_PFCP_NODE : +case VIRTCHNL2_PROTO_HDR_PFCP_SESSION : +case VIRTCHNL2_PROTO_HDR_RTP : +case VIRTCHNL2_PROTO_HDR_NO_PROTO : +default : +continue ; + } + adapter->ptype_tbl[ptype->ptype_id_10] = proto_hdr; + } + } + } + +free_ptype_info: +rte_free (ptype_info); +clear_cmd (adapter); +return ret; +} +int idpf_adapter_init (struct idpf_adapter *adapter) {
@@ -135,6 +345,12 @@ idpf_adapter_init(struct idpf_adapter *adapter) goto err_check_api; } + ret =idpf_get_pkt_type (adapter); +if (ret !=0 ) { +DRV_LOG (ERR ,"Failed to set ptype table" ); + goto err_check_api; + } +return 0 ; err_check_api:
drivers/common/idpf/idpf_common_device.h +7 -0
@@ -5,6 +5,7 @@#ifndef _IDPF_COMMON_DEVICE_H_#define _IDPF_COMMON_DEVICE_H_ +#include <rte_mbuf_ptype.h> #include <base/idpf_prototype.h> #include <base/virtchnl2.h> #include <idpf_common_logs.h>
@@ -19,6 +20,10 @@#define IDPF_DFLT_INTERVAL 16 +#define IDPF_GET_PTYPE_SIZE (p) \ + (sizeof(struct virtchnl2_ptype) + \ + (((p)->proto_id_count ? ((p)->proto_id_count - 1) : 0) * sizeof((p)->proto_id[0]))) +struct idpf_adapter {struct idpf_hw hw;struct virtchnl2_version_info virtchnl_version;
@@ -26,6 +31,8 @@ struct idpf_adapter {volatile uint32_t pend_cmd;/* pending command not finished */ uint32_t cmd_retval;/* return value of the cmd response from cp */ uint8_t *mbx_resp;/* buffer to store the mailbox response from cp */ + + uint32_t ptype_tbl[IDPF_MAX_PKT_TYPE] __rte_cache_min_aligned; };struct idpf_chunks_info {
drivers/common/idpf/idpf_common_virtchnl.h +3 -5
@@ -17,6 +17,9 @@ int idpf_vc_set_rss_lut(struct idpf_vport *vport);int idpf_vc_set_rss_hash (struct idpf_vport *vport);int idpf_vc_config_irq_map_unmap (struct idpf_vport *vport,uint16_t nb_rxq,bool map); +int idpf_vc_query_ptype_info (struct idpf_adapter *adapter); +int idpf_read_one_msg (struct idpf_adapter *adapter,uint32_t ops, +uint16_t buf_len,uint8_t *buf);__rte_internal int idpf_switch_queue(struct idpf_vport *vport, uint16_t qid,bool rx,bool on);
@@ -29,11 +32,6 @@ int idpf_vc_alloc_vectors(struct idpf_vport *vport, uint16_t num_vectors);__rte_internal int idpf_vc_dealloc_vectors(struct idpf_vport *vport);__rte_internal -int idpf_vc_query_ptype_info(struct idpf_adapter *adapter); -__rte_internal -int idpf_read_one_msg(struct idpf_adapter *adapter, uint32_t ops, -uint16_t buf_len,uint8_t *buf); -__rte_internal int idpf_execute_vc_cmd(struct idpf_adapter *adapter,struct idpf_cmd_info *args);
drivers/common/idpf/meson.build +2 -0
@@ -1,6 +1,8 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2022 Intel Corporation +deps += ['mbuf'] + sources = files( 'idpf_common_device.c', 'idpf_common_virtchnl.c',
drivers/common/idpf/version.map +0 -2
@@ -12,8 +12,6 @@ INTERNAL { idpf_vc_ena_dis_vport; idpf_vc_alloc_vectors; idpf_vc_dealloc_vectors; - idpf_vc_query_ptype_info; - idpf_read_one_msg; idpf_execute_vc_cmd; idpf_adapter_init; idpf_adapter_deinit;
drivers/net/idpf/idpf_ethdev.c +0 -6
@@ -593,12 +593,6 @@ idpf_adapter_ext_init(struct rte_pci_device *pci_dev, struct idpf_adapter_ext *a goto err_adapter_init; } - ret =idpf_get_pkt_type (adapter); -if (ret !=0 ) { -PMD_INIT_LOG (ERR ,"Failed to set ptype table" ); - goto err_get_ptype; - } - adapter->max_vport_nb = adapter->base.caps.max_vports; adapter->vports = rte_zmalloc("vports",
drivers/net/idpf/idpf_ethdev.h +0 -4
@@ -88,8 +88,6 @@ struct idpf_adapter_ext {uint16_t used_vecs_num; - uint32_t ptype_tbl[IDPF_MAX_PKT_TYPE] __rte_cache_min_aligned; -bool rx_vec_allowed;bool tx_vec_allowed;bool rx_use_avx512;
@@ -106,6 +104,4 @@ TAILQ_HEAD(idpf_adapter_list, idpf_adapter_ext);#define IDPF_ADAPTER_TO_EXT (p) \ container_of((p), struct idpf_adapter_ext, base) -int idpf_get_pkt_type (struct idpf_adapter_ext *adapter); -#endif /* _IDPF_ETHDEV_H_ */
drivers/net/idpf/idpf_rxtx.c +2 -2
@@ -1407,7 +1407,7 @@ idpf_splitq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, rx_id_bufq1 = rxq->bufq1->rx_next_avail; rx_id_bufq2 = rxq->bufq2->rx_next_avail; rx_desc_ring = rxq->rx_ring; - ptype_tbl = ad->ptype_tbl; + ptype_tbl = rxq->adapter->ptype_tbl;if ((rxq->offloads &RTE_ETH_RX_OFFLOAD_TIMESTAMP ) !=0 ) rxq->hw_register_set =1 ;
@@ -1812,7 +1812,7 @@ idpf_singleq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, rx_id = rxq->rx_tail; rx_ring = rxq->rx_ring; - ptype_tbl = ad->ptype_tbl; + ptype_tbl = rxq->adapter->ptype_tbl;if ((rxq->offloads &RTE_ETH_RX_OFFLOAD_TIMESTAMP ) !=0 ) rxq->hw_register_set =1 ;
drivers/net/idpf/idpf_rxtx.h +0 -4
@@ -82,10 +82,6 @@#define IDPF_TX_OFFLOAD_NOTSUP_MASK \ (RTE_MBUF_F_TX_OFFLOAD_MASK ^ IDPF_TX_OFFLOAD_MASK) -#define IDPF_GET_PTYPE_SIZE (p) \ - (sizeof(struct virtchnl2_ptype) + \ - (((p)->proto_id_count ? ((p)->proto_id_count - 1) : 0) * sizeof((p)->proto_id[0]))) -extern uint64_t idpf_timestamp_dynflag;struct idpf_rx_queue {
drivers/net/idpf/idpf_rxtx_vec_avx512.c +1 -2
@@ -245,8 +245,7 @@ _idpf_singleq_recv_raw_pkts_avx512(struct idpf_rx_queue *rxq, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) { -struct idpf_adapter_ext *adapter =IDPF_ADAPTER_TO_EXT (rxq->adapter); -const uint32_t *type_table = adapter->ptype_tbl; +const uint32_t *type_table = rxq->adapter->ptype_tbl;const __m256i mbuf_init =_mm256_set_epi64x (0 ,0 ,0 , rxq->mbuf_initializer);
drivers/net/idpf/idpf_vchnl.c +0 -213
219 lines not on this page · raw message
Signature · 1 line
2.26.2
PATCH 9/15 common/idpf: init create vport info
In reply to [email protected]From: Beilei Xing <[email protected]>
Initialize create vport info in common module.
--- drivers/common/idpf/idpf_common_device.c | 35 +++++++++++++++++ drivers/common/idpf/idpf_common_device.h | 11 ++++++ drivers/common/idpf/version.map | 1 + drivers/net/idpf/idpf_ethdev.c | 48 +++--------------------- drivers/net/idpf/idpf_ethdev.h | 8 ---- 5 files changed, 53 insertions(+), 50 deletions(-)
drivers/common/idpf/idpf_common_device.c +35 -0
@@ -637,4 +637,39 @@ idpf_config_irq_unmap(struct idpf_vport *vport, uint16_t nb_rx_queues)return 0 ; } +int +idpf_create_vport_info_init (struct idpf_vport *vport, +struct virtchnl2_create_vport *vport_info) +{ +struct idpf_adapter *adapter = vport->adapter; + + vport_info->vport_type =rte_cpu_to_le_16 (VIRTCHNL2_VPORT_TYPE_DEFAULT ); +if (adapter->txq_model ==0 ) { + vport_info->txq_model = +rte_cpu_to_le_16 (VIRTCHNL2_QUEUE_MODEL_SPLIT ); + vport_info->num_tx_q =IDPF_DEFAULT_TXQ_NUM ; + vport_info->num_tx_complq = +IDPF_DEFAULT_TXQ_NUM *IDPF_TX_COMPLQ_PER_GRP ; + }else { + vport_info->txq_model = +rte_cpu_to_le_16 (VIRTCHNL2_QUEUE_MODEL_SINGLE ); + vport_info->num_tx_q =IDPF_DEFAULT_TXQ_NUM ; + vport_info->num_tx_complq =0 ; + } +if (adapter->rxq_model ==0 ) { + vport_info->rxq_model = +rte_cpu_to_le_16 (VIRTCHNL2_QUEUE_MODEL_SPLIT ); + vport_info->num_rx_q =IDPF_DEFAULT_RXQ_NUM ; + vport_info->num_rx_bufq = +IDPF_DEFAULT_RXQ_NUM *IDPF_RX_BUFQ_PER_GRP ; + }else { + vport_info->rxq_model = +rte_cpu_to_le_16 (VIRTCHNL2_QUEUE_MODEL_SINGLE ); + vport_info->num_rx_q =IDPF_DEFAULT_RXQ_NUM ; + vport_info->num_rx_bufq =0 ; + } + +return 0 ; +} +RTE_LOG_REGISTER_SUFFIX (idpf_common_logtype, common,NOTICE );
drivers/common/idpf/idpf_common_device.h +11 -0
@@ -16,6 +16,11 @@#define IDPF_CTLQ_LEN 64#define IDPF_DFLT_MBX_BUF_SIZE 4096 +#define IDPF_DEFAULT_RXQ_NUM 16 +#define IDPF_RX_BUFQ_PER_GRP 2 +#define IDPF_DEFAULT_TXQ_NUM 16 +#define IDPF_TX_COMPLQ_PER_GRP 1 +#define IDPF_MAX_PKT_TYPE 1024#define IDPF_DFLT_INTERVAL 16
@@ -33,6 +38,9 @@ struct idpf_adapter {uint8_t *mbx_resp;/* buffer to store the mailbox response from cp */ uint32_t ptype_tbl[IDPF_MAX_PKT_TYPE] __rte_cache_min_aligned; + +uint32_t txq_model;/* 0 - split queue model, non-0 - single queue model */ +uint32_t rxq_model;/* 0 - split queue model, non-0 - single queue model */ };struct idpf_chunks_info {
@@ -165,5 +173,8 @@ __rte_internalint idpf_config_irq_map (struct idpf_vport *vport,uint16_t nb_rx_queues);__rte_internal int idpf_config_irq_unmap(struct idpf_vport *vport, uint16_t nb_rx_queues); +__rte_internal +int idpf_create_vport_info_init(struct idpf_vport *vport, +struct virtchnl2_create_vport *vport_info);#endif /* _IDPF_COMMON_DEVICE_H_ */
drivers/common/idpf/version.map +1 -0
@@ -20,6 +20,7 @@ INTERNAL { idpf_config_rss; idpf_config_irq_map; idpf_config_irq_unmap; + idpf_create_vport_info_init; local: *; };
drivers/net/idpf/idpf_ethdev.c +6 -42
81 lines not on this page · raw message
drivers/net/idpf/idpf_ethdev.h +0 -8
@@ -22,14 +22,9 @@#define IDPF_MAX_VPORT_NUM 8 -#define IDPF_DEFAULT_RXQ_NUM 16 -#define IDPF_DEFAULT_TXQ_NUM 16 -#define IDPF_INVALID_VPORT_IDX 0xffff#define IDPF_TXQ_PER_GRP 1 -#define IDPF_TX_COMPLQ_PER_GRP 1#define IDPF_RXQ_PER_GRP 1 -#define IDPF_RX_BUFQ_PER_GRP 2#define IDPF_DFLT_Q_VEC_NUM 1
@@ -77,9 +72,6 @@ struct idpf_adapter_ext {char name[IDPF_ADAPTER_NAME_LEN ]; -uint32_t txq_model;/* 0 - split queue model, non-0 - single queue model */ -uint32_t rxq_model;/* 0 - split queue model, non-0 - single queue model */ -struct idpf_vport **vports;uint16_t max_vport_nb;
Signature · 1 line
2.26.2
PATCH 10/15 common/idpf: add vector flags in vport
In reply to [email protected]From: Beilei Xing <[email protected]>
Add vector flags in idpf_vport structure.
--- drivers/common/idpf/idpf_common_device.h | 5 +++++ drivers/net/idpf/idpf_ethdev.h | 5 ----- drivers/net/idpf/idpf_rxtx.c | 22 ++++++++++------------ 3 files changed, 15 insertions(+), 17 deletions(-)
drivers/common/idpf/idpf_common_device.h +5 -0
@@ -100,6 +100,11 @@ struct idpf_vport {uint16_t devarg_id;bool stopped; + +bool rx_vec_allowed; +bool tx_vec_allowed; +bool rx_use_avx512; +bool tx_use_avx512; };/* Message type read in virtual channel from PF */
drivers/net/idpf/idpf_ethdev.h +0 -5
@@ -80,11 +80,6 @@ struct idpf_adapter_ext {uint16_t used_vecs_num; -bool rx_vec_allowed; -bool tx_vec_allowed; -bool rx_use_avx512; -bool tx_use_avx512; -/* For PTP */ uint64_t time_hw; };
drivers/net/idpf/idpf_rxtx.c +10 -12
@@ -2221,25 +2221,24 @@ idpf_set_rx_function(struct rte_eth_dev *dev) {struct idpf_vport *vport = dev->data->dev_private;#ifdef RTE_ARCH_X86 -struct idpf_adapter_ext *ad =IDPF_ADAPTER_TO_EXT (vport->adapter);struct idpf_rx_queue *rxq;int i;if (idpf_rx_vec_dev_check_default (dev) ==IDPF_VECTOR_PATH &&rte_vect_get_max_simd_bitwidth () >=RTE_VECT_SIMD_128 ) { - ad->rx_vec_allowed = true; + vport->rx_vec_allowed = true; if (rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_512)#ifdef CC_AVX512_SUPPORT if (rte_cpu_get_flag_enabled (RTE_CPUFLAG_AVX512F ) ==1 &&rte_cpu_get_flag_enabled (RTE_CPUFLAG_AVX512BW ) ==1 ) - ad->rx_use_avx512 = true; + vport->rx_use_avx512 = true;#else PMD_DRV_LOG (NOTICE ,"AVX512 is not supported in build env" );#endif /* CC_AVX512_SUPPORT */ }else { - ad->rx_vec_allowed = false; + vport->rx_vec_allowed = false; }#endif /* RTE_ARCH_X86 */
@@ -2247,13 +2246,13 @@ idpf_set_rx_function(struct rte_eth_dev *dev)if (vport->rxq_model ==VIRTCHNL2_QUEUE_MODEL_SPLIT ) { dev->rx_pkt_burst = idpf_splitq_recv_pkts; }else { -if (ad->rx_vec_allowed) { +if (vport->rx_vec_allowed) {for (i =0 ; i < dev->data->nb_tx_queues; i++) { rxq = dev->data->rx_queues[i]; (void )idpf_singleq_rx_vec_setup (rxq); }#ifdef CC_AVX512_SUPPORT -if (ad->rx_use_avx512) { +if (vport->rx_use_avx512) { dev->rx_pkt_burst = idpf_singleq_recv_pkts_avx512;return ; }
@@ -2275,7 +2274,6 @@ idpf_set_tx_function(struct rte_eth_dev *dev) {struct idpf_vport *vport = dev->data->dev_private;#ifdef RTE_ARCH_X86 -struct idpf_adapter_ext *ad =IDPF_ADAPTER_TO_EXT (vport->adapter);#ifdef CC_AVX512_SUPPORT struct idpf_tx_queue *txq;int i;
@@ -2283,18 +2281,18 @@ idpf_set_tx_function(struct rte_eth_dev *dev)if (idpf_rx_vec_dev_check_default (dev) ==IDPF_VECTOR_PATH &&rte_vect_get_max_simd_bitwidth () >=RTE_VECT_SIMD_128 ) { - ad->tx_vec_allowed = true; + vport->tx_vec_allowed = true; if (rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_512)#ifdef CC_AVX512_SUPPORT if (rte_cpu_get_flag_enabled (RTE_CPUFLAG_AVX512F ) ==1 &&rte_cpu_get_flag_enabled (RTE_CPUFLAG_AVX512BW ) ==1 ) - ad->tx_use_avx512 = true; + vport->tx_use_avx512 = true;#else PMD_DRV_LOG (NOTICE ,"AVX512 is not supported in build env" );#endif /* CC_AVX512_SUPPORT */ }else { - ad->tx_vec_allowed = false; + vport->tx_vec_allowed = false; }#endif /* RTE_ARCH_X86 */
@@ -2303,9 +2301,9 @@ idpf_set_tx_function(struct rte_eth_dev *dev) dev->tx_pkt_prepare = idpf_prep_pkts; } else { #ifdef RTE_ARCH_X86 - if (ad->tx_vec_allowed) { + if (vport->tx_vec_allowed) { #ifdef CC_AVX512_SUPPORT - if (ad->tx_use_avx512) { + if (vport->tx_use_avx512) { for (i = 0; i < dev->data->nb_tx_queues; i++) { txq = dev->data->tx_queues[i]; if (txq == NULL)
Signature · 1 line
2.26.2
PATCH 11/15 common/idpf: add rxq and txq struct
In reply to [email protected]From: Beilei Xing <[email protected]>
Add idpf_rxq and idpf_txq structure in common module. Move configure rxq and txq to common module.
--- drivers/common/idpf/idpf_common_device.h | 2 + drivers/common/idpf/idpf_common_rxtx.h | 112 +++++++++++++ drivers/common/idpf/idpf_common_virtchnl.c | 160 ++++++++++++++++++ drivers/common/idpf/idpf_common_virtchnl.h | 9 +- drivers/common/idpf/version.map | 3 +- drivers/net/idpf/idpf_ethdev.h | 2 - drivers/net/idpf/idpf_rxtx.h | 97 +---------- drivers/net/idpf/idpf_vchnl.c | 184 --------------------- drivers/net/idpf/meson.build | 1 - 9 files changed, 283 insertions(+), 287 deletions(-) create mode 100644 drivers/common/idpf/idpf_common_rxtx.h delete mode 100644 drivers/net/idpf/idpf_vchnl.c
drivers/common/idpf/idpf_common_device.h +2 -0
@@ -18,8 +18,10 @@#define IDPF_DEFAULT_RXQ_NUM 16#define IDPF_RX_BUFQ_PER_GRP 2 +#define IDPF_RXQ_PER_GRP 1#define IDPF_DEFAULT_TXQ_NUM 16#define IDPF_TX_COMPLQ_PER_GRP 1 +#define IDPF_TXQ_PER_GRP 1#define IDPF_MAX_PKT_TYPE 1024
drivers/common/idpf/idpf_common_rxtx.h new file +112 -0
112 lines not on this page · raw message
drivers/common/idpf/idpf_common_virtchnl.c +160 -0
163 lines not on this page · raw message
drivers/common/idpf/idpf_common_virtchnl.h +6 -3
@@ -6,6 +6,7 @@#define _IDPF_COMMON_VIRTCHNL_H_#include <idpf_common_device.h> +#include <idpf_common_rxtx.h> int idpf_vc_check_api_version (struct idpf_adapter *adapter);int idpf_vc_get_caps (struct idpf_adapter *adapter);
@@ -20,6 +21,8 @@ int idpf_vc_config_irq_map_unmap(struct idpf_vport *vport,int idpf_vc_query_ptype_info (struct idpf_adapter *adapter);int idpf_read_one_msg (struct idpf_adapter *adapter,uint32_t ops,uint16_t buf_len,uint8_t *buf); +int idpf_execute_vc_cmd (struct idpf_adapter *adapter, +struct idpf_cmd_info *args);__rte_internal int idpf_switch_queue(struct idpf_vport *vport, uint16_t qid,bool rx,bool on);
@@ -32,7 +35,7 @@ int idpf_vc_alloc_vectors(struct idpf_vport *vport, uint16_t num_vectors);__rte_internal int idpf_vc_dealloc_vectors(struct idpf_vport *vport);__rte_internal -int idpf_execute_vc_cmd(struct idpf_adapter *adapter, -struct idpf_cmd_info *args); - +int idpf_vc_config_rxq(struct idpf_vport *vport, struct idpf_rx_queue *rxq); +__rte_internal +int idpf_vc_config_txq(struct idpf_vport *vport, struct idpf_tx_queue *txq);#endif /* _IDPF_COMMON_VIRTCHNL_H_ */
drivers/common/idpf/version.map +2 -1
@@ -12,7 +12,8 @@ INTERNAL { idpf_vc_ena_dis_vport; idpf_vc_alloc_vectors; idpf_vc_dealloc_vectors; - idpf_execute_vc_cmd; + idpf_vc_config_rxq; + idpf_vc_config_txq; idpf_adapter_init; idpf_adapter_deinit; idpf_vport_init;
drivers/net/idpf/idpf_ethdev.h +0 -2
@@ -23,8 +23,6 @@#define IDPF_MAX_VPORT_NUM 8#define IDPF_INVALID_VPORT_IDX 0xffff -#define IDPF_TXQ_PER_GRP 1 -#define IDPF_RXQ_PER_GRP 1#define IDPF_DFLT_Q_VEC_NUM 1
drivers/net/idpf/idpf_rxtx.h +1 -96
119 lines not on this page · raw message
drivers/net/idpf/idpf_vchnl.c deleted +0 -184
184 lines not on this page · raw message
drivers/net/idpf/meson.build +0 -1
@@ -12,7 +12,6 @@ deps += ['common_idpf'] sources = files( 'idpf_ethdev.c', 'idpf_rxtx.c', - 'idpf_vchnl.c', ) if arch_subdir == 'x86'
Signature · 1 line
2.26.2
PATCH 12/15 common/idpf: add help functions for queue setup and release
In reply to [email protected]From: Beilei Xing <[email protected]>
Refine rxq setup and txq setup.
Move some help functions of queue setup and queue release to common module.
--- drivers/common/idpf/idpf_common_rxtx.c | 414 +++++++++ drivers/common/idpf/idpf_common_rxtx.h | 57 ++ drivers/common/idpf/meson.build | 1 + drivers/common/idpf/version.map | 15 + drivers/net/idpf/idpf_rxtx.c | 1029 ++++++----------------- drivers/net/idpf/idpf_rxtx.h | 9 - drivers/net/idpf/idpf_rxtx_vec_avx512.c | 2 +- 7 files changed, 762 insertions(+), 765 deletions(-) create mode 100644 drivers/common/idpf/idpf_common_rxtx.c
drivers/common/idpf/idpf_common_rxtx.c new file +414 -0
@@ -0,0 +1,414 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2022 Intel Corporation +*/ + +#include <rte_mbuf_dyn.h> +#include "idpf_common_rxtx.h" + +int +check_rx_thresh (uint16_t nb_desc,uint16_t thresh) +{ +/* The following constraints must be satisfied: +* thresh < rxq->nb_rx_desc +*/ +if (thresh >= nb_desc) { +DRV_LOG (ERR ,"rx_free_thresh (%u) must be less than %u" , + thresh, nb_desc); +return -EINVAL ; + } + +return 0 ; +} + +int +check_tx_thresh (uint16_t nb_desc,uint16_t tx_rs_thresh, +uint16_t tx_free_thresh) +{ +/* TX descriptors will have their RS bit set after tx_rs_thresh +* descriptors have been used. The TX descriptor ring will be cleaned +* after tx_free_thresh descriptors are used or if the number of +* descriptors required to transmit a packet is greater than the +* number of free TX descriptors. +* +* The following constraints must be satisfied: +* - tx_rs_thresh must be less than the size of the ring minus 2. +* - tx_free_thresh must be less than the size of the ring minus 3. +* - tx_rs_thresh must be less than or equal to tx_free_thresh. +* - tx_rs_thresh must be a divisor of the ring size. +* +* One descriptor in the TX ring is used as a sentinel to avoid a H/W +* race condition, hence the maximum threshold constraints. When set +* to zero use default values. +*/ +if (tx_rs_thresh >= (nb_desc -2 )) { +DRV_LOG (ERR ,"tx_rs_thresh (%u) must be less than the " +"number of TX descriptors (%u) minus 2" , + tx_rs_thresh, nb_desc); +return -EINVAL ; + } +if (tx_free_thresh >= (nb_desc -3 )) { +DRV_LOG (ERR ,"tx_free_thresh (%u) must be less than the " +"number of TX descriptors (%u) minus 3." , + tx_free_thresh, nb_desc); +return -EINVAL ; + } +if (tx_rs_thresh > tx_free_thresh) { +DRV_LOG (ERR ,"tx_rs_thresh (%u) must be less than or " +"equal to tx_free_thresh (%u)." , + tx_rs_thresh, tx_free_thresh); +return -EINVAL ; + } +if ((nb_desc % tx_rs_thresh) !=0 ) { +DRV_LOG (ERR ,"tx_rs_thresh (%u) must be a divisor of the " +"number of TX descriptors (%u)." , + tx_rs_thresh, nb_desc); +return -EINVAL ; + } + +return 0 ; +} + +void +release_rxq_mbufs (struct idpf_rx_queue *rxq) +{ +uint16_t i; + +if (rxq->sw_ring ==NULL ) +return ; + +for (i =0 ; i < rxq->nb_rx_desc; i++) { +if (rxq->sw_ring[i] !=NULL ) { +rte_pktmbuf_free_seg (rxq->sw_ring[i]); + rxq->sw_ring[i] =NULL ; + } + } +} + +void +release_txq_mbufs (struct idpf_tx_queue *txq) +{ +uint16_t nb_desc, i; + +if (txq ==NULL || txq->sw_ring ==NULL ) { +DRV_LOG (DEBUG ,"Pointer to rxq or sw_ring is NULL" ); +return ; + } + +if (txq->sw_nb_desc !=0 ) { +/* For split queue model, descriptor ring */ + nb_desc = txq->sw_nb_desc; + }else { +/* For single queue model */ + nb_desc = txq->nb_tx_desc; + } +for (i =0 ; i < nb_desc; i++) { +if (txq->sw_ring[i].mbuf !=NULL ) { +rte_pktmbuf_free_seg (txq->sw_ring[i].mbuf); + txq->sw_ring[i].mbuf =NULL ; + } + } +} + +void +reset_split_rx_descq (struct idpf_rx_queue *rxq) +{ +uint16_t len; +uint32_t i; + +if (rxq ==NULL ) +return ; + + len = rxq->nb_rx_desc +IDPF_RX_MAX_BURST ; + +for (i =0 ; i < len *sizeof (struct virtchnl2_rx_flex_desc_adv_nic_3 ); + i++) + ((volatile char *)rxq->rx_ring)[i] =0 ; + + rxq->rx_tail =0 ; + rxq->expected_gen_id =1 ; +} + +void +reset_split_rx_bufq (struct idpf_rx_queue *rxq) +{ +uint16_t len; +uint32_t i; + +if (rxq ==NULL ) +return ; + + len = rxq->nb_rx_desc +IDPF_RX_MAX_BURST ; + +for (i =0 ; i < len *sizeof (struct virtchnl2_splitq_rx_buf_desc ); + i++) + ((volatile char *)rxq->rx_ring)[i] =0 ; + +memset (&rxq->fake_mbuf,0x0 ,sizeof (rxq->fake_mbuf)); + +for (i =0 ; i <IDPF_RX_MAX_BURST ; i++) + rxq->sw_ring[rxq->nb_rx_desc + i] = &rxq->fake_mbuf; + +/* The next descriptor id which can be received. */ + rxq->rx_next_avail =0 ; + +/* The next descriptor id which can be refilled. */ + rxq->rx_tail =0 ; +/* The number of descriptors which can be refilled. */ + rxq->nb_rx_hold = rxq->nb_rx_desc -1 ; + + rxq->bufq1 =NULL ; + rxq->bufq2 =NULL ; +} + +void +reset_split_rx_queue (struct idpf_rx_queue *rxq) +{ +reset_split_rx_descq (rxq); +reset_split_rx_bufq (rxq->bufq1); +reset_split_rx_bufq (rxq->bufq2); +} + +void +reset_single_rx_queue (struct idpf_rx_queue *rxq) +{ +uint16_t len; +uint32_t i; + +if (rxq ==NULL ) +return ; + + len = rxq->nb_rx_desc +IDPF_RX_MAX_BURST ; + +for (i =0 ; i < len *sizeof (struct virtchnl2_singleq_rx_buf_desc ); + i++) + ((volatile char *)rxq->rx_ring)[i] =0 ; + +memset (&rxq->fake_mbuf,0x0 ,sizeof (rxq->fake_mbuf)); + +for (i =0 ; i <IDPF_RX_MAX_BURST ; i++) + rxq->sw_ring[rxq->nb_rx_desc + i] = &rxq->fake_mbuf; + + rxq->rx_tail =0 ; + rxq->nb_rx_hold =0 ; + +rte_pktmbuf_free (rxq->pkt_first_seg); + + rxq->pkt_first_seg =NULL ; + rxq->pkt_last_seg =NULL ; + rxq->rxrearm_start =0 ; + rxq->rxrearm_nb =0 ; +} + +void +reset_split_tx_descq (struct idpf_tx_queue *txq) +{ +struct idpf_tx_entry *txe; +uint32_t i, size; +uint16_t prev; + +if (txq ==NULL ) { +DRV_LOG (DEBUG ,"Pointer to txq is NULL" ); +return ; + } + + size =sizeof (struct idpf_flex_tx_sched_desc ) * txq->nb_tx_desc; +for (i =0 ; i < size; i++) + ((volatile char *)txq->desc_ring)[i] =0 ; + + txe = txq->sw_ring; + prev = (uint16_t )(txq->sw_nb_desc -1 ); +for (i =0 ; i < txq->sw_nb_desc; i++) { + txe[i].mbuf =NULL ; + txe[i].last_id = i; + txe[prev].next_id = i; + prev = i; + } + + txq->tx_tail =0 ; + txq->nb_used =0 ; + +/* Use this as next to clean for split desc queue */ + txq->last_desc_cleaned =0 ; + txq->sw_tail =0 ; + txq->nb_free = txq->nb_tx_desc -1 ; +} + +void +reset_split_tx_complq (struct idpf_tx_queue *cq) +{ +uint32_t i, size; + +if (cq ==NULL ) { +DRV_LOG (DEBUG ,"Pointer to complq is NULL" ); +return ; + } + + size =sizeof (struct idpf_splitq_tx_compl_desc ) * cq->nb_tx_desc; +for (i =0 ; i < size; i++) + ((volatile char *)cq->compl_ring)[i] =0 ; + + cq->tx_tail =0 ; + cq->expected_gen_id =1 ; +} + +void +reset_single_tx_queue (struct idpf_tx_queue *txq) +{ +struct idpf_tx_entry *txe; +uint32_t i, size; +uint16_t prev; + +if (txq ==NULL ) { +DRV_LOG (DEBUG ,"Pointer to txq is NULL" ); +return ; + } + + txe = txq->sw_ring; + size =sizeof (struct idpf_flex_tx_desc ) * txq->nb_tx_desc; +for (i =0 ; i < size; i++) + ((volatile char *)txq->tx_ring)[i] =0 ; + + prev = (uint16_t )(txq->nb_tx_desc -1 ); +for (i =0 ; i < txq->nb_tx_desc; i++) { + txq->tx_ring[i].qw1.cmd_dtype = +rte_cpu_to_le_16 (IDPF_TX_DESC_DTYPE_DESC_DONE ); + txe[i].mbuf =NULL ; + txe[i].last_id = i; + txe[prev].next_id = i; + prev = i; + } + + txq->tx_tail =0 ; + txq->nb_used =0 ; + + txq->last_desc_cleaned = txq->nb_tx_desc -1 ; + txq->nb_free = txq->nb_tx_desc -1 ; + + txq->next_dd = txq->rs_thresh -1 ; + txq->next_rs = txq->rs_thresh -1 ; +} + +void +idpf_rx_queue_release (void *rxq) +{ +struct idpf_rx_queue *q = rxq; + +if (q ==NULL ) +return ; + +/* Split queue */ +if (q->bufq1 !=NULL && q->bufq2 !=NULL ) { + q->bufq1->ops->release_mbufs (q->bufq1); +rte_free (q->bufq1->sw_ring); +rte_memzone_free (q->bufq1->mz); +rte_free (q->bufq1); + q->bufq2->ops->release_mbufs (q->bufq2); +rte_free (q->bufq2->sw_ring); +rte_memzone_free (q->bufq2->mz); +rte_free (q->bufq2); +rte_memzone_free (q->mz); +rte_free (q); +return ; + } + +/* Single queue */ + q->ops->release_mbufs (q); +rte_free (q->sw_ring); +rte_memzone_free (q->mz); +rte_free (q); +} + +void +idpf_tx_queue_release (void *txq) +{ +struct idpf_tx_queue *q = txq; + +if (q ==NULL ) +return ; + +if (q->complq) { +rte_memzone_free (q->complq->mz); +rte_free (q->complq); + } + + q->ops->release_mbufs (q); +rte_free (q->sw_ring); +rte_memzone_free (q->mz); +rte_free (q); +} + +int +idpf_alloc_single_rxq_mbufs (struct idpf_rx_queue *rxq) +{ +volatile struct virtchnl2_singleq_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 ==NULL )) { +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)); + + rxd = &((volatile struct virtchnl2_singleq_rx_buf_desc *)(rxq->rx_ring))[i]; + rxd->pkt_addr = dma_addr; + rxd->hdr_addr =0 ; + rxd->rsvd1 =0 ; + rxd->rsvd2 =0 ; + rxq->sw_ring[i] = mbuf; + } + +return 0 ; +} + +int +idpf_alloc_split_rxq_mbufs (struct idpf_rx_queue *rxq) +{ +volatile struct virtchnl2_splitq_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 ==NULL )) { +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)); + + rxd = &((volatile struct virtchnl2_splitq_rx_buf_desc *)(rxq->rx_ring))[i]; + rxd->qword0.buf_id = i; + rxd->qword0.rsvd0 =0 ; + rxd->qword0.rsvd1 =0 ; + rxd->pkt_addr = dma_addr; + rxd->hdr_addr =0 ; + rxd->rsvd2 =0 ; + + rxq->sw_ring[i] = mbuf; + } + + rxq->nb_rx_hold =0 ; + rxq->rx_tail = rxq->nb_rx_desc -1 ; + +return 0 ; +}
drivers/common/idpf/idpf_common_rxtx.h +57 -0
72 lines not on this page · raw message
drivers/common/idpf/meson.build +1 -0
@@ -5,6 +5,7 @@ deps += ['mbuf'] sources = files( 'idpf_common_device.c', + 'idpf_common_rxtx.c', 'idpf_common_virtchnl.c', )
drivers/common/idpf/version.map +15 -0
@@ -22,6 +22,21 @@ INTERNAL { idpf_config_irq_map; idpf_config_irq_unmap; idpf_create_vport_info_init; + check_rx_thresh; + check_tx_thresh; + release_rxq_mbufs; + release_txq_mbufs; + reset_split_rx_descq; + reset_split_rx_bufq; + reset_split_rx_queue; + reset_single_rx_queue; + reset_split_tx_descq; + reset_split_tx_complq; + reset_single_tx_queue; + idpf_rx_queue_release; + idpf_tx_queue_release; + idpf_alloc_single_rxq_mbufs; + idpf_alloc_split_rxq_mbufs; local: *; };
drivers/net/idpf/idpf_rxtx.c +274 -755
1,218 lines not on this page · raw message
drivers/net/idpf/idpf_rxtx.h +0 -9
@@ -51,7 +51,6 @@/* Base address of the HW descriptor ring should be 128B aligned. */ #define IDPF_RING_BASE_ALIGN 128 -#define IDPF_RX_MAX_BURST 32#define IDPF_DEFAULT_RX_FREE_THRESH 32/* used for Vector PMD */
@@ -101,14 +100,6 @@ union idpf_tx_offload { }; }; -struct idpf_rxq_ops { -void (*release_mbufs)(struct idpf_rx_queue *rxq); -}; - -struct idpf_txq_ops { -void (*release_mbufs)(struct idpf_tx_queue *txq); -}; - int idpf_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx, uint16_t nb_desc, unsigned int socket_id, const struct rte_eth_rxconf *rx_conf,
drivers/net/idpf/idpf_rxtx_vec_avx512.c +1 -1
@@ -562,7 +562,7 @@ idpf_tx_free_bufs_avx512(struct idpf_tx_queue *txq) txep = (void *)txq->sw_ring; txep += txq->next_dd - (n -1 ); -if (txq->offloads &RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE && (n &31 ) ==0 ) { +if (txq->offloads &IDPF_TX_OFFLOAD_MBUF_FAST_FREE && (n &31 ) ==0 ) {struct rte_mempool *mp = txep[0 ].mbuf->pool;struct rte_mempool_cache *cache =rte_mempool_default_cache (mp,rte_lcore_id ());
Signature · 1 line
2.26.2
PATCH 13/15 common/idpf: add scalar data path
In reply to [email protected]From: Beilei Xing <[email protected]>
Add timestamp filed to idpf_adapter structure.
Add scalar data path for single queue model and split queue model.
--- drivers/common/idpf/idpf_common_device.h | 5 + drivers/common/idpf/idpf_common_logs.h | 24 + drivers/common/idpf/idpf_common_rxtx.c | 985 +++++++++++++++++++++++ drivers/common/idpf/idpf_common_rxtx.h | 87 ++ drivers/common/idpf/version.map | 6 + drivers/net/idpf/idpf_ethdev.c | 2 - drivers/net/idpf/idpf_ethdev.h | 4 - drivers/net/idpf/idpf_logs.h | 24 - drivers/net/idpf/idpf_rxtx.c | 936 +-------------------- drivers/net/idpf/idpf_rxtx.h | 132 --- drivers/net/idpf/idpf_rxtx_vec_avx512.c | 6 +- 11 files changed, 1111 insertions(+), 1100 deletions(-)
drivers/common/idpf/idpf_common_device.h +5 -0
@@ -23,6 +23,8 @@#define IDPF_TX_COMPLQ_PER_GRP 1#define IDPF_TXQ_PER_GRP 1 +#define IDPF_MIN_FRAME_SIZE 14 +#define IDPF_MAX_PKT_TYPE 1024#define IDPF_DFLT_INTERVAL 16
@@ -43,6 +45,9 @@ struct idpf_adapter {uint32_t txq_model;/* 0 - split queue model, non-0 - single queue model */ uint32_t rxq_model;/* 0 - split queue model, non-0 - single queue model */ + +/* For timestamp */ +uint64_t time_hw; };struct idpf_chunks_info {
drivers/common/idpf/idpf_common_logs.h +24 -0
@@ -20,4 +20,28 @@ extern int idpf_common_logtype; #define DRV_LOG(level, fmt, args...) \ DRV_LOG_RAW(level, fmt "\n", ## args) +#ifdef RTE_LIBRTE_IDPF_DEBUG_RX +#define RX_LOG (level, ...) \ + RTE_LOG(level, \ + PMD, \ + RTE_FMT("%s(): " \ + RTE_FMT_HEAD(__VA_ARGS__,) "\n", \ + __func__, \ + RTE_FMT_TAIL(__VA_ARGS__,))) +#else +#define RX_LOG(level, fmt, args...) do { } while (0) +#endif + +#ifdef RTE_LIBRTE_IDPF_DEBUG_TX +#define TX_LOG (level, ...) \ + RTE_LOG(level, \ + PMD, \ + RTE_FMT("%s(): " \ + RTE_FMT_HEAD(__VA_ARGS__,) "\n", \ + __func__, \ + RTE_FMT_TAIL(__VA_ARGS__,))) +#else +#define TX_LOG(level, fmt, args...) do { } while (0) +#endif +#endif /* _IDPF_COMMON_LOGS_H_ */
drivers/common/idpf/idpf_common_rxtx.c +985 -0
1,002 lines not on this page · raw message
drivers/common/idpf/idpf_common_rxtx.h +87 -0
113 lines not on this page · raw message
drivers/common/idpf/version.map +6 -0
@@ -35,8 +35,14 @@ INTERNAL { reset_single_tx_queue; idpf_rx_queue_release; idpf_tx_queue_release; + idpf_register_ts_mbuf; idpf_alloc_single_rxq_mbufs; idpf_alloc_split_rxq_mbufs; + idpf_splitq_recv_pkts; + idpf_splitq_xmit_pkts; + idpf_singleq_recv_pkts; + idpf_singleq_xmit_pkts; + idpf_prep_pkts; local: *; };
drivers/net/idpf/idpf_ethdev.c +0 -2
@@ -22,8 +22,6 @@ rte_spinlock_t idpf_adapter_lock;struct idpf_adapter_list idpf_adapter_list;bool idpf_adapter_list_init; -uint64_t idpf_timestamp_dynflag; -static const char *const idpf_valid_args[] = {IDPF_TX_SINGLE_Q ,IDPF_RX_SINGLE_Q ,
drivers/net/idpf/idpf_ethdev.h +0 -4
@@ -28,7 +28,6 @@#define IDPF_MIN_BUF_SIZE 1024#define IDPF_MAX_FRAME_SIZE 9728 -#define IDPF_MIN_FRAME_SIZE 14#define IDPF_NUM_MACADDR_MAX 64
@@ -77,9 +76,6 @@ struct idpf_adapter_ext {uint16_t cur_vport_nb;uint16_t used_vecs_num; - -/* For PTP */ -uint64_t time_hw; };TAILQ_HEAD (idpf_adapter_list, idpf_adapter_ext);
drivers/net/idpf/idpf_logs.h +0 -24
@@ -29,28 +29,4 @@ extern int idpf_logtype_driver; #define PMD_DRV_LOG(level, fmt, args...) \ PMD_DRV_LOG_RAW(level, fmt "\n", ## args) -#ifdef RTE_LIBRTE_IDPF_DEBUG_RX -#define PMD_RX_LOG (level, ...) \ - RTE_LOG(level, \ - PMD, \ - RTE_FMT("%s(): " \ - RTE_FMT_HEAD(__VA_ARGS__,) "\n", \ - __func__, \ - RTE_FMT_TAIL(__VA_ARGS__,))) -#else -#define PMD_RX_LOG(level, fmt, args...) do { } while (0) -#endif - -#ifdef RTE_LIBRTE_IDPF_DEBUG_TX -#define PMD_TX_LOG (level, ...) \ - RTE_LOG(level, \ - PMD, \ - RTE_FMT("%s(): " \ - RTE_FMT_HEAD(__VA_ARGS__,) "\n", \ - __func__, \ - RTE_FMT_TAIL(__VA_ARGS__,))) -#else -#define PMD_TX_LOG(level, fmt, args...) do { } while (0) -#endif -#endif /* _IDPF_LOGS_H_ */
drivers/net/idpf/idpf_rxtx.c +2 -934
954 lines not on this page · raw message
drivers/net/idpf/idpf_rxtx.h +0 -132
162 lines not on this page · raw message
drivers/net/idpf/idpf_rxtx_vec_avx512.c +2 -4
@@ -38,8 +38,7 @@ idpf_singleq_rearm_common(struct idpf_rx_queue *rxq) dma_addr0); } } - rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed += -IDPF_RXQ_REARM_THRESH ; + rxq->rx_stats.mbuf_alloc_failed +=IDPF_RXQ_REARM_THRESH ;return ; }struct rte_mbuf *mb0, *mb1, *mb2, *mb3;
@@ -168,8 +167,7 @@ idpf_singleq_rearm(struct idpf_rx_queue *rxq) dma_addr0); } } - rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed += -IDPF_RXQ_REARM_THRESH ; + rxq->rx_stats.mbuf_alloc_failed +=IDPF_RXQ_REARM_THRESH ;return ; } }
Signature · 1 line
2.26.2
PATCH 14/15 common/idpf: add vec queue setup
In reply to [email protected]From: Beilei Xing <[email protected]>
Add vector queue setup for single queue model.
--- drivers/common/idpf/idpf_common_rxtx.c | 57 ++++++++++++++++++++++++++ drivers/common/idpf/idpf_common_rxtx.h | 2 + drivers/common/idpf/version.map | 1 + drivers/net/idpf/idpf_rxtx.c | 57 -------------------------- drivers/net/idpf/idpf_rxtx.h | 1 - 5 files changed, 60 insertions(+), 58 deletions(-)
drivers/common/idpf/idpf_common_rxtx.c +57 -0
@@ -1397,3 +1397,60 @@ idpf_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts,return i; } + +static void __rte_cold +release_rxq_mbufs_vec (struct idpf_rx_queue *rxq) +{ +const uint16_t mask = rxq->nb_rx_desc -1 ; +uint16_t i; + +if (rxq->sw_ring ==NULL || rxq->rxrearm_nb >= rxq->nb_rx_desc) +return ; + +/* free all mbufs that are valid in the ring */ +if (rxq->rxrearm_nb ==0 ) { +for (i =0 ; i < rxq->nb_rx_desc; i++) { +if (rxq->sw_ring[i] !=NULL ) +rte_pktmbuf_free_seg (rxq->sw_ring[i]); + } + }else { +for (i = rxq->rx_tail; i != rxq->rxrearm_start; i = (i +1 ) & mask) { +if (rxq->sw_ring[i] !=NULL ) +rte_pktmbuf_free_seg (rxq->sw_ring[i]); + } + } + + rxq->rxrearm_nb = rxq->nb_rx_desc; + +/* set all entries to NULL */ +memset (rxq->sw_ring,0 ,sizeof (rxq->sw_ring[0 ]) * rxq->nb_rx_desc); +} + +static const struct idpf_rxq_ops def_singleq_rx_ops_vec = { + .release_mbufs = release_rxq_mbufs_vec, +}; + +static inline int +idpf_singleq_rx_vec_setup_default (struct idpf_rx_queue *rxq) +{ +uintptr_t p; +struct rte_mbuf mb_def = { .buf_addr =0 };/* zeroed mbuf */ + + mb_def.nb_segs =1 ; + mb_def.data_off =RTE_PKTMBUF_HEADROOM ; + mb_def.port = rxq->port_id; +rte_mbuf_refcnt_set (&mb_def,1 ); + +/* prevent compiler reordering: rearm_data covers previous fields */ +rte_compiler_barrier (); + p = (uintptr_t )&mb_def.rearm_data; + rxq->mbuf_initializer = *(uint64_t *)p; +return 0 ; +} + +int __rte_cold +idpf_singleq_rx_vec_setup (struct idpf_rx_queue *rxq) +{ + rxq->ops = &def_singleq_rx_ops_vec; +return idpf_singleq_rx_vec_setup_default (rxq); +}
drivers/common/idpf/idpf_common_rxtx.h +2 -0
@@ -252,5 +252,7 @@ uint16_t idpf_singleq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,__rte_internal uint16_t idpf_prep_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,uint16_t nb_pkts); +__rte_internal +int idpf_singleq_rx_vec_setup(struct idpf_rx_queue *rxq);#endif /* _IDPF_COMMON_RXTX_H_ */
drivers/common/idpf/version.map +1 -0
@@ -43,6 +43,7 @@ INTERNAL { idpf_singleq_recv_pkts; idpf_singleq_xmit_pkts; idpf_prep_pkts; + idpf_singleq_rx_vec_setup; local: *; };
drivers/net/idpf/idpf_rxtx.c +0 -57
63 lines not on this page · raw message
drivers/net/idpf/idpf_rxtx.h +0 -1
@@ -44,7 +44,6 @@ void idpf_dev_rx_queue_release(struct rte_eth_dev *dev, uint16_t qid);int idpf_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); -int idpf_singleq_rx_vec_setup (struct idpf_rx_queue *rxq);int idpf_tx_queue_init (struct rte_eth_dev *dev,uint16_t tx_queue_id);int idpf_tx_queue_start (struct rte_eth_dev *dev,uint16_t tx_queue_id);int idpf_tx_queue_stop (struct rte_eth_dev *dev,uint16_t tx_queue_id);
Signature · 1 line
2.26.2
PATCH 15/15 common/idpf: add avx512 for single queue model
In reply to [email protected]From: Beilei Xing <[email protected]>
Add avx512 vector path for single queue model.
---
drivers/common/idpf/idpf_common_rxtx.h | 20 +++++++++++++
.../idpf/idpf_common_rxtx_avx512.c} | 4 +--
drivers/common/idpf/meson.build | 30 +++++++++++++++++++
drivers/common/idpf/version.map | 3 ++
drivers/net/idpf/idpf_rxtx.h | 13 --------
drivers/net/idpf/meson.build | 17 -----------
6 files changed, 55 insertions(+), 32 deletions(-)
rename drivers/{net/idpf/idpf_rxtx_vec_avx512.c => common/idpf/idpf_common_rxtx_avx512.c} (99%)drivers/common/idpf/idpf_common_rxtx.h +20 -0
@@ -47,6 +47,12 @@#define IDPF_TX_OFFLOAD_NOTSUP_MASK \ (RTE_MBUF_F_TX_OFFLOAD_MASK ^ IDPF_TX_OFFLOAD_MASK) +/* used for Vector PMD */ +#define IDPF_VPMD_RX_MAX_BURST 32 +#define IDPF_VPMD_TX_MAX_BURST 32 +#define IDPF_VPMD_DESCS_PER_LOOP 4 +#define IDPF_RXQ_REARM_THRESH 64 +/* MTS */ #define GLTSYN_CMD_SYNC_0_0 (PF_TIMESYNC_BASE + 0x0)#define PF_GLTSYN_SHTIME_0_0 (PF_TIMESYNC_BASE + 0x4)
@@ -193,6 +199,10 @@ union idpf_tx_offload { }; }; +struct idpf_tx_vec_entry { +struct rte_mbuf *mbuf; +}; +struct idpf_rxq_ops {void (*release_mbufs)(struct idpf_rx_queue *rxq); };
@@ -254,5 +264,15 @@ uint16_t idpf_prep_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts);__rte_internal int idpf_singleq_rx_vec_setup(struct idpf_rx_queue *rxq); +__rte_internal +int idpf_singleq_tx_vec_setup_avx512(struct idpf_tx_queue *txq); +__rte_internal +uint16_t idpf_singleq_recv_pkts_avx512(void *rx_queue, +struct rte_mbuf **rx_pkts, +uint16_t nb_pkts); +__rte_internal +uint16_t idpf_singleq_xmit_pkts_avx512(void *tx_queue, +struct rte_mbuf **tx_pkts, +uint16_t nb_pkts);#endif /* _IDPF_COMMON_RXTX_H_ */
drivers/common/idpf/idpf_common_rxtx_avx512.c renamed from drivers/net/idpf/idpf_rxtx_vec_avx512.c +2 -2
@@ -2,9 +2,9 @@* Copyright(c) 2022 Intel Corporation */ -#include "idpf_rxtx_vec_common.h" -#include <rte_vect.h> +#include <idpf_common_device.h> +#include <idpf_common_rxtx.h> #ifndef __INTEL_COMPILER#pragma GCC diagnostic ignored "-Wcast-qual"
drivers/common/idpf/meson.build +30 -0
@@ -9,4 +9,34 @@ sources = files( 'idpf_common_virtchnl.c', ) +if arch_subdir == 'x86' + idpf_avx512_cpu_support = ( + cc.get_define('__AVX512F__', args: machine_args) != '' and + cc.get_define('__AVX512BW__', args: machine_args) != '' + ) + + idpf_avx512_cc_support = ( + not machine_args.contains('-mno-avx512f') and + cc.has_argument('-mavx512f') and + cc.has_argument('-mavx512bw') + ) + + if idpf_avx512_cpu_support == true or idpf_avx512_cc_support == true + cflags += ['-DCC_AVX512_SUPPORT'] + avx512_args = [cflags, '-mavx512f', '-mavx512bw'] + if cc.has_argument('-march=skylake-avx512') + avx512_args += '-march=skylake-avx512' + endif + idpf_common_avx512_lib = static_library( + 'idpf_common_avx512_lib', + 'idpf_common_rxtx_avx512.c', + dependencies: [ + static_rte_mbuf, + ], + include_directories: includes, + c_args: avx512_args) + objs += idpf_common_avx512_lib.extract_objects('idpf_common_rxtx_avx512.c') + endif +endif + subdir('base')
drivers/common/idpf/version.map +3 -0
@@ -44,6 +44,9 @@ INTERNAL { idpf_singleq_xmit_pkts; idpf_prep_pkts; idpf_singleq_rx_vec_setup; + idpf_singleq_tx_vec_setup_avx512; + idpf_singleq_recv_pkts_avx512; + idpf_singleq_xmit_pkts_avx512; local: *; };
drivers/net/idpf/idpf_rxtx.h +0 -13
@@ -19,23 +19,14 @@#define IDPF_DEFAULT_RX_FREE_THRESH 32/* used for Vector PMD */ -#define IDPF_VPMD_RX_MAX_BURST 32 -#define IDPF_VPMD_TX_MAX_BURST 32 -#define IDPF_VPMD_DESCS_PER_LOOP 4 -#define IDPF_RXQ_REARM_THRESH 64#define IDPF_DEFAULT_TX_RS_THRESH 32#define IDPF_DEFAULT_TX_FREE_THRESH 32 -struct idpf_tx_vec_entry { -struct rte_mbuf *mbuf; -}; -int idpf_rx_queue_setup (struct rte_eth_dev *dev,uint16_t queue_idx,uint16_t nb_desc,unsigned int socket_id,const struct rte_eth_rxconf *rx_conf,struct rte_mempool *mp); -int idpf_singleq_tx_vec_setup_avx512 (struct idpf_tx_queue *txq);int idpf_rx_queue_init (struct rte_eth_dev *dev,uint16_t rx_queue_id);int idpf_rx_queue_start (struct rte_eth_dev *dev,uint16_t rx_queue_id);int idpf_rx_queue_stop (struct rte_eth_dev *dev,uint16_t rx_queue_id);
@@ -48,10 +39,6 @@ int idpf_tx_queue_init(struct rte_eth_dev *dev, uint16_t tx_queue_id);int idpf_tx_queue_start (struct rte_eth_dev *dev,uint16_t tx_queue_id);int idpf_tx_queue_stop (struct rte_eth_dev *dev,uint16_t tx_queue_id);void idpf_dev_tx_queue_release (struct rte_eth_dev *dev,uint16_t qid); -uint16_t idpf_singleq_recv_pkts_avx512 (void *rx_queue,struct rte_mbuf **rx_pkts, -uint16_t nb_pkts); -uint16_t idpf_singleq_xmit_pkts_avx512 (void *tx_queue,struct rte_mbuf **tx_pkts, -uint16_t nb_pkts);void idpf_stop_queues (struct rte_eth_dev *dev);
drivers/net/idpf/meson.build +0 -17
@@ -28,22 +28,5 @@ if arch_subdir == 'x86' if idpf_avx512_cpu_support == true or idpf_avx512_cc_support == true cflags += ['-DCC_AVX512_SUPPORT'] - avx512_args = [cflags, '-mavx512f', '-mavx512bw'] - if cc.has_argument('-march=skylake-avx512') - avx512_args += '-march=skylake-avx512' - endif - idpf_avx512_lib = static_library( - 'idpf_avx512_lib', - 'idpf_rxtx_vec_avx512.c', - dependencies: [ - static_rte_common_idpf, - static_rte_ethdev, - static_rte_bus_pci, - static_rte_kvargs, - static_rte_hash, - ], - include_directories: includes, - c_args: avx512_args) - objs += idpf_avx512_lib.extract_objects('idpf_rxtx_vec_avx512.c') endif endif
Signature · 1 line
2.26.2
v2 cover net/idpf: introduce idpf common modle
In reply to [email protected]From: Beilei Xing <[email protected]>
Refactor idpf pmd by introducing idpf common module, which will be also consumed by a new PMD - CPFL (Control Plane Function Library) PMD.
The patchset depends on this following patchset:
https://patches.dpdk.org/project/dpdk/cover/[email protected]/
v2 changes:
- Refine irq map/unmap functions.
- Fix cross compile issue.
Beilei Xing (15):
common/idpf: add adapter structure
common/idpf: add vport structure
common/idpf: move vc functions to common module common/idpf: introduce adapter init and deinit common/idpf: add vport init/deinit
common/idpf: add config RSS
common/idpf: add irq map/unmap
common/idpf: move ptype table to adapter structure common/idpf: init create vport info
common/idpf: add vector flags in vport common/idpf: add rxq and txq struct
common/idpf: add help functions for queue setup and release common/idpf: add scalar data path
common/idpf: add vec queue setup
common/idpf: add avx512 for single queue model
drivers/common/idpf/base/meson.build | 2 +-
drivers/common/idpf/idpf_common_device.c | 664 ++++++
drivers/common/idpf/idpf_common_device.h | 192 ++
drivers/common/idpf/idpf_common_logs.h | 47 +
drivers/common/idpf/idpf_common_rxtx.c | 1458 ++++++++++++
drivers/common/idpf/idpf_common_rxtx.h | 278 +++
.../idpf/idpf_common_rxtx_avx512.c} | 14 +-
.../idpf/idpf_common_virtchnl.c} | 881 ++-----
drivers/common/idpf/idpf_common_virtchnl.h | 41 +
drivers/common/idpf/meson.build | 38 +
drivers/common/idpf/version.map | 40 +
drivers/net/idpf/idpf_ethdev.c | 544 +----
drivers/net/idpf/idpf_ethdev.h | 194 +-
drivers/net/idpf/idpf_logs.h | 24 -
drivers/net/idpf/idpf_rxtx.c | 2033 +++--------------
drivers/net/idpf/idpf_rxtx.h | 253 +-
drivers/net/idpf/meson.build | 18 -
17 files changed, 3344 insertions(+), 3377 deletions(-)
create mode 100644 drivers/common/idpf/idpf_common_device.c
create mode 100644 drivers/common/idpf/idpf_common_device.h
create mode 100644 drivers/common/idpf/idpf_common_logs.h
create mode 100644 drivers/common/idpf/idpf_common_rxtx.c
create mode 100644 drivers/common/idpf/idpf_common_rxtx.h
rename drivers/{net/idpf/idpf_rxtx_vec_avx512.c => common/idpf/idpf_common_rxtx_avx512.c} (98%)
rename drivers/{net/idpf/idpf_vchnl.c => common/idpf/idpf_common_virtchnl.c} (56%)
create mode 100644 drivers/common/idpf/idpf_common_virtchnl.hSignature · 1 line
2.26.2
PATCH v2 1/15 common/idpf: add adapter structure
From: Beilei Xing <[email protected]>
Add structure idpf_adapter in common module, the structure includes some basic fields.
Introduce structure idpf_adapter_ext in PMD, this structure includes extra fileds except idpf_adapter.
--- drivers/common/idpf/idpf_common_device.h | 20 ++++++ drivers/net/idpf/idpf_ethdev.c | 91 ++++++++++-------------- drivers/net/idpf/idpf_ethdev.h | 25 +++---- drivers/net/idpf/idpf_rxtx.c | 16 ++--- drivers/net/idpf/idpf_rxtx.h | 4 +- drivers/net/idpf/idpf_rxtx_vec_avx512.c | 3 +- drivers/net/idpf/idpf_vchnl.c | 30 ++++---- 7 files changed, 99 insertions(+), 90 deletions(-) create mode 100644 drivers/common/idpf/idpf_common_device.h
drivers/common/idpf/idpf_common_device.h new file +20 -0
@@ -0,0 +1,20 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2022 Intel Corporation +*/ + +#ifndef _IDPF_COMMON_DEVICE_H_ +#define _IDPF_COMMON_DEVICE_H_ + +#include <base/idpf_prototype.h> +#include <base/virtchnl2.h> + +struct idpf_adapter { +struct idpf_hw hw; +struct virtchnl2_version_info virtchnl_version; +struct virtchnl2_get_capabilities caps; +volatile uint32_t pend_cmd;/* pending command not finished */ +uint32_t cmd_retval;/* return value of the cmd response from cp */ +uint8_t *mbx_resp;/* buffer to store the mailbox response from cp */ +}; + +#endif /* _IDPF_COMMON_DEVICE_H_ */
drivers/net/idpf/idpf_ethdev.c +38 -53
232 lines not on this page · raw message
drivers/net/idpf/idpf_ethdev.h +11 -14
@@ -15,6 +15,7 @@#include "idpf_logs.h" +#include <idpf_common_device.h> #include <base/idpf_prototype.h> #include <base/virtchnl2.h>
@@ -91,7 +92,7 @@ struct idpf_chunks_info { };struct idpf_vport_param { -struct idpf_adapter *adapter; +struct idpf_adapter_ext *adapter;uint16_t devarg_id;/* arg id from user */ uint16_t idx;/* index in adapter->vports[]*/ };
@@ -144,17 +145,11 @@ struct idpf_devargs {uint16_t req_vport_nb; }; -struct idpf_adapter { -TAILQ_ENTRY (idpf_adapter) next; -struct idpf_hw hw; -char name[IDPF_ADAPTER_NAME_LEN ]; - -struct virtchnl2_version_info virtchnl_version; -struct virtchnl2_get_capabilities *caps; +struct idpf_adapter_ext { +TAILQ_ENTRY (idpf_adapter_ext) next; +struct idpf_adapter base; -volatile uint32_t pend_cmd;/* pending command not finished */ -uint32_t cmd_retval;/* return value of the cmd response from ipf */ -uint8_t *mbx_resp;/* buffer to store the mailbox response from ipf */ +char name[IDPF_ADAPTER_NAME_LEN ];uint32_t txq_model;/* 0 - split queue model, non-0 - single queue model */ uint32_t rxq_model;/* 0 - split queue model, non-0 - single queue model */
@@ -182,10 +177,12 @@ struct idpf_adapter {uint64_t time_hw; }; -TAILQ_HEAD (idpf_adapter_list, idpf_adapter); +TAILQ_HEAD (idpf_adapter_list, idpf_adapter_ext);#define IDPF_DEV_TO_PCI (eth_dev) \ RTE_DEV_TO_PCI((eth_dev)->device) +#define IDPF_ADAPTER_TO_EXT (p) \ + container_of((p), struct idpf_adapter_ext, base)/* structure used for sending and checking response of virtchnl ops */ struct idpf_cmd_info {
@@ -234,10 +231,10 @@ atomic_set_cmd(struct idpf_adapter *adapter, uint32_t ops)return !ret; } -struct idpf_adapter *idpf_find_adapter (struct rte_pci_device *pci_dev); +struct idpf_adapter_ext *idpf_find_adapter_ext (struct rte_pci_device *pci_dev);void idpf_handle_virtchnl_msg (struct rte_eth_dev *dev);int idpf_vc_check_api_version (struct idpf_adapter *adapter); -int idpf_get_pkt_type (struct idpf_adapter *adapter); +int idpf_get_pkt_type (struct idpf_adapter_ext *adapter);int idpf_vc_get_caps (struct idpf_adapter *adapter);int idpf_vc_create_vport (struct idpf_vport *vport,struct virtchnl2_create_vport *vport_info);
drivers/net/idpf/idpf_rxtx.c +8 -8
@@ -1384,7 +1384,7 @@ idpf_splitq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,struct idpf_rx_queue *rxq;const uint32_t *ptype_tbl;uint8_t status_err0_qw1; -struct idpf_adapter *ad; +struct idpf_adapter_ext *ad;struct rte_mbuf *rxm;uint16_t rx_id_bufq1;uint16_t rx_id_bufq2;
@@ -1398,7 +1398,7 @@ idpf_splitq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, nb_rx =0 ; rxq = rx_queue; - ad = rxq->adapter; + ad =IDPF_ADAPTER_TO_EXT (rxq->adapter);if (unlikely (rxq ==NULL ) ||unlikely (!rxq->q_started))return nb_rx;
@@ -1407,7 +1407,7 @@ idpf_splitq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, rx_id_bufq1 = rxq->bufq1->rx_next_avail; rx_id_bufq2 = rxq->bufq2->rx_next_avail; rx_desc_ring = rxq->rx_ring; - ptype_tbl = rxq->adapter->ptype_tbl; + ptype_tbl = ad->ptype_tbl;if ((rxq->offloads &RTE_ETH_RX_OFFLOAD_TIMESTAMP ) !=0 ) rxq->hw_register_set =1 ;
@@ -1791,7 +1791,7 @@ idpf_singleq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,const uint32_t *ptype_tbl;uint16_t rx_id, nb_hold;struct rte_eth_dev *dev; -struct idpf_adapter *ad; +struct idpf_adapter_ext *ad;uint16_t rx_packet_len;struct rte_mbuf *rxm;struct rte_mbuf *nmb;
@@ -1805,14 +1805,14 @@ idpf_singleq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, nb_hold =0 ; rxq = rx_queue; - ad = rxq->adapter; + ad =IDPF_ADAPTER_TO_EXT (rxq->adapter);if (unlikely (rxq ==NULL ) ||unlikely (!rxq->q_started))return nb_rx; rx_id = rxq->rx_tail; rx_ring = rxq->rx_ring; - ptype_tbl = rxq->adapter->ptype_tbl; + ptype_tbl = ad->ptype_tbl;if ((rxq->offloads &RTE_ETH_RX_OFFLOAD_TIMESTAMP ) !=0 ) rxq->hw_register_set =1 ;
@@ -2221,7 +2221,7 @@ idpf_set_rx_function(struct rte_eth_dev *dev) {struct idpf_vport *vport = dev->data->dev_private;#ifdef RTE_ARCH_X86 -struct idpf_adapter *ad = vport->adapter; +struct idpf_adapter_ext *ad =IDPF_ADAPTER_TO_EXT (vport->adapter);struct idpf_rx_queue *rxq;int i;
@@ -2275,7 +2275,7 @@ idpf_set_tx_function(struct rte_eth_dev *dev) {struct idpf_vport *vport = dev->data->dev_private;#ifdef RTE_ARCH_X86 -struct idpf_adapter *ad = vport->adapter; +struct idpf_adapter_ext *ad =IDPF_ADAPTER_TO_EXT (vport->adapter);#ifdef CC_AVX512_SUPPORT struct idpf_tx_queue *txq;int i;
drivers/net/idpf/idpf_rxtx.h +2 -2
@@ -247,11 +247,11 @@ void idpf_set_tx_function(struct rte_eth_dev *dev);/* Helper function to convert a 32b nanoseconds timestamp to 64b. */ static inline uint64_t -idpf_tstamp_convert_32b_64b (struct idpf_adapter *ad,uint32_t flag, +idpf_tstamp_convert_32b_64b (struct idpf_adapter_ext *ad,uint32_t flag,uint32_t in_timestamp) {#ifdef RTE_ARCH_X86_64 -struct idpf_hw *hw = &ad->hw; +struct idpf_hw *hw = &ad->base.hw;const uint64_t mask =0xFFFFFFFF ;uint32_t hi, lo, lo2, delta;uint64_t ns;
drivers/net/idpf/idpf_rxtx_vec_avx512.c +2 -1
@@ -245,7 +245,8 @@ _idpf_singleq_recv_raw_pkts_avx512(struct idpf_rx_queue *rxq, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) { -const uint32_t *type_table = rxq->adapter->ptype_tbl; +struct idpf_adapter_ext *adapter =IDPF_ADAPTER_TO_EXT (rxq->adapter); +const uint32_t *type_table = adapter->ptype_tbl;const __m256i mbuf_init =_mm256_set_epi64x (0 ,0 ,0 , rxq->mbuf_initializer);
drivers/net/idpf/idpf_vchnl.c +18 -12
@@ -311,13 +311,17 @@ idpf_vc_check_api_version(struct idpf_adapter *adapter) } int __rte_cold -idpf_get_pkt_type (struct idpf_adapter *adapter) +idpf_get_pkt_type (struct idpf_adapter_ext *adapter) {struct virtchnl2_get_ptype_info *ptype_info; -uint16_t ptype_recvd =0 , ptype_offset, i, j; +struct idpf_adapter *base; +uint16_t ptype_offset, i, j; +uint16_t ptype_recvd =0 ;int ret; - ret =idpf_vc_query_ptype_info (adapter); + base = &adapter->base; + + ret =idpf_vc_query_ptype_info (base);if (ret !=0 ) {PMD_DRV_LOG (ERR ,"Fail to query packet type information" );return ret;
@@ -328,7 +332,7 @@ idpf_get_pkt_type(struct idpf_adapter *adapter)return -ENOMEM ;while (ptype_recvd <IDPF_MAX_PKT_TYPE ) { - ret =idpf_read_one_msg (adapter,VIRTCHNL2_OP_GET_PTYPE_INFO , + ret =idpf_read_one_msg (base,VIRTCHNL2_OP_GET_PTYPE_INFO ,IDPF_DFLT_MBX_BUF_SIZE , (u8 *)ptype_info);if (ret !=0 ) {PMD_DRV_LOG (ERR ,"Fail to get packet type information" );
@@ -515,7 +519,7 @@ idpf_get_pkt_type(struct idpf_adapter *adapter) free_ptype_info:rte_free (ptype_info); -clear_cmd (adapter); +clear_cmd (base);return ret; }
@@ -577,7 +581,7 @@ idpf_vc_get_caps(struct idpf_adapter *adapter)return err; } -rte_memcpy (adapter->caps, args.out_buffer,sizeof (caps_msg)); +rte_memcpy (&adapter->caps, args.out_buffer,sizeof (caps_msg));return 0 ; }
@@ -740,7 +744,8 @@ idpf_vc_set_rss_hash(struct idpf_vport *vport)int idpf_vc_config_rxqs (struct idpf_vport *vport) { -struct idpf_adapter *adapter = vport->adapter; +struct idpf_adapter *base = vport->adapter; +struct idpf_adapter_ext *adapter =IDPF_ADAPTER_TO_EXT (base);struct idpf_rx_queue **rxq = (struct idpf_rx_queue **)vport->dev_data->rx_queues;struct virtchnl2_config_rx_queues *vc_rxqs =NULL ;
@@ -832,10 +837,10 @@ idpf_vc_config_rxqs(struct idpf_vport *vport) 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_buffer = base->mbx_resp; args.out_size =IDPF_DFLT_MBX_BUF_SIZE ; - err =idpf_execute_vc_cmd (adapter, &args); + err =idpf_execute_vc_cmd (base, &args);rte_free (vc_rxqs);if (err !=0 ) {PMD_DRV_LOG (ERR ,"Failed to execute command of VIRTCHNL2_OP_CONFIG_RX_QUEUES" );
@@ -940,7 +945,8 @@ idpf_vc_config_rxq(struct idpf_vport *vport, uint16_t rxq_id)int idpf_vc_config_txqs (struct idpf_vport *vport) { -struct idpf_adapter *adapter = vport->adapter; +struct idpf_adapter *base = vport->adapter; +struct idpf_adapter_ext *adapter =IDPF_ADAPTER_TO_EXT (base);struct idpf_tx_queue **txq = (struct idpf_tx_queue **)vport->dev_data->tx_queues;struct virtchnl2_config_tx_queues *vc_txqs =NULL ;
@@ -1010,10 +1016,10 @@ idpf_vc_config_txqs(struct idpf_vport *vport) 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_buffer = base->mbx_resp; args.out_size =IDPF_DFLT_MBX_BUF_SIZE ; - err =idpf_execute_vc_cmd (adapter, &args); + err =idpf_execute_vc_cmd (base, &args);rte_free (vc_txqs);if (err !=0 ) {PMD_DRV_LOG (ERR ,"Failed to execute command of VIRTCHNL2_OP_CONFIG_TX_QUEUES" );
Signature · 1 line
2.26.2
PATCH v2 2/15 common/idpf: add vport structure
In reply to [email protected]From: Beilei Xing <[email protected]>
Move idpf_vport structure to common module, remove ethdev dependency. Also remove unused functions.
--- drivers/common/idpf/idpf_common_device.h | 59 ++++++ drivers/net/idpf/idpf_ethdev.c | 10 +- drivers/net/idpf/idpf_ethdev.h | 66 +----- drivers/net/idpf/idpf_rxtx.c | 4 +- drivers/net/idpf/idpf_rxtx.h | 3 + drivers/net/idpf/idpf_vchnl.c | 252 +++-------------------- 6 files changed, 96 insertions(+), 298 deletions(-)
drivers/common/idpf/idpf_common_device.h +59 -0
@@ -17,4 +17,63 @@ struct idpf_adapter {uint8_t *mbx_resp;/* buffer to store the mailbox response from cp */ }; +struct idpf_chunks_info { +uint32_t tx_start_qid; +uint32_t rx_start_qid; +/* Valid only if split queue model */ +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 idpf_vport { +struct idpf_adapter *adapter;/* Backreference to associated adapter */ +struct virtchnl2_create_vport *vport_info;/* virtchnl response info handling */ +uint16_t sw_idx;/* SW index in adapter->vports[]*/ +uint16_t vport_id; +uint32_t txq_model; +uint32_t rxq_model; +uint16_t num_tx_q; +/* valid only if txq_model is split Q */ +uint16_t num_tx_complq; +uint16_t num_rx_q; +/* valid only if rxq_model is split Q */ +uint16_t num_rx_bufq; + +uint16_t max_mtu; +uint8_t default_mac_addr[VIRTCHNL_ETH_LENGTH_OF_ADDRESS ]; + +enum virtchnl_rss_algorithm rss_algorithm; +uint16_t rss_key_size; +uint16_t rss_lut_size; + +void *dev_data;/* Pointer to the device data */ +uint16_t max_pkt_len;/* Maximum packet length */ + +/* RSS info */ +uint32_t *rss_lut; +uint8_t *rss_key; +uint64_t rss_hf; + +/* MSIX info*/ +struct virtchnl2_queue_vector *qv_map;/* queue vector mapping */ +uint16_t max_vectors; +struct virtchnl2_alloc_vectors *recv_vectors; + +/* Chunk info */ +struct idpf_chunks_info chunks_info; + +uint16_t devarg_id; + +bool stopped; +}; +#endif /* _IDPF_COMMON_DEVICE_H_ */
drivers/net/idpf/idpf_ethdev.c +6 -4
@@ -275,11 +275,13 @@ static int idpf_init_rss(struct idpf_vport *vport) {struct rte_eth_rss_conf *rss_conf; +struct rte_eth_dev_data *dev_data;uint16_t i, nb_q, lut_size;int ret =0 ; - rss_conf = &vport->dev_data->dev_conf.rx_adv_conf.rss_conf; - nb_q = vport->dev_data->nb_rx_queues; + dev_data = vport->dev_data; + rss_conf = &dev_data->dev_conf.rx_adv_conf.rss_conf; + nb_q = dev_data->nb_rx_queues; vport->rss_key =rte_zmalloc ("rss_key" , vport->rss_key_size,0 );
@@ -466,7 +468,7 @@ idpf_config_rx_queues_irqs(struct rte_eth_dev *dev) } vport->qv_map = qv_map; -if (idpf_vc_config_irq_map_unmap (vport, true) !=0 ) { +if (idpf_vc_config_irq_map_unmap (vport, dev->data->nb_rx_queues, true) !=0 ) {PMD_DRV_LOG (ERR ,"config interrupt mapping failed" ); goto config_irq_map_err; }
@@ -582,7 +584,7 @@ idpf_dev_stop(struct rte_eth_dev *dev)idpf_stop_queues (dev); -idpf_vc_config_irq_map_unmap (vport, false); +idpf_vc_config_irq_map_unmap (vport, dev->data->nb_rx_queues, false);if (vport->recv_vectors !=NULL )idpf_vc_dealloc_vectors (vport);
drivers/net/idpf/idpf_ethdev.h +2 -64
88 lines not on this page · raw message
drivers/net/idpf/idpf_rxtx.c +2 -2
@@ -1066,7 +1066,7 @@ idpf_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id) dev->data->rx_queues[rx_queue_id];int err =0 ; - err =idpf_vc_config_rxq (vport, rx_queue_id); + err =idpf_vc_config_rxq (vport, rxq);if (err !=0 ) {PMD_DRV_LOG (ERR ,"Fail to configure Rx queue %u" , rx_queue_id);return err;
@@ -1117,7 +1117,7 @@ idpf_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id) dev->data->tx_queues[tx_queue_id];int err =0 ; - err =idpf_vc_config_txq (vport, tx_queue_id); + err =idpf_vc_config_txq (vport, txq);if (err !=0 ) {PMD_DRV_LOG (ERR ,"Fail to configure Tx queue %u" , tx_queue_id);return err;
drivers/net/idpf/idpf_rxtx.h +3 -0
@@ -243,6 +243,9 @@ void idpf_stop_queues(struct rte_eth_dev *dev);void idpf_set_rx_function (struct rte_eth_dev *dev);void idpf_set_tx_function (struct rte_eth_dev *dev); +int idpf_vc_config_rxq (struct idpf_vport *vport,struct idpf_rx_queue *rxq); +int idpf_vc_config_txq (struct idpf_vport *vport,struct idpf_tx_queue *txq); +#define IDPF_TIMESYNC_REG_WRAP_GUARD_BAND 10000/* Helper function to convert a 32b nanoseconds timestamp to 64b. */ static inline uint64_t
drivers/net/idpf/idpf_vchnl.c +24 -228
327 lines not on this page · raw message
Signature · 1 line
2.26.2
PATCH v2 3/15 common/idpf: move vc functions to common module
In reply to [email protected]From: Beilei Xing <[email protected]>
Move most of virtual channel functions to idpf common module.
--- drivers/common/idpf/base/meson.build | 2 +- drivers/common/idpf/idpf_common_device.c | 8 + drivers/common/idpf/idpf_common_device.h | 61 ++ drivers/common/idpf/idpf_common_logs.h | 23 + drivers/common/idpf/idpf_common_virtchnl.c | 815 +++++++++++++++++++++ drivers/common/idpf/idpf_common_virtchnl.h | 48 ++ drivers/common/idpf/meson.build | 5 + drivers/common/idpf/version.map | 16 + drivers/net/idpf/idpf_ethdev.c | 9 +- drivers/net/idpf/idpf_ethdev.h | 85 +-- drivers/net/idpf/idpf_vchnl.c | 815 +-------------------- 11 files changed, 981 insertions(+), 906 deletions(-) create mode 100644 drivers/common/idpf/idpf_common_device.c create mode 100644 drivers/common/idpf/idpf_common_logs.h create mode 100644 drivers/common/idpf/idpf_common_virtchnl.c create mode 100644 drivers/common/idpf/idpf_common_virtchnl.h
drivers/common/idpf/base/meson.build +1 -1
@@ -1,7 +1,7 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2022 Intel Corporation -sources = files( +sources += files( 'idpf_common.c', 'idpf_controlq.c', 'idpf_controlq_setup.c',
drivers/common/idpf/idpf_common_device.c new file +8 -0
@@ -0,0 +1,8 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2022 Intel Corporation +*/ + +#include <rte_log.h> +#include <idpf_common_device.h> + +RTE_LOG_REGISTER_SUFFIX (idpf_common_logtype, common,NOTICE );
drivers/common/idpf/idpf_common_device.h +61 -0
71 lines not on this page · raw message
drivers/common/idpf/idpf_common_logs.h new file +23 -0
@@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2022 Intel Corporation +*/ + +#ifndef _IDPF_COMMON_LOGS_H_ +#define _IDPF_COMMON_LOGS_H_ + +#include <rte_log.h> + +extern int idpf_common_logtype; + +#define DRV_LOG_RAW (level, ...) \ + rte_log(RTE_LOG_ ## level, \ + idpf_common_logtype, \ + RTE_FMT("%s(): " \ + RTE_FMT_HEAD(__VA_ARGS__,) "\n", \ + __func__, \ + RTE_FMT_TAIL(__VA_ARGS__,))) + +#define DRV_LOG(level, fmt, args...) \ + DRV_LOG_RAW(level, fmt "\n", ## args) + +#endif /* _IDPF_COMMON_LOGS_H_ */
drivers/common/idpf/idpf_common_virtchnl.c new file +815 -0
815 lines not on this page · raw message
drivers/common/idpf/idpf_common_virtchnl.h new file +48 -0
48 lines not on this page · raw message
drivers/common/idpf/meson.build +5 -0
@@ -1,4 +1,9 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2022 Intel Corporation +sources = files( + 'idpf_common_device.c', + 'idpf_common_virtchnl.c', +) + subdir('base')
drivers/common/idpf/version.map +16 -0
@@ -7,6 +7,22 @@ INTERNAL { idpf_ctlq_recv; idpf_ctlq_send; idpf_ctlq_post_rx_buffs; + idpf_vc_check_api_version; + idpf_vc_get_caps; + idpf_vc_create_vport; + idpf_vc_destroy_vport; + idpf_vc_set_rss_key; + idpf_vc_set_rss_lut; + idpf_vc_set_rss_hash; + idpf_switch_queue; + idpf_vc_ena_dis_queues; + idpf_vc_ena_dis_vport; + idpf_vc_config_irq_map_unmap; + idpf_vc_alloc_vectors; + idpf_vc_dealloc_vectors; + idpf_vc_query_ptype_info; + idpf_read_one_msg; + idpf_execute_vc_cmd; local: *; };
drivers/net/idpf/idpf_ethdev.c +1 -8
@@ -942,13 +942,6 @@ idpf_adapter_init(struct rte_pci_device *pci_dev, struct idpf_adapter_ext *adapt goto err_api; } - adapter->max_rxq_per_msg = (IDPF_DFLT_MBX_BUF_SIZE - -sizeof (struct virtchnl2_config_rx_queues )) / -sizeof (struct virtchnl2_rxq_info ); - adapter->max_txq_per_msg = (IDPF_DFLT_MBX_BUF_SIZE - -sizeof (struct virtchnl2_config_tx_queues )) / -sizeof (struct virtchnl2_txq_info ); - adapter->cur_vports =0 ; adapter->cur_vport_nb =0 ;
@@ -1075,7 +1068,7 @@ static const struct rte_pci_id pci_id_idpf_map[] = { { .vendor_id = 0, /* sentinel */ }, }; -struct idpf_adapter_ext * +static struct idpf_adapter_ext *idpf_find_adapter_ext (struct rte_pci_device *pci_dev) {struct idpf_adapter_ext *adapter;
drivers/net/idpf/idpf_ethdev.h +1 -84
121 lines not on this page · raw message
drivers/net/idpf/idpf_vchnl.c +2 -813
842 lines not on this page · raw message
Signature · 1 line
2.26.2
PATCH v2 4/15 common/idpf: introduce adapter init and deinit
In reply to [email protected]From: Beilei Xing <[email protected]>
Introduce base init and deinit in common module.
--- drivers/common/idpf/idpf_common_device.c | 153 ++++++++++++++++++++ drivers/common/idpf/idpf_common_device.h | 6 + drivers/common/idpf/idpf_common_virtchnl.h | 2 - drivers/common/idpf/version.map | 4 +- drivers/net/idpf/idpf_ethdev.c | 158 +++------------------ drivers/net/idpf/idpf_ethdev.h | 2 - 6 files changed, 178 insertions(+), 147 deletions(-)
drivers/common/idpf/idpf_common_device.c +153 -0
@@ -4,5 +4,158 @@#include <rte_log.h> #include <idpf_common_device.h> +#include <idpf_common_virtchnl.h> + +static void +idpf_reset_pf (struct idpf_hw *hw) +{ +uint32_t reg; + + reg =IDPF_READ_REG (hw,PFGEN_CTRL ); +IDPF_WRITE_REG (hw,PFGEN_CTRL , (reg |PFGEN_CTRL_PFSWR )); +} + +#define IDPF_RESET_WAIT_CNT 100 +static int +idpf_check_pf_reset_done (struct idpf_hw *hw) +{ +uint32_t reg; +int i; + +for (i =0 ; i <IDPF_RESET_WAIT_CNT ; i++) { + reg =IDPF_READ_REG (hw,PFGEN_RSTAT ); +if (reg !=0xFFFFFFFF && (reg &PFGEN_RSTAT_PFR_STATE_M )) +return 0 ; +rte_delay_ms (1000 ); + } + +DRV_LOG (ERR ,"IDPF reset timeout" ); +return -EBUSY ; +} + +#define CTLQ_NUM 2 +static int +idpf_init_mbx (struct idpf_hw *hw) +{ +struct idpf_ctlq_create_info ctlq_info[CTLQ_NUM ] = { + { + .type =IDPF_CTLQ_TYPE_MAILBOX_TX , + .id =IDPF_CTLQ_ID , + .len =IDPF_CTLQ_LEN , + .buf_size =IDPF_DFLT_MBX_BUF_SIZE , + .reg = { + .head =PF_FW_ATQH , + .tail =PF_FW_ATQT , + .len =PF_FW_ATQLEN , + .bah =PF_FW_ATQBAH , + .bal =PF_FW_ATQBAL , + .len_mask =PF_FW_ATQLEN_ATQLEN_M , + .len_ena_mask =PF_FW_ATQLEN_ATQENABLE_M , + .head_mask =PF_FW_ATQH_ATQH_M , + } + }, + { + .type =IDPF_CTLQ_TYPE_MAILBOX_RX , + .id =IDPF_CTLQ_ID , + .len =IDPF_CTLQ_LEN , + .buf_size =IDPF_DFLT_MBX_BUF_SIZE , + .reg = { + .head =PF_FW_ARQH , + .tail =PF_FW_ARQT , + .len =PF_FW_ARQLEN , + .bah =PF_FW_ARQBAH , + .bal =PF_FW_ARQBAL , + .len_mask =PF_FW_ARQLEN_ARQLEN_M , + .len_ena_mask =PF_FW_ARQLEN_ARQENABLE_M , + .head_mask =PF_FW_ARQH_ARQH_M , + } + } + }; +struct idpf_ctlq_info *ctlq; +int ret; + + ret =idpf_ctlq_init (hw,CTLQ_NUM , ctlq_info); +if (ret !=0 ) +return ret; + +LIST_FOR_EACH_ENTRY_SAFE (ctlq,NULL , &hw->cq_list_head, + struct idpf_ctlq_info, cq_list) { +if (ctlq->q_id ==IDPF_CTLQ_ID && + ctlq->cq_type ==IDPF_CTLQ_TYPE_MAILBOX_TX ) + hw->asq = ctlq; +if (ctlq->q_id ==IDPF_CTLQ_ID && + ctlq->cq_type ==IDPF_CTLQ_TYPE_MAILBOX_RX ) + hw->arq = ctlq; + } + +if (hw->asq ==NULL || hw->arq ==NULL ) { +idpf_ctlq_deinit (hw); + ret = -ENOENT ; + } + +return ret; +} + +int +idpf_adapter_init (struct idpf_adapter *adapter) +{ +struct idpf_hw *hw = &adapter->hw; +int ret; + +idpf_reset_pf (hw); + ret =idpf_check_pf_reset_done (hw); +if (ret !=0 ) { +DRV_LOG (ERR ,"IDPF is still resetting" ); + goto err_check_reset; + } + + ret =idpf_init_mbx (hw); +if (ret !=0 ) { +DRV_LOG (ERR ,"Failed to init mailbox" ); + goto err_check_reset; + } + + adapter->mbx_resp =rte_zmalloc ("idpf_adapter_mbx_resp" , +IDPF_DFLT_MBX_BUF_SIZE ,0 ); +if (adapter->mbx_resp ==NULL ) { +DRV_LOG (ERR ,"Failed to allocate idpf_adapter_mbx_resp memory" ); + ret = -ENOMEM ; + goto err_mbx_resp; + } + + ret =idpf_vc_check_api_version (adapter); +if (ret !=0 ) { +DRV_LOG (ERR ,"Failed to check api version" ); + goto err_check_api; + } + + ret =idpf_vc_get_caps (adapter); +if (ret !=0 ) { +DRV_LOG (ERR ,"Failed to get capabilities" ); + goto err_check_api; + } + +return 0 ; + +err_check_api: +rte_free (adapter->mbx_resp); + adapter->mbx_resp =NULL ; +err_mbx_resp: +idpf_ctlq_deinit (hw); +err_check_reset: +return ret; +} + +int +idpf_adapter_deinit (struct idpf_adapter *adapter) +{ +struct idpf_hw *hw = &adapter->hw; + +idpf_ctlq_deinit (hw); +rte_free (adapter->mbx_resp); + adapter->mbx_resp =NULL ; + +return 0 ; +}RTE_LOG_REGISTER_SUFFIX (idpf_common_logtype, common,NOTICE );
drivers/common/idpf/idpf_common_device.h +6 -0
@@ -9,6 +9,7 @@#include <base/virtchnl2.h> #include <idpf_common_logs.h> +#define IDPF_CTLQ_ID -1#define IDPF_CTLQ_LEN 64#define IDPF_DFLT_MBX_BUF_SIZE 4096
@@ -137,4 +138,9 @@ atomic_set_cmd(struct idpf_adapter *adapter, uint32_t ops)return !ret; } +__rte_internal +int idpf_adapter_init(struct idpf_adapter *adapter); +__rte_internal +int idpf_adapter_deinit(struct idpf_adapter *adapter); +#endif /* _IDPF_COMMON_DEVICE_H_ */
drivers/common/idpf/idpf_common_virtchnl.h +0 -2
@@ -7,9 +7,7 @@#include <idpf_common_device.h> -__rte_internal int idpf_vc_check_api_version (struct idpf_adapter *adapter); -__rte_internal int idpf_vc_get_caps (struct idpf_adapter *adapter); __rte_internal int idpf_vc_create_vport(struct idpf_vport *vport,
drivers/common/idpf/version.map +2 -2
@@ -7,8 +7,6 @@ INTERNAL { idpf_ctlq_recv; idpf_ctlq_send; idpf_ctlq_post_rx_buffs; - idpf_vc_check_api_version; - idpf_vc_get_caps; idpf_vc_create_vport; idpf_vc_destroy_vport; idpf_vc_set_rss_key;
@@ -23,6 +21,8 @@ INTERNAL { idpf_vc_query_ptype_info; idpf_read_one_msg; idpf_execute_vc_cmd; + idpf_adapter_init; + idpf_adapter_deinit; local: *; };
drivers/net/idpf/idpf_ethdev.c +17 -141
219 lines not on this page · raw message
drivers/net/idpf/idpf_ethdev.h +0 -2
@@ -31,8 +31,6 @@#define IDPF_RXQ_PER_GRP 1#define IDPF_RX_BUFQ_PER_GRP 2 -#define IDPF_CTLQ_ID -1 -#define IDPF_DFLT_Q_VEC_NUM 1#define IDPF_DFLT_INTERVAL 16
Signature · 1 line
2.26.2
PATCH v2 5/15 common/idpf: add vport init/deinit
In reply to [email protected]From: Beilei Xing <[email protected]>
Add vport init/deinit in common module.
--- drivers/common/idpf/idpf_common_device.c | 128 +++++++++++++++++++ drivers/common/idpf/idpf_common_device.h | 8 ++ drivers/common/idpf/idpf_common_virtchnl.c | 16 +-- drivers/common/idpf/idpf_common_virtchnl.h | 2 - drivers/common/idpf/version.map | 4 +- drivers/net/idpf/idpf_ethdev.c | 138 ++------------------- 6 files changed, 156 insertions(+), 140 deletions(-)
drivers/common/idpf/idpf_common_device.c +128 -0
@@ -158,4 +158,132 @@ idpf_adapter_deinit(struct idpf_adapter *adapter)return 0 ; } +int +idpf_vport_init (struct idpf_vport *vport, +struct virtchnl2_create_vport *create_vport_info, +void *dev_data) +{ +struct virtchnl2_create_vport *vport_info; +int i, type, ret; + + vport->vport_info =rte_zmalloc (NULL ,IDPF_DFLT_MBX_BUF_SIZE ,0 ); +if (vport->vport_info ==NULL ) { +DRV_LOG (ERR ,"Failed to allocate vport_info" ); + ret = -ENOMEM ; + goto err_vport_info; + } + + ret =idpf_vc_create_vport (vport, create_vport_info); +if (ret !=0 ) { +DRV_LOG (ERR ,"Failed to create vport." ); + goto err_create_vport; + } + + vport_info = vport->vport_info; + vport->vport_id = vport_info->vport_id; + vport->txq_model = vport_info->txq_model; + vport->rxq_model = vport_info->rxq_model; + vport->num_tx_q = vport_info->num_tx_q; + vport->num_tx_complq = vport_info->num_tx_complq; + vport->num_rx_q = vport_info->num_rx_q; + vport->num_rx_bufq = vport_info->num_rx_bufq; + vport->max_mtu = vport_info->max_mtu; +rte_memcpy (vport->default_mac_addr, + vport_info->default_mac_addr,ETH_ALEN ); + vport->rss_algorithm = vport_info->rss_algorithm; + vport->rss_key_size =RTE_MIN (IDPF_RSS_KEY_LEN , + vport_info->rss_key_size); + vport->rss_lut_size = vport_info->rss_lut_size; + +for (i =0 ; i < vport_info->chunks.num_chunks; i++) { + type = vport_info->chunks.chunks[i].type; +switch (type) { +case VIRTCHNL2_QUEUE_TYPE_TX : + vport->chunks_info.tx_start_qid = + vport_info->chunks.chunks[i].start_queue_id; + vport->chunks_info.tx_qtail_start = + vport_info->chunks.chunks[i].qtail_reg_start; + vport->chunks_info.tx_qtail_spacing = + vport_info->chunks.chunks[i].qtail_reg_spacing; +break ; +case VIRTCHNL2_QUEUE_TYPE_RX : + vport->chunks_info.rx_start_qid = + vport_info->chunks.chunks[i].start_queue_id; + vport->chunks_info.rx_qtail_start = + vport_info->chunks.chunks[i].qtail_reg_start; + vport->chunks_info.rx_qtail_spacing = + vport_info->chunks.chunks[i].qtail_reg_spacing; +break ; +case VIRTCHNL2_QUEUE_TYPE_TX_COMPLETION : + vport->chunks_info.tx_compl_start_qid = + vport_info->chunks.chunks[i].start_queue_id; + vport->chunks_info.tx_compl_qtail_start = + vport_info->chunks.chunks[i].qtail_reg_start; + vport->chunks_info.tx_compl_qtail_spacing = + vport_info->chunks.chunks[i].qtail_reg_spacing; +break ; +case VIRTCHNL2_QUEUE_TYPE_RX_BUFFER : + vport->chunks_info.rx_buf_start_qid = + vport_info->chunks.chunks[i].start_queue_id; + vport->chunks_info.rx_buf_qtail_start = + vport_info->chunks.chunks[i].qtail_reg_start; + vport->chunks_info.rx_buf_qtail_spacing = + vport_info->chunks.chunks[i].qtail_reg_spacing; +break ; +default : +DRV_LOG (ERR ,"Unsupported queue type" ); +break ; + } + } + + vport->dev_data = dev_data; + + vport->rss_key =rte_zmalloc ("rss_key" , + vport->rss_key_size,0 ); +if (vport->rss_key ==NULL ) { +DRV_LOG (ERR ,"Failed to allocate RSS key" ); + ret = -ENOMEM ; + goto err_rss_key; + } + + vport->rss_lut =rte_zmalloc ("rss_lut" , +sizeof (uint32_t ) * vport->rss_lut_size,0 ); +if (vport->rss_lut ==NULL ) { +DRV_LOG (ERR ,"Failed to allocate RSS lut" ); + ret = -ENOMEM ; + goto err_rss_lut; + } + +return 0 ; + +err_rss_lut: + vport->dev_data =NULL ; +rte_free (vport->rss_key); + vport->rss_key =NULL ; +err_rss_key: +idpf_vc_destroy_vport (vport); +err_create_vport: +rte_free (vport->vport_info); + vport->vport_info =NULL ; +err_vport_info: +return ret; +} +int +idpf_vport_deinit (struct idpf_vport *vport) +{ +rte_free (vport->rss_lut); + vport->rss_lut =NULL ; + +rte_free (vport->rss_key); + vport->rss_key =NULL ; + + vport->dev_data =NULL ; + +rte_free (vport->vport_info); + vport->vport_info =NULL ; + +idpf_vc_destroy_vport (vport); + +return 0 ; +}RTE_LOG_REGISTER_SUFFIX (idpf_common_logtype, common,NOTICE );
drivers/common/idpf/idpf_common_device.h +8 -0
@@ -9,6 +9,8 @@#include <base/virtchnl2.h> #include <idpf_common_logs.h> +#define IDPF_RSS_KEY_LEN 52 +#define IDPF_CTLQ_ID -1#define IDPF_CTLQ_LEN 64#define IDPF_DFLT_MBX_BUF_SIZE 4096
@@ -142,5 +144,11 @@ __rte_internalint idpf_adapter_init (struct idpf_adapter *adapter);__rte_internal int idpf_adapter_deinit(struct idpf_adapter *adapter); +__rte_internal +int idpf_vport_init(struct idpf_vport *vport, +struct virtchnl2_create_vport *vport_req_info, +void *dev_data); +__rte_internal +int idpf_vport_deinit(struct idpf_vport *vport);#endif /* _IDPF_COMMON_DEVICE_H_ */
drivers/common/idpf/idpf_common_virtchnl.c +8 -8
@@ -355,7 +355,7 @@ idpf_vc_get_caps(struct idpf_adapter *adapter)int idpf_vc_create_vport (struct idpf_vport *vport, -struct virtchnl2_create_vport *vport_req_info) +struct virtchnl2_create_vport *create_vport_info) {struct idpf_adapter *adapter = vport->adapter;struct virtchnl2_create_vport vport_msg;
@@ -363,13 +363,13 @@ idpf_vc_create_vport(struct idpf_vport *vport,int err =-1 ;memset (&vport_msg,0 ,sizeof (struct virtchnl2_create_vport )); - vport_msg.vport_type = vport_req_info->vport_type; - vport_msg.txq_model = vport_req_info->txq_model; - vport_msg.rxq_model = vport_req_info->rxq_model; - vport_msg.num_tx_q = vport_req_info->num_tx_q; - vport_msg.num_tx_complq = vport_req_info->num_tx_complq; - vport_msg.num_rx_q = vport_req_info->num_rx_q; - vport_msg.num_rx_bufq = vport_req_info->num_rx_bufq; + vport_msg.vport_type = create_vport_info->vport_type; + vport_msg.txq_model = create_vport_info->txq_model; + vport_msg.rxq_model = create_vport_info->rxq_model; + vport_msg.num_tx_q = create_vport_info->num_tx_q; + vport_msg.num_tx_complq = create_vport_info->num_tx_complq; + vport_msg.num_rx_q = create_vport_info->num_rx_q; + vport_msg.num_rx_bufq = create_vport_info->num_rx_bufq;memset (&args,0 ,sizeof (args)); args.ops =VIRTCHNL2_OP_CREATE_VPORT ;
drivers/common/idpf/idpf_common_virtchnl.h +0 -2
@@ -9,10 +9,8 @@int idpf_vc_check_api_version (struct idpf_adapter *adapter);int idpf_vc_get_caps (struct idpf_adapter *adapter); -__rte_internal int idpf_vc_create_vport (struct idpf_vport *vport,struct virtchnl2_create_vport *vport_info); -__rte_internal int idpf_vc_destroy_vport (struct idpf_vport *vport);__rte_internal int idpf_vc_set_rss_key(struct idpf_vport *vport);
drivers/common/idpf/version.map +2 -2
@@ -7,8 +7,6 @@ INTERNAL { idpf_ctlq_recv; idpf_ctlq_send; idpf_ctlq_post_rx_buffs; - idpf_vc_create_vport; - idpf_vc_destroy_vport; idpf_vc_set_rss_key; idpf_vc_set_rss_lut; idpf_vc_set_rss_hash;
@@ -23,6 +21,8 @@ INTERNAL { idpf_execute_vc_cmd; idpf_adapter_init; idpf_adapter_deinit; + idpf_vport_init; + idpf_vport_deinit; local: *; };
drivers/net/idpf/idpf_ethdev.c +10 -128
209 lines not on this page · raw message
Signature · 1 line
2.26.2
RE: [PATCH v2 05/15] common/idpf: add vport init/deinit
Quoted 33 lines
-----Original Message-----
From: Xing, Beilei <[email protected]>
Sent: Friday, January 6, 2023 5:16 PM
To: Wu, Jingjing <[email protected]>
Cc: [email protected]; Zhang, Qi Z <[email protected]>; Xing, Beilei <[email protected]>; Wu, Wenjun1 <[email protected]>
Subject: [PATCH v2 05/15] common/idpf: add vport init/deinitFrom: Beilei Xing <[email protected]>
Add vport init/deinit in common module.
Signed-off-by Wenjun Wu <[email protected]>Signed-off-by Beilei Xing <[email protected]>--- drivers/common/idpf/idpf_common_device.c | 128 +++++++++++++++++++ drivers/common/idpf/idpf_common_device.h | 8 ++ drivers/common/idpf/idpf_common_virtchnl.c | 16 +-- drivers/common/idpf/idpf_common_virtchnl.h | 2 - drivers/common/idpf/version.map | 4 +- drivers/net/idpf/idpf_ethdev.c | 138 ++------------------- 6 files changed, 156 insertions(+), 140 deletions(-)drivers/common/idpf/idpf_common_device.c +0
-0@@ -158,4 +158,132 @@ idpf_adapter_deinit(struct idpf_adapter *adapter)return 0 ; }
drivers/common/idpf/idpf_common_device.c idpf_adapter_deinit(struct idpf_adapter *adapter) · line 169
Quoted 10 lines
drivers/common/idpf/idpf_common_device.c +9
-0+int +idpf_vport_init (struct idpf_vport *vport, +struct virtchnl2_create_vport *create_vport_info, +void *dev_data) +{ +struct virtchnl2_create_vport *vport_info; +int i, type, ret; + + vport->vport_info =rte_zmalloc (NULL ,IDPF_DFLT_MBX_BUF_SIZE ,0 );
Can we embed vport_info structure into the vport structure?
Seems its not necessary to malloc/free the vport_info which always associated with a vport structure?
RE: [PATCH v2 05/15] common/idpf: add vport init/deinit
Quoted 45 lines
-----Original Message-----
From: Zhang, Qi Z <[email protected]>
Sent: Sunday, January 8, 2023 8:11 PM
To: Xing, Beilei <[email protected]>; Wu, Jingjing <[email protected]>
Cc: [email protected]; Wu, Wenjun1 <[email protected]>
Subject: RE: [PATCH v2 05/15] common/idpf: add vport init/deinitQuoted 8 lines
-----Original Message-----
From: Xing, Beilei <[email protected]>
Sent: Friday, January 6, 2023 5:16 PM
To: Wu, Jingjing <[email protected]>
Cc: [email protected]; Zhang, Qi Z <[email protected]>; Xing, Beilei <[email protected]>; Wu, Wenjun1 <[email protected]>
Subject: [PATCH v2 05/15] common/idpf: add vport init/deinitQuoted 8 lines
From: Beilei Xing <[email protected]>
Add vport init/deinit in common module.
Signed-off-by Wenjun Wu <[email protected]>Signed-off-by Beilei Xing <[email protected]>--- drivers/common/idpf/idpf_common_device.c | 128+++++++++++++++++++
drivers/common/idpf/idpf_common_device.c idpf_adapter_deinit(struct idpf_adapter
Quoted 13 lines
drivers/common/idpf/idpf_common_device.h | 8 ++ drivers/common/idpf/idpf_common_virtchnl.c | 16 +-- drivers/common/idpf/idpf_common_virtchnl.h | 2 - drivers/common/idpf/version.map | 4 +- drivers/net/idpf/idpf_ethdev.c | 138 ++------------------- 6 files changed, 156 insertions(+), 140 deletions(-)drivers/common/idpf/idpf_common_device.c +0
-0@@ -158,4 +158,132 @@ idpf_adapter_deinit(struct idpf_adapter*adapter)
Quoted 3 lines
drivers/common/idpf/idpf_common_device.c +0
-0return 0 ; }
Quoted 14 lines
drivers/common/idpf/idpf_common_device.c idpf_adapter_deinit(struct idpf_adapter *adapter) · line 169
Quoted 9 lines
drivers/common/idpf/idpf_common_device.c +9
-0+int +idpf_vport_init (struct idpf_vport *vport, +struct virtchnl2_create_vport *create_vport_info, +void *dev_data) +{ +struct virtchnl2_create_vport *vport_info; +int i, type, ret; + + vport->vport_info =rte_zmalloc (NULL ,IDPF_DFLT_MBX_BUF_SIZE ,0 );Can we embed
vport_infostructure into the vport structure? Seems its not necessary to malloc/free thevport_infowhich always associated with a vport structure?
Make sense, will update in the next version.
PATCH v2 6/15 common/idpf: add config RSS
In reply to [email protected]From: Beilei Xing <[email protected]>
Move configure RSS to common module.
--- drivers/common/idpf/idpf_common_device.c | 25 +++++++++++++++++++++ drivers/common/idpf/idpf_common_device.h | 2 ++ drivers/common/idpf/idpf_common_virtchnl.h | 3 --- drivers/common/idpf/version.map | 4 +--- drivers/net/idpf/idpf_ethdev.c | 26 ---------------------- 5 files changed, 28 insertions(+), 32 deletions(-)
drivers/common/idpf/idpf_common_device.c +25 -0
@@ -286,4 +286,29 @@ idpf_vport_deinit(struct idpf_vport *vport)return 0 ; } +int +idpf_config_rss (struct idpf_vport *vport) +{ +int ret; + + ret =idpf_vc_set_rss_key (vport); +if (ret !=0 ) { +DRV_LOG (ERR ,"Failed to configure RSS key" ); +return ret; + } + + ret =idpf_vc_set_rss_lut (vport); +if (ret !=0 ) { +DRV_LOG (ERR ,"Failed to configure RSS lut" ); +return ret; + } + + ret =idpf_vc_set_rss_hash (vport); +if (ret !=0 ) { +DRV_LOG (ERR ,"Failed to configure RSS hash" ); +return ret; + } + +return ret; +}RTE_LOG_REGISTER_SUFFIX (idpf_common_logtype, common,NOTICE );
drivers/common/idpf/idpf_common_device.h +2 -0
@@ -150,5 +150,7 @@ int idpf_vport_init(struct idpf_vport *vport, void *dev_data);__rte_internal int idpf_vport_deinit(struct idpf_vport *vport); +__rte_internal +int idpf_config_rss(struct idpf_vport *vport);#endif /* _IDPF_COMMON_DEVICE_H_ */
drivers/common/idpf/idpf_common_virtchnl.h +0 -3
@@ -12,11 +12,8 @@ int idpf_vc_get_caps(struct idpf_adapter *adapter);int idpf_vc_create_vport (struct idpf_vport *vport,struct virtchnl2_create_vport *vport_info);int idpf_vc_destroy_vport (struct idpf_vport *vport); -__rte_internal int idpf_vc_set_rss_key (struct idpf_vport *vport); -__rte_internal int idpf_vc_set_rss_lut (struct idpf_vport *vport); -__rte_internal int idpf_vc_set_rss_hash (struct idpf_vport *vport); __rte_internal int idpf_switch_queue(struct idpf_vport *vport, uint16_t qid,
drivers/common/idpf/version.map +1 -3
@@ -7,9 +7,6 @@ INTERNAL { idpf_ctlq_recv; idpf_ctlq_send; idpf_ctlq_post_rx_buffs; - idpf_vc_set_rss_key; - idpf_vc_set_rss_lut; - idpf_vc_set_rss_hash; idpf_switch_queue; idpf_vc_ena_dis_queues; idpf_vc_ena_dis_vport;
@@ -23,6 +20,7 @@ INTERNAL { idpf_adapter_deinit; idpf_vport_init; idpf_vport_deinit; + idpf_config_rss; local: *; };
drivers/net/idpf/idpf_ethdev.c +0 -26
@@ -178,32 +178,6 @@ idpf_init_vport_req_info(struct rte_eth_dev *dev,return 0 ; } -static int -idpf_config_rss (struct idpf_vport *vport) -{ -int ret; - - ret =idpf_vc_set_rss_key (vport); -if (ret !=0 ) { -PMD_INIT_LOG (ERR ,"Failed to configure RSS key" ); -return ret; - } - - ret =idpf_vc_set_rss_lut (vport); -if (ret !=0 ) { -PMD_INIT_LOG (ERR ,"Failed to configure RSS lut" ); -return ret; - } - - ret =idpf_vc_set_rss_hash (vport); -if (ret !=0 ) { -PMD_INIT_LOG (ERR ,"Failed to configure RSS hash" ); -return ret; - } - -return ret; -} -static int idpf_init_rss (struct idpf_vport *vport) {
Signature · 1 line
2.26.2
PATCH v2 7/15 common/idpf: add irq map/unmap
In reply to [email protected]From: Beilei Xing <[email protected]>
Add irq map/unmap functions in common module.
--- drivers/common/idpf/idpf_common_device.c | 99 ++++++++++++++++++++ drivers/common/idpf/idpf_common_device.h | 6 ++ drivers/common/idpf/idpf_common_virtchnl.c | 8 -- drivers/common/idpf/idpf_common_virtchnl.h | 5 +- drivers/common/idpf/version.map | 3 +- drivers/net/idpf/idpf_ethdev.c | 102 +++------------------ drivers/net/idpf/idpf_ethdev.h | 1 - 7 files changed, 121 insertions(+), 103 deletions(-)
drivers/common/idpf/idpf_common_device.c +99 -0
@@ -254,8 +254,21 @@ idpf_vport_init(struct idpf_vport *vport, goto err_rss_lut; } +/* recv_vectors is used for VIRTCHNL2_OP_ALLOC_VECTORS response, +* reserve maximum size for it now, may need optimization in future. +*/ + vport->recv_vectors =rte_zmalloc ("recv_vectors" ,IDPF_DFLT_MBX_BUF_SIZE ,0 ); +if (vport->recv_vectors ==NULL ) { +DRV_LOG (ERR ,"Failed to allocate ecv_vectors" ); + ret = -ENOMEM ; + goto err_recv_vec; + } +return 0 ; +err_recv_vec: +rte_free (vport->rss_lut); + vport->rss_lut =NULL ; err_rss_lut: vport->dev_data =NULL ;rte_free (vport->rss_key);
@@ -271,6 +284,8 @@ idpf_vport_init(struct idpf_vport *vport,int idpf_vport_deinit (struct idpf_vport *vport) { +rte_free (vport->recv_vectors); + vport->recv_vectors =NULL ;rte_free (vport->rss_lut); vport->rss_lut =NULL ;
@@ -311,4 +326,88 @@ idpf_config_rss(struct idpf_vport *vport)return ret; } + +int +idpf_config_irq_map (struct idpf_vport *vport,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; + + 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); + 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 = vport->chunks_info.rx_start_qid + i; + qv_map[i].vector_id = + vport->recv_vectors->vchunks.vchunks->start_vector_id; + } + vport->qv_map = qv_map; + +if (idpf_vc_config_irq_map_unmap (vport, nb_rx_queues, true) !=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 -1 ; +} + +int +idpf_config_irq_unmap (struct idpf_vport *vport,uint16_t nb_rx_queues) +{ +idpf_vc_config_irq_map_unmap (vport, nb_rx_queues, false); + +rte_free (vport->qv_map); + vport->qv_map =NULL ; + +return 0 ; +} +RTE_LOG_REGISTER_SUFFIX (idpf_common_logtype, common,NOTICE );
drivers/common/idpf/idpf_common_device.h +6 -0
@@ -17,6 +17,8 @@#define IDPF_MAX_PKT_TYPE 1024 +#define IDPF_DFLT_INTERVAL 16 +struct idpf_adapter {struct idpf_hw hw;struct virtchnl2_version_info virtchnl_version;
@@ -152,5 +154,9 @@ __rte_internalint idpf_vport_deinit (struct idpf_vport *vport);__rte_internal int idpf_config_rss(struct idpf_vport *vport); +__rte_internal +int idpf_config_irq_map(struct idpf_vport *vport, uint16_t nb_rx_queues); +__rte_internal +int idpf_config_irq_unmap(struct idpf_vport *vport, uint16_t nb_rx_queues);#endif /* _IDPF_COMMON_DEVICE_H_ */
drivers/common/idpf/idpf_common_virtchnl.c +0 -8
@@ -573,14 +573,6 @@ idpf_vc_alloc_vectors(struct idpf_vport *vport, uint16_t num_vectors)if (err !=0 )DRV_LOG (ERR ,"Failed to execute command VIRTCHNL2_OP_ALLOC_VECTORS" ); -if (vport->recv_vectors ==NULL ) { - vport->recv_vectors =rte_zmalloc ("recv_vectors" , len,0 ); -if (vport->recv_vectors ==NULL ) { -rte_free (alloc_vec); -return -ENOMEM ; - } - } -rte_memcpy (vport->recv_vectors, args.out_buffer, len);rte_free (alloc_vec);return err;
drivers/common/idpf/idpf_common_virtchnl.h +2 -3
@@ -15,6 +15,8 @@ int idpf_vc_destroy_vport(struct idpf_vport *vport);int idpf_vc_set_rss_key (struct idpf_vport *vport);int idpf_vc_set_rss_lut (struct idpf_vport *vport);int idpf_vc_set_rss_hash (struct idpf_vport *vport); +int idpf_vc_config_irq_map_unmap (struct idpf_vport *vport, +uint16_t nb_rxq,bool map);__rte_internal int idpf_switch_queue(struct idpf_vport *vport, uint16_t qid,bool rx,bool on);
@@ -23,9 +25,6 @@ int idpf_vc_ena_dis_queues(struct idpf_vport *vport, bool enable);__rte_internal int idpf_vc_ena_dis_vport(struct idpf_vport *vport, bool enable);__rte_internal -int idpf_vc_config_irq_map_unmap(struct idpf_vport *vport, -uint16_t nb_rxq,bool map); -__rte_internal int idpf_vc_alloc_vectors(struct idpf_vport *vport, uint16_t num_vectors);__rte_internal int idpf_vc_dealloc_vectors(struct idpf_vport *vport);
drivers/common/idpf/version.map +2 -1
@@ -10,7 +10,6 @@ INTERNAL { idpf_switch_queue; idpf_vc_ena_dis_queues; idpf_vc_ena_dis_vport; - idpf_vc_config_irq_map_unmap; idpf_vc_alloc_vectors; idpf_vc_dealloc_vectors; idpf_vc_query_ptype_info;
@@ -21,6 +20,8 @@ INTERNAL { idpf_vport_init; idpf_vport_deinit; idpf_config_rss; + idpf_config_irq_map; + idpf_config_irq_unmap; local: *; };
drivers/net/idpf/idpf_ethdev.c +12 -90
149 lines not on this page · raw message
drivers/net/idpf/idpf_ethdev.h +0 -1
@@ -32,7 +32,6 @@#define IDPF_RX_BUFQ_PER_GRP 2#define IDPF_DFLT_Q_VEC_NUM 1 -#define IDPF_DFLT_INTERVAL 16#define IDPF_MIN_BUF_SIZE 1024#define IDPF_MAX_FRAME_SIZE 9728
Signature · 1 line
2.26.2
RE: [PATCH v2 07/15] common/idpf: add irq map/unmap
Quoted 10 lines
-----Original Message-----
From: Xing, Beilei <[email protected]>
Sent: Friday, January 6, 2023 5:16 PM
To: Wu, Jingjing <[email protected]>
Cc: [email protected]; Zhang, Qi Z <[email protected]>; Xing, Beilei <[email protected]>
Subject: [PATCH v2 07/15] common/idpf: add irq map/unmap
Quoted 3 lines
From: Beilei Xing <[email protected]>
Add irq map/unmap functions in common module.
Seems patch not just adding new functions, but also move something from net/idpf to common/idpf. Better to add more description, and same to other patch in this patch set.
Quoted 19 lines
Signed-off-by Jingjing Wu <[email protected]>Signed-off-by Beilei Xing <[email protected]>--- drivers/common/idpf/idpf_common_device.c | 99 ++++++++++++++++++++ drivers/common/idpf/idpf_common_device.h | 6 ++ drivers/common/idpf/idpf_common_virtchnl.c | 8 -- drivers/common/idpf/idpf_common_virtchnl.h | 5 +- drivers/common/idpf/version.map | 3 +- drivers/net/idpf/idpf_ethdev.c | 102 +++------------------ drivers/net/idpf/idpf_ethdev.h | 1 - 7 files changed, 121 insertions(+), 103 deletions(-)drivers/common/idpf/idpf_common_device.c +0
-0
...
PATCH v2 8/15 common/idpf: move ptype table to adapter structure
In reply to [email protected]From: Beilei Xing <[email protected]>
Move ptype_tbl field to idpf_adapter structure.
Move get_pkt_type to common module.
--- drivers/common/idpf/idpf_common_device.c | 216 +++++++++++++++++++++ drivers/common/idpf/idpf_common_device.h | 7 + drivers/common/idpf/idpf_common_virtchnl.h | 8 +- drivers/common/idpf/meson.build | 2 + drivers/common/idpf/version.map | 2 - drivers/net/idpf/idpf_ethdev.c | 6 - drivers/net/idpf/idpf_ethdev.h | 4 - drivers/net/idpf/idpf_rxtx.c | 4 +- drivers/net/idpf/idpf_rxtx.h | 4 - drivers/net/idpf/idpf_rxtx_vec_avx512.c | 3 +- drivers/net/idpf/idpf_vchnl.c | 213 -------------------- 11 files changed, 231 insertions(+), 238 deletions(-)
drivers/common/idpf/idpf_common_device.c +216 -0
@@ -96,6 +96,216 @@ idpf_init_mbx(struct idpf_hw *hw)return ret; } +static int +idpf_get_pkt_type (struct idpf_adapter *adapter) +{ +struct virtchnl2_get_ptype_info *ptype_info; +uint16_t ptype_offset, i, j; +uint16_t ptype_recvd =0 ; +int ret; + + ret =idpf_vc_query_ptype_info (adapter); +if (ret !=0 ) { +DRV_LOG (ERR ,"Fail to query packet type information" ); +return ret; + } + + ptype_info =rte_zmalloc ("ptype_info" ,IDPF_DFLT_MBX_BUF_SIZE ,0 ); +if (ptype_info ==NULL ) +return -ENOMEM ; + +while (ptype_recvd <IDPF_MAX_PKT_TYPE ) { + ret =idpf_read_one_msg (adapter,VIRTCHNL2_OP_GET_PTYPE_INFO , +IDPF_DFLT_MBX_BUF_SIZE , (uint8_t *)ptype_info); +if (ret !=0 ) { +DRV_LOG (ERR ,"Fail to get packet type information" ); + goto free_ptype_info; + } + + ptype_recvd += ptype_info->num_ptypes; + ptype_offset =sizeof (struct virtchnl2_get_ptype_info ) - +sizeof (struct virtchnl2_ptype ); + +for (i =0 ; i <rte_cpu_to_le_16 (ptype_info->num_ptypes); i++) { +bool is_inner = false, is_ip = false; +struct virtchnl2_ptype *ptype; +uint32_t proto_hdr =0 ; + + ptype = (struct virtchnl2_ptype *) + ((uint8_t *)ptype_info + ptype_offset); + ptype_offset +=IDPF_GET_PTYPE_SIZE (ptype); +if (ptype_offset >IDPF_DFLT_MBX_BUF_SIZE ) { + ret = -EINVAL ; + goto free_ptype_info; + } + +if (rte_cpu_to_le_16 (ptype->ptype_id_10) ==0xFFFF ) + goto free_ptype_info; + +for (j =0 ; j < ptype->proto_id_count; j++) { +switch (rte_cpu_to_le_16 (ptype->proto_id[j])) { +case VIRTCHNL2_PROTO_HDR_GRE : +case VIRTCHNL2_PROTO_HDR_VXLAN : + proto_hdr &= ~RTE_PTYPE_L4_MASK ; + proto_hdr |=RTE_PTYPE_TUNNEL_GRENAT ; + is_inner = true; +break ; +case VIRTCHNL2_PROTO_HDR_MAC : +if (is_inner) { + proto_hdr &= ~RTE_PTYPE_INNER_L2_MASK ; + proto_hdr |=RTE_PTYPE_INNER_L2_ETHER ; + }else { + proto_hdr &= ~RTE_PTYPE_L2_MASK ; + proto_hdr |=RTE_PTYPE_L2_ETHER ; + } +break ; +case VIRTCHNL2_PROTO_HDR_VLAN : +if (is_inner) { + proto_hdr &= ~RTE_PTYPE_INNER_L2_MASK ; + proto_hdr |=RTE_PTYPE_INNER_L2_ETHER_VLAN ; + } +break ; +case VIRTCHNL2_PROTO_HDR_PTP : + proto_hdr &= ~RTE_PTYPE_L2_MASK ; + proto_hdr |=RTE_PTYPE_L2_ETHER_TIMESYNC ; +break ; +case VIRTCHNL2_PROTO_HDR_LLDP : + proto_hdr &= ~RTE_PTYPE_L2_MASK ; + proto_hdr |=RTE_PTYPE_L2_ETHER_LLDP ; +break ; +case VIRTCHNL2_PROTO_HDR_ARP : + proto_hdr &= ~RTE_PTYPE_L2_MASK ; + proto_hdr |=RTE_PTYPE_L2_ETHER_ARP ; +break ; +case VIRTCHNL2_PROTO_HDR_PPPOE : + proto_hdr &= ~RTE_PTYPE_L2_MASK ; + proto_hdr |=RTE_PTYPE_L2_ETHER_PPPOE ; +break ; +case VIRTCHNL2_PROTO_HDR_IPV4 : +if (!is_ip) { + proto_hdr |=RTE_PTYPE_L3_IPV4_EXT_UNKNOWN ; + is_ip = true; + }else { + proto_hdr |=RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | +RTE_PTYPE_TUNNEL_IP ; + is_inner = true; + } +break ; +case VIRTCHNL2_PROTO_HDR_IPV6 : +if (!is_ip) { + proto_hdr |=RTE_PTYPE_L3_IPV6_EXT_UNKNOWN ; + is_ip = true; + }else { + proto_hdr |=RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | +RTE_PTYPE_TUNNEL_IP ; + is_inner = true; + } +break ; +case VIRTCHNL2_PROTO_HDR_IPV4_FRAG : +case VIRTCHNL2_PROTO_HDR_IPV6_FRAG : +if (is_inner) + proto_hdr |=RTE_PTYPE_INNER_L4_FRAG ; +else + proto_hdr |=RTE_PTYPE_L4_FRAG ; +break ; +case VIRTCHNL2_PROTO_HDR_UDP : +if (is_inner) + proto_hdr |=RTE_PTYPE_INNER_L4_UDP ; +else + proto_hdr |=RTE_PTYPE_L4_UDP ; +break ; +case VIRTCHNL2_PROTO_HDR_TCP : +if (is_inner) + proto_hdr |=RTE_PTYPE_INNER_L4_TCP ; +else + proto_hdr |=RTE_PTYPE_L4_TCP ; +break ; +case VIRTCHNL2_PROTO_HDR_SCTP : +if (is_inner) + proto_hdr |=RTE_PTYPE_INNER_L4_SCTP ; +else + proto_hdr |=RTE_PTYPE_L4_SCTP ; +break ; +case VIRTCHNL2_PROTO_HDR_ICMP : +if (is_inner) + proto_hdr |=RTE_PTYPE_INNER_L4_ICMP ; +else + proto_hdr |=RTE_PTYPE_L4_ICMP ; +break ; +case VIRTCHNL2_PROTO_HDR_ICMPV6 : +if (is_inner) + proto_hdr |=RTE_PTYPE_INNER_L4_ICMP ; +else + proto_hdr |=RTE_PTYPE_L4_ICMP ; +break ; +case VIRTCHNL2_PROTO_HDR_L2TPV2 : +case VIRTCHNL2_PROTO_HDR_L2TPV2_CONTROL : +case VIRTCHNL2_PROTO_HDR_L2TPV3 : + is_inner = true; + proto_hdr |=RTE_PTYPE_TUNNEL_L2TP ; +break ; +case VIRTCHNL2_PROTO_HDR_NVGRE : + is_inner = true; + proto_hdr |=RTE_PTYPE_TUNNEL_NVGRE ; +break ; +case VIRTCHNL2_PROTO_HDR_GTPC_TEID : + is_inner = true; + proto_hdr |=RTE_PTYPE_TUNNEL_GTPC ; +break ; +case VIRTCHNL2_PROTO_HDR_GTPU : +case VIRTCHNL2_PROTO_HDR_GTPU_UL : +case VIRTCHNL2_PROTO_HDR_GTPU_DL : + is_inner = true; + proto_hdr |=RTE_PTYPE_TUNNEL_GTPU ; +break ; +case VIRTCHNL2_PROTO_HDR_PAY : +case VIRTCHNL2_PROTO_HDR_IPV6_EH : +case VIRTCHNL2_PROTO_HDR_PRE_MAC : +case VIRTCHNL2_PROTO_HDR_POST_MAC : +case VIRTCHNL2_PROTO_HDR_ETHERTYPE : +case VIRTCHNL2_PROTO_HDR_SVLAN : +case VIRTCHNL2_PROTO_HDR_CVLAN : +case VIRTCHNL2_PROTO_HDR_MPLS : +case VIRTCHNL2_PROTO_HDR_MMPLS : +case VIRTCHNL2_PROTO_HDR_CTRL : +case VIRTCHNL2_PROTO_HDR_ECP : +case VIRTCHNL2_PROTO_HDR_EAPOL : +case VIRTCHNL2_PROTO_HDR_PPPOD : +case VIRTCHNL2_PROTO_HDR_IGMP : +case VIRTCHNL2_PROTO_HDR_AH : +case VIRTCHNL2_PROTO_HDR_ESP : +case VIRTCHNL2_PROTO_HDR_IKE : +case VIRTCHNL2_PROTO_HDR_NATT_KEEP : +case VIRTCHNL2_PROTO_HDR_GTP : +case VIRTCHNL2_PROTO_HDR_GTP_EH : +case VIRTCHNL2_PROTO_HDR_GTPCV2 : +case VIRTCHNL2_PROTO_HDR_ECPRI : +case VIRTCHNL2_PROTO_HDR_VRRP : +case VIRTCHNL2_PROTO_HDR_OSPF : +case VIRTCHNL2_PROTO_HDR_TUN : +case VIRTCHNL2_PROTO_HDR_VXLAN_GPE : +case VIRTCHNL2_PROTO_HDR_GENEVE : +case VIRTCHNL2_PROTO_HDR_NSH : +case VIRTCHNL2_PROTO_HDR_QUIC : +case VIRTCHNL2_PROTO_HDR_PFCP : +case VIRTCHNL2_PROTO_HDR_PFCP_NODE : +case VIRTCHNL2_PROTO_HDR_PFCP_SESSION : +case VIRTCHNL2_PROTO_HDR_RTP : +case VIRTCHNL2_PROTO_HDR_NO_PROTO : +default : +continue ; + } + adapter->ptype_tbl[ptype->ptype_id_10] = proto_hdr; + } + } + } + +free_ptype_info: +rte_free (ptype_info); +clear_cmd (adapter); +return ret; +} +int idpf_adapter_init (struct idpf_adapter *adapter) {
@@ -135,6 +345,12 @@ idpf_adapter_init(struct idpf_adapter *adapter) goto err_check_api; } + ret =idpf_get_pkt_type (adapter); +if (ret !=0 ) { +DRV_LOG (ERR ,"Failed to set ptype table" ); + goto err_check_api; + } +return 0 ; err_check_api:
drivers/common/idpf/idpf_common_device.h +7 -0
@@ -5,6 +5,7 @@#ifndef _IDPF_COMMON_DEVICE_H_#define _IDPF_COMMON_DEVICE_H_ +#include <rte_mbuf_ptype.h> #include <base/idpf_prototype.h> #include <base/virtchnl2.h> #include <idpf_common_logs.h>
@@ -19,6 +20,10 @@#define IDPF_DFLT_INTERVAL 16 +#define IDPF_GET_PTYPE_SIZE (p) \ + (sizeof(struct virtchnl2_ptype) + \ + (((p)->proto_id_count ? ((p)->proto_id_count - 1) : 0) * sizeof((p)->proto_id[0]))) +struct idpf_adapter {struct idpf_hw hw;struct virtchnl2_version_info virtchnl_version;
@@ -26,6 +31,8 @@ struct idpf_adapter {volatile uint32_t pend_cmd;/* pending command not finished */ uint32_t cmd_retval;/* return value of the cmd response from cp */ uint8_t *mbx_resp;/* buffer to store the mailbox response from cp */ + + uint32_t ptype_tbl[IDPF_MAX_PKT_TYPE] __rte_cache_min_aligned; };struct idpf_chunks_info {
drivers/common/idpf/idpf_common_virtchnl.h +3 -5
@@ -17,6 +17,9 @@ int idpf_vc_set_rss_lut(struct idpf_vport *vport);int idpf_vc_set_rss_hash (struct idpf_vport *vport);int idpf_vc_config_irq_map_unmap (struct idpf_vport *vport,uint16_t nb_rxq,bool map); +int idpf_vc_query_ptype_info (struct idpf_adapter *adapter); +int idpf_read_one_msg (struct idpf_adapter *adapter,uint32_t ops, +uint16_t buf_len,uint8_t *buf);__rte_internal int idpf_switch_queue(struct idpf_vport *vport, uint16_t qid,bool rx,bool on);
@@ -29,11 +32,6 @@ int idpf_vc_alloc_vectors(struct idpf_vport *vport, uint16_t num_vectors);__rte_internal int idpf_vc_dealloc_vectors(struct idpf_vport *vport);__rte_internal -int idpf_vc_query_ptype_info(struct idpf_adapter *adapter); -__rte_internal -int idpf_read_one_msg(struct idpf_adapter *adapter, uint32_t ops, -uint16_t buf_len,uint8_t *buf); -__rte_internal int idpf_execute_vc_cmd(struct idpf_adapter *adapter,struct idpf_cmd_info *args);
drivers/common/idpf/meson.build +2 -0
@@ -1,6 +1,8 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2022 Intel Corporation +deps += ['mbuf'] + sources = files( 'idpf_common_device.c', 'idpf_common_virtchnl.c',
drivers/common/idpf/version.map +0 -2
@@ -12,8 +12,6 @@ INTERNAL { idpf_vc_ena_dis_vport; idpf_vc_alloc_vectors; idpf_vc_dealloc_vectors; - idpf_vc_query_ptype_info; - idpf_read_one_msg; idpf_execute_vc_cmd; idpf_adapter_init; idpf_adapter_deinit;
drivers/net/idpf/idpf_ethdev.c +0 -6
@@ -602,12 +602,6 @@ idpf_adapter_ext_init(struct rte_pci_device *pci_dev, struct idpf_adapter_ext *a goto err_adapter_init; } - ret =idpf_get_pkt_type (adapter); -if (ret !=0 ) { -PMD_INIT_LOG (ERR ,"Failed to set ptype table" ); - goto err_get_ptype; - } - adapter->max_vport_nb = adapter->base.caps.max_vports; adapter->vports = rte_zmalloc("vports",
drivers/net/idpf/idpf_ethdev.h +0 -4
@@ -89,8 +89,6 @@ struct idpf_adapter_ext {uint16_t used_vecs_num; - uint32_t ptype_tbl[IDPF_MAX_PKT_TYPE] __rte_cache_min_aligned; -bool rx_vec_allowed;bool tx_vec_allowed;bool rx_use_avx512;
@@ -107,6 +105,4 @@ TAILQ_HEAD(idpf_adapter_list, idpf_adapter_ext);#define IDPF_ADAPTER_TO_EXT (p) \ container_of((p), struct idpf_adapter_ext, base) -int idpf_get_pkt_type (struct idpf_adapter_ext *adapter); -#endif /* _IDPF_ETHDEV_H_ */
drivers/net/idpf/idpf_rxtx.c +2 -2
@@ -1407,7 +1407,7 @@ idpf_splitq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, rx_id_bufq1 = rxq->bufq1->rx_next_avail; rx_id_bufq2 = rxq->bufq2->rx_next_avail; rx_desc_ring = rxq->rx_ring; - ptype_tbl = ad->ptype_tbl; + ptype_tbl = rxq->adapter->ptype_tbl;if ((rxq->offloads &RTE_ETH_RX_OFFLOAD_TIMESTAMP ) !=0 ) rxq->hw_register_set =1 ;
@@ -1812,7 +1812,7 @@ idpf_singleq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, rx_id = rxq->rx_tail; rx_ring = rxq->rx_ring; - ptype_tbl = ad->ptype_tbl; + ptype_tbl = rxq->adapter->ptype_tbl;if ((rxq->offloads &RTE_ETH_RX_OFFLOAD_TIMESTAMP ) !=0 ) rxq->hw_register_set =1 ;
drivers/net/idpf/idpf_rxtx.h +0 -4
@@ -82,10 +82,6 @@#define IDPF_TX_OFFLOAD_NOTSUP_MASK \ (RTE_MBUF_F_TX_OFFLOAD_MASK ^ IDPF_TX_OFFLOAD_MASK) -#define IDPF_GET_PTYPE_SIZE (p) \ - (sizeof(struct virtchnl2_ptype) + \ - (((p)->proto_id_count ? ((p)->proto_id_count - 1) : 0) * sizeof((p)->proto_id[0]))) -extern uint64_t idpf_timestamp_dynflag;struct idpf_rx_queue {
drivers/net/idpf/idpf_rxtx_vec_avx512.c +1 -2
@@ -245,8 +245,7 @@ _idpf_singleq_recv_raw_pkts_avx512(struct idpf_rx_queue *rxq, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) { -struct idpf_adapter_ext *adapter =IDPF_ADAPTER_TO_EXT (rxq->adapter); -const uint32_t *type_table = adapter->ptype_tbl; +const uint32_t *type_table = rxq->adapter->ptype_tbl;const __m256i mbuf_init =_mm256_set_epi64x (0 ,0 ,0 , rxq->mbuf_initializer);
drivers/net/idpf/idpf_vchnl.c +0 -213
219 lines not on this page · raw message
Signature · 1 line
2.26.2
PATCH v2 9/15 common/idpf: init create vport info
In reply to [email protected]From: Beilei Xing <[email protected]>
Initialize create vport info in common module.
--- drivers/common/idpf/idpf_common_device.c | 35 +++++++++++++++++ drivers/common/idpf/idpf_common_device.h | 11 ++++++ drivers/common/idpf/version.map | 1 + drivers/net/idpf/idpf_ethdev.c | 48 +++--------------------- drivers/net/idpf/idpf_ethdev.h | 8 ---- 5 files changed, 53 insertions(+), 50 deletions(-)
drivers/common/idpf/idpf_common_device.c +35 -0
@@ -626,4 +626,39 @@ idpf_config_irq_unmap(struct idpf_vport *vport, uint16_t nb_rx_queues)return 0 ; } +int +idpf_create_vport_info_init (struct idpf_vport *vport, +struct virtchnl2_create_vport *vport_info) +{ +struct idpf_adapter *adapter = vport->adapter; + + vport_info->vport_type =rte_cpu_to_le_16 (VIRTCHNL2_VPORT_TYPE_DEFAULT ); +if (adapter->txq_model ==0 ) { + vport_info->txq_model = +rte_cpu_to_le_16 (VIRTCHNL2_QUEUE_MODEL_SPLIT ); + vport_info->num_tx_q =IDPF_DEFAULT_TXQ_NUM ; + vport_info->num_tx_complq = +IDPF_DEFAULT_TXQ_NUM *IDPF_TX_COMPLQ_PER_GRP ; + }else { + vport_info->txq_model = +rte_cpu_to_le_16 (VIRTCHNL2_QUEUE_MODEL_SINGLE ); + vport_info->num_tx_q =IDPF_DEFAULT_TXQ_NUM ; + vport_info->num_tx_complq =0 ; + } +if (adapter->rxq_model ==0 ) { + vport_info->rxq_model = +rte_cpu_to_le_16 (VIRTCHNL2_QUEUE_MODEL_SPLIT ); + vport_info->num_rx_q =IDPF_DEFAULT_RXQ_NUM ; + vport_info->num_rx_bufq = +IDPF_DEFAULT_RXQ_NUM *IDPF_RX_BUFQ_PER_GRP ; + }else { + vport_info->rxq_model = +rte_cpu_to_le_16 (VIRTCHNL2_QUEUE_MODEL_SINGLE ); + vport_info->num_rx_q =IDPF_DEFAULT_RXQ_NUM ; + vport_info->num_rx_bufq =0 ; + } + +return 0 ; +} +RTE_LOG_REGISTER_SUFFIX (idpf_common_logtype, common,NOTICE );
drivers/common/idpf/idpf_common_device.h +11 -0
@@ -16,6 +16,11 @@#define IDPF_CTLQ_LEN 64#define IDPF_DFLT_MBX_BUF_SIZE 4096 +#define IDPF_DEFAULT_RXQ_NUM 16 +#define IDPF_RX_BUFQ_PER_GRP 2 +#define IDPF_DEFAULT_TXQ_NUM 16 +#define IDPF_TX_COMPLQ_PER_GRP 1 +#define IDPF_MAX_PKT_TYPE 1024#define IDPF_DFLT_INTERVAL 16
@@ -33,6 +38,9 @@ struct idpf_adapter {uint8_t *mbx_resp;/* buffer to store the mailbox response from cp */ uint32_t ptype_tbl[IDPF_MAX_PKT_TYPE] __rte_cache_min_aligned; + +uint32_t txq_model;/* 0 - split queue model, non-0 - single queue model */ +uint32_t rxq_model;/* 0 - split queue model, non-0 - single queue model */ };struct idpf_chunks_info {
@@ -165,5 +173,8 @@ __rte_internalint idpf_config_irq_map (struct idpf_vport *vport,uint16_t nb_rx_queues);__rte_internal int idpf_config_irq_unmap(struct idpf_vport *vport, uint16_t nb_rx_queues); +__rte_internal +int idpf_create_vport_info_init(struct idpf_vport *vport, +struct virtchnl2_create_vport *vport_info);#endif /* _IDPF_COMMON_DEVICE_H_ */
drivers/common/idpf/version.map +1 -0
@@ -20,6 +20,7 @@ INTERNAL { idpf_config_rss; idpf_config_irq_map; idpf_config_irq_unmap; + idpf_create_vport_info_init; local: *; };
drivers/net/idpf/idpf_ethdev.c +6 -42
81 lines not on this page · raw message
drivers/net/idpf/idpf_ethdev.h +0 -8
@@ -22,14 +22,9 @@#define IDPF_MAX_VPORT_NUM 8 -#define IDPF_DEFAULT_RXQ_NUM 16 -#define IDPF_DEFAULT_TXQ_NUM 16 -#define IDPF_INVALID_VPORT_IDX 0xffff#define IDPF_TXQ_PER_GRP 1 -#define IDPF_TX_COMPLQ_PER_GRP 1#define IDPF_RXQ_PER_GRP 1 -#define IDPF_RX_BUFQ_PER_GRP 2#define IDPF_DFLT_Q_VEC_NUM 1
@@ -78,9 +73,6 @@ struct idpf_adapter_ext {char name[IDPF_ADAPTER_NAME_LEN ]; -uint32_t txq_model;/* 0 - split queue model, non-0 - single queue model */ -uint32_t rxq_model;/* 0 - split queue model, non-0 - single queue model */ -struct idpf_vport **vports;uint16_t max_vport_nb;
Signature · 1 line
2.26.2
PATCH v2 10/15 common/idpf: add vector flags in vport
In reply to [email protected]From: Beilei Xing <[email protected]>
Add vector flags in idpf_vport structure.
--- drivers/common/idpf/idpf_common_device.h | 5 +++++ drivers/net/idpf/idpf_ethdev.h | 5 ----- drivers/net/idpf/idpf_rxtx.c | 22 ++++++++++------------ 3 files changed, 15 insertions(+), 17 deletions(-)
drivers/common/idpf/idpf_common_device.h +5 -0
@@ -100,6 +100,11 @@ struct idpf_vport {uint16_t devarg_id;bool stopped; + +bool rx_vec_allowed; +bool tx_vec_allowed; +bool rx_use_avx512; +bool tx_use_avx512; };/* Message type read in virtual channel from PF */
drivers/net/idpf/idpf_ethdev.h +0 -5
@@ -81,11 +81,6 @@ struct idpf_adapter_ext {uint16_t used_vecs_num; -bool rx_vec_allowed; -bool tx_vec_allowed; -bool rx_use_avx512; -bool tx_use_avx512; -/* For PTP */ uint64_t time_hw; };
drivers/net/idpf/idpf_rxtx.c +10 -12
@@ -2221,25 +2221,24 @@ idpf_set_rx_function(struct rte_eth_dev *dev) {struct idpf_vport *vport = dev->data->dev_private;#ifdef RTE_ARCH_X86 -struct idpf_adapter_ext *ad =IDPF_ADAPTER_TO_EXT (vport->adapter);struct idpf_rx_queue *rxq;int i;if (idpf_rx_vec_dev_check_default (dev) ==IDPF_VECTOR_PATH &&rte_vect_get_max_simd_bitwidth () >=RTE_VECT_SIMD_128 ) { - ad->rx_vec_allowed = true; + vport->rx_vec_allowed = true; if (rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_512)#ifdef CC_AVX512_SUPPORT if (rte_cpu_get_flag_enabled (RTE_CPUFLAG_AVX512F ) ==1 &&rte_cpu_get_flag_enabled (RTE_CPUFLAG_AVX512BW ) ==1 ) - ad->rx_use_avx512 = true; + vport->rx_use_avx512 = true;#else PMD_DRV_LOG (NOTICE ,"AVX512 is not supported in build env" );#endif /* CC_AVX512_SUPPORT */ }else { - ad->rx_vec_allowed = false; + vport->rx_vec_allowed = false; }#endif /* RTE_ARCH_X86 */
@@ -2247,13 +2246,13 @@ idpf_set_rx_function(struct rte_eth_dev *dev)if (vport->rxq_model ==VIRTCHNL2_QUEUE_MODEL_SPLIT ) { dev->rx_pkt_burst = idpf_splitq_recv_pkts; }else { -if (ad->rx_vec_allowed) { +if (vport->rx_vec_allowed) {for (i =0 ; i < dev->data->nb_tx_queues; i++) { rxq = dev->data->rx_queues[i]; (void )idpf_singleq_rx_vec_setup (rxq); }#ifdef CC_AVX512_SUPPORT -if (ad->rx_use_avx512) { +if (vport->rx_use_avx512) { dev->rx_pkt_burst = idpf_singleq_recv_pkts_avx512;return ; }
@@ -2275,7 +2274,6 @@ idpf_set_tx_function(struct rte_eth_dev *dev) {struct idpf_vport *vport = dev->data->dev_private;#ifdef RTE_ARCH_X86 -struct idpf_adapter_ext *ad =IDPF_ADAPTER_TO_EXT (vport->adapter);#ifdef CC_AVX512_SUPPORT struct idpf_tx_queue *txq;int i;
@@ -2283,18 +2281,18 @@ idpf_set_tx_function(struct rte_eth_dev *dev)if (idpf_rx_vec_dev_check_default (dev) ==IDPF_VECTOR_PATH &&rte_vect_get_max_simd_bitwidth () >=RTE_VECT_SIMD_128 ) { - ad->tx_vec_allowed = true; + vport->tx_vec_allowed = true; if (rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_512)#ifdef CC_AVX512_SUPPORT if (rte_cpu_get_flag_enabled (RTE_CPUFLAG_AVX512F ) ==1 &&rte_cpu_get_flag_enabled (RTE_CPUFLAG_AVX512BW ) ==1 ) - ad->tx_use_avx512 = true; + vport->tx_use_avx512 = true;#else PMD_DRV_LOG (NOTICE ,"AVX512 is not supported in build env" );#endif /* CC_AVX512_SUPPORT */ }else { - ad->tx_vec_allowed = false; + vport->tx_vec_allowed = false; }#endif /* RTE_ARCH_X86 */
@@ -2303,9 +2301,9 @@ idpf_set_tx_function(struct rte_eth_dev *dev) dev->tx_pkt_prepare = idpf_prep_pkts; } else { #ifdef RTE_ARCH_X86 - if (ad->tx_vec_allowed) { + if (vport->tx_vec_allowed) { #ifdef CC_AVX512_SUPPORT - if (ad->tx_use_avx512) { + if (vport->tx_use_avx512) { for (i = 0; i < dev->data->nb_tx_queues; i++) { txq = dev->data->tx_queues[i]; if (txq == NULL)
Signature · 1 line
2.26.2
PATCH v2 11/15 common/idpf: add rxq and txq struct
In reply to [email protected]From: Beilei Xing <[email protected]>
Add idpf_rxq and idpf_txq structure in common module. Move configure rxq and txq to common module.
--- drivers/common/idpf/idpf_common_device.h | 2 + drivers/common/idpf/idpf_common_rxtx.h | 112 +++++++++++++ drivers/common/idpf/idpf_common_virtchnl.c | 160 ++++++++++++++++++ drivers/common/idpf/idpf_common_virtchnl.h | 9 +- drivers/common/idpf/version.map | 3 +- drivers/net/idpf/idpf_ethdev.h | 2 - drivers/net/idpf/idpf_rxtx.h | 97 +---------- drivers/net/idpf/idpf_vchnl.c | 184 --------------------- drivers/net/idpf/meson.build | 1 - 9 files changed, 283 insertions(+), 287 deletions(-) create mode 100644 drivers/common/idpf/idpf_common_rxtx.h delete mode 100644 drivers/net/idpf/idpf_vchnl.c
drivers/common/idpf/idpf_common_device.h +2 -0
@@ -18,8 +18,10 @@#define IDPF_DEFAULT_RXQ_NUM 16#define IDPF_RX_BUFQ_PER_GRP 2 +#define IDPF_RXQ_PER_GRP 1#define IDPF_DEFAULT_TXQ_NUM 16#define IDPF_TX_COMPLQ_PER_GRP 1 +#define IDPF_TXQ_PER_GRP 1#define IDPF_MAX_PKT_TYPE 1024
drivers/common/idpf/idpf_common_rxtx.h new file +112 -0
112 lines not on this page · raw message
drivers/common/idpf/idpf_common_virtchnl.c +160 -0
163 lines not on this page · raw message
drivers/common/idpf/idpf_common_virtchnl.h +6 -3
@@ -6,6 +6,7 @@#define _IDPF_COMMON_VIRTCHNL_H_#include <idpf_common_device.h> +#include <idpf_common_rxtx.h> int idpf_vc_check_api_version (struct idpf_adapter *adapter);int idpf_vc_get_caps (struct idpf_adapter *adapter);
@@ -20,6 +21,8 @@ int idpf_vc_config_irq_map_unmap(struct idpf_vport *vport,int idpf_vc_query_ptype_info (struct idpf_adapter *adapter);int idpf_read_one_msg (struct idpf_adapter *adapter,uint32_t ops,uint16_t buf_len,uint8_t *buf); +int idpf_execute_vc_cmd (struct idpf_adapter *adapter, +struct idpf_cmd_info *args);__rte_internal int idpf_switch_queue(struct idpf_vport *vport, uint16_t qid,bool rx,bool on);
@@ -32,7 +35,7 @@ int idpf_vc_alloc_vectors(struct idpf_vport *vport, uint16_t num_vectors);__rte_internal int idpf_vc_dealloc_vectors(struct idpf_vport *vport);__rte_internal -int idpf_execute_vc_cmd(struct idpf_adapter *adapter, -struct idpf_cmd_info *args); - +int idpf_vc_config_rxq(struct idpf_vport *vport, struct idpf_rx_queue *rxq); +__rte_internal +int idpf_vc_config_txq(struct idpf_vport *vport, struct idpf_tx_queue *txq);#endif /* _IDPF_COMMON_VIRTCHNL_H_ */
drivers/common/idpf/version.map +2 -1
@@ -12,7 +12,8 @@ INTERNAL { idpf_vc_ena_dis_vport; idpf_vc_alloc_vectors; idpf_vc_dealloc_vectors; - idpf_execute_vc_cmd; + idpf_vc_config_rxq; + idpf_vc_config_txq; idpf_adapter_init; idpf_adapter_deinit; idpf_vport_init;
drivers/net/idpf/idpf_ethdev.h +0 -2
@@ -23,8 +23,6 @@#define IDPF_MAX_VPORT_NUM 8#define IDPF_INVALID_VPORT_IDX 0xffff -#define IDPF_TXQ_PER_GRP 1 -#define IDPF_RXQ_PER_GRP 1#define IDPF_DFLT_Q_VEC_NUM 1
drivers/net/idpf/idpf_rxtx.h +1 -96
119 lines not on this page · raw message
drivers/net/idpf/idpf_vchnl.c deleted +0 -184
184 lines not on this page · raw message
drivers/net/idpf/meson.build +0 -1
@@ -12,7 +12,6 @@ deps += ['common_idpf'] sources = files( 'idpf_ethdev.c', 'idpf_rxtx.c', - 'idpf_vchnl.c', ) if arch_subdir == 'x86'
Signature · 1 line
2.26.2
PATCH v2 12/15 common/idpf: add help functions for queue setup and release
In reply to [email protected]From: Beilei Xing <[email protected]>
Refine rxq setup and txq setup.
Move some help functions of queue setup and queue release to common module.
--- drivers/common/idpf/idpf_common_rxtx.c | 414 +++++++++ drivers/common/idpf/idpf_common_rxtx.h | 57 ++ drivers/common/idpf/meson.build | 1 + drivers/common/idpf/version.map | 15 + drivers/net/idpf/idpf_rxtx.c | 1029 ++++++----------------- drivers/net/idpf/idpf_rxtx.h | 9 - drivers/net/idpf/idpf_rxtx_vec_avx512.c | 2 +- 7 files changed, 762 insertions(+), 765 deletions(-) create mode 100644 drivers/common/idpf/idpf_common_rxtx.c
drivers/common/idpf/idpf_common_rxtx.c new file +414 -0
@@ -0,0 +1,414 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2022 Intel Corporation +*/ + +#include <rte_mbuf_dyn.h> +#include "idpf_common_rxtx.h" + +int +check_rx_thresh (uint16_t nb_desc,uint16_t thresh) +{ +/* The following constraints must be satisfied: +* thresh < rxq->nb_rx_desc +*/ +if (thresh >= nb_desc) { +DRV_LOG (ERR ,"rx_free_thresh (%u) must be less than %u" , + thresh, nb_desc); +return -EINVAL ; + } + +return 0 ; +} + +int +check_tx_thresh (uint16_t nb_desc,uint16_t tx_rs_thresh, +uint16_t tx_free_thresh) +{ +/* TX descriptors will have their RS bit set after tx_rs_thresh +* descriptors have been used. The TX descriptor ring will be cleaned +* after tx_free_thresh descriptors are used or if the number of +* descriptors required to transmit a packet is greater than the +* number of free TX descriptors. +* +* The following constraints must be satisfied: +* - tx_rs_thresh must be less than the size of the ring minus 2. +* - tx_free_thresh must be less than the size of the ring minus 3. +* - tx_rs_thresh must be less than or equal to tx_free_thresh. +* - tx_rs_thresh must be a divisor of the ring size. +* +* One descriptor in the TX ring is used as a sentinel to avoid a H/W +* race condition, hence the maximum threshold constraints. When set +* to zero use default values. +*/ +if (tx_rs_thresh >= (nb_desc -2 )) { +DRV_LOG (ERR ,"tx_rs_thresh (%u) must be less than the " +"number of TX descriptors (%u) minus 2" , + tx_rs_thresh, nb_desc); +return -EINVAL ; + } +if (tx_free_thresh >= (nb_desc -3 )) { +DRV_LOG (ERR ,"tx_free_thresh (%u) must be less than the " +"number of TX descriptors (%u) minus 3." , + tx_free_thresh, nb_desc); +return -EINVAL ; + } +if (tx_rs_thresh > tx_free_thresh) { +DRV_LOG (ERR ,"tx_rs_thresh (%u) must be less than or " +"equal to tx_free_thresh (%u)." , + tx_rs_thresh, tx_free_thresh); +return -EINVAL ; + } +if ((nb_desc % tx_rs_thresh) !=0 ) { +DRV_LOG (ERR ,"tx_rs_thresh (%u) must be a divisor of the " +"number of TX descriptors (%u)." , + tx_rs_thresh, nb_desc); +return -EINVAL ; + } + +return 0 ; +} + +void +release_rxq_mbufs (struct idpf_rx_queue *rxq) +{ +uint16_t i; + +if (rxq->sw_ring ==NULL ) +return ; + +for (i =0 ; i < rxq->nb_rx_desc; i++) { +if (rxq->sw_ring[i] !=NULL ) { +rte_pktmbuf_free_seg (rxq->sw_ring[i]); + rxq->sw_ring[i] =NULL ; + } + } +} + +void +release_txq_mbufs (struct idpf_tx_queue *txq) +{ +uint16_t nb_desc, i; + +if (txq ==NULL || txq->sw_ring ==NULL ) { +DRV_LOG (DEBUG ,"Pointer to rxq or sw_ring is NULL" ); +return ; + } + +if (txq->sw_nb_desc !=0 ) { +/* For split queue model, descriptor ring */ + nb_desc = txq->sw_nb_desc; + }else { +/* For single queue model */ + nb_desc = txq->nb_tx_desc; + } +for (i =0 ; i < nb_desc; i++) { +if (txq->sw_ring[i].mbuf !=NULL ) { +rte_pktmbuf_free_seg (txq->sw_ring[i].mbuf); + txq->sw_ring[i].mbuf =NULL ; + } + } +} + +void +reset_split_rx_descq (struct idpf_rx_queue *rxq) +{ +uint16_t len; +uint32_t i; + +if (rxq ==NULL ) +return ; + + len = rxq->nb_rx_desc +IDPF_RX_MAX_BURST ; + +for (i =0 ; i < len *sizeof (struct virtchnl2_rx_flex_desc_adv_nic_3 ); + i++) + ((volatile char *)rxq->rx_ring)[i] =0 ; + + rxq->rx_tail =0 ; + rxq->expected_gen_id =1 ; +} + +void +reset_split_rx_bufq (struct idpf_rx_queue *rxq) +{ +uint16_t len; +uint32_t i; + +if (rxq ==NULL ) +return ; + + len = rxq->nb_rx_desc +IDPF_RX_MAX_BURST ; + +for (i =0 ; i < len *sizeof (struct virtchnl2_splitq_rx_buf_desc ); + i++) + ((volatile char *)rxq->rx_ring)[i] =0 ; + +memset (&rxq->fake_mbuf,0x0 ,sizeof (rxq->fake_mbuf)); + +for (i =0 ; i <IDPF_RX_MAX_BURST ; i++) + rxq->sw_ring[rxq->nb_rx_desc + i] = &rxq->fake_mbuf; + +/* The next descriptor id which can be received. */ + rxq->rx_next_avail =0 ; + +/* The next descriptor id which can be refilled. */ + rxq->rx_tail =0 ; +/* The number of descriptors which can be refilled. */ + rxq->nb_rx_hold = rxq->nb_rx_desc -1 ; + + rxq->bufq1 =NULL ; + rxq->bufq2 =NULL ; +} + +void +reset_split_rx_queue (struct idpf_rx_queue *rxq) +{ +reset_split_rx_descq (rxq); +reset_split_rx_bufq (rxq->bufq1); +reset_split_rx_bufq (rxq->bufq2); +} + +void +reset_single_rx_queue (struct idpf_rx_queue *rxq) +{ +uint16_t len; +uint32_t i; + +if (rxq ==NULL ) +return ; + + len = rxq->nb_rx_desc +IDPF_RX_MAX_BURST ; + +for (i =0 ; i < len *sizeof (struct virtchnl2_singleq_rx_buf_desc ); + i++) + ((volatile char *)rxq->rx_ring)[i] =0 ; + +memset (&rxq->fake_mbuf,0x0 ,sizeof (rxq->fake_mbuf)); + +for (i =0 ; i <IDPF_RX_MAX_BURST ; i++) + rxq->sw_ring[rxq->nb_rx_desc + i] = &rxq->fake_mbuf; + + rxq->rx_tail =0 ; + rxq->nb_rx_hold =0 ; + +rte_pktmbuf_free (rxq->pkt_first_seg); + + rxq->pkt_first_seg =NULL ; + rxq->pkt_last_seg =NULL ; + rxq->rxrearm_start =0 ; + rxq->rxrearm_nb =0 ; +} + +void +reset_split_tx_descq (struct idpf_tx_queue *txq) +{ +struct idpf_tx_entry *txe; +uint32_t i, size; +uint16_t prev; + +if (txq ==NULL ) { +DRV_LOG (DEBUG ,"Pointer to txq is NULL" ); +return ; + } + + size =sizeof (struct idpf_flex_tx_sched_desc ) * txq->nb_tx_desc; +for (i =0 ; i < size; i++) + ((volatile char *)txq->desc_ring)[i] =0 ; + + txe = txq->sw_ring; + prev = (uint16_t )(txq->sw_nb_desc -1 ); +for (i =0 ; i < txq->sw_nb_desc; i++) { + txe[i].mbuf =NULL ; + txe[i].last_id = i; + txe[prev].next_id = i; + prev = i; + } + + txq->tx_tail =0 ; + txq->nb_used =0 ; + +/* Use this as next to clean for split desc queue */ + txq->last_desc_cleaned =0 ; + txq->sw_tail =0 ; + txq->nb_free = txq->nb_tx_desc -1 ; +} + +void +reset_split_tx_complq (struct idpf_tx_queue *cq) +{ +uint32_t i, size; + +if (cq ==NULL ) { +DRV_LOG (DEBUG ,"Pointer to complq is NULL" ); +return ; + } + + size =sizeof (struct idpf_splitq_tx_compl_desc ) * cq->nb_tx_desc; +for (i =0 ; i < size; i++) + ((volatile char *)cq->compl_ring)[i] =0 ; + + cq->tx_tail =0 ; + cq->expected_gen_id =1 ; +} + +void +reset_single_tx_queue (struct idpf_tx_queue *txq) +{ +struct idpf_tx_entry *txe; +uint32_t i, size; +uint16_t prev; + +if (txq ==NULL ) { +DRV_LOG (DEBUG ,"Pointer to txq is NULL" ); +return ; + } + + txe = txq->sw_ring; + size =sizeof (struct idpf_flex_tx_desc ) * txq->nb_tx_desc; +for (i =0 ; i < size; i++) + ((volatile char *)txq->tx_ring)[i] =0 ; + + prev = (uint16_t )(txq->nb_tx_desc -1 ); +for (i =0 ; i < txq->nb_tx_desc; i++) { + txq->tx_ring[i].qw1.cmd_dtype = +rte_cpu_to_le_16 (IDPF_TX_DESC_DTYPE_DESC_DONE ); + txe[i].mbuf =NULL ; + txe[i].last_id = i; + txe[prev].next_id = i; + prev = i; + } + + txq->tx_tail =0 ; + txq->nb_used =0 ; + + txq->last_desc_cleaned = txq->nb_tx_desc -1 ; + txq->nb_free = txq->nb_tx_desc -1 ; + + txq->next_dd = txq->rs_thresh -1 ; + txq->next_rs = txq->rs_thresh -1 ; +} + +void +idpf_rx_queue_release (void *rxq) +{ +struct idpf_rx_queue *q = rxq; + +if (q ==NULL ) +return ; + +/* Split queue */ +if (q->bufq1 !=NULL && q->bufq2 !=NULL ) { + q->bufq1->ops->release_mbufs (q->bufq1); +rte_free (q->bufq1->sw_ring); +rte_memzone_free (q->bufq1->mz); +rte_free (q->bufq1); + q->bufq2->ops->release_mbufs (q->bufq2); +rte_free (q->bufq2->sw_ring); +rte_memzone_free (q->bufq2->mz); +rte_free (q->bufq2); +rte_memzone_free (q->mz); +rte_free (q); +return ; + } + +/* Single queue */ + q->ops->release_mbufs (q); +rte_free (q->sw_ring); +rte_memzone_free (q->mz); +rte_free (q); +} + +void +idpf_tx_queue_release (void *txq) +{ +struct idpf_tx_queue *q = txq; + +if (q ==NULL ) +return ; + +if (q->complq) { +rte_memzone_free (q->complq->mz); +rte_free (q->complq); + } + + q->ops->release_mbufs (q); +rte_free (q->sw_ring); +rte_memzone_free (q->mz); +rte_free (q); +} + +int +idpf_alloc_single_rxq_mbufs (struct idpf_rx_queue *rxq) +{ +volatile struct virtchnl2_singleq_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 ==NULL )) { +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)); + + rxd = &((volatile struct virtchnl2_singleq_rx_buf_desc *)(rxq->rx_ring))[i]; + rxd->pkt_addr = dma_addr; + rxd->hdr_addr =0 ; + rxd->rsvd1 =0 ; + rxd->rsvd2 =0 ; + rxq->sw_ring[i] = mbuf; + } + +return 0 ; +} + +int +idpf_alloc_split_rxq_mbufs (struct idpf_rx_queue *rxq) +{ +volatile struct virtchnl2_splitq_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 ==NULL )) { +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)); + + rxd = &((volatile struct virtchnl2_splitq_rx_buf_desc *)(rxq->rx_ring))[i]; + rxd->qword0.buf_id = i; + rxd->qword0.rsvd0 =0 ; + rxd->qword0.rsvd1 =0 ; + rxd->pkt_addr = dma_addr; + rxd->hdr_addr =0 ; + rxd->rsvd2 =0 ; + + rxq->sw_ring[i] = mbuf; + } + + rxq->nb_rx_hold =0 ; + rxq->rx_tail = rxq->nb_rx_desc -1 ; + +return 0 ; +}
drivers/common/idpf/idpf_common_rxtx.h +57 -0
72 lines not on this page · raw message
drivers/common/idpf/meson.build +1 -0
@@ -5,6 +5,7 @@ deps += ['mbuf'] sources = files( 'idpf_common_device.c', + 'idpf_common_rxtx.c', 'idpf_common_virtchnl.c', )
drivers/common/idpf/version.map +15 -0
@@ -22,6 +22,21 @@ INTERNAL { idpf_config_irq_map; idpf_config_irq_unmap; idpf_create_vport_info_init; + check_rx_thresh; + check_tx_thresh; + release_rxq_mbufs; + release_txq_mbufs; + reset_split_rx_descq; + reset_split_rx_bufq; + reset_split_rx_queue; + reset_single_rx_queue; + reset_split_tx_descq; + reset_split_tx_complq; + reset_single_tx_queue; + idpf_rx_queue_release; + idpf_tx_queue_release; + idpf_alloc_single_rxq_mbufs; + idpf_alloc_split_rxq_mbufs; local: *; };
drivers/net/idpf/idpf_rxtx.c +274 -755
1,218 lines not on this page · raw message
drivers/net/idpf/idpf_rxtx.h +0 -9
@@ -51,7 +51,6 @@/* Base address of the HW descriptor ring should be 128B aligned. */ #define IDPF_RING_BASE_ALIGN 128 -#define IDPF_RX_MAX_BURST 32#define IDPF_DEFAULT_RX_FREE_THRESH 32/* used for Vector PMD */
@@ -101,14 +100,6 @@ union idpf_tx_offload { }; }; -struct idpf_rxq_ops { -void (*release_mbufs)(struct idpf_rx_queue *rxq); -}; - -struct idpf_txq_ops { -void (*release_mbufs)(struct idpf_tx_queue *txq); -}; - int idpf_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx, uint16_t nb_desc, unsigned int socket_id, const struct rte_eth_rxconf *rx_conf,
drivers/net/idpf/idpf_rxtx_vec_avx512.c +1 -1
@@ -562,7 +562,7 @@ idpf_tx_free_bufs_avx512(struct idpf_tx_queue *txq) txep = (void *)txq->sw_ring; txep += txq->next_dd - (n -1 ); -if (txq->offloads &RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE && (n &31 ) ==0 ) { +if (txq->offloads &IDPF_TX_OFFLOAD_MBUF_FAST_FREE && (n &31 ) ==0 ) {struct rte_mempool *mp = txep[0 ].mbuf->pool;struct rte_mempool_cache *cache =rte_mempool_default_cache (mp,rte_lcore_id ());
Signature · 1 line
2.26.2
PATCH v2 13/15 common/idpf: add scalar data path
In reply to [email protected]From: Beilei Xing <[email protected]>
Add timestamp filed to idpf_adapter structure.
Add scalar data path for single queue model and split queue model.
--- drivers/common/idpf/idpf_common_device.h | 5 + drivers/common/idpf/idpf_common_logs.h | 24 + drivers/common/idpf/idpf_common_rxtx.c | 987 +++++++++++++++++++++++ drivers/common/idpf/idpf_common_rxtx.h | 89 +- drivers/common/idpf/version.map | 6 + drivers/net/idpf/idpf_ethdev.c | 2 - drivers/net/idpf/idpf_ethdev.h | 4 - drivers/net/idpf/idpf_logs.h | 24 - drivers/net/idpf/idpf_rxtx.c | 935 --------------------- drivers/net/idpf/idpf_rxtx.h | 132 --- drivers/net/idpf/idpf_rxtx_vec_avx512.c | 8 +- 11 files changed, 1114 insertions(+), 1102 deletions(-)
drivers/common/idpf/idpf_common_device.h +5 -0
@@ -23,6 +23,8 @@#define IDPF_TX_COMPLQ_PER_GRP 1#define IDPF_TXQ_PER_GRP 1 +#define IDPF_MIN_FRAME_SIZE 14 +#define IDPF_MAX_PKT_TYPE 1024#define IDPF_DFLT_INTERVAL 16
@@ -43,6 +45,9 @@ struct idpf_adapter {uint32_t txq_model;/* 0 - split queue model, non-0 - single queue model */ uint32_t rxq_model;/* 0 - split queue model, non-0 - single queue model */ + +/* For timestamp */ +uint64_t time_hw; };struct idpf_chunks_info {
drivers/common/idpf/idpf_common_logs.h +24 -0
@@ -20,4 +20,28 @@ extern int idpf_common_logtype; #define DRV_LOG(level, fmt, args...) \ DRV_LOG_RAW(level, fmt "\n", ## args) +#ifdef RTE_LIBRTE_IDPF_DEBUG_RX +#define RX_LOG (level, ...) \ + RTE_LOG(level, \ + PMD, \ + RTE_FMT("%s(): " \ + RTE_FMT_HEAD(__VA_ARGS__,) "\n", \ + __func__, \ + RTE_FMT_TAIL(__VA_ARGS__,))) +#else +#define RX_LOG(level, fmt, args...) do { } while (0) +#endif + +#ifdef RTE_LIBRTE_IDPF_DEBUG_TX +#define TX_LOG (level, ...) \ + RTE_LOG(level, \ + PMD, \ + RTE_FMT("%s(): " \ + RTE_FMT_HEAD(__VA_ARGS__,) "\n", \ + __func__, \ + RTE_FMT_TAIL(__VA_ARGS__,))) +#else +#define TX_LOG(level, fmt, args...) do { } while (0) +#endif +#endif /* _IDPF_COMMON_LOGS_H_ */
drivers/common/idpf/idpf_common_rxtx.c +987 -0
1,004 lines not on this page · raw message
drivers/common/idpf/idpf_common_rxtx.h +88 -1
116 lines not on this page · raw message
drivers/common/idpf/version.map +6 -0
@@ -35,8 +35,14 @@ INTERNAL { reset_single_tx_queue; idpf_rx_queue_release; idpf_tx_queue_release; + idpf_register_ts_mbuf; idpf_alloc_single_rxq_mbufs; idpf_alloc_split_rxq_mbufs; + idpf_splitq_recv_pkts; + idpf_splitq_xmit_pkts; + idpf_singleq_recv_pkts; + idpf_singleq_xmit_pkts; + idpf_prep_pkts; local: *; };
drivers/net/idpf/idpf_ethdev.c +0 -2
@@ -22,8 +22,6 @@ rte_spinlock_t idpf_adapter_lock;struct idpf_adapter_list idpf_adapter_list;bool idpf_adapter_list_init; -uint64_t idpf_timestamp_dynflag; -static const char *const idpf_valid_args[] = {IDPF_TX_SINGLE_Q ,IDPF_RX_SINGLE_Q ,
drivers/net/idpf/idpf_ethdev.h +0 -4
@@ -28,7 +28,6 @@#define IDPF_MIN_BUF_SIZE 1024#define IDPF_MAX_FRAME_SIZE 9728 -#define IDPF_MIN_FRAME_SIZE 14#define IDPF_DEFAULT_MTU RTE_ETHER_MTU#define IDPF_NUM_MACADDR_MAX 64
@@ -78,9 +77,6 @@ struct idpf_adapter_ext {uint16_t cur_vport_nb;uint16_t used_vecs_num; - -/* For PTP */ -uint64_t time_hw; };TAILQ_HEAD (idpf_adapter_list, idpf_adapter_ext);
drivers/net/idpf/idpf_logs.h +0 -24
@@ -29,28 +29,4 @@ extern int idpf_logtype_driver; #define PMD_DRV_LOG(level, fmt, args...) \ PMD_DRV_LOG_RAW(level, fmt "\n", ## args) -#ifdef RTE_LIBRTE_IDPF_DEBUG_RX -#define PMD_RX_LOG (level, ...) \ - RTE_LOG(level, \ - PMD, \ - RTE_FMT("%s(): " \ - RTE_FMT_HEAD(__VA_ARGS__,) "\n", \ - __func__, \ - RTE_FMT_TAIL(__VA_ARGS__,))) -#else -#define PMD_RX_LOG(level, fmt, args...) do { } while (0) -#endif - -#ifdef RTE_LIBRTE_IDPF_DEBUG_TX -#define PMD_TX_LOG (level, ...) \ - RTE_LOG(level, \ - PMD, \ - RTE_FMT("%s(): " \ - RTE_FMT_HEAD(__VA_ARGS__,) "\n", \ - __func__, \ - RTE_FMT_TAIL(__VA_ARGS__,))) -#else -#define PMD_TX_LOG(level, fmt, args...) do { } while (0) -#endif -#endif /* _IDPF_LOGS_H_ */
drivers/net/idpf/idpf_rxtx.c +0 -935
953 lines not on this page · raw message
drivers/net/idpf/idpf_rxtx.h +0 -132
162 lines not on this page · raw message
drivers/net/idpf/idpf_rxtx_vec_avx512.c +4 -4
@@ -38,8 +38,8 @@ idpf_singleq_rearm_common(struct idpf_rx_queue *rxq) dma_addr0); } } - rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed += -IDPF_RXQ_REARM_THRESH ; +rte_atomic64_add (&rxq->rx_stats.mbuf_alloc_failed, +IDPF_RXQ_REARM_THRESH );return ; }struct rte_mbuf *mb0, *mb1, *mb2, *mb3;
@@ -168,8 +168,8 @@ idpf_singleq_rearm(struct idpf_rx_queue *rxq) dma_addr0); } } - rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed += -IDPF_RXQ_REARM_THRESH ; +rte_atomic64_add (&rxq->rx_stats.mbuf_alloc_failed, +IDPF_RXQ_REARM_THRESH );return ; } }
Signature · 1 line
2.26.2
PATCH v2 14/15 common/idpf: add vec queue setup
In reply to [email protected]From: Beilei Xing <[email protected]>
Add vector queue setup for single queue model.
--- drivers/common/idpf/idpf_common_rxtx.c | 57 ++++++++++++++++++++++++++ drivers/common/idpf/idpf_common_rxtx.h | 2 + drivers/common/idpf/version.map | 1 + drivers/net/idpf/idpf_rxtx.c | 57 -------------------------- drivers/net/idpf/idpf_rxtx.h | 1 - 5 files changed, 60 insertions(+), 58 deletions(-)
drivers/common/idpf/idpf_common_rxtx.c +57 -0
@@ -1399,3 +1399,60 @@ idpf_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts,return i; } + +static void __rte_cold +release_rxq_mbufs_vec (struct idpf_rx_queue *rxq) +{ +const uint16_t mask = rxq->nb_rx_desc -1 ; +uint16_t i; + +if (rxq->sw_ring ==NULL || rxq->rxrearm_nb >= rxq->nb_rx_desc) +return ; + +/* free all mbufs that are valid in the ring */ +if (rxq->rxrearm_nb ==0 ) { +for (i =0 ; i < rxq->nb_rx_desc; i++) { +if (rxq->sw_ring[i] !=NULL ) +rte_pktmbuf_free_seg (rxq->sw_ring[i]); + } + }else { +for (i = rxq->rx_tail; i != rxq->rxrearm_start; i = (i +1 ) & mask) { +if (rxq->sw_ring[i] !=NULL ) +rte_pktmbuf_free_seg (rxq->sw_ring[i]); + } + } + + rxq->rxrearm_nb = rxq->nb_rx_desc; + +/* set all entries to NULL */ +memset (rxq->sw_ring,0 ,sizeof (rxq->sw_ring[0 ]) * rxq->nb_rx_desc); +} + +static const struct idpf_rxq_ops def_singleq_rx_ops_vec = { + .release_mbufs = release_rxq_mbufs_vec, +}; + +static inline int +idpf_singleq_rx_vec_setup_default (struct idpf_rx_queue *rxq) +{ +uintptr_t p; +struct rte_mbuf mb_def = { .buf_addr =0 };/* zeroed mbuf */ + + mb_def.nb_segs =1 ; + mb_def.data_off =RTE_PKTMBUF_HEADROOM ; + mb_def.port = rxq->port_id; +rte_mbuf_refcnt_set (&mb_def,1 ); + +/* prevent compiler reordering: rearm_data covers previous fields */ +rte_compiler_barrier (); + p = (uintptr_t )&mb_def.rearm_data; + rxq->mbuf_initializer = *(uint64_t *)p; +return 0 ; +} + +int __rte_cold +idpf_singleq_rx_vec_setup (struct idpf_rx_queue *rxq) +{ + rxq->ops = &def_singleq_rx_ops_vec; +return idpf_singleq_rx_vec_setup_default (rxq); +}
drivers/common/idpf/idpf_common_rxtx.h +2 -0
@@ -252,5 +252,7 @@ uint16_t idpf_singleq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,__rte_internal uint16_t idpf_prep_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,uint16_t nb_pkts); +__rte_internal +int idpf_singleq_rx_vec_setup(struct idpf_rx_queue *rxq);#endif /* _IDPF_COMMON_RXTX_H_ */
drivers/common/idpf/version.map +1 -0
@@ -43,6 +43,7 @@ INTERNAL { idpf_singleq_recv_pkts; idpf_singleq_xmit_pkts; idpf_prep_pkts; + idpf_singleq_rx_vec_setup; local: *; };
drivers/net/idpf/idpf_rxtx.c +0 -57
63 lines not on this page · raw message
drivers/net/idpf/idpf_rxtx.h +0 -1
@@ -44,7 +44,6 @@ void idpf_dev_rx_queue_release(struct rte_eth_dev *dev, uint16_t qid);int idpf_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); -int idpf_singleq_rx_vec_setup (struct idpf_rx_queue *rxq);int idpf_tx_queue_init (struct rte_eth_dev *dev,uint16_t tx_queue_id);int idpf_tx_queue_start (struct rte_eth_dev *dev,uint16_t tx_queue_id);int idpf_tx_queue_stop (struct rte_eth_dev *dev,uint16_t tx_queue_id);
Signature · 1 line
2.26.2
PATCH v2 15/15 common/idpf: add avx512 for single queue model
In reply to [email protected]From: Beilei Xing <[email protected]>
Add avx512 vector path for single queue model.
---
drivers/common/idpf/idpf_common_rxtx.h | 20 +++++++++++++
.../idpf/idpf_common_rxtx_avx512.c} | 4 +--
drivers/common/idpf/meson.build | 30 +++++++++++++++++++
drivers/common/idpf/version.map | 3 ++
drivers/net/idpf/idpf_rxtx.h | 13 --------
drivers/net/idpf/meson.build | 17 -----------
6 files changed, 55 insertions(+), 32 deletions(-)
rename drivers/{net/idpf/idpf_rxtx_vec_avx512.c => common/idpf/idpf_common_rxtx_avx512.c} (99%)drivers/common/idpf/idpf_common_rxtx.h +20 -0
@@ -47,6 +47,12 @@#define IDPF_TX_OFFLOAD_NOTSUP_MASK \ (RTE_MBUF_F_TX_OFFLOAD_MASK ^ IDPF_TX_OFFLOAD_MASK) +/* used for Vector PMD */ +#define IDPF_VPMD_RX_MAX_BURST 32 +#define IDPF_VPMD_TX_MAX_BURST 32 +#define IDPF_VPMD_DESCS_PER_LOOP 4 +#define IDPF_RXQ_REARM_THRESH 64 +/* MTS */ #define GLTSYN_CMD_SYNC_0_0 (PF_TIMESYNC_BASE + 0x0)#define PF_GLTSYN_SHTIME_0_0 (PF_TIMESYNC_BASE + 0x4)
@@ -193,6 +199,10 @@ union idpf_tx_offload { }; }; +struct idpf_tx_vec_entry { +struct rte_mbuf *mbuf; +}; +struct idpf_rxq_ops {void (*release_mbufs)(struct idpf_rx_queue *rxq); };
@@ -254,5 +264,15 @@ uint16_t idpf_prep_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts);__rte_internal int idpf_singleq_rx_vec_setup(struct idpf_rx_queue *rxq); +__rte_internal +int idpf_singleq_tx_vec_setup_avx512(struct idpf_tx_queue *txq); +__rte_internal +uint16_t idpf_singleq_recv_pkts_avx512(void *rx_queue, +struct rte_mbuf **rx_pkts, +uint16_t nb_pkts); +__rte_internal +uint16_t idpf_singleq_xmit_pkts_avx512(void *tx_queue, +struct rte_mbuf **tx_pkts, +uint16_t nb_pkts);#endif /* _IDPF_COMMON_RXTX_H_ */
drivers/common/idpf/idpf_common_rxtx_avx512.c renamed from drivers/net/idpf/idpf_rxtx_vec_avx512.c +2 -2
@@ -2,9 +2,9 @@* Copyright(c) 2022 Intel Corporation */ -#include "idpf_rxtx_vec_common.h" -#include <rte_vect.h> +#include <idpf_common_device.h> +#include <idpf_common_rxtx.h> #ifndef __INTEL_COMPILER#pragma GCC diagnostic ignored "-Wcast-qual"
drivers/common/idpf/meson.build +30 -0
@@ -9,4 +9,34 @@ sources = files( 'idpf_common_virtchnl.c', ) +if arch_subdir == 'x86' + idpf_avx512_cpu_support = ( + cc.get_define('__AVX512F__', args: machine_args) != '' and + cc.get_define('__AVX512BW__', args: machine_args) != '' + ) + + idpf_avx512_cc_support = ( + not machine_args.contains('-mno-avx512f') and + cc.has_argument('-mavx512f') and + cc.has_argument('-mavx512bw') + ) + + if idpf_avx512_cpu_support == true or idpf_avx512_cc_support == true + cflags += ['-DCC_AVX512_SUPPORT'] + avx512_args = [cflags, '-mavx512f', '-mavx512bw'] + if cc.has_argument('-march=skylake-avx512') + avx512_args += '-march=skylake-avx512' + endif + idpf_common_avx512_lib = static_library( + 'idpf_common_avx512_lib', + 'idpf_common_rxtx_avx512.c', + dependencies: [ + static_rte_mbuf, + ], + include_directories: includes, + c_args: avx512_args) + objs += idpf_common_avx512_lib.extract_objects('idpf_common_rxtx_avx512.c') + endif +endif + subdir('base')
drivers/common/idpf/version.map +3 -0
@@ -44,6 +44,9 @@ INTERNAL { idpf_singleq_xmit_pkts; idpf_prep_pkts; idpf_singleq_rx_vec_setup; + idpf_singleq_tx_vec_setup_avx512; + idpf_singleq_recv_pkts_avx512; + idpf_singleq_xmit_pkts_avx512; local: *; };
drivers/net/idpf/idpf_rxtx.h +0 -13
@@ -19,23 +19,14 @@#define IDPF_DEFAULT_RX_FREE_THRESH 32/* used for Vector PMD */ -#define IDPF_VPMD_RX_MAX_BURST 32 -#define IDPF_VPMD_TX_MAX_BURST 32 -#define IDPF_VPMD_DESCS_PER_LOOP 4 -#define IDPF_RXQ_REARM_THRESH 64#define IDPF_DEFAULT_TX_RS_THRESH 32#define IDPF_DEFAULT_TX_FREE_THRESH 32 -struct idpf_tx_vec_entry { -struct rte_mbuf *mbuf; -}; -int idpf_rx_queue_setup (struct rte_eth_dev *dev,uint16_t queue_idx,uint16_t nb_desc,unsigned int socket_id,const struct rte_eth_rxconf *rx_conf,struct rte_mempool *mp); -int idpf_singleq_tx_vec_setup_avx512 (struct idpf_tx_queue *txq);int idpf_rx_queue_init (struct rte_eth_dev *dev,uint16_t rx_queue_id);int idpf_rx_queue_start (struct rte_eth_dev *dev,uint16_t rx_queue_id);int idpf_rx_queue_stop (struct rte_eth_dev *dev,uint16_t rx_queue_id);
@@ -48,10 +39,6 @@ int idpf_tx_queue_init(struct rte_eth_dev *dev, uint16_t tx_queue_id);int idpf_tx_queue_start (struct rte_eth_dev *dev,uint16_t tx_queue_id);int idpf_tx_queue_stop (struct rte_eth_dev *dev,uint16_t tx_queue_id);void idpf_dev_tx_queue_release (struct rte_eth_dev *dev,uint16_t qid); -uint16_t idpf_singleq_recv_pkts_avx512 (void *rx_queue,struct rte_mbuf **rx_pkts, -uint16_t nb_pkts); -uint16_t idpf_singleq_xmit_pkts_avx512 (void *tx_queue,struct rte_mbuf **tx_pkts, -uint16_t nb_pkts);void idpf_stop_queues (struct rte_eth_dev *dev);
drivers/net/idpf/meson.build +0 -17
@@ -28,22 +28,5 @@ if arch_subdir == 'x86' if idpf_avx512_cpu_support == true or idpf_avx512_cc_support == true cflags += ['-DCC_AVX512_SUPPORT'] - avx512_args = [cflags, '-mavx512f', '-mavx512bw'] - if cc.has_argument('-march=skylake-avx512') - avx512_args += '-march=skylake-avx512' - endif - idpf_avx512_lib = static_library( - 'idpf_avx512_lib', - 'idpf_rxtx_vec_avx512.c', - dependencies: [ - static_rte_common_idpf, - static_rte_ethdev, - static_rte_bus_pci, - static_rte_kvargs, - static_rte_hash, - ], - include_directories: includes, - c_args: avx512_args) - objs += idpf_avx512_lib.extract_objects('idpf_rxtx_vec_avx512.c') endif endif
Signature · 1 line
2.26.2