LCOV - code coverage report
Current view: top level - root/contrail/vrouter/dpdk - vr_dpdk_pmd_context.c (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 28 52 53.8 %
Date: 2026-08-03 02:19:58 Functions: 5 8 62.5 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* SPDX-License-Identifier: BSD-2-Clause
       2             :  * Copyright(c) HCL TECHNOLOGIES LTD
       3             :  * Submitted on behalf of a third-party: Intel Corporation, a
       4             :  * Delaware corporation, having its principal place of business
       5             :  * at 2200 Mission College Boulevard,
       6             :  * Santa Clara, California 95052, USA
       7             :  */
       8             : 
       9             : #include <errno.h>
      10             : 
      11             : #include <rte_eal.h>
      12             : #include <rte_launch.h>
      13             : 
      14             : #include "vr_dpdk_pmd_context.h"
      15             : 
      16             : static struct vr_dpdk_pmd_ctx *pmd_ctx;
      17             : 
      18             : void
      19           0 : vr_dpdk_pmd_ctx_register(struct vr_dpdk_pmd_ctx *ctx)
      20             : {
      21           0 :     pmd_ctx = ctx;
      22           0 : }
      23             : 
      24             : void
      25           0 : vr_dpdk_pmd_ctx_deregister(void)
      26             : {
      27           0 :     pmd_ctx = NULL;
      28           0 : }
      29             : 
      30             : int
      31           0 : vr_dpdk_pmd_ctx_print_usage(void)
      32             : {
      33           0 :     struct vr_dpdk_pmd_ctx *ctx = pmd_ctx;
      34             : 
      35           0 :     if (ctx != NULL && ctx->print_usage != NULL) {
      36           0 :         return ctx->print_usage();
      37             :     }
      38             : 
      39           0 :     return -ENOTSUP;
      40             : }
      41             : 
      42             : int
      43         230 : vr_dpdk_pmd_ctx_parse_opt(int vr_argc, char *vr_argv[], size_t optindex, char opt, char *optarg)
      44             : {
      45         230 :     struct vr_dpdk_pmd_ctx *ctx = pmd_ctx;
      46             : 
      47         230 :     if (ctx != NULL && ctx->parse_opt != NULL) {
      48           0 :         return ctx->parse_opt(vr_argc, vr_argv, optindex, opt, optarg);
      49             :     }
      50             : 
      51         230 :     return -ENOTSUP;
      52             : }
      53             : 
      54             : int
      55          53 : vr_dpdk_pmd_ctx_init(int eal_argc, char *eal_argv[])
      56             : {
      57          53 :     struct vr_dpdk_pmd_ctx *ctx = pmd_ctx;
      58          53 :     bool init_callable = ctx != NULL &&
      59           0 :                          ctx->is_enabled != NULL &&
      60          53 :                          ctx->is_enabled() &&
      61           0 :                          ctx->init != NULL;
      62             : 
      63          53 :     if (init_callable) {
      64           0 :         return ctx->init(eal_argc, eal_argv);
      65             :     }
      66             : 
      67          53 :     return rte_eal_init(eal_argc, eal_argv);
      68             : }
      69             : 
      70             : int
      71          53 : vr_dpdk_pmd_ctx_exit(void)
      72             : {
      73          53 :     struct vr_dpdk_pmd_ctx *ctx = pmd_ctx;
      74          53 :     bool exit_callable = ctx != NULL &&
      75           0 :                          ctx->is_enabled != NULL &&
      76          53 :                          ctx->is_enabled() &&
      77           0 :                          ctx->exit != NULL;
      78             : 
      79          53 :     if (exit_callable) {
      80           0 :         return ctx->exit();
      81             :     }
      82             : 
      83          53 :     return rte_eal_cleanup();
      84             : }
      85             : 
      86             : int
      87          53 : vr_dpdk_pmd_ctx_lcore_request(char *lcores_string, size_t lcores_string_sz, char *service_core_mapping)
      88             : {
      89          53 :     struct vr_dpdk_pmd_ctx *ctx = pmd_ctx;
      90          53 :     bool request_callable = ctx != NULL &&
      91           0 :                             ctx->is_enabled != NULL &&
      92          53 :                             ctx->is_enabled() &&
      93           0 :                             ctx->lcore_request != NULL;
      94             : 
      95          53 :     if (request_callable) {
      96           0 :         return ctx->lcore_request(lcores_string, lcores_string_sz, service_core_mapping);
      97             :     }
      98             : 
      99          53 :     return -ENOTSUP;
     100             : }
     101             : 
     102             : int
     103          53 : vr_dpdk_pmd_ctx_launch_lcores(vr_dpdk_lcore_launch_cb_t launch_cb)
     104             : {
     105          53 :     struct vr_dpdk_pmd_ctx *ctx = pmd_ctx;
     106          53 :     bool launch_callable = ctx != NULL &&
     107           0 :                            ctx->is_enabled != NULL &&
     108          53 :                            ctx->is_enabled() &&
     109           0 :                            ctx->launch_lcores != NULL;
     110             : 
     111          53 :     if (launch_callable) {
     112           0 :         return ctx->launch_lcores(launch_cb);
     113             :     }
     114             : 
     115          53 :     return rte_eal_mp_remote_launch(launch_cb, NULL, CALL_MASTER);
     116             : }

Generated by: LCOV version 1.14