LCOV - code coverage report
Current view: top level - drivers/net/hinic3/base - hinic3_hwdev.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 203 0.0 %
Date: 2026-11-01 19:11:22 Functions: 0 20 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 82 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright(c) 2025 Huawei Technologies Co., Ltd
       3                 :            :  */
       4                 :            : 
       5                 :            : #include <dev_vfio.h>
       6                 :            : 
       7                 :            : #include "hinic3_compat.h"
       8                 :            : #include "hinic3_cmd.h"
       9                 :            : #include "hinic3_cmdq.h"
      10                 :            : #include "hinic3_csr.h"
      11                 :            : #include "hinic3_eqs.h"
      12                 :            : #include "hinic3_hw_cfg.h"
      13                 :            : #include "hinic3_hw_comm.h"
      14                 :            : #include "hinic3_hwdev.h"
      15                 :            : #include "hinic3_hwif.h"
      16                 :            : #include "hinic3_mbox.h"
      17                 :            : #include "hinic3_mgmt.h"
      18                 :            : #include "hinic3_wq.h"
      19                 :            : #include "hinic3_nic_cfg.h"
      20                 :            : 
      21                 :            : enum hinic3_pcie_nosnoop { HINIC3_PCIE_SNOOP = 0, HINIC3_PCIE_NO_SNOOP = 1 };
      22                 :            : 
      23                 :            : enum hinic3_pcie_tph {
      24                 :            :         HINIC3_PCIE_TPH_DISABLE = 0,
      25                 :            :         HINIC3_PCIE_TPH_ENABLE = 1
      26                 :            : };
      27                 :            : 
      28                 :            : #define HINIC3_DMA_ATTR_INDIR_IDX_SHIFT 0
      29                 :            : 
      30                 :            : #define HINIC3_DMA_ATTR_INDIR_IDX_MASK 0x3FF
      31                 :            : 
      32                 :            : #define HINIC3_DMA_ATTR_INDIR_IDX_SET(val, member)            \
      33                 :            :         (((uint32_t)(val) & HINIC3_DMA_ATTR_INDIR_##member##_MASK) \
      34                 :            :          << HINIC3_DMA_ATTR_INDIR_##member##_SHIFT)
      35                 :            : 
      36                 :            : #define HINIC3_DMA_ATTR_INDIR_IDX_CLEAR(val, member)      \
      37                 :            :         ((val) & (~(HINIC3_DMA_ATTR_INDIR_##member##_MASK \
      38                 :            :                     << HINIC3_DMA_ATTR_INDIR_##member##_SHIFT)))
      39                 :            : 
      40                 :            : #define HINIC3_DMA_ATTR_ENTRY_ST_SHIFT          0
      41                 :            : #define HINIC3_DMA_ATTR_ENTRY_AT_SHIFT          8
      42                 :            : #define HINIC3_DMA_ATTR_ENTRY_PH_SHIFT          10
      43                 :            : #define HINIC3_DMA_ATTR_ENTRY_NO_SNOOPING_SHIFT 12
      44                 :            : #define HINIC3_DMA_ATTR_ENTRY_TPH_EN_SHIFT      13
      45                 :            : 
      46                 :            : #define HINIC3_DMA_ATTR_ENTRY_ST_MASK          0xFF
      47                 :            : #define HINIC3_DMA_ATTR_ENTRY_AT_MASK          0x3
      48                 :            : #define HINIC3_DMA_ATTR_ENTRY_PH_MASK          0x3
      49                 :            : #define HINIC3_DMA_ATTR_ENTRY_NO_SNOOPING_MASK 0x1
      50                 :            : #define HINIC3_DMA_ATTR_ENTRY_TPH_EN_MASK      0x1
      51                 :            : 
      52                 :            : #define HINIC3_DMA_ATTR_ENTRY_SET(val, member)                \
      53                 :            :         (((uint32_t)(val) & HINIC3_DMA_ATTR_ENTRY_##member##_MASK) \
      54                 :            :          << HINIC3_DMA_ATTR_ENTRY_##member##_SHIFT)
      55                 :            : 
      56                 :            : #define HINIC3_DMA_ATTR_ENTRY_CLEAR(val, member)          \
      57                 :            :         ((val) & (~(HINIC3_DMA_ATTR_ENTRY_##member##_MASK \
      58                 :            :                     << HINIC3_DMA_ATTR_ENTRY_##member##_SHIFT)))
      59                 :            : 
      60                 :            : #define HINIC3_PCIE_ST_DISABLE 0
      61                 :            : #define HINIC3_PCIE_AT_DISABLE 0
      62                 :            : #define HINIC3_PCIE_PH_DISABLE 0
      63                 :            : 
      64                 :            : #define PCIE_MSIX_ATTR_ENTRY 0
      65                 :            : 
      66                 :            : #define HINIC3_DEFAULT_EQ_MSIX_PENDING_LIMIT    0
      67                 :            : #define HINIC3_DEFAULT_EQ_MSIX_COALESCE_TIMER_CFG 0xFF
      68                 :            : #define HINIC3_DEFAULT_EQ_MSIX_RESEND_TIMER_CFG 7
      69                 :            : typedef void (*mgmt_event_cb)(struct hinic3_hwdev *hwdev, struct hinic3_handler_info *handler_info);
      70                 :            : 
      71                 :            : struct mgmt_event_handle {
      72                 :            :         uint16_t cmd;
      73                 :            :         mgmt_event_cb proc;
      74                 :            : };
      75                 :            : 
      76                 :            : bool
      77                 :          0 : hinic3_is_vfio_iommu_enable(const struct rte_eth_dev *eth_dev)
      78                 :            : {
      79                 :          0 :         struct rte_pci_device *pci_dev = RTE_CLASS_TO_BUS_DEVICE(eth_dev, *pci_dev);
      80                 :            : 
      81   [ #  #  #  # ]:          0 :         return pci_dev->kdrv == RTE_PCI_KDRV_VFIO &&
      82                 :          0 :                         dev_vfio_get_iova_mode() == DEV_VFIO_IOVA_MODE_VA;
      83                 :            : }
      84                 :            : 
      85                 :            : int
      86                 :          0 : hinic3_vf_handle_pf_comm_mbox(struct hinic3_hwdev *hwdev, __rte_unused void *pri_handle,
      87                 :            :                               struct hinic3_handler_info *handler_info)
      88                 :            : {
      89         [ #  # ]:          0 :         if (!hwdev)
      90                 :            :                 return -EINVAL;
      91                 :            : 
      92                 :          0 :         PMD_DRV_LOG(WARNING, "Unsupported pf mbox event %d to process", handler_info->cmd);
      93                 :            : 
      94                 :          0 :         return 0;
      95                 :            : }
      96                 :            : 
      97                 :            : static void
      98                 :          0 : fault_event_handler(__rte_unused struct hinic3_hwdev *hwdev,
      99                 :            :                     __rte_unused struct hinic3_handler_info *handler_info)
     100                 :            : {
     101                 :          0 :         PMD_DRV_LOG(WARNING, "Unsupported fault event handler");
     102                 :          0 : }
     103                 :            : 
     104                 :            : static void
     105                 :          0 : ffm_event_msg_handler(__rte_unused struct hinic3_hwdev *hwdev,
     106                 :            :                       struct hinic3_handler_info *handler_info)
     107                 :            : {
     108                 :          0 :         struct ffm_intr_info *intr = handler_info->buf_in;
     109                 :            : 
     110         [ #  # ]:          0 :         if (handler_info->in_size != sizeof(*intr)) {
     111                 :          0 :                 PMD_DRV_LOG(ERR,
     112                 :            :                             "Invalid fault event report, length: %d, should be %zu",
     113                 :            :                             handler_info->in_size, sizeof(*intr));
     114                 :          0 :                 return;
     115                 :            :         }
     116                 :            : 
     117                 :          0 :         PMD_DRV_LOG(ERR,
     118                 :            :                     "node_id: 0x%x, err_type: 0x%x, err_level: %d, err_csr_addr: 0x%08x, err_csr_value: 0x%08x",
     119                 :            :                     intr->node_id, intr->err_type, intr->err_level,
     120                 :            :                     intr->err_csr_addr, intr->err_csr_value);
     121                 :            : 
     122                 :          0 :         *handler_info->out_size = sizeof(*intr);
     123                 :            : }
     124                 :            : 
     125                 :            : static const struct mgmt_event_handle mgmt_event_proc[] = {
     126                 :            :         {
     127                 :            :                 .cmd = HINIC3_MGMT_CMD_FAULT_REPORT,
     128                 :            :                 .proc = fault_event_handler,
     129                 :            :         },
     130                 :            : 
     131                 :            :         {
     132                 :            :                 .cmd = HINIC3_MGMT_CMD_FFM_SET,
     133                 :            :                 .proc = ffm_event_msg_handler,
     134                 :            :         },
     135                 :            : };
     136                 :            : 
     137                 :            : void
     138                 :          0 : hinic3_pf_handle_mgmt_comm_event(struct hinic3_hwdev *hwdev, __rte_unused void *pri_handle,
     139                 :            :                                   struct hinic3_handler_info *handler_info)
     140                 :            : {
     141                 :            :         uint32_t i, event_num = RTE_DIM(mgmt_event_proc);
     142                 :            : 
     143         [ #  # ]:          0 :         if (!hwdev)
     144                 :            :                 return;
     145                 :            : 
     146         [ #  # ]:          0 :         for (i = 0; i < event_num; i++) {
     147         [ #  # ]:          0 :                 if (handler_info->cmd == mgmt_event_proc[i].cmd) {
     148         [ #  # ]:          0 :                         if (mgmt_event_proc[i].proc)
     149                 :          0 :                                 mgmt_event_proc[i].proc(hwdev, handler_info);
     150                 :          0 :                         return;
     151                 :            :                 }
     152                 :            :         }
     153                 :            : 
     154                 :          0 :         PMD_DRV_LOG(WARNING, "Unsupported mgmt cpu event %d to process", handler_info->cmd);
     155                 :            : }
     156                 :            : 
     157                 :            : static int
     158                 :          0 : set_dma_attr_entry(struct hinic3_hwdev *hwdev,
     159                 :            :                     uint8_t entry_idx,  uint8_t st,
     160                 :            :                     uint8_t at,  uint8_t ph,
     161                 :            :                     enum hinic3_pcie_nosnoop no_snooping,
     162                 :            :                     enum hinic3_pcie_tph tph_en)
     163                 :            : {
     164                 :            :         struct hinic3_dma_attr_table attr;
     165                 :          0 :         uint16_t out_size = sizeof(attr);
     166                 :            :         int err;
     167                 :            : 
     168                 :            :         memset(&attr, 0, sizeof(attr));
     169                 :          0 :         attr.func_id = hinic3_global_func_id(hwdev);
     170                 :          0 :         attr.entry_idx = entry_idx;
     171                 :          0 :         attr.st = st;
     172                 :          0 :         attr.at = at;
     173                 :          0 :         attr.ph = ph;
     174                 :          0 :         attr.no_snooping = no_snooping;
     175                 :          0 :         attr.tph_en = tph_en;
     176                 :            : 
     177                 :          0 :         err = hinic3_msg_to_mgmt_sync(hwdev, HINIC3_MOD_COMM,
     178                 :            :                                       HINIC3_MGMT_CMD_SET_DMA_ATTR, &attr,
     179                 :            :                                       sizeof(attr), &attr, &out_size);
     180   [ #  #  #  #  :          0 :         if (err || !out_size || attr.head.status) {
                   #  # ]
     181                 :          0 :                 PMD_DRV_LOG(ERR,
     182                 :            :                             "Set dma attribute failed, err: %d, status: 0x%x, out_size: 0x%x",
     183                 :            :                             err, attr.head.status, out_size);
     184                 :          0 :                 return -EIO;
     185                 :            :         }
     186                 :            : 
     187                 :            :         return 0;
     188                 :            : }
     189                 :            : 
     190                 :            : /**
     191                 :            :  * Initialize the default dma attributes.
     192                 :            :  *
     193                 :            :  * @param[in] hwdev
     194                 :            :  * Pointer to hardware device structure.
     195                 :            :  *
     196                 :            :  * 0 on success, non-zero on failure.
     197                 :            :  */
     198                 :            : static int
     199                 :            : dma_attr_table_init(struct hinic3_hwdev *hwdev)
     200                 :            : {
     201                 :          0 :         return set_dma_attr_entry(hwdev,
     202                 :            :                 PCIE_MSIX_ATTR_ENTRY, HINIC3_PCIE_ST_DISABLE,
     203                 :            :                 HINIC3_PCIE_AT_DISABLE, HINIC3_PCIE_PH_DISABLE,
     204                 :            :                 HINIC3_PCIE_SNOOP, HINIC3_PCIE_TPH_DISABLE);
     205                 :            : }
     206                 :            : 
     207                 :            : static int
     208                 :          0 : init_aeqs_msix_attr(struct hinic3_hwdev *hwdev)
     209                 :            : {
     210                 :          0 :         struct hinic3_aeqs *aeqs = hwdev->aeqs;
     211                 :          0 :         struct interrupt_info info = {0};
     212                 :            :         struct hinic3_eq *eq = NULL;
     213                 :            :         uint16_t q_id;
     214                 :            :         int err;
     215                 :            : 
     216                 :            :         info.lli_set = 0;
     217                 :          0 :         info.interrupt_coalesce_set = 1;
     218                 :            :         info.pending_limt = HINIC3_DEFAULT_EQ_MSIX_PENDING_LIMIT;
     219                 :          0 :         info.coalesce_timer_cfg = HINIC3_DEFAULT_EQ_MSIX_COALESCE_TIMER_CFG;
     220                 :          0 :         info.resend_timer_cfg = HINIC3_DEFAULT_EQ_MSIX_RESEND_TIMER_CFG;
     221                 :            : 
     222         [ #  # ]:          0 :         for (q_id = 0; q_id < aeqs->num_aeqs; q_id++) {
     223                 :          0 :                 eq = &aeqs->aeq[q_id];
     224                 :          0 :                 info.msix_index = eq->eq_irq.msix_entry_idx;
     225                 :          0 :                 err = hinic3_set_interrupt_cfg(hwdev, info);
     226         [ #  # ]:          0 :                 if (err) {
     227                 :          0 :                         PMD_DRV_LOG(ERR, "Set msix attr for aeq %d failed", q_id);
     228                 :          0 :                         return -EFAULT;
     229                 :            :                 }
     230                 :            :         }
     231                 :            : 
     232                 :            :         return 0;
     233                 :            : }
     234                 :            : 
     235                 :            : static int
     236                 :          0 : hinic3_comm_pf_to_mgmt_init(struct hinic3_hwdev *hwdev)
     237                 :            : {
     238                 :            :         int err;
     239                 :            : 
     240                 :            :         /* VF does not support send msg to mgmt directly. */
     241         [ #  # ]:          0 :         if (hinic3_func_type(hwdev) == TYPE_VF)
     242                 :            :                 return 0;
     243                 :            : 
     244                 :          0 :         err = hinic3_pf_to_mgmt_init(hwdev);
     245         [ #  # ]:          0 :         if (err)
     246                 :          0 :                 return err;
     247                 :            : 
     248                 :            :         return 0;
     249                 :            : }
     250                 :            : 
     251                 :            : static void
     252                 :          0 : hinic3_comm_pf_to_mgmt_free(struct hinic3_hwdev *hwdev)
     253                 :            : {
     254                 :            :         /* VF does not support send msg to mgmt directly. */
     255         [ #  # ]:          0 :         if (hinic3_func_type(hwdev) == TYPE_VF)
     256                 :            :                 return;
     257                 :            : 
     258                 :          0 :         hinic3_pf_to_mgmt_free(hwdev);
     259                 :            : }
     260                 :            : 
     261                 :            : static int
     262                 :          0 : hinic3_comm_cmdqs_init(struct hinic3_hwdev *hwdev)
     263                 :            : {
     264                 :            :         int err;
     265                 :            : 
     266                 :          0 :         err = hinic3_cmdq_init(hwdev);
     267         [ #  # ]:          0 :         if (err) {
     268                 :          0 :                 PMD_DRV_LOG(ERR, "Init cmd queues failed");
     269                 :          0 :                 return err;
     270                 :            :         }
     271                 :            : 
     272                 :          0 :         err = hinic3_set_cmdq_depth(hwdev, HINIC3_CMDQ_DEPTH);
     273         [ #  # ]:          0 :         if (err) {
     274                 :          0 :                 PMD_DRV_LOG(ERR, "Set cmdq depth failed");
     275                 :          0 :                 goto set_cmdq_depth_err;
     276                 :            :         }
     277                 :            : 
     278                 :            :         return 0;
     279                 :            : 
     280                 :            : set_cmdq_depth_err:
     281                 :          0 :         hinic3_cmdqs_free(hwdev);
     282                 :            : 
     283                 :          0 :         return err;
     284                 :            : }
     285                 :            : 
     286                 :            : static void
     287                 :            : hinic3_comm_cmdqs_free(struct hinic3_hwdev *hwdev)
     288                 :            : {
     289                 :          0 :         hinic3_cmdqs_free(hwdev);
     290                 :            : }
     291                 :            : 
     292                 :            : static void
     293                 :            : hinic3_sync_mgmt_func_state(struct hinic3_hwdev *hwdev)
     294                 :            : {
     295                 :          0 :         hinic3_set_pf_status(hwdev->hwif, HINIC3_PF_STATUS_ACTIVE_FLAG);
     296                 :            : }
     297                 :            : 
     298                 :            : static int
     299                 :          0 : get_func_misc_info(struct hinic3_hwdev *hwdev)
     300                 :            : {
     301                 :            :         int err;
     302                 :            : 
     303                 :          0 :         err = hinic3_get_board_info(hwdev, &hwdev->board_info);
     304         [ #  # ]:          0 :         if (err) {
     305                 :            :                 /* For the PF/VF of secondary host, return error. */
     306         [ #  # ]:          0 :                 if (hinic3_pcie_itf_id(hwdev))
     307                 :            :                         return err;
     308                 :            : 
     309                 :            :                 memset(&hwdev->board_info, 0xff,
     310                 :            :                        sizeof(struct hinic3_board_info));
     311                 :            :         }
     312                 :            : 
     313                 :          0 :         err = hinic3_get_mgmt_version(hwdev, hwdev->mgmt_ver,
     314                 :            :                                       HINIC3_MGMT_VERSION_MAX_LEN);
     315         [ #  # ]:          0 :         if (err) {
     316                 :          0 :                 PMD_DRV_LOG(ERR, "Get mgmt cpu version failed");
     317                 :          0 :                 return err;
     318                 :            :         }
     319                 :            : 
     320                 :            :         return 0;
     321                 :            : }
     322                 :            : 
     323                 :            : static int
     324                 :          0 : init_mgmt_channel(struct hinic3_hwdev *hwdev)
     325                 :            : {
     326                 :            :         int err;
     327                 :            : 
     328                 :          0 :         err = hinic3_aeqs_init(hwdev);
     329         [ #  # ]:          0 :         if (err) {
     330                 :          0 :                 PMD_DRV_LOG(ERR, "Init async event queues failed");
     331                 :          0 :                 return err;
     332                 :            :         }
     333                 :            : 
     334                 :          0 :         err = hinic3_comm_pf_to_mgmt_init(hwdev);
     335         [ #  # ]:          0 :         if (err) {
     336                 :          0 :                 PMD_DRV_LOG(ERR, "Init mgmt channel failed");
     337                 :          0 :                 goto msg_init_err;
     338                 :            :         }
     339                 :            : 
     340                 :          0 :         err = hinic3_func_to_func_init(hwdev);
     341         [ #  # ]:          0 :         if (err) {
     342                 :          0 :                 PMD_DRV_LOG(ERR, "Init mailbox channel failed");
     343                 :          0 :                 goto func_to_func_init_err;
     344                 :            :         }
     345                 :            : 
     346                 :            :         return 0;
     347                 :            : 
     348                 :            : func_to_func_init_err:
     349                 :          0 :         hinic3_comm_pf_to_mgmt_free(hwdev);
     350                 :            : 
     351                 :          0 : msg_init_err:
     352                 :          0 :         hinic3_aeqs_free(hwdev);
     353                 :            : 
     354                 :          0 :         return err;
     355                 :            : }
     356                 :            : 
     357                 :            : static void
     358                 :          0 : free_mgmt_channel(struct hinic3_hwdev *hwdev)
     359                 :            : {
     360                 :          0 :         hinic3_func_to_func_free(hwdev);
     361                 :          0 :         hinic3_comm_pf_to_mgmt_free(hwdev);
     362                 :          0 :         hinic3_aeqs_free(hwdev);
     363                 :          0 : }
     364                 :            : 
     365                 :            : static int
     366                 :          0 : init_cmdqs_channel(struct hinic3_hwdev *hwdev)
     367                 :            : {
     368                 :            :         int err;
     369                 :            : 
     370                 :            :         err = dma_attr_table_init(hwdev);
     371         [ #  # ]:          0 :         if (err) {
     372                 :          0 :                 PMD_DRV_LOG(ERR, "Init dma attr table failed");
     373                 :          0 :                 goto dma_attr_init_err;
     374                 :            :         }
     375                 :            : 
     376                 :          0 :         err = init_aeqs_msix_attr(hwdev);
     377         [ #  # ]:          0 :         if (err)
     378                 :          0 :                 goto init_aeqs_msix_err;
     379                 :            : 
     380                 :            :         /* Set default wq page_size. */
     381                 :          0 :         hwdev->wq_page_size = HINIC3_DEFAULT_WQ_PAGE_SIZE;
     382                 :          0 :         err = hinic3_set_wq_page_size(hwdev, hinic3_global_func_id(hwdev),
     383                 :            :                                       hwdev->wq_page_size);
     384         [ #  # ]:          0 :         if (err) {
     385                 :          0 :                 PMD_DRV_LOG(ERR, "Set wq page size failed");
     386                 :          0 :                 goto init_wq_pg_size_err;
     387                 :            :         }
     388                 :            : 
     389                 :          0 :         err = hinic3_comm_cmdqs_init(hwdev);
     390         [ #  # ]:          0 :         if (err) {
     391                 :          0 :                 PMD_DRV_LOG(ERR, "Init cmd queues failed");
     392                 :          0 :                 goto cmdq_init_err;
     393                 :            :         }
     394                 :            : 
     395                 :            :         return 0;
     396                 :            : 
     397                 :            : cmdq_init_err:
     398         [ #  # ]:          0 :         if (HINIC3_FUNC_TYPE(hwdev) != TYPE_VF)
     399                 :          0 :                 hinic3_set_wq_page_size(hwdev, hinic3_global_func_id(hwdev),
     400                 :            :                                         HINIC3_HW_WQ_PAGE_SIZE);
     401                 :          0 : init_wq_pg_size_err:
     402                 :            : init_aeqs_msix_err:
     403                 :            : dma_attr_init_err:
     404                 :            : 
     405                 :            :         return err;
     406                 :            : }
     407                 :            : 
     408                 :            : static int
     409                 :          0 : hinic3_init_comm_ch(struct hinic3_hwdev *hwdev)
     410                 :            : {
     411                 :            :         int err;
     412                 :            : 
     413                 :          0 :         err = init_mgmt_channel(hwdev);
     414         [ #  # ]:          0 :         if (err) {
     415                 :          0 :                 PMD_DRV_LOG(ERR, "Init mgmt channel failed");
     416                 :          0 :                 return err;
     417                 :            :         }
     418                 :            : 
     419                 :          0 :         err = get_func_misc_info(hwdev);
     420         [ #  # ]:          0 :         if (err) {
     421                 :          0 :                 PMD_DRV_LOG(ERR, "Get function msic information failed");
     422                 :          0 :                 goto get_func_info_err;
     423                 :            :         }
     424                 :            : 
     425                 :          0 :         err = hinic3_func_reset(hwdev, HINIC3_NIC_RES | HINIC3_COMM_RES);
     426         [ #  # ]:          0 :         if (err) {
     427                 :          0 :                 PMD_DRV_LOG(ERR, "Reset function failed");
     428                 :          0 :                 goto func_reset_err;
     429                 :            :         }
     430                 :            : 
     431                 :          0 :         err = hinic3_get_comm_features(hwdev, hwdev->features, HINIC3_MAX_FEATURE_QWORD);
     432         [ #  # ]:          0 :         if (err) {
     433                 :          0 :                 PMD_DRV_LOG(ERR, "Get comm features failed");
     434                 :          0 :                 goto get_common_features_err;
     435                 :            :         }
     436                 :            : 
     437                 :          0 :         err = hinic3_set_func_svc_used_state(hwdev, HINIC3_MOD_COMM, 1);
     438         [ #  # ]:          0 :         if (err)
     439                 :          0 :                 goto set_used_state_err;
     440                 :            : 
     441                 :          0 :         err = init_cmdqs_channel(hwdev);
     442         [ #  # ]:          0 :         if (err) {
     443                 :          0 :                 PMD_DRV_LOG(ERR, "Init cmdq channel failed");
     444                 :          0 :                 goto init_cmdqs_channel_err;
     445                 :            :         }
     446                 :            : 
     447                 :            :         hinic3_sync_mgmt_func_state(hwdev);
     448                 :            : 
     449                 :          0 :         return 0;
     450                 :            : 
     451                 :            : init_cmdqs_channel_err:
     452                 :          0 :         hinic3_set_func_svc_used_state(hwdev, HINIC3_MOD_COMM, 0);
     453                 :          0 : set_used_state_err:
     454                 :          0 : func_reset_err:
     455                 :          0 : get_common_features_err:
     456                 :          0 : get_func_info_err:
     457                 :          0 :         free_mgmt_channel(hwdev);
     458                 :            : 
     459                 :          0 :         return err;
     460                 :            : }
     461                 :            : 
     462                 :            : static void
     463                 :          0 : hinic3_uninit_comm_ch(struct hinic3_hwdev *hwdev)
     464                 :            : {
     465                 :          0 :         hinic3_set_pf_status(hwdev->hwif, HINIC3_PF_STATUS_INIT);
     466                 :            : 
     467                 :            :         hinic3_comm_cmdqs_free(hwdev);
     468                 :            : 
     469         [ #  # ]:          0 :         if (HINIC3_FUNC_TYPE(hwdev) != TYPE_VF)
     470                 :          0 :                 hinic3_set_wq_page_size(hwdev, hinic3_global_func_id(hwdev),
     471                 :            :                                         HINIC3_HW_WQ_PAGE_SIZE);
     472                 :            : 
     473                 :          0 :         hinic3_set_func_svc_used_state(hwdev, HINIC3_MOD_COMM, 0);
     474                 :            : 
     475                 :          0 :         hinic3_func_to_func_free(hwdev);
     476                 :            : 
     477                 :          0 :         hinic3_comm_pf_to_mgmt_free(hwdev);
     478                 :            : 
     479                 :          0 :         hinic3_aeqs_free(hwdev);
     480                 :          0 : }
     481                 :            : 
     482                 :            : int
     483                 :          0 : hinic3_init_hwdev(struct hinic3_hwdev *hwdev)
     484                 :            : {
     485                 :            :         int err;
     486                 :            : 
     487                 :          0 :         hwdev->chip_fault_stats = rte_zmalloc("chip_fault_stats",
     488                 :            :                                               HINIC3_CHIP_FAULT_SIZE,
     489                 :            :                                               RTE_CACHE_LINE_SIZE);
     490         [ #  # ]:          0 :         if (!hwdev->chip_fault_stats) {
     491                 :          0 :                 PMD_DRV_LOG(ERR, "Alloc memory for chip_fault_stats failed");
     492                 :          0 :                 return -ENOMEM;
     493                 :            :         }
     494                 :            : 
     495                 :          0 :         err = hinic3_init_hwif(hwdev);
     496         [ #  # ]:          0 :         if (err) {
     497                 :          0 :                 PMD_DRV_LOG(ERR, "Initialize hwif failed");
     498                 :          0 :                 goto init_hwif_err;
     499                 :            :         }
     500                 :            : 
     501                 :          0 :         err = hinic3_init_comm_ch(hwdev);
     502         [ #  # ]:          0 :         if (err) {
     503                 :          0 :                 PMD_DRV_LOG(ERR, "Init communication channel failed");
     504                 :          0 :                 goto init_comm_ch_err;
     505                 :            :         }
     506                 :            : 
     507                 :          0 :         err = hinic3_init_cfg_mgmt(hwdev);
     508         [ #  # ]:          0 :         if (err) {
     509                 :          0 :                 PMD_DRV_LOG(ERR, "Init cfg_mgnt failed");
     510                 :          0 :                 goto init_cfg_err;
     511                 :            :         }
     512                 :            : 
     513                 :          0 :         err = hinic3_init_capability(hwdev);
     514         [ #  # ]:          0 :         if (err) {
     515                 :          0 :                 PMD_DRV_LOG(ERR, "Init capability failed");
     516                 :          0 :                 goto init_cap_err;
     517                 :            :         }
     518                 :            : 
     519                 :            :         return 0;
     520                 :            : 
     521                 :            : init_cap_err:
     522                 :          0 :         hinic3_deinit_cfg_mgmt(hwdev);
     523                 :          0 : init_cfg_err:
     524                 :          0 :         hinic3_uninit_comm_ch(hwdev);
     525                 :            : 
     526                 :          0 : init_comm_ch_err:
     527                 :          0 :         hinic3_deinit_hwif(hwdev);
     528                 :            : 
     529                 :          0 : init_hwif_err:
     530                 :          0 :         rte_free(hwdev->chip_fault_stats);
     531                 :            : 
     532                 :          0 :         return -EFAULT;
     533                 :            : }
     534                 :            : 
     535                 :            : void
     536                 :          0 : hinic3_free_hwdev(struct hinic3_hwdev *hwdev)
     537                 :            : {
     538                 :          0 :         hinic3_deinit_cfg_mgmt(hwdev);
     539                 :            : 
     540                 :          0 :         hinic3_uninit_comm_ch(hwdev);
     541                 :            : 
     542                 :          0 :         hinic3_deinit_hwif(hwdev);
     543                 :            : 
     544                 :          0 :         rte_free(hwdev->chip_fault_stats);
     545                 :          0 : }
     546                 :            : 
     547                 :            : const struct rte_memzone *
     548                 :          0 : hinic3_dma_zone_reserve(const struct rte_eth_dev *dev, const char *ring_name,
     549                 :            :                         uint16_t queue_id, size_t size, unsigned int align, int socket_id)
     550                 :            : {
     551                 :          0 :         return rte_eth_dma_zone_reserve(dev, ring_name, queue_id, size, align, socket_id);
     552                 :            : }
     553                 :            : 
     554                 :            : int
     555                 :          0 : hinic3_memzone_free(const struct rte_memzone *mz)
     556                 :            : {
     557                 :          0 :         return rte_memzone_free(mz);
     558                 :            : }

Generated by: LCOV version 1.14