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

Generated by: LCOV version 1.14