LCOV - code coverage report
Current view: top level - drivers/net/idpf - idpf_rxtx.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 427 0.0 %
Date: 2025-01-02 22:41:34 Functions: 0 19 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 212 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright(c) 2022 Intel Corporation
       3                 :            :  */
       4                 :            : 
       5                 :            : #include <ethdev_driver.h>
       6                 :            : #include <rte_net.h>
       7                 :            : #include <rte_vect.h>
       8                 :            : 
       9                 :            : #include "idpf_ethdev.h"
      10                 :            : #include "idpf_rxtx.h"
      11                 :            : #include "idpf_rxtx_vec_common.h"
      12                 :            : 
      13                 :            : static uint64_t
      14                 :          0 : idpf_rx_offload_convert(uint64_t offload)
      15                 :            : {
      16                 :            :         uint64_t ol = 0;
      17                 :            : 
      18         [ #  # ]:          0 :         if ((offload & RTE_ETH_RX_OFFLOAD_IPV4_CKSUM) != 0)
      19                 :            :                 ol |= IDPF_RX_OFFLOAD_IPV4_CKSUM;
      20         [ #  # ]:          0 :         if ((offload & RTE_ETH_RX_OFFLOAD_UDP_CKSUM) != 0)
      21                 :          0 :                 ol |= IDPF_RX_OFFLOAD_UDP_CKSUM;
      22         [ #  # ]:          0 :         if ((offload & RTE_ETH_RX_OFFLOAD_TCP_CKSUM) != 0)
      23                 :          0 :                 ol |= IDPF_RX_OFFLOAD_TCP_CKSUM;
      24         [ #  # ]:          0 :         if ((offload & RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM) != 0)
      25                 :          0 :                 ol |= IDPF_RX_OFFLOAD_OUTER_IPV4_CKSUM;
      26         [ #  # ]:          0 :         if ((offload & RTE_ETH_RX_OFFLOAD_TIMESTAMP) != 0)
      27                 :          0 :                 ol |= IDPF_RX_OFFLOAD_TIMESTAMP;
      28                 :            : 
      29                 :          0 :         return ol;
      30                 :            : }
      31                 :            : 
      32                 :            : static uint64_t
      33                 :          0 : idpf_tx_offload_convert(uint64_t offload)
      34                 :            : {
      35                 :            :         uint64_t ol = 0;
      36                 :            : 
      37         [ #  # ]:          0 :         if ((offload & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) != 0)
      38                 :            :                 ol |= IDPF_TX_OFFLOAD_IPV4_CKSUM;
      39         [ #  # ]:          0 :         if ((offload & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) != 0)
      40                 :          0 :                 ol |= IDPF_TX_OFFLOAD_UDP_CKSUM;
      41         [ #  # ]:          0 :         if ((offload & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) != 0)
      42                 :          0 :                 ol |= IDPF_TX_OFFLOAD_TCP_CKSUM;
      43         [ #  # ]:          0 :         if ((offload & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) != 0)
      44                 :          0 :                 ol |= IDPF_TX_OFFLOAD_SCTP_CKSUM;
      45         [ #  # ]:          0 :         if ((offload & RTE_ETH_TX_OFFLOAD_MULTI_SEGS) != 0)
      46                 :          0 :                 ol |= IDPF_TX_OFFLOAD_MULTI_SEGS;
      47         [ #  # ]:          0 :         if ((offload & RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE) != 0)
      48                 :          0 :                 ol |= IDPF_TX_OFFLOAD_MBUF_FAST_FREE;
      49                 :            : 
      50                 :          0 :         return ol;
      51                 :            : }
      52                 :            : 
      53                 :            : static const struct idpf_rxq_ops def_rxq_ops = {
      54                 :            :         .release_mbufs = idpf_qc_rxq_mbufs_release,
      55                 :            : };
      56                 :            : 
      57                 :            : static const struct idpf_txq_ops def_txq_ops = {
      58                 :            :         .release_mbufs = idpf_qc_txq_mbufs_release,
      59                 :            : };
      60                 :            : 
      61                 :            : static const struct rte_memzone *
      62   [ #  #  #  #  :          0 : idpf_dma_zone_reserve(struct rte_eth_dev *dev, uint16_t queue_idx,
                      # ]
      63                 :            :                       uint16_t len, uint16_t queue_type,
      64                 :            :                       unsigned int socket_id, bool splitq)
      65                 :            : {
      66                 :            :         char ring_name[RTE_MEMZONE_NAMESIZE];
      67                 :            :         const struct rte_memzone *mz;
      68                 :            :         uint32_t ring_size;
      69                 :            : 
      70                 :            :         memset(ring_name, 0, RTE_MEMZONE_NAMESIZE);
      71   [ #  #  #  #  :          0 :         switch (queue_type) {
                      # ]
      72                 :          0 :         case VIRTCHNL2_QUEUE_TYPE_TX:
      73         [ #  # ]:          0 :                 if (splitq)
      74                 :          0 :                         ring_size = RTE_ALIGN(len * sizeof(struct idpf_flex_tx_sched_desc),
      75                 :            :                                               IDPF_DMA_MEM_ALIGN);
      76                 :            :                 else
      77                 :          0 :                         ring_size = RTE_ALIGN(len * sizeof(struct idpf_base_tx_desc),
      78                 :            :                                               IDPF_DMA_MEM_ALIGN);
      79                 :            :                 rte_memcpy(ring_name, "idpf Tx ring", sizeof("idpf Tx ring"));
      80                 :            :                 break;
      81                 :          0 :         case VIRTCHNL2_QUEUE_TYPE_RX:
      82         [ #  # ]:          0 :                 if (splitq)
      83                 :          0 :                         ring_size = RTE_ALIGN(len * sizeof(struct virtchnl2_rx_flex_desc_adv_nic_3),
      84                 :            :                                               IDPF_DMA_MEM_ALIGN);
      85                 :            :                 else
      86                 :          0 :                         ring_size = RTE_ALIGN(len * sizeof(struct virtchnl2_singleq_rx_buf_desc),
      87                 :            :                                               IDPF_DMA_MEM_ALIGN);
      88                 :            :                 rte_memcpy(ring_name, "idpf Rx ring", sizeof("idpf Rx ring"));
      89                 :            :                 break;
      90                 :          0 :         case VIRTCHNL2_QUEUE_TYPE_TX_COMPLETION:
      91         [ #  # ]:          0 :                 ring_size = RTE_ALIGN(len * sizeof(struct idpf_splitq_tx_compl_desc),
      92                 :            :                                       IDPF_DMA_MEM_ALIGN);
      93                 :            :                 rte_memcpy(ring_name, "idpf Tx compl ring", sizeof("idpf Tx compl ring"));
      94                 :            :                 break;
      95                 :          0 :         case VIRTCHNL2_QUEUE_TYPE_RX_BUFFER:
      96         [ #  # ]:          0 :                 ring_size = RTE_ALIGN(len * sizeof(struct virtchnl2_splitq_rx_buf_desc),
      97                 :            :                                       IDPF_DMA_MEM_ALIGN);
      98                 :            :                 rte_memcpy(ring_name, "idpf Rx buf ring", sizeof("idpf Rx buf ring"));
      99                 :            :                 break;
     100                 :          0 :         default:
     101                 :          0 :                 PMD_INIT_LOG(ERR, "Invalid queue type");
     102                 :          0 :                 return NULL;
     103                 :            :         }
     104                 :            : 
     105                 :          0 :         mz = rte_eth_dma_zone_reserve(dev, ring_name, queue_idx,
     106                 :            :                                       ring_size, IDPF_RING_BASE_ALIGN,
     107                 :            :                                       socket_id);
     108         [ #  # ]:          0 :         if (mz == NULL) {
     109                 :          0 :                 PMD_INIT_LOG(ERR, "Failed to reserve DMA memory for ring");
     110                 :          0 :                 return NULL;
     111                 :            :         }
     112                 :            : 
     113                 :            :         /* Zero all the descriptors in the ring. */
     114                 :          0 :         memset(mz->addr, 0, ring_size);
     115                 :            : 
     116                 :          0 :         return mz;
     117                 :            : }
     118                 :            : 
     119                 :            : static void
     120                 :            : idpf_dma_zone_release(const struct rte_memzone *mz)
     121                 :            : {
     122                 :          0 :         rte_memzone_free(mz);
     123                 :          0 : }
     124                 :            : 
     125                 :            : static int
     126                 :          0 : idpf_rx_split_bufq_setup(struct rte_eth_dev *dev, struct idpf_rx_queue *rxq,
     127                 :            :                          uint16_t queue_idx, uint16_t rx_free_thresh,
     128                 :            :                          uint16_t nb_desc, unsigned int socket_id,
     129                 :            :                          struct rte_mempool *mp, uint8_t bufq_id)
     130                 :            : {
     131                 :          0 :         struct idpf_vport *vport = dev->data->dev_private;
     132                 :          0 :         struct idpf_adapter *adapter = vport->adapter;
     133                 :            :         struct idpf_hw *hw = &adapter->hw;
     134                 :            :         const struct rte_memzone *mz;
     135                 :            :         struct idpf_rx_queue *bufq;
     136                 :            :         uint16_t len;
     137                 :            :         int ret;
     138                 :            : 
     139                 :          0 :         bufq = rte_zmalloc_socket("idpf bufq",
     140                 :            :                                    sizeof(struct idpf_rx_queue),
     141                 :            :                                    RTE_CACHE_LINE_SIZE,
     142                 :            :                                    socket_id);
     143         [ #  # ]:          0 :         if (bufq == NULL) {
     144                 :          0 :                 PMD_INIT_LOG(ERR, "Failed to allocate memory for rx buffer queue.");
     145                 :            :                 ret = -ENOMEM;
     146                 :          0 :                 goto err_bufq1_alloc;
     147                 :            :         }
     148                 :            : 
     149                 :          0 :         bufq->mp = mp;
     150                 :          0 :         bufq->nb_rx_desc = nb_desc;
     151                 :          0 :         bufq->rx_free_thresh = rx_free_thresh;
     152                 :          0 :         bufq->queue_id = vport->chunks_info.rx_buf_start_qid + queue_idx;
     153                 :          0 :         bufq->port_id = dev->data->port_id;
     154                 :          0 :         bufq->rx_hdr_len = 0;
     155         [ #  # ]:          0 :         bufq->adapter = adapter;
     156                 :            : 
     157                 :          0 :         len = rte_pktmbuf_data_room_size(bufq->mp) - RTE_PKTMBUF_HEADROOM;
     158                 :          0 :         bufq->rx_buf_len = RTE_ALIGN_FLOOR(len, (1 << IDPF_RLAN_CTX_DBUF_S));
     159                 :          0 :         bufq->rx_buf_len = RTE_MIN(bufq->rx_buf_len, IDPF_RX_MAX_DATA_BUF_SIZE);
     160                 :            : 
     161                 :            :         /* Allocate a little more to support bulk allocate. */
     162                 :          0 :         len = nb_desc + IDPF_RX_MAX_BURST;
     163                 :            : 
     164                 :          0 :         mz = idpf_dma_zone_reserve(dev, queue_idx, len,
     165                 :            :                                    VIRTCHNL2_QUEUE_TYPE_RX_BUFFER,
     166                 :            :                                    socket_id, true);
     167         [ #  # ]:          0 :         if (mz == NULL) {
     168                 :            :                 ret = -ENOMEM;
     169                 :          0 :                 goto err_mz_reserve;
     170                 :            :         }
     171                 :            : 
     172                 :          0 :         bufq->rx_ring_phys_addr = mz->iova;
     173                 :          0 :         bufq->rx_ring = mz->addr;
     174                 :          0 :         bufq->mz = mz;
     175                 :            : 
     176                 :          0 :         bufq->sw_ring =
     177                 :          0 :                 rte_zmalloc_socket("idpf rx bufq sw ring",
     178                 :            :                                    sizeof(struct rte_mbuf *) * len,
     179                 :            :                                    RTE_CACHE_LINE_SIZE,
     180                 :            :                                    socket_id);
     181         [ #  # ]:          0 :         if (bufq->sw_ring == NULL) {
     182                 :          0 :                 PMD_INIT_LOG(ERR, "Failed to allocate memory for SW ring");
     183                 :            :                 ret = -ENOMEM;
     184                 :          0 :                 goto err_sw_ring_alloc;
     185                 :            :         }
     186                 :            : 
     187                 :          0 :         idpf_qc_split_rx_bufq_reset(bufq);
     188                 :          0 :         bufq->qrx_tail = hw->hw_addr + (vport->chunks_info.rx_buf_qtail_start +
     189                 :          0 :                          queue_idx * vport->chunks_info.rx_buf_qtail_spacing);
     190                 :          0 :         bufq->ops = &def_rxq_ops;
     191                 :          0 :         bufq->q_set = true;
     192                 :            : 
     193         [ #  # ]:          0 :         if (bufq_id == IDPF_RX_SPLIT_BUFQ1_ID) {
     194                 :          0 :                 rxq->bufq1 = bufq;
     195         [ #  # ]:          0 :         } else if (bufq_id == IDPF_RX_SPLIT_BUFQ2_ID) {
     196                 :          0 :                 rxq->bufq2 = bufq;
     197                 :            :         } else {
     198                 :          0 :                 PMD_INIT_LOG(ERR, "Invalid buffer queue index.");
     199                 :            :                 ret = -EINVAL;
     200                 :          0 :                 goto err_bufq_id;
     201                 :            :         }
     202                 :            : 
     203                 :            :         return 0;
     204                 :            : 
     205                 :            : err_bufq_id:
     206                 :          0 :         rte_free(bufq->sw_ring);
     207                 :          0 : err_sw_ring_alloc:
     208                 :            :         idpf_dma_zone_release(mz);
     209                 :          0 : err_mz_reserve:
     210                 :          0 :         rte_free(bufq);
     211                 :            : err_bufq1_alloc:
     212                 :            :         return ret;
     213                 :            : }
     214                 :            : 
     215                 :            : static void
     216                 :          0 : idpf_rx_split_bufq_release(struct idpf_rx_queue *bufq)
     217                 :            : {
     218                 :          0 :         rte_free(bufq->sw_ring);
     219                 :          0 :         idpf_dma_zone_release(bufq->mz);
     220                 :          0 :         rte_free(bufq);
     221                 :          0 : }
     222                 :            : 
     223                 :            : int
     224                 :          0 : idpf_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
     225                 :            :                     uint16_t nb_desc, unsigned int socket_id,
     226                 :            :                     const struct rte_eth_rxconf *rx_conf,
     227                 :            :                     struct rte_mempool *mp)
     228                 :            : {
     229                 :          0 :         struct idpf_vport *vport = dev->data->dev_private;
     230                 :          0 :         struct idpf_adapter *adapter = vport->adapter;
     231                 :            :         struct idpf_hw *hw = &adapter->hw;
     232                 :            :         const struct rte_memzone *mz;
     233                 :            :         struct idpf_rx_queue *rxq;
     234                 :            :         uint16_t rx_free_thresh;
     235                 :            :         uint64_t offloads;
     236                 :            :         bool is_splitq;
     237                 :            :         uint16_t len;
     238                 :            :         int ret;
     239                 :            : 
     240                 :          0 :         offloads = rx_conf->offloads | dev->data->dev_conf.rxmode.offloads;
     241                 :            : 
     242                 :            :         /* Check free threshold */
     243         [ #  # ]:          0 :         rx_free_thresh = (rx_conf->rx_free_thresh == 0) ?
     244                 :            :                 IDPF_DEFAULT_RX_FREE_THRESH :
     245                 :            :                 rx_conf->rx_free_thresh;
     246         [ #  # ]:          0 :         if (idpf_qc_rx_thresh_check(nb_desc, rx_free_thresh) != 0)
     247                 :            :                 return -EINVAL;
     248                 :            : 
     249                 :            :         /* Free memory if needed */
     250         [ #  # ]:          0 :         if (dev->data->rx_queues[queue_idx] != NULL) {
     251                 :          0 :                 idpf_qc_rx_queue_release(dev->data->rx_queues[queue_idx]);
     252                 :          0 :                 dev->data->rx_queues[queue_idx] = NULL;
     253                 :            :         }
     254                 :            : 
     255                 :            :         /* Setup Rx queue */
     256                 :          0 :         rxq = rte_zmalloc_socket("idpf rxq",
     257                 :            :                                  sizeof(struct idpf_rx_queue),
     258                 :            :                                  RTE_CACHE_LINE_SIZE,
     259                 :            :                                  socket_id);
     260         [ #  # ]:          0 :         if (rxq == NULL) {
     261                 :          0 :                 PMD_INIT_LOG(ERR, "Failed to allocate memory for rx queue data structure");
     262                 :            :                 ret = -ENOMEM;
     263                 :          0 :                 goto err_rxq_alloc;
     264                 :            :         }
     265                 :            : 
     266                 :          0 :         is_splitq = !!(vport->rxq_model == VIRTCHNL2_QUEUE_MODEL_SPLIT);
     267                 :            : 
     268                 :          0 :         rxq->mp = mp;
     269                 :          0 :         rxq->nb_rx_desc = nb_desc;
     270                 :          0 :         rxq->rx_free_thresh = rx_free_thresh;
     271                 :          0 :         rxq->queue_id = vport->chunks_info.rx_start_qid + queue_idx;
     272                 :          0 :         rxq->port_id = dev->data->port_id;
     273                 :          0 :         rxq->rx_deferred_start = rx_conf->rx_deferred_start;
     274                 :          0 :         rxq->rx_hdr_len = 0;
     275                 :          0 :         rxq->adapter = adapter;
     276         [ #  # ]:          0 :         rxq->offloads = idpf_rx_offload_convert(offloads);
     277                 :            : 
     278                 :          0 :         len = rte_pktmbuf_data_room_size(rxq->mp) - RTE_PKTMBUF_HEADROOM;
     279                 :          0 :         rxq->rx_buf_len = RTE_ALIGN_FLOOR(len, (1 << IDPF_RLAN_CTX_DBUF_S));
     280                 :          0 :         rxq->rx_buf_len = RTE_MIN(rxq->rx_buf_len, IDPF_RX_MAX_DATA_BUF_SIZE);
     281                 :            : 
     282                 :            :         /* Allocate a little more to support bulk allocate. */
     283                 :          0 :         len = nb_desc + IDPF_RX_MAX_BURST;
     284                 :          0 :         mz = idpf_dma_zone_reserve(dev, queue_idx, len, VIRTCHNL2_QUEUE_TYPE_RX,
     285                 :            :                                    socket_id, is_splitq);
     286         [ #  # ]:          0 :         if (mz == NULL) {
     287                 :            :                 ret = -ENOMEM;
     288                 :          0 :                 goto err_mz_reserve;
     289                 :            :         }
     290                 :          0 :         rxq->rx_ring_phys_addr = mz->iova;
     291                 :          0 :         rxq->rx_ring = mz->addr;
     292                 :          0 :         rxq->mz = mz;
     293                 :            : 
     294         [ #  # ]:          0 :         if (!is_splitq) {
     295                 :          0 :                 rxq->sw_ring = rte_zmalloc_socket("idpf rxq sw ring",
     296                 :            :                                                   sizeof(struct rte_mbuf *) * len,
     297                 :            :                                                   RTE_CACHE_LINE_SIZE,
     298                 :            :                                                   socket_id);
     299         [ #  # ]:          0 :                 if (rxq->sw_ring == NULL) {
     300                 :          0 :                         PMD_INIT_LOG(ERR, "Failed to allocate memory for SW ring");
     301                 :            :                         ret = -ENOMEM;
     302                 :          0 :                         goto err_sw_ring_alloc;
     303                 :            :                 }
     304                 :            : 
     305                 :          0 :                 idpf_qc_single_rx_queue_reset(rxq);
     306                 :          0 :                 rxq->qrx_tail = hw->hw_addr + (vport->chunks_info.rx_qtail_start +
     307                 :          0 :                                 queue_idx * vport->chunks_info.rx_qtail_spacing);
     308                 :          0 :                 rxq->ops = &def_rxq_ops;
     309                 :            :         } else {
     310                 :          0 :                 idpf_qc_split_rx_descq_reset(rxq);
     311                 :            : 
     312                 :            :                 /* Setup Rx buffer queues */
     313                 :          0 :                 ret = idpf_rx_split_bufq_setup(dev, rxq, 2 * queue_idx,
     314                 :            :                                                rx_free_thresh, nb_desc,
     315                 :            :                                                socket_id, mp, 1);
     316         [ #  # ]:          0 :                 if (ret != 0) {
     317                 :          0 :                         PMD_INIT_LOG(ERR, "Failed to setup buffer queue 1");
     318                 :            :                         ret = -EINVAL;
     319                 :          0 :                         goto err_bufq1_setup;
     320                 :            :                 }
     321                 :            : 
     322                 :          0 :                 ret = idpf_rx_split_bufq_setup(dev, rxq, 2 * queue_idx + 1,
     323                 :            :                                                rx_free_thresh, nb_desc,
     324                 :            :                                                socket_id, mp, 2);
     325         [ #  # ]:          0 :                 if (ret != 0) {
     326                 :          0 :                         PMD_INIT_LOG(ERR, "Failed to setup buffer queue 2");
     327                 :            :                         ret = -EINVAL;
     328                 :          0 :                         goto err_bufq2_setup;
     329                 :            :                 }
     330                 :            :         }
     331                 :            : 
     332                 :          0 :         rxq->q_set = true;
     333                 :          0 :         dev->data->rx_queues[queue_idx] = rxq;
     334                 :            : 
     335                 :          0 :         return 0;
     336                 :            : 
     337                 :            : err_bufq2_setup:
     338                 :          0 :         idpf_rx_split_bufq_release(rxq->bufq1);
     339                 :          0 : err_bufq1_setup:
     340                 :          0 : err_sw_ring_alloc:
     341                 :            :         idpf_dma_zone_release(mz);
     342                 :          0 : err_mz_reserve:
     343                 :          0 :         rte_free(rxq);
     344                 :            : err_rxq_alloc:
     345                 :            :         return ret;
     346                 :            : }
     347                 :            : 
     348                 :            : static int
     349                 :          0 : idpf_tx_complq_setup(struct rte_eth_dev *dev, struct idpf_tx_queue *txq,
     350                 :            :                      uint16_t queue_idx, uint16_t nb_desc,
     351                 :            :                      unsigned int socket_id)
     352                 :            : {
     353                 :          0 :         struct idpf_vport *vport = dev->data->dev_private;
     354                 :            :         const struct rte_memzone *mz;
     355                 :            :         struct idpf_tx_queue *cq;
     356                 :            :         int ret;
     357                 :            : 
     358                 :          0 :         cq = rte_zmalloc_socket("idpf splitq cq",
     359                 :            :                                 sizeof(struct idpf_tx_queue),
     360                 :            :                                 RTE_CACHE_LINE_SIZE,
     361                 :            :                                 socket_id);
     362         [ #  # ]:          0 :         if (cq == NULL) {
     363                 :          0 :                 PMD_INIT_LOG(ERR, "Failed to allocate memory for Tx compl queue");
     364                 :            :                 ret = -ENOMEM;
     365                 :          0 :                 goto err_cq_alloc;
     366                 :            :         }
     367                 :            : 
     368                 :          0 :         cq->nb_tx_desc = nb_desc;
     369                 :          0 :         cq->queue_id = vport->chunks_info.tx_compl_start_qid + queue_idx;
     370                 :          0 :         cq->port_id = dev->data->port_id;
     371                 :          0 :         cq->txqs = dev->data->tx_queues;
     372                 :          0 :         cq->tx_start_qid = vport->chunks_info.tx_start_qid;
     373                 :            : 
     374                 :          0 :         mz = idpf_dma_zone_reserve(dev, queue_idx, nb_desc,
     375                 :            :                                    VIRTCHNL2_QUEUE_TYPE_TX_COMPLETION,
     376                 :            :                                    socket_id, true);
     377         [ #  # ]:          0 :         if (mz == NULL) {
     378                 :            :                 ret = -ENOMEM;
     379                 :          0 :                 goto err_mz_reserve;
     380                 :            :         }
     381                 :          0 :         cq->tx_ring_phys_addr = mz->iova;
     382                 :          0 :         cq->compl_ring = mz->addr;
     383                 :          0 :         cq->mz = mz;
     384                 :          0 :         idpf_qc_split_tx_complq_reset(cq);
     385                 :            : 
     386                 :          0 :         txq->complq = cq;
     387                 :            : 
     388                 :          0 :         return 0;
     389                 :            : 
     390                 :            : err_mz_reserve:
     391                 :          0 :         rte_free(cq);
     392                 :            : err_cq_alloc:
     393                 :            :         return ret;
     394                 :            : }
     395                 :            : 
     396                 :            : int
     397                 :          0 : idpf_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
     398                 :            :                     uint16_t nb_desc, unsigned int socket_id,
     399                 :            :                     const struct rte_eth_txconf *tx_conf)
     400                 :            : {
     401                 :          0 :         struct idpf_vport *vport = dev->data->dev_private;
     402                 :          0 :         struct idpf_adapter *adapter = vport->adapter;
     403                 :            :         uint16_t tx_rs_thresh, tx_free_thresh;
     404                 :            :         struct idpf_hw *hw = &adapter->hw;
     405                 :            :         const struct rte_memzone *mz;
     406                 :            :         struct idpf_tx_queue *txq;
     407                 :            :         uint64_t offloads;
     408                 :            :         uint16_t len;
     409                 :            :         bool is_splitq;
     410                 :            :         int ret;
     411                 :            : 
     412                 :          0 :         offloads = tx_conf->offloads | dev->data->dev_conf.txmode.offloads;
     413                 :            : 
     414         [ #  # ]:          0 :         tx_rs_thresh = (uint16_t)((tx_conf->tx_rs_thresh > 0) ?
     415                 :            :                 tx_conf->tx_rs_thresh : IDPF_DEFAULT_TX_RS_THRESH);
     416         [ #  # ]:          0 :         tx_free_thresh = (uint16_t)((tx_conf->tx_free_thresh > 0) ?
     417                 :            :                 tx_conf->tx_free_thresh : IDPF_DEFAULT_TX_FREE_THRESH);
     418         [ #  # ]:          0 :         if (idpf_qc_tx_thresh_check(nb_desc, tx_rs_thresh, tx_free_thresh) != 0)
     419                 :            :                 return -EINVAL;
     420                 :            : 
     421                 :            :         /* Free memory if needed. */
     422         [ #  # ]:          0 :         if (dev->data->tx_queues[queue_idx] != NULL) {
     423                 :          0 :                 idpf_qc_tx_queue_release(dev->data->tx_queues[queue_idx]);
     424                 :          0 :                 dev->data->tx_queues[queue_idx] = NULL;
     425                 :            :         }
     426                 :            : 
     427                 :            :         /* Allocate the TX queue data structure. */
     428                 :          0 :         txq = rte_zmalloc_socket("idpf txq",
     429                 :            :                                  sizeof(struct idpf_tx_queue),
     430                 :            :                                  RTE_CACHE_LINE_SIZE,
     431                 :            :                                  socket_id);
     432         [ #  # ]:          0 :         if (txq == NULL) {
     433                 :          0 :                 PMD_INIT_LOG(ERR, "Failed to allocate memory for tx queue structure");
     434                 :            :                 ret = -ENOMEM;
     435                 :          0 :                 goto err_txq_alloc;
     436                 :            :         }
     437                 :            : 
     438                 :          0 :         is_splitq = !!(vport->txq_model == VIRTCHNL2_QUEUE_MODEL_SPLIT);
     439                 :            : 
     440                 :          0 :         txq->nb_tx_desc = nb_desc;
     441                 :          0 :         txq->rs_thresh = tx_rs_thresh;
     442                 :          0 :         txq->free_thresh = tx_free_thresh;
     443                 :          0 :         txq->queue_id = vport->chunks_info.tx_start_qid + queue_idx;
     444                 :          0 :         txq->port_id = dev->data->port_id;
     445                 :          0 :         txq->offloads = idpf_tx_offload_convert(offloads);
     446                 :          0 :         txq->tx_deferred_start = tx_conf->tx_deferred_start;
     447                 :            : 
     448         [ #  # ]:          0 :         if (is_splitq)
     449                 :          0 :                 len = 2 * nb_desc;
     450                 :            :         else
     451                 :            :                 len = nb_desc;
     452                 :          0 :         txq->sw_nb_desc = len;
     453                 :            : 
     454                 :            :         /* Allocate TX hardware ring descriptors. */
     455                 :          0 :         mz = idpf_dma_zone_reserve(dev, queue_idx, nb_desc, VIRTCHNL2_QUEUE_TYPE_TX,
     456                 :            :                                    socket_id, is_splitq);
     457         [ #  # ]:          0 :         if (mz == NULL) {
     458                 :            :                 ret = -ENOMEM;
     459                 :          0 :                 goto err_mz_reserve;
     460                 :            :         }
     461                 :          0 :         txq->tx_ring_phys_addr = mz->iova;
     462                 :          0 :         txq->mz = mz;
     463                 :            : 
     464                 :          0 :         txq->sw_ring = rte_zmalloc_socket("idpf tx sw ring",
     465                 :            :                                           sizeof(struct idpf_tx_entry) * len,
     466                 :            :                                           RTE_CACHE_LINE_SIZE, socket_id);
     467         [ #  # ]:          0 :         if (txq->sw_ring == NULL) {
     468                 :          0 :                 PMD_INIT_LOG(ERR, "Failed to allocate memory for SW TX ring");
     469                 :            :                 ret = -ENOMEM;
     470                 :          0 :                 goto err_sw_ring_alloc;
     471                 :            :         }
     472                 :            : 
     473         [ #  # ]:          0 :         if (!is_splitq) {
     474                 :          0 :                 txq->tx_ring = mz->addr;
     475                 :          0 :                 idpf_qc_single_tx_queue_reset(txq);
     476                 :            :         } else {
     477                 :          0 :                 txq->desc_ring = mz->addr;
     478                 :          0 :                 idpf_qc_split_tx_descq_reset(txq);
     479                 :            : 
     480                 :            :                 /* Setup tx completion queue if split model */
     481                 :          0 :                 ret = idpf_tx_complq_setup(dev, txq, queue_idx,
     482                 :            :                                            2 * nb_desc, socket_id);
     483         [ #  # ]:          0 :                 if (ret != 0)
     484                 :          0 :                         goto err_complq_setup;
     485                 :            :         }
     486                 :            : 
     487                 :          0 :         txq->qtx_tail = hw->hw_addr + (vport->chunks_info.tx_qtail_start +
     488                 :          0 :                         queue_idx * vport->chunks_info.tx_qtail_spacing);
     489                 :          0 :         txq->ops = &def_txq_ops;
     490                 :          0 :         txq->q_set = true;
     491                 :          0 :         dev->data->tx_queues[queue_idx] = txq;
     492                 :            : 
     493                 :          0 :         return 0;
     494                 :            : 
     495                 :            : err_complq_setup:
     496                 :          0 : err_sw_ring_alloc:
     497                 :            :         idpf_dma_zone_release(mz);
     498                 :          0 : err_mz_reserve:
     499                 :          0 :         rte_free(txq);
     500                 :            : err_txq_alloc:
     501                 :            :         return ret;
     502                 :            : }
     503                 :            : 
     504                 :            : int
     505                 :          0 : idpf_rx_queue_init(struct rte_eth_dev *dev, uint16_t rx_queue_id)
     506                 :            : {
     507                 :            :         struct idpf_rx_queue *rxq;
     508                 :            :         uint16_t max_pkt_len;
     509                 :            :         uint32_t frame_size;
     510                 :            :         int err;
     511                 :            : 
     512         [ #  # ]:          0 :         if (rx_queue_id >= dev->data->nb_rx_queues)
     513                 :            :                 return -EINVAL;
     514                 :            : 
     515                 :          0 :         rxq = dev->data->rx_queues[rx_queue_id];
     516                 :            : 
     517   [ #  #  #  # ]:          0 :         if (rxq == NULL || !rxq->q_set) {
     518                 :          0 :                 PMD_DRV_LOG(ERR, "RX queue %u not available or setup",
     519                 :            :                                         rx_queue_id);
     520                 :          0 :                 return -EINVAL;
     521                 :            :         }
     522                 :            : 
     523                 :          0 :         frame_size = dev->data->mtu + IDPF_ETH_OVERHEAD;
     524                 :            : 
     525                 :          0 :         max_pkt_len =
     526                 :          0 :             RTE_MIN((uint32_t)IDPF_SUPPORT_CHAIN_NUM * rxq->rx_buf_len,
     527                 :            :                     frame_size);
     528                 :            : 
     529                 :          0 :         rxq->max_pkt_len = max_pkt_len;
     530   [ #  #  #  # ]:          0 :         if ((dev->data->dev_conf.rxmode.offloads & RTE_ETH_RX_OFFLOAD_SCATTER) ||
     531                 :            :             frame_size > rxq->rx_buf_len)
     532                 :          0 :                 dev->data->scattered_rx = 1;
     533                 :            : 
     534                 :          0 :         err = idpf_qc_ts_mbuf_register(rxq);
     535         [ #  # ]:          0 :         if (err != 0) {
     536                 :          0 :                 PMD_DRV_LOG(ERR, "fail to residter timestamp mbuf %u",
     537                 :            :                                         rx_queue_id);
     538                 :          0 :                 return -EIO;
     539                 :            :         }
     540                 :            : 
     541         [ #  # ]:          0 :         if (rxq->adapter->is_rx_singleq) {
     542                 :            :                 /* Single queue */
     543                 :          0 :                 err = idpf_qc_single_rxq_mbufs_alloc(rxq);
     544         [ #  # ]:          0 :                 if (err != 0) {
     545                 :          0 :                         PMD_DRV_LOG(ERR, "Failed to allocate RX queue mbuf");
     546                 :          0 :                         return err;
     547                 :            :                 }
     548                 :            : 
     549                 :            :                 rte_wmb();
     550                 :            : 
     551                 :            :                 /* Init the RX tail register. */
     552                 :          0 :                 IDPF_PCI_REG_WRITE(rxq->qrx_tail, rxq->nb_rx_desc - 1);
     553                 :            :         } else {
     554                 :            :                 /* Split queue */
     555                 :          0 :                 err = idpf_qc_split_rxq_mbufs_alloc(rxq->bufq1);
     556         [ #  # ]:          0 :                 if (err != 0) {
     557                 :          0 :                         PMD_DRV_LOG(ERR, "Failed to allocate RX buffer queue mbuf");
     558                 :          0 :                         return err;
     559                 :            :                 }
     560                 :          0 :                 err = idpf_qc_split_rxq_mbufs_alloc(rxq->bufq2);
     561         [ #  # ]:          0 :                 if (err != 0) {
     562                 :          0 :                         PMD_DRV_LOG(ERR, "Failed to allocate RX buffer queue mbuf");
     563                 :          0 :                         return err;
     564                 :            :                 }
     565                 :            : 
     566                 :            :                 rte_wmb();
     567                 :            : 
     568                 :            :                 /* Init the RX tail register. */
     569                 :          0 :                 IDPF_PCI_REG_WRITE(rxq->bufq1->qrx_tail, rxq->bufq1->rx_tail);
     570                 :          0 :                 IDPF_PCI_REG_WRITE(rxq->bufq2->qrx_tail, rxq->bufq2->rx_tail);
     571                 :            :         }
     572                 :            : 
     573                 :            :         return err;
     574                 :            : }
     575                 :            : 
     576                 :            : int
     577                 :          0 : idpf_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id)
     578                 :            : {
     579                 :          0 :         struct idpf_vport *vport = dev->data->dev_private;
     580                 :          0 :         struct idpf_rx_queue *rxq =
     581                 :          0 :                 dev->data->rx_queues[rx_queue_id];
     582                 :            :         int err = 0;
     583                 :            : 
     584                 :          0 :         err = idpf_vc_rxq_config(vport, rxq);
     585         [ #  # ]:          0 :         if (err != 0) {
     586                 :          0 :                 PMD_DRV_LOG(ERR, "Fail to configure Rx queue %u", rx_queue_id);
     587                 :          0 :                 return err;
     588                 :            :         }
     589                 :            : 
     590                 :          0 :         err = idpf_rx_queue_init(dev, rx_queue_id);
     591         [ #  # ]:          0 :         if (err != 0) {
     592                 :          0 :                 PMD_DRV_LOG(ERR, "Failed to init RX queue %u",
     593                 :            :                             rx_queue_id);
     594                 :          0 :                 return err;
     595                 :            :         }
     596                 :            : 
     597                 :            :         /* Ready to switch the queue on */
     598                 :          0 :         err = idpf_vc_queue_switch(vport, rx_queue_id, true, true,
     599                 :            :                                                         VIRTCHNL2_QUEUE_TYPE_RX);
     600         [ #  # ]:          0 :         if (err != 0) {
     601                 :          0 :                 PMD_DRV_LOG(ERR, "Failed to switch RX queue %u on",
     602                 :            :                             rx_queue_id);
     603                 :            :         } else {
     604                 :          0 :                 rxq->q_started = true;
     605                 :          0 :                 dev->data->rx_queue_state[rx_queue_id] =
     606                 :            :                         RTE_ETH_QUEUE_STATE_STARTED;
     607                 :            :         }
     608                 :            : 
     609                 :            :         return err;
     610                 :            : }
     611                 :            : 
     612                 :            : int
     613                 :          0 : idpf_tx_queue_init(struct rte_eth_dev *dev, uint16_t tx_queue_id)
     614                 :            : {
     615                 :            :         struct idpf_tx_queue *txq;
     616                 :            : 
     617         [ #  # ]:          0 :         if (tx_queue_id >= dev->data->nb_tx_queues)
     618                 :            :                 return -EINVAL;
     619                 :            : 
     620                 :          0 :         txq = dev->data->tx_queues[tx_queue_id];
     621                 :            : 
     622                 :            :         /* Init the RX tail register. */
     623                 :          0 :         IDPF_PCI_REG_WRITE(txq->qtx_tail, 0);
     624                 :            : 
     625                 :          0 :         return 0;
     626                 :            : }
     627                 :            : 
     628                 :            : int
     629                 :          0 : idpf_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id)
     630                 :            : {
     631                 :          0 :         struct idpf_vport *vport = dev->data->dev_private;
     632                 :          0 :         struct idpf_tx_queue *txq =
     633                 :          0 :                 dev->data->tx_queues[tx_queue_id];
     634                 :            :         int err = 0;
     635                 :            : 
     636                 :          0 :         err = idpf_vc_txq_config(vport, txq);
     637         [ #  # ]:          0 :         if (err != 0) {
     638                 :          0 :                 PMD_DRV_LOG(ERR, "Fail to configure Tx queue %u", tx_queue_id);
     639                 :          0 :                 return err;
     640                 :            :         }
     641                 :            : 
     642                 :          0 :         err = idpf_tx_queue_init(dev, tx_queue_id);
     643         [ #  # ]:          0 :         if (err != 0) {
     644                 :          0 :                 PMD_DRV_LOG(ERR, "Failed to init TX queue %u",
     645                 :            :                             tx_queue_id);
     646                 :          0 :                 return err;
     647                 :            :         }
     648                 :            : 
     649                 :            :         /* Ready to switch the queue on */
     650                 :          0 :         err = idpf_vc_queue_switch(vport, tx_queue_id, false, true,
     651                 :            :                                                         VIRTCHNL2_QUEUE_TYPE_TX);
     652         [ #  # ]:          0 :         if (err != 0) {
     653                 :          0 :                 PMD_DRV_LOG(ERR, "Failed to switch TX queue %u on",
     654                 :            :                             tx_queue_id);
     655                 :            :         } else {
     656                 :          0 :                 txq->q_started = true;
     657                 :          0 :                 dev->data->tx_queue_state[tx_queue_id] =
     658                 :            :                         RTE_ETH_QUEUE_STATE_STARTED;
     659                 :            :         }
     660                 :            : 
     661                 :            :         return err;
     662                 :            : }
     663                 :            : 
     664                 :            : int
     665                 :          0 : idpf_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id)
     666                 :            : {
     667                 :          0 :         struct idpf_vport *vport = dev->data->dev_private;
     668                 :            :         struct idpf_rx_queue *rxq;
     669                 :            :         int err;
     670                 :            : 
     671         [ #  # ]:          0 :         if (rx_queue_id >= dev->data->nb_rx_queues)
     672                 :            :                 return -EINVAL;
     673                 :            : 
     674                 :          0 :         err = idpf_vc_queue_switch(vport, rx_queue_id, true, false,
     675                 :            :                                                         VIRTCHNL2_QUEUE_TYPE_RX);
     676         [ #  # ]:          0 :         if (err != 0) {
     677                 :          0 :                 PMD_DRV_LOG(ERR, "Failed to switch RX queue %u off",
     678                 :            :                             rx_queue_id);
     679                 :          0 :                 return err;
     680                 :            :         }
     681                 :            : 
     682                 :          0 :         rxq = dev->data->rx_queues[rx_queue_id];
     683                 :          0 :         rxq->q_started = false;
     684         [ #  # ]:          0 :         if (vport->rxq_model == VIRTCHNL2_QUEUE_MODEL_SINGLE) {
     685                 :          0 :                 rxq->ops->release_mbufs(rxq);
     686                 :          0 :                 idpf_qc_single_rx_queue_reset(rxq);
     687                 :            :         } else {
     688                 :          0 :                 rxq->bufq1->ops->release_mbufs(rxq->bufq1);
     689                 :          0 :                 rxq->bufq2->ops->release_mbufs(rxq->bufq2);
     690                 :          0 :                 idpf_qc_split_rx_queue_reset(rxq);
     691                 :            :         }
     692                 :          0 :         dev->data->rx_queue_state[rx_queue_id] = RTE_ETH_QUEUE_STATE_STOPPED;
     693                 :            : 
     694                 :          0 :         return 0;
     695                 :            : }
     696                 :            : 
     697                 :            : int
     698                 :          0 : idpf_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id)
     699                 :            : {
     700                 :          0 :         struct idpf_vport *vport = dev->data->dev_private;
     701                 :            :         struct idpf_tx_queue *txq;
     702                 :            :         int err;
     703                 :            : 
     704         [ #  # ]:          0 :         if (tx_queue_id >= dev->data->nb_tx_queues)
     705                 :            :                 return -EINVAL;
     706                 :            : 
     707                 :          0 :         err = idpf_vc_queue_switch(vport, tx_queue_id, false, false,
     708                 :            :                                                         VIRTCHNL2_QUEUE_TYPE_TX);
     709         [ #  # ]:          0 :         if (err != 0) {
     710                 :          0 :                 PMD_DRV_LOG(ERR, "Failed to switch TX queue %u off",
     711                 :            :                             tx_queue_id);
     712                 :          0 :                 return err;
     713                 :            :         }
     714                 :            : 
     715                 :          0 :         txq = dev->data->tx_queues[tx_queue_id];
     716                 :          0 :         txq->q_started = false;
     717                 :          0 :         txq->ops->release_mbufs(txq);
     718         [ #  # ]:          0 :         if (vport->txq_model == VIRTCHNL2_QUEUE_MODEL_SINGLE) {
     719                 :          0 :                 idpf_qc_single_tx_queue_reset(txq);
     720                 :            :         } else {
     721                 :          0 :                 idpf_qc_split_tx_descq_reset(txq);
     722                 :          0 :                 idpf_qc_split_tx_complq_reset(txq->complq);
     723                 :            :         }
     724                 :          0 :         dev->data->tx_queue_state[tx_queue_id] = RTE_ETH_QUEUE_STATE_STOPPED;
     725                 :            : 
     726                 :          0 :         return 0;
     727                 :            : }
     728                 :            : 
     729                 :            : void
     730                 :          0 : idpf_dev_rx_queue_release(struct rte_eth_dev *dev, uint16_t qid)
     731                 :            : {
     732                 :          0 :         idpf_qc_rx_queue_release(dev->data->rx_queues[qid]);
     733                 :          0 : }
     734                 :            : 
     735                 :            : void
     736                 :          0 : idpf_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid)
     737                 :            : {
     738                 :          0 :         idpf_qc_tx_queue_release(dev->data->tx_queues[qid]);
     739                 :          0 : }
     740                 :            : 
     741                 :            : void
     742                 :          0 : idpf_stop_queues(struct rte_eth_dev *dev)
     743                 :            : {
     744                 :            :         struct idpf_rx_queue *rxq;
     745                 :            :         struct idpf_tx_queue *txq;
     746                 :            :         int i;
     747                 :            : 
     748         [ #  # ]:          0 :         for (i = 0; i < dev->data->nb_rx_queues; i++) {
     749                 :          0 :                 rxq = dev->data->rx_queues[i];
     750         [ #  # ]:          0 :                 if (rxq == NULL)
     751                 :          0 :                         continue;
     752                 :            : 
     753         [ #  # ]:          0 :                 if (idpf_rx_queue_stop(dev, i) != 0)
     754                 :          0 :                         PMD_DRV_LOG(WARNING, "Fail to stop Rx queue %d", i);
     755                 :            :         }
     756                 :            : 
     757         [ #  # ]:          0 :         for (i = 0; i < dev->data->nb_tx_queues; i++) {
     758                 :          0 :                 txq = dev->data->tx_queues[i];
     759         [ #  # ]:          0 :                 if (txq == NULL)
     760                 :          0 :                         continue;
     761                 :            : 
     762         [ #  # ]:          0 :                 if (idpf_tx_queue_stop(dev, i) != 0)
     763                 :          0 :                         PMD_DRV_LOG(WARNING, "Fail to stop Tx queue %d", i);
     764                 :            :         }
     765                 :          0 : }
     766                 :            : 
     767                 :            : void
     768                 :          0 : idpf_set_rx_function(struct rte_eth_dev *dev)
     769                 :            : {
     770                 :          0 :         struct idpf_vport *vport = dev->data->dev_private;
     771                 :            : #ifdef RTE_ARCH_X86
     772                 :            :         struct idpf_rx_queue *rxq;
     773                 :            :         int i;
     774                 :            : 
     775   [ #  #  #  # ]:          0 :         if (idpf_rx_vec_dev_check_default(dev) == IDPF_VECTOR_PATH &&
     776                 :          0 :             rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_128) {
     777                 :          0 :                 vport->rx_vec_allowed = true;
     778                 :            : 
     779         [ #  # ]:          0 :                 if (rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_512)
     780                 :            : #ifdef CC_AVX512_SUPPORT
     781   [ #  #  #  # ]:          0 :                         if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F) == 1 &&
     782         [ #  # ]:          0 :                             rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512BW) == 1 &&
     783                 :          0 :                             rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512DQ))
     784                 :          0 :                                 vport->rx_use_avx512 = true;
     785                 :            : #else
     786                 :            :                 PMD_DRV_LOG(NOTICE,
     787                 :            :                             "AVX512 is not supported in build env");
     788                 :            : #endif /* CC_AVX512_SUPPORT */
     789                 :            :         } else {
     790                 :          0 :                 vport->rx_vec_allowed = false;
     791                 :            :         }
     792                 :            : #endif /* RTE_ARCH_X86 */
     793                 :            : 
     794                 :            : #ifdef RTE_ARCH_X86
     795         [ #  # ]:          0 :         if (vport->rxq_model == VIRTCHNL2_QUEUE_MODEL_SPLIT) {
     796         [ #  # ]:          0 :                 if (vport->rx_vec_allowed) {
     797         [ #  # ]:          0 :                         for (i = 0; i < dev->data->nb_rx_queues; i++) {
     798                 :          0 :                                 rxq = dev->data->rx_queues[i];
     799                 :          0 :                                 (void)idpf_qc_splitq_rx_vec_setup(rxq);
     800                 :            :                         }
     801                 :            : #ifdef CC_AVX512_SUPPORT
     802         [ #  # ]:          0 :                         if (vport->rx_use_avx512) {
     803                 :          0 :                                 PMD_DRV_LOG(NOTICE,
     804                 :            :                                             "Using Split AVX512 Vector Rx (port %d).",
     805                 :            :                                             dev->data->port_id);
     806                 :          0 :                                 dev->rx_pkt_burst = idpf_dp_splitq_recv_pkts_avx512;
     807                 :          0 :                                 return;
     808                 :            :                         }
     809                 :            : #endif /* CC_AVX512_SUPPORT */
     810                 :            :                 }
     811                 :          0 :                 PMD_DRV_LOG(NOTICE,
     812                 :            :                             "Using Split Scalar Rx (port %d).",
     813                 :            :                             dev->data->port_id);
     814                 :          0 :                 dev->rx_pkt_burst = idpf_dp_splitq_recv_pkts;
     815                 :            :         } else {
     816         [ #  # ]:          0 :                 if (vport->rx_vec_allowed) {
     817         [ #  # ]:          0 :                         for (i = 0; i < dev->data->nb_tx_queues; i++) {
     818                 :          0 :                                 rxq = dev->data->rx_queues[i];
     819                 :          0 :                                 (void)idpf_qc_singleq_rx_vec_setup(rxq);
     820                 :            :                         }
     821                 :            : #ifdef CC_AVX512_SUPPORT
     822         [ #  # ]:          0 :                         if (vport->rx_use_avx512) {
     823                 :          0 :                                 PMD_DRV_LOG(NOTICE,
     824                 :            :                                             "Using Single AVX512 Vector Rx (port %d).",
     825                 :            :                                             dev->data->port_id);
     826                 :          0 :                                 dev->rx_pkt_burst = idpf_dp_singleq_recv_pkts_avx512;
     827                 :          0 :                                 return;
     828                 :            :                         }
     829                 :            : #endif /* CC_AVX512_SUPPORT */
     830                 :            :                 }
     831                 :            : 
     832         [ #  # ]:          0 :                 if (dev->data->scattered_rx) {
     833                 :          0 :                         PMD_DRV_LOG(NOTICE,
     834                 :            :                                     "Using Single Scalar Scatterd Rx (port %d).",
     835                 :            :                                     dev->data->port_id);
     836                 :          0 :                         dev->rx_pkt_burst = idpf_dp_singleq_recv_scatter_pkts;
     837                 :          0 :                         return;
     838                 :            :                 }
     839                 :          0 :                 PMD_DRV_LOG(NOTICE,
     840                 :            :                             "Using Single Scalar Rx (port %d).",
     841                 :            :                             dev->data->port_id);
     842                 :          0 :                 dev->rx_pkt_burst = idpf_dp_singleq_recv_pkts;
     843                 :            :         }
     844                 :            : #else
     845                 :            :         if (vport->rxq_model == VIRTCHNL2_QUEUE_MODEL_SPLIT) {
     846                 :            :                 PMD_DRV_LOG(NOTICE,
     847                 :            :                             "Using Split Scalar Rx (port %d).",
     848                 :            :                             dev->data->port_id);
     849                 :            :                 dev->rx_pkt_burst = idpf_dp_splitq_recv_pkts;
     850                 :            :         } else {
     851                 :            :                 if (dev->data->scattered_rx) {
     852                 :            :                         PMD_DRV_LOG(NOTICE,
     853                 :            :                                     "Using Single Scalar Scatterd Rx (port %d).",
     854                 :            :                                     dev->data->port_id);
     855                 :            :                         dev->rx_pkt_burst = idpf_dp_singleq_recv_scatter_pkts;
     856                 :            :                         return;
     857                 :            :                 }
     858                 :            :                 PMD_DRV_LOG(NOTICE,
     859                 :            :                             "Using Single Scalar Rx (port %d).",
     860                 :            :                             dev->data->port_id);
     861                 :            :                 dev->rx_pkt_burst = idpf_dp_singleq_recv_pkts;
     862                 :            :         }
     863                 :            : #endif /* RTE_ARCH_X86 */
     864                 :            : }
     865                 :            : 
     866                 :            : void
     867                 :          0 : idpf_set_tx_function(struct rte_eth_dev *dev)
     868                 :            : {
     869                 :          0 :         struct idpf_vport *vport = dev->data->dev_private;
     870                 :            : #ifdef RTE_ARCH_X86
     871                 :            : #ifdef CC_AVX512_SUPPORT
     872                 :            :         struct idpf_tx_queue *txq;
     873                 :            :         int i;
     874                 :            : #endif /* CC_AVX512_SUPPORT */
     875                 :            : 
     876   [ #  #  #  # ]:          0 :         if (idpf_tx_vec_dev_check_default(dev) == IDPF_VECTOR_PATH &&
     877                 :          0 :             rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_128) {
     878                 :          0 :                 vport->tx_vec_allowed = true;
     879         [ #  # ]:          0 :                 if (rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_512)
     880                 :            : #ifdef CC_AVX512_SUPPORT
     881                 :            :                 {
     882   [ #  #  #  # ]:          0 :                         if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F) == 1 &&
     883                 :          0 :                             rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512BW) == 1)
     884                 :          0 :                                 vport->tx_use_avx512 = true;
     885         [ #  # ]:          0 :                         if (vport->tx_use_avx512) {
     886         [ #  # ]:          0 :                                 for (i = 0; i < dev->data->nb_tx_queues; i++) {
     887                 :          0 :                                         txq = dev->data->tx_queues[i];
     888                 :          0 :                                         idpf_qc_tx_vec_avx512_setup(txq);
     889                 :            :                                 }
     890                 :            :                         }
     891                 :            :                 }
     892                 :            : #else
     893                 :            :                 PMD_DRV_LOG(NOTICE,
     894                 :            :                             "AVX512 is not supported in build env");
     895                 :            : #endif /* CC_AVX512_SUPPORT */
     896                 :            :         } else {
     897                 :          0 :                 vport->tx_vec_allowed = false;
     898                 :            :         }
     899                 :            : #endif /* RTE_ARCH_X86 */
     900                 :            : 
     901                 :            : #ifdef RTE_ARCH_X86
     902         [ #  # ]:          0 :         if (vport->txq_model == VIRTCHNL2_QUEUE_MODEL_SPLIT) {
     903         [ #  # ]:          0 :                 if (vport->tx_vec_allowed) {
     904                 :            : #ifdef CC_AVX512_SUPPORT
     905         [ #  # ]:          0 :                         if (vport->tx_use_avx512) {
     906                 :          0 :                                 PMD_DRV_LOG(NOTICE,
     907                 :            :                                             "Using Split AVX512 Vector Tx (port %d).",
     908                 :            :                                             dev->data->port_id);
     909                 :          0 :                                 dev->tx_pkt_burst = idpf_dp_splitq_xmit_pkts_avx512;
     910                 :          0 :                                 dev->tx_pkt_prepare = idpf_dp_prep_pkts;
     911                 :          0 :                                 return;
     912                 :            :                         }
     913                 :            : #endif /* CC_AVX512_SUPPORT */
     914                 :            :                 }
     915                 :          0 :                 PMD_DRV_LOG(NOTICE,
     916                 :            :                             "Using Split Scalar Tx (port %d).",
     917                 :            :                             dev->data->port_id);
     918                 :          0 :                 dev->tx_pkt_burst = idpf_dp_splitq_xmit_pkts;
     919                 :          0 :                 dev->tx_pkt_prepare = idpf_dp_prep_pkts;
     920                 :            :         } else {
     921         [ #  # ]:          0 :                 if (vport->tx_vec_allowed) {
     922                 :            : #ifdef CC_AVX512_SUPPORT
     923         [ #  # ]:          0 :                         if (vport->tx_use_avx512) {
     924         [ #  # ]:          0 :                                 for (i = 0; i < dev->data->nb_tx_queues; i++) {
     925                 :          0 :                                         txq = dev->data->tx_queues[i];
     926         [ #  # ]:          0 :                                         if (txq == NULL)
     927                 :          0 :                                                 continue;
     928                 :          0 :                                         idpf_qc_tx_vec_avx512_setup(txq);
     929                 :            :                                 }
     930                 :          0 :                                 PMD_DRV_LOG(NOTICE,
     931                 :            :                                             "Using Single AVX512 Vector Tx (port %d).",
     932                 :            :                                             dev->data->port_id);
     933                 :          0 :                                 dev->tx_pkt_burst = idpf_dp_singleq_xmit_pkts_avx512;
     934                 :          0 :                                 dev->tx_pkt_prepare = idpf_dp_prep_pkts;
     935                 :          0 :                                 return;
     936                 :            :                         }
     937                 :            : #endif /* CC_AVX512_SUPPORT */
     938                 :            :                 }
     939                 :          0 :                 PMD_DRV_LOG(NOTICE,
     940                 :            :                             "Using Single Scalar Tx (port %d).",
     941                 :            :                             dev->data->port_id);
     942                 :          0 :                 dev->tx_pkt_burst = idpf_dp_singleq_xmit_pkts;
     943                 :          0 :                 dev->tx_pkt_prepare = idpf_dp_prep_pkts;
     944                 :            :         }
     945                 :            : #else
     946                 :            :         if (vport->txq_model == VIRTCHNL2_QUEUE_MODEL_SPLIT) {
     947                 :            :                 PMD_DRV_LOG(NOTICE,
     948                 :            :                             "Using Split Scalar Tx (port %d).",
     949                 :            :                             dev->data->port_id);
     950                 :            :                 dev->tx_pkt_burst = idpf_dp_splitq_xmit_pkts;
     951                 :            :                 dev->tx_pkt_prepare = idpf_dp_prep_pkts;
     952                 :            :         } else {
     953                 :            :                 PMD_DRV_LOG(NOTICE,
     954                 :            :                             "Using Single Scalar Tx (port %d).",
     955                 :            :                             dev->data->port_id);
     956                 :            :                 dev->tx_pkt_burst = idpf_dp_singleq_xmit_pkts;
     957                 :            :                 dev->tx_pkt_prepare = idpf_dp_prep_pkts;
     958                 :            :         }
     959                 :            : #endif /* RTE_ARCH_X86 */
     960                 :            : }

Generated by: LCOV version 1.14