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

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright (c) 2022 Marvell.
       3                 :            :  */
       4                 :            : 
       5                 :            : #include <dev_driver.h>
       6                 :            : #include <rte_eal.h>
       7                 :            : #include <rte_malloc.h>
       8                 :            : 
       9                 :            : #include "rte_mldev_pmd.h"
      10                 :            : 
      11                 :            : struct rte_ml_dev *
      12                 :          0 : rte_ml_dev_pmd_create(const char *name, struct rte_device *device,
      13                 :            :                       struct rte_ml_dev_pmd_init_params *params)
      14                 :            : {
      15                 :            :         struct rte_ml_dev *dev;
      16                 :            : 
      17                 :          0 :         RTE_MLDEV_LOG(INFO, "ML device initialisation - name: %s, socket_id: %u", name,
      18                 :            :                       params->socket_id);
      19                 :            : 
      20                 :            :         /* Allocate device structure */
      21                 :          0 :         dev = rte_ml_dev_pmd_allocate(name, params->socket_id);
      22         [ #  # ]:          0 :         if (dev == NULL) {
      23                 :          0 :                 RTE_MLDEV_LOG(ERR, "Failed to allocate ML device for %s", name);
      24                 :          0 :                 return NULL;
      25                 :            :         }
      26                 :            : 
      27                 :            :         /* Allocate private device structure */
      28         [ #  # ]:          0 :         if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
      29                 :          0 :                 dev->data->dev_private =
      30                 :          0 :                         rte_zmalloc_socket("ml_dev_private", params->private_data_size,
      31                 :          0 :                                            RTE_CACHE_LINE_SIZE, params->socket_id);
      32                 :            : 
      33         [ #  # ]:          0 :                 if (dev->data->dev_private == NULL) {
      34                 :          0 :                         RTE_MLDEV_LOG(ERR, "Cannot allocate memory for mldev %s private data",
      35                 :            :                                       name);
      36                 :          0 :                         rte_ml_dev_pmd_release(dev);
      37                 :          0 :                         return NULL;
      38                 :            :                 }
      39                 :            :         }
      40                 :          0 :         dev->device = device;
      41                 :            : 
      42                 :          0 :         return dev;
      43                 :            : }
      44                 :            : 
      45                 :            : int
      46                 :          0 : rte_ml_dev_pmd_destroy(struct rte_ml_dev *dev)
      47                 :            : {
      48                 :            :         int ret;
      49                 :            : 
      50                 :          0 :         RTE_MLDEV_LOG(INFO, "Releasing ML device - name: %s", dev->device->name);
      51                 :          0 :         ret = rte_ml_dev_pmd_release(dev);
      52         [ #  # ]:          0 :         if (ret)
      53                 :            :                 return ret;
      54                 :            : 
      55         [ #  # ]:          0 :         if (rte_eal_process_type() == RTE_PROC_PRIMARY)
      56                 :          0 :                 rte_free(dev->data->dev_private);
      57                 :            : 
      58                 :          0 :         dev->data = NULL;
      59                 :          0 :         dev->device = NULL;
      60                 :            : 
      61                 :          0 :         return 0;
      62                 :            : }

Generated by: LCOV version 1.14