LCOV - code coverage report
Current view: top level - drivers/net/zxdh - zxdh_pci.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 187 0.0 %
Date: 2025-03-01 20:23:48 Functions: 0 25 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 70 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright(c) 2024 ZTE Corporation
       3                 :            :  */
       4                 :            : 
       5                 :            : #include <stdint.h>
       6                 :            : #include <unistd.h>
       7                 :            : 
       8                 :            : #include <rte_io.h>
       9                 :            : #include <rte_bus.h>
      10                 :            : #include <rte_pci.h>
      11                 :            : #include <rte_common.h>
      12                 :            : #include <rte_cycles.h>
      13                 :            : 
      14                 :            : #include "zxdh_ethdev.h"
      15                 :            : #include "zxdh_pci.h"
      16                 :            : #include "zxdh_logs.h"
      17                 :            : #include "zxdh_queue.h"
      18                 :            : 
      19                 :            : #define ZXDH_PMD_DEFAULT_GUEST_FEATURES   \
      20                 :            :                 (1ULL << ZXDH_NET_F_MRG_RXBUF | \
      21                 :            :                 1ULL << ZXDH_NET_F_STATUS    | \
      22                 :            :                 1ULL << ZXDH_NET_F_MQ        | \
      23                 :            :                 1ULL << ZXDH_F_ANY_LAYOUT    | \
      24                 :            :                 1ULL << ZXDH_F_VERSION_1     | \
      25                 :            :                 1ULL << ZXDH_F_RING_PACKED   | \
      26                 :            :                 1ULL << ZXDH_F_IN_ORDER      | \
      27                 :            :                 1ULL << ZXDH_F_NOTIFICATION_DATA | \
      28                 :            :                 1ULL << ZXDH_NET_F_MAC)
      29                 :            : 
      30                 :            : static void
      31                 :          0 : zxdh_read_dev_config(struct zxdh_hw *hw, size_t offset,
      32                 :            :                 void *dst, int32_t length)
      33                 :            : {
      34                 :            :         int32_t i       = 0;
      35                 :            :         uint8_t *p      = NULL;
      36                 :            :         uint8_t old_gen = 0;
      37                 :            :         uint8_t new_gen = 0;
      38                 :            : 
      39                 :            :         do {
      40                 :          0 :                 old_gen = rte_read8(&hw->common_cfg->config_generation);
      41                 :            : 
      42                 :            :                 p = dst;
      43         [ #  # ]:          0 :                 for (i = 0;  i < length; i++)
      44                 :          0 :                         *p++ = rte_read8((uint8_t *)hw->dev_cfg + offset + i);
      45                 :            : 
      46                 :          0 :                 new_gen = rte_read8(&hw->common_cfg->config_generation);
      47         [ #  # ]:          0 :         } while (old_gen != new_gen);
      48                 :          0 : }
      49                 :            : 
      50                 :            : static void
      51                 :          0 : zxdh_write_dev_config(struct zxdh_hw *hw, size_t offset,
      52                 :            :                 const void *src, int32_t length)
      53                 :            : {
      54                 :            :         int32_t i = 0;
      55                 :            :         const uint8_t *p = src;
      56                 :            : 
      57         [ #  # ]:          0 :         for (i = 0;  i < length; i++)
      58                 :          0 :                 rte_write8((*p++), (((uint8_t *)hw->dev_cfg) + offset + i));
      59                 :          0 : }
      60                 :            : 
      61                 :            : static uint8_t
      62                 :          0 : zxdh_get_status(struct zxdh_hw *hw)
      63                 :            : {
      64                 :          0 :         return rte_read8(&hw->common_cfg->device_status);
      65                 :            : }
      66                 :            : 
      67                 :            : static void
      68                 :          0 : zxdh_set_status(struct zxdh_hw *hw, uint8_t status)
      69                 :            : {
      70                 :          0 :         rte_write8(status, &hw->common_cfg->device_status);
      71                 :          0 : }
      72                 :            : 
      73                 :            : static uint64_t
      74                 :          0 : zxdh_get_features(struct zxdh_hw *hw)
      75                 :            : {
      76                 :            :         uint32_t features_lo = 0;
      77                 :            :         uint32_t features_hi = 0;
      78                 :            : 
      79                 :          0 :         rte_write32(0, &hw->common_cfg->device_feature_select);
      80                 :          0 :         features_lo = rte_read32(&hw->common_cfg->device_feature);
      81                 :            : 
      82                 :          0 :         rte_write32(1, &hw->common_cfg->device_feature_select);
      83                 :          0 :         features_hi = rte_read32(&hw->common_cfg->device_feature);
      84                 :            : 
      85                 :          0 :         return ((uint64_t)features_hi << 32) | features_lo;
      86                 :            : }
      87                 :            : 
      88                 :            : static void
      89                 :          0 : zxdh_set_features(struct zxdh_hw *hw, uint64_t features)
      90                 :            : {
      91                 :          0 :         rte_write32(0, &hw->common_cfg->guest_feature_select);
      92                 :          0 :         rte_write32(features & ((1ULL << 32) - 1), &hw->common_cfg->guest_feature);
      93                 :          0 :         rte_write32(1, &hw->common_cfg->guest_feature_select);
      94                 :          0 :         rte_write32(features >> 32, &hw->common_cfg->guest_feature);
      95                 :          0 : }
      96                 :            : 
      97                 :            : static uint16_t
      98                 :          0 : zxdh_set_config_irq(struct zxdh_hw *hw, uint16_t vec)
      99                 :            : {
     100                 :          0 :         rte_write16(vec, &hw->common_cfg->msix_config);
     101                 :          0 :         return rte_read16(&hw->common_cfg->msix_config);
     102                 :            : }
     103                 :            : 
     104                 :            : static uint16_t
     105                 :          0 : zxdh_set_queue_irq(struct zxdh_hw *hw, struct zxdh_virtqueue *vq, uint16_t vec)
     106                 :            : {
     107                 :          0 :         rte_write16(vq->vq_queue_index, &hw->common_cfg->queue_select);
     108                 :          0 :         rte_write16(vec, &hw->common_cfg->queue_msix_vector);
     109                 :          0 :         return rte_read16(&hw->common_cfg->queue_msix_vector);
     110                 :            : }
     111                 :            : 
     112                 :            : static uint8_t
     113                 :          0 : zxdh_get_isr(struct zxdh_hw *hw)
     114                 :            : {
     115                 :          0 :         return rte_read8(hw->isr);
     116                 :            : }
     117                 :            : 
     118                 :            : static uint16_t
     119                 :          0 : zxdh_get_queue_num(struct zxdh_hw *hw, uint16_t queue_id)
     120                 :            : {
     121                 :          0 :         rte_write16(queue_id, &hw->common_cfg->queue_select);
     122                 :          0 :         return rte_read16(&hw->common_cfg->queue_size);
     123                 :            : }
     124                 :            : 
     125                 :            : static void
     126                 :          0 : zxdh_set_queue_num(struct zxdh_hw *hw, uint16_t queue_id, uint16_t vq_size)
     127                 :            : {
     128                 :          0 :         rte_write16(queue_id, &hw->common_cfg->queue_select);
     129                 :          0 :         rte_write16(vq_size, &hw->common_cfg->queue_size);
     130                 :          0 : }
     131                 :            : 
     132                 :            : static int32_t
     133                 :          0 : check_vq_phys_addr_ok(struct zxdh_virtqueue *vq)
     134                 :            : {
     135         [ #  # ]:          0 :         if ((vq->vq_ring_mem + vq->vq_ring_size - 1) >> (ZXDH_PCI_QUEUE_ADDR_SHIFT + 32)) {
     136                 :          0 :                 PMD_DRV_LOG(ERR, "vring address shouldn't be above 16TB!");
     137                 :          0 :                 return 0;
     138                 :            :         }
     139                 :            :         return 1;
     140                 :            : }
     141                 :            : 
     142                 :            : static inline void
     143                 :            : io_write64_twopart(uint64_t val, uint32_t *lo, uint32_t *hi)
     144                 :            : {
     145                 :          0 :         rte_write32(val & ((1ULL << 32) - 1), lo);
     146                 :          0 :         rte_write32(val >> 32, hi);
     147                 :            : }
     148                 :            : 
     149                 :            : static int32_t
     150                 :          0 : zxdh_setup_queue(struct zxdh_hw *hw, struct zxdh_virtqueue *vq)
     151                 :            : {
     152                 :            :         uint64_t desc_addr  = 0;
     153                 :            :         uint64_t avail_addr = 0;
     154                 :            :         uint64_t used_addr  = 0;
     155                 :            :         uint16_t notify_off = 0;
     156                 :            : 
     157         [ #  # ]:          0 :         if (!check_vq_phys_addr_ok(vq))
     158                 :            :                 return -1;
     159                 :            : 
     160                 :          0 :         desc_addr = vq->vq_ring_mem;
     161                 :          0 :         avail_addr = desc_addr + vq->vq_nentries * sizeof(struct zxdh_vring_desc);
     162         [ #  # ]:          0 :         if (zxdh_pci_packed_queue(vq->hw)) {
     163                 :          0 :                 used_addr = RTE_ALIGN_CEIL((avail_addr +
     164                 :            :                                 sizeof(struct zxdh_vring_packed_desc_event)),
     165                 :            :                                 ZXDH_PCI_VRING_ALIGN);
     166                 :            :         } else {
     167                 :          0 :                 used_addr = RTE_ALIGN_CEIL(avail_addr + offsetof(struct zxdh_vring_avail,
     168                 :            :                                                 ring[vq->vq_nentries]), ZXDH_PCI_VRING_ALIGN);
     169                 :            :         }
     170                 :            : 
     171                 :          0 :         rte_write16(vq->vq_queue_index, &hw->common_cfg->queue_select);
     172                 :            : 
     173                 :            :         io_write64_twopart(desc_addr, &hw->common_cfg->queue_desc_lo,
     174                 :          0 :                                            &hw->common_cfg->queue_desc_hi);
     175                 :            :         io_write64_twopart(avail_addr, &hw->common_cfg->queue_avail_lo,
     176                 :          0 :                                            &hw->common_cfg->queue_avail_hi);
     177                 :            :         io_write64_twopart(used_addr, &hw->common_cfg->queue_used_lo,
     178                 :          0 :                                            &hw->common_cfg->queue_used_hi);
     179                 :            : 
     180                 :          0 :         notify_off = rte_read16(&hw->common_cfg->queue_notify_off); /* default 0 */
     181                 :            :         notify_off = 0;
     182                 :          0 :         vq->notify_addr = (void *)((uint8_t *)hw->notify_base +
     183                 :            :                         notify_off * hw->notify_off_multiplier);
     184                 :            : 
     185                 :          0 :         rte_write16(1, &hw->common_cfg->queue_enable);
     186                 :            : 
     187                 :          0 :         return 0;
     188                 :            : }
     189                 :            : 
     190                 :            : static void
     191                 :          0 : zxdh_del_queue(struct zxdh_hw *hw, struct zxdh_virtqueue *vq)
     192                 :            : {
     193                 :          0 :         rte_write16(vq->vq_queue_index, &hw->common_cfg->queue_select);
     194                 :            : 
     195                 :            :         io_write64_twopart(0, &hw->common_cfg->queue_desc_lo,
     196                 :          0 :                                            &hw->common_cfg->queue_desc_hi);
     197                 :            :         io_write64_twopart(0, &hw->common_cfg->queue_avail_lo,
     198                 :          0 :                                            &hw->common_cfg->queue_avail_hi);
     199                 :            :         io_write64_twopart(0, &hw->common_cfg->queue_used_lo,
     200                 :          0 :                                            &hw->common_cfg->queue_used_hi);
     201                 :            : 
     202                 :          0 :         rte_write16(0, &hw->common_cfg->queue_enable);
     203                 :          0 : }
     204                 :            : 
     205                 :            : static void
     206         [ #  # ]:          0 : zxdh_notify_queue(struct zxdh_hw *hw, struct zxdh_virtqueue *vq)
     207                 :            : {
     208                 :            :         uint32_t notify_data = 0;
     209                 :            : 
     210         [ #  # ]:          0 :         if (!zxdh_pci_with_feature(hw, ZXDH_F_NOTIFICATION_DATA)) {
     211                 :          0 :                 rte_write16(vq->vq_queue_index, vq->notify_addr);
     212                 :          0 :                 return;
     213                 :            :         }
     214                 :            : 
     215         [ #  # ]:          0 :         notify_data = ((uint32_t)vq->vq_avail_idx << 16) | vq->vq_queue_index;
     216         [ #  # ]:          0 :         if (zxdh_pci_with_feature(hw, ZXDH_F_RING_PACKED) &&
     217         [ #  # ]:          0 :                         (vq->vq_packed.cached_flags & ZXDH_VRING_PACKED_DESC_F_AVAIL))
     218                 :          0 :                 notify_data |= RTE_BIT32(31);
     219                 :            : 
     220                 :          0 :         PMD_DRV_LOG(DEBUG, "queue:%d notify_data 0x%x notify_addr 0x%p",
     221                 :            :                                  vq->vq_queue_index, notify_data, vq->notify_addr);
     222                 :          0 :         rte_write32(notify_data, vq->notify_addr);
     223                 :            : }
     224                 :            : 
     225                 :            : const struct zxdh_pci_ops zxdh_dev_pci_ops = {
     226                 :            :         .read_dev_cfg   = zxdh_read_dev_config,
     227                 :            :         .write_dev_cfg  = zxdh_write_dev_config,
     228                 :            :         .get_status     = zxdh_get_status,
     229                 :            :         .set_status     = zxdh_set_status,
     230                 :            :         .get_features   = zxdh_get_features,
     231                 :            :         .set_features   = zxdh_set_features,
     232                 :            :         .set_queue_irq  = zxdh_set_queue_irq,
     233                 :            :         .set_config_irq = zxdh_set_config_irq,
     234                 :            :         .get_isr        = zxdh_get_isr,
     235                 :            :         .get_queue_num  = zxdh_get_queue_num,
     236                 :            :         .set_queue_num  = zxdh_set_queue_num,
     237                 :            :         .setup_queue    = zxdh_setup_queue,
     238                 :            :         .del_queue      = zxdh_del_queue,
     239                 :            :         .notify_queue   = zxdh_notify_queue,
     240                 :            : };
     241                 :            : 
     242                 :            : uint8_t
     243                 :          0 : zxdh_pci_isr(struct zxdh_hw *hw)
     244                 :            : {
     245                 :          0 :         return ZXDH_VTPCI_OPS(hw)->get_isr(hw);
     246                 :            : }
     247                 :            : 
     248                 :            : uint16_t
     249                 :          0 : zxdh_pci_get_features(struct zxdh_hw *hw)
     250                 :            : {
     251                 :          0 :         return ZXDH_VTPCI_OPS(hw)->get_features(hw);
     252                 :            : }
     253                 :            : 
     254                 :            : void
     255                 :          0 : zxdh_pci_reset(struct zxdh_hw *hw)
     256                 :            : {
     257                 :          0 :         PMD_DRV_LOG(INFO, "port %u device start reset, just wait", hw->port_id);
     258                 :            :         uint32_t retry = 0;
     259                 :            : 
     260                 :          0 :         ZXDH_VTPCI_OPS(hw)->set_status(hw, ZXDH_CONFIG_STATUS_RESET);
     261                 :            :         /* Flush status write and wait device ready max 3 seconds. */
     262         [ #  # ]:          0 :         while (ZXDH_VTPCI_OPS(hw)->get_status(hw) != ZXDH_CONFIG_STATUS_RESET) {
     263                 :          0 :                 ++retry;
     264                 :            :                 rte_delay_ms(1);
     265                 :            :         }
     266                 :          0 :         PMD_DRV_LOG(INFO, "port %u device reset %u ms done", hw->port_id, retry);
     267                 :          0 : }
     268                 :            : 
     269                 :            : void
     270                 :          0 : zxdh_pci_reinit_complete(struct zxdh_hw *hw)
     271                 :            : {
     272                 :          0 :         zxdh_pci_set_status(hw, ZXDH_CONFIG_STATUS_DRIVER_OK);
     273                 :          0 : }
     274                 :            : 
     275                 :            : void
     276                 :          0 : zxdh_pci_set_status(struct zxdh_hw *hw, uint8_t status)
     277                 :            : {
     278         [ #  # ]:          0 :         if (status != ZXDH_CONFIG_STATUS_RESET)
     279                 :          0 :                 status |= ZXDH_VTPCI_OPS(hw)->get_status(hw);
     280                 :            : 
     281                 :          0 :         ZXDH_VTPCI_OPS(hw)->set_status(hw, status);
     282                 :          0 : }
     283                 :            : 
     284                 :            : static void
     285                 :          0 : *get_cfg_addr(struct rte_pci_device *dev, struct zxdh_pci_cap *cap)
     286                 :            : {
     287                 :          0 :         uint8_t  bar    = cap->bar;
     288                 :          0 :         uint32_t length = cap->length;
     289                 :          0 :         uint32_t offset = cap->offset;
     290                 :            : 
     291         [ #  # ]:          0 :         if (bar >= PCI_MAX_RESOURCE) {
     292                 :          0 :                 PMD_DRV_LOG(ERR, "invalid bar: %u", bar);
     293                 :          0 :                 return NULL;
     294                 :            :         }
     295         [ #  # ]:          0 :         if (offset + length < offset) {
     296                 :          0 :                 PMD_DRV_LOG(ERR, "offset(%u) + length(%u) overflows", offset, length);
     297                 :          0 :                 return NULL;
     298                 :            :         }
     299         [ #  # ]:          0 :         if (offset + length > dev->mem_resource[bar].len) {
     300                 :          0 :                 PMD_DRV_LOG(ERR, "invalid cap: overflows bar space");
     301                 :          0 :                 return NULL;
     302                 :            :         }
     303                 :          0 :         uint8_t *base = dev->mem_resource[bar].addr;
     304                 :            : 
     305         [ #  # ]:          0 :         if (base == NULL) {
     306                 :          0 :                 PMD_DRV_LOG(ERR, "bar %u base addr is NULL", bar);
     307                 :          0 :                 return NULL;
     308                 :            :         }
     309                 :          0 :         return base + offset;
     310                 :            : }
     311                 :            : 
     312                 :            : int32_t
     313                 :          0 : zxdh_read_pci_caps(struct rte_pci_device *dev, struct zxdh_hw *hw)
     314                 :            : {
     315                 :            :         struct zxdh_pci_cap cap;
     316                 :            :         uint8_t pos = 0;
     317                 :            :         int32_t ret = 0;
     318                 :            : 
     319         [ #  # ]:          0 :         if (dev->mem_resource[0].addr == NULL) {
     320                 :          0 :                 PMD_DRV_LOG(ERR, "bar0 base addr is NULL");
     321                 :          0 :                 return -1;
     322                 :            :         }
     323                 :            : 
     324                 :          0 :         hw->use_msix = zxdh_pci_msix_detect(dev);
     325                 :            : 
     326                 :          0 :         pos = rte_pci_find_capability(dev, RTE_PCI_CAP_ID_VNDR);
     327         [ #  # ]:          0 :         while (pos) {
     328                 :          0 :                 ret = rte_pci_read_config(dev, &cap, sizeof(cap), pos);
     329         [ #  # ]:          0 :                 if (ret != sizeof(cap)) {
     330                 :          0 :                         PMD_DRV_LOG(ERR, "failed to read pci cap at pos: %x ret %d", pos, ret);
     331                 :          0 :                         break;
     332                 :            :                 }
     333         [ #  # ]:          0 :                 if (cap.cap_vndr != RTE_PCI_CAP_ID_VNDR) {
     334                 :          0 :                         PMD_DRV_LOG(DEBUG, "[%2x] skipping non VNDR cap id: %02x",
     335                 :            :                                 pos, cap.cap_vndr);
     336                 :          0 :                         goto next;
     337                 :            :                 }
     338                 :          0 :                 PMD_DRV_LOG(DEBUG, "[%2x] cfg type: %u, bar: %u, offset: %04x, len: %u",
     339                 :            :                         pos, cap.cfg_type, cap.bar, cap.offset, cap.length);
     340                 :            : 
     341   [ #  #  #  #  :          0 :                 switch (cap.cfg_type) {
                   #  # ]
     342                 :          0 :                 case ZXDH_PCI_CAP_COMMON_CFG:
     343                 :          0 :                         hw->common_cfg = get_cfg_addr(dev, &cap);
     344                 :          0 :                         break;
     345                 :          0 :                 case ZXDH_PCI_CAP_NOTIFY_CFG: {
     346                 :          0 :                         ret = rte_pci_read_config(dev, &hw->notify_off_multiplier,
     347                 :          0 :                                                 4, pos + sizeof(cap));
     348         [ #  # ]:          0 :                         if (ret != 4)
     349                 :          0 :                                 PMD_DRV_LOG(ERR,
     350                 :            :                                         "failed to read notify_off_multiplier, ret %d", ret);
     351                 :            :                         else
     352                 :          0 :                                 hw->notify_base = get_cfg_addr(dev, &cap);
     353                 :            :                         break;
     354                 :            :                 }
     355                 :          0 :                 case ZXDH_PCI_CAP_DEVICE_CFG:
     356                 :          0 :                         hw->dev_cfg = get_cfg_addr(dev, &cap);
     357                 :          0 :                         break;
     358                 :          0 :                 case ZXDH_PCI_CAP_ISR_CFG:
     359                 :          0 :                         hw->isr = get_cfg_addr(dev, &cap);
     360                 :          0 :                         break;
     361                 :          0 :                 case ZXDH_PCI_CAP_PCI_CFG: {
     362                 :          0 :                         hw->pcie_id = *(uint16_t *)&cap.padding[1];
     363                 :          0 :                         PMD_DRV_LOG(DEBUG, "get pcie id 0x%x", hw->pcie_id);
     364                 :            : 
     365         [ #  # ]:          0 :                         if ((hw->pcie_id >> 11) & 0x1) /* PF */ {
     366                 :          0 :                                 PMD_DRV_LOG(DEBUG, "EP %u PF %u",
     367                 :            :                                         hw->pcie_id >> 12, (hw->pcie_id >> 8) & 0x7);
     368                 :            :                         } else { /* VF */
     369                 :          0 :                                 PMD_DRV_LOG(DEBUG, "EP %u PF %u VF %u",
     370                 :            :                                         hw->pcie_id >> 12,
     371                 :            :                                         (hw->pcie_id >> 8) & 0x7,
     372                 :            :                                         hw->pcie_id & 0xff);
     373                 :            :                         }
     374                 :            :                         break;
     375                 :            :                 }
     376                 :            :                 }
     377                 :          0 : next:
     378                 :          0 :         pos = cap.cap_next;
     379                 :            :         }
     380   [ #  #  #  # ]:          0 :         if (hw->common_cfg == NULL || hw->notify_base == NULL ||
     381   [ #  #  #  # ]:          0 :                 hw->dev_cfg == NULL || hw->isr == NULL) {
     382                 :          0 :                 PMD_DRV_LOG(ERR, "no zxdh pci device found");
     383                 :          0 :                 return -1;
     384                 :            :         }
     385                 :            :         return 0;
     386                 :            : }
     387                 :            : 
     388                 :            : void
     389                 :          0 : zxdh_pci_read_dev_config(struct zxdh_hw *hw, size_t offset, void *dst, int32_t length)
     390                 :            : {
     391                 :          0 :         ZXDH_VTPCI_OPS(hw)->read_dev_cfg(hw, offset, dst, length);
     392                 :          0 : }
     393                 :            : 
     394                 :            : void
     395                 :          0 : zxdh_get_pci_dev_config(struct zxdh_hw *hw)
     396                 :            : {
     397                 :            :         uint64_t guest_features = 0;
     398                 :            :         uint64_t nego_features = 0;
     399                 :          0 :         uint32_t max_queue_pairs = 0;
     400                 :            : 
     401                 :          0 :         hw->host_features = zxdh_pci_get_features(hw);
     402                 :            : 
     403                 :            :         guest_features = (uint64_t)ZXDH_PMD_DEFAULT_GUEST_FEATURES;
     404                 :          0 :         nego_features = guest_features & hw->host_features;
     405                 :            : 
     406                 :          0 :         hw->guest_features = nego_features;
     407                 :            : 
     408         [ #  # ]:          0 :         if (hw->guest_features & (1ULL << ZXDH_NET_F_MAC)) {
     409                 :          0 :                 zxdh_pci_read_dev_config(hw, offsetof(struct zxdh_net_config, mac),
     410                 :          0 :                                 &hw->mac_addr, RTE_ETHER_ADDR_LEN);
     411                 :            :         } else {
     412                 :          0 :                 rte_eth_random_addr(&hw->mac_addr[0]);
     413                 :            :         }
     414                 :            : 
     415                 :          0 :         zxdh_pci_read_dev_config(hw, offsetof(struct zxdh_net_config, max_virtqueue_pairs),
     416                 :            :                         &max_queue_pairs, sizeof(max_queue_pairs));
     417                 :            : 
     418         [ #  # ]:          0 :         if (max_queue_pairs == 0)
     419                 :          0 :                 hw->max_queue_pairs = ZXDH_RX_QUEUES_MAX;
     420                 :            :         else
     421                 :          0 :                 hw->max_queue_pairs = RTE_MIN(ZXDH_RX_QUEUES_MAX, max_queue_pairs);
     422                 :          0 :         PMD_DRV_LOG(DEBUG, "set max queue pairs %d", hw->max_queue_pairs);
     423                 :          0 : }
     424                 :            : 
     425                 :          0 : enum zxdh_msix_status zxdh_pci_msix_detect(struct rte_pci_device *dev)
     426                 :            : {
     427                 :          0 :         uint16_t flags = 0;
     428                 :            :         uint8_t pos = 0;
     429                 :            :         int16_t ret = 0;
     430                 :            : 
     431                 :          0 :         pos = rte_pci_find_capability(dev, RTE_PCI_CAP_ID_MSIX);
     432                 :            : 
     433         [ #  # ]:          0 :         if (pos > 0) {
     434                 :          0 :                 ret = rte_pci_read_config(dev, &flags, 2, pos + RTE_PCI_MSIX_FLAGS);
     435   [ #  #  #  # ]:          0 :                 if (ret == 2 && flags & RTE_PCI_MSIX_FLAGS_ENABLE)
     436                 :            :                         return ZXDH_MSIX_ENABLED;
     437                 :            :                 else
     438                 :          0 :                         return ZXDH_MSIX_DISABLED;
     439                 :            :         }
     440                 :            :         return ZXDH_MSIX_NONE;
     441                 :            : }

Generated by: LCOV version 1.14