LCOV - code coverage report
Current view: top level - drivers/net/nfp - nfp_service.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 22 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 12 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright (c) 2023 Corigine, Inc.
       3                 :            :  * All rights reserved.
       4                 :            :  */
       5                 :            : 
       6                 :            : #include "nfp_service.h"
       7                 :            : 
       8                 :            : #include <errno.h>
       9                 :            : #include <rte_cycles.h>
      10                 :            : 
      11                 :            : #include "nfp_logs.h"
      12                 :            : 
      13                 :            : /* Disable service and try to get service status */
      14                 :            : #define NFP_SERVICE_DISABLE_WAIT_COUNT 3000
      15                 :            : 
      16                 :            : int
      17                 :          0 : nfp_service_enable(const struct rte_service_spec *service_spec,
      18                 :            :                 struct nfp_service_info *info)
      19                 :            : {
      20                 :            :         int ret;
      21                 :            :         int32_t lcore_count;
      22                 :            : 
      23                 :          0 :         lcore_count = rte_service_lcore_count();
      24         [ #  # ]:          0 :         if (lcore_count == 0)
      25                 :            :                 return -ENOTSUP;
      26                 :            : 
      27                 :            :         /* Register the service */
      28                 :          0 :         ret = rte_service_component_register(service_spec, &info->id);
      29         [ #  # ]:          0 :         if (ret != 0) {
      30                 :          0 :                 PMD_DRV_LOG(DEBUG, "Could not register %s.", service_spec->name);
      31                 :          0 :                 return -EINVAL;
      32                 :            :         }
      33                 :            : 
      34                 :            :         /* Set the NFP service runstate of a component. */
      35                 :          0 :         rte_service_component_runstate_set(info->id, 1);
      36                 :            : 
      37                 :          0 :         PMD_DRV_LOG(DEBUG, "Enable service %s successfully.", service_spec->name);
      38                 :            : 
      39                 :          0 :         return 0;
      40                 :            : }
      41                 :            : 
      42                 :            : int
      43                 :          0 : nfp_service_disable(struct nfp_service_info *info)
      44                 :            : {
      45                 :            :         uint32_t i;
      46                 :            :         const char *service_name;
      47                 :            : 
      48                 :          0 :         service_name = rte_service_get_name(info->id);
      49         [ #  # ]:          0 :         if (service_name == NULL) {
      50                 :          0 :                 PMD_DRV_LOG(ERR, "Could not find service %u.", info->id);
      51                 :          0 :                 return -EINVAL;
      52                 :            :         }
      53                 :            : 
      54                 :          0 :         rte_service_component_runstate_set(info->id, 0);
      55                 :            : 
      56         [ #  # ]:          0 :         for (i = 0; i < NFP_SERVICE_DISABLE_WAIT_COUNT; i++) {
      57         [ #  # ]:          0 :                 if (rte_service_may_be_active(info->id) == 0)
      58                 :            :                         break;
      59                 :            :                 rte_delay_ms(1);
      60                 :            :         }
      61                 :            : 
      62         [ #  # ]:          0 :         if (i == NFP_SERVICE_DISABLE_WAIT_COUNT)
      63                 :          0 :                 PMD_DRV_LOG(ERR, "Could not stop service %s.", service_name);
      64                 :            : 
      65                 :          0 :         rte_service_component_unregister(info->id);
      66                 :            : 
      67                 :          0 :         return 0;
      68                 :            : }

Generated by: LCOV version 1.14