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

Generated by: LCOV version 1.14