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

Generated by: LCOV version 1.14