LCOV - code coverage report
Current view: top level - app/graph - mempool.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 31 0.0 %
Date: 2025-02-01 18:54:23 Functions: 0 3 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright(c) 2023 Marvell.
       3                 :            :  */
       4                 :            : 
       5                 :            : #include <stdio.h>
       6                 :            : #include <stdlib.h>
       7                 :            : #include <string.h>
       8                 :            : 
       9                 :            : #include <cmdline_parse.h>
      10                 :            : #include <cmdline_parse_num.h>
      11                 :            : #include <cmdline_parse_string.h>
      12                 :            : #include <cmdline_socket.h>
      13                 :            : #include <rte_common.h>
      14                 :            : #include <rte_mbuf.h>
      15                 :            : 
      16                 :            : #include "mempool_priv.h"
      17                 :            : #include "module_api.h"
      18                 :            : 
      19                 :            : static const char
      20                 :            : cmd_mempool_help[] = "mempool <mempool_name> size <mbuf_size> buffers <number_of_buffers> "
      21                 :            :                      "cache <cache_size> numa <numa_id>";
      22                 :            : 
      23                 :            : struct mempools mpconfig;
      24                 :            : 
      25                 :            : int
      26                 :          0 : mempool_process(struct mempool_config *config)
      27                 :            : {
      28                 :            :         struct rte_mempool *mp;
      29                 :            :         uint8_t nb_pools;
      30                 :            : 
      31                 :          0 :         nb_pools = mpconfig.nb_pools;
      32                 :          0 :         rte_strscpy(mpconfig.config[nb_pools].name, config->name, RTE_MEMPOOL_NAMESIZE);
      33                 :          0 :         mpconfig.config[nb_pools].pool_size = config->pool_size;
      34                 :          0 :         mpconfig.config[nb_pools].buffer_size = config->buffer_size;
      35                 :          0 :         mpconfig.config[nb_pools].cache_size = config->cache_size;
      36                 :          0 :         mpconfig.config[nb_pools].numa_node = config->numa_node;
      37                 :            : 
      38                 :          0 :         mp = rte_pktmbuf_pool_create(config->name, config->pool_size, config->cache_size,
      39                 :          0 :                 128, config->buffer_size, config->numa_node);
      40                 :          0 :         if (!mp)
      41                 :            :                 return -EINVAL;
      42                 :            : 
      43                 :          0 :         mpconfig.mp[nb_pools] = mp;
      44                 :          0 :         nb_pools++;
      45                 :          0 :         mpconfig.nb_pools = nb_pools;
      46                 :            : 
      47                 :          0 :         return 0;
      48                 :            : }
      49                 :            : 
      50                 :            : void
      51                 :          0 : cmd_help_mempool_parsed(__rte_unused void *parsed_result, __rte_unused struct cmdline *cl,
      52                 :            :                         __rte_unused void *data)
      53                 :            : {
      54                 :            :         size_t len;
      55                 :            : 
      56                 :          0 :         len = strlen(conn->msg_out);
      57                 :          0 :         conn->msg_out += len;
      58                 :          0 :         snprintf(conn->msg_out, conn->msg_out_len_max, "\n%s\n%s\n",
      59                 :            :                  "----------------------------- mempool command help -----------------------------",
      60                 :            :                  cmd_mempool_help);
      61                 :            : 
      62                 :          0 :         len = strlen(conn->msg_out);
      63                 :          0 :         conn->msg_out_len_max -= len;
      64                 :          0 : }
      65                 :            : 
      66                 :            : void
      67                 :          0 : cmd_mempool_parsed(void *parsed_result, __rte_unused struct cmdline *cl, __rte_unused void *data)
      68                 :            : {
      69                 :            :         struct cmd_mempool_result *res = parsed_result;
      70                 :            :         struct mempool_config config;
      71                 :            :         int rc = -EINVAL;
      72                 :            : 
      73                 :            : 
      74                 :          0 :         rte_strscpy(config.name, res->name, RTE_MEMPOOL_NAMESIZE);
      75                 :          0 :         config.name[strlen(res->name)] = '\0';
      76                 :          0 :         config.pool_size = res->nb_bufs;
      77                 :          0 :         config.buffer_size = res->buf_sz;
      78                 :          0 :         config.cache_size = res->cache_size;
      79                 :          0 :         config.numa_node = res->node;
      80                 :            : 
      81                 :          0 :         rc = mempool_process(&config);
      82                 :          0 :         if (rc < 0)
      83                 :            :                 printf(MSG_CMD_FAIL, "mempool");
      84                 :          0 : }

Generated by: LCOV version 1.14