LCOV - code coverage report
Current view: top level - app/graph - feature.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 52 0.0 %
Date: 2025-08-01 17:49:26 Functions: 0 7 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) 2025 Marvell International Ltd.
       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_ethdev.h>
      14                 :            : 
      15                 :            : #include "module_api.h"
      16                 :            : 
      17                 :            : static const char
      18                 :            : cmd_feature_arcs_help[] = "feature arcs    # Display all feature arcs";
      19                 :            : 
      20                 :            : static const char
      21                 :            : cmd_feature_show_help[] = "feature <arc_name> show   # Display features within an arc";
      22                 :            : 
      23                 :            : static const char
      24                 :            : cmd_feature_enable_help[] = "feature enable <arc name> <feature name> <port-id>";
      25                 :            : 
      26                 :            : static const char
      27                 :            : cmd_feature_disable_help[] = "feature disable <arc name> <feature name> <port-id>";
      28                 :            : 
      29                 :            : static void
      30                 :          0 : feature_show(const char *arc_name)
      31                 :            : {
      32                 :            :         rte_graph_feature_arc_t _arc;
      33                 :            :         uint32_t length, count, i;
      34                 :            : 
      35                 :          0 :         length = strlen(conn->msg_out);
      36                 :          0 :         conn->msg_out += length;
      37                 :            : 
      38                 :          0 :         if (rte_graph_feature_arc_lookup_by_name(arc_name, &_arc) < 0)
      39                 :          0 :                 return;
      40                 :            : 
      41                 :          0 :         count = rte_graph_feature_arc_num_features(_arc);
      42                 :            : 
      43                 :          0 :         if (count) {
      44                 :          0 :                 snprintf(conn->msg_out, conn->msg_out_len_max, "\n%s%s%s\n",
      45                 :            :                          "----------------------------- feature arc: ",
      46                 :          0 :                          rte_graph_feature_arc_get(_arc)->feature_arc_name,
      47                 :            :                          " -----------------------------");
      48                 :          0 :                 for (i = 0; i < count; i++)
      49                 :          0 :                         snprintf(conn->msg_out + strlen(conn->msg_out),
      50                 :          0 :                                  conn->msg_out_len_max, "%s\n",
      51                 :            :                                  rte_graph_feature_arc_feature_to_name(_arc, i));
      52                 :            :         }
      53                 :          0 :         length = strlen(conn->msg_out);
      54                 :          0 :         conn->msg_out_len_max -= length;
      55                 :            : }
      56                 :            : 
      57                 :            : static void
      58                 :          0 : feature_arcs_show(void)
      59                 :            : {
      60                 :            :         uint32_t length, count, i;
      61                 :            :         char **names;
      62                 :            : 
      63                 :          0 :         length = strlen(conn->msg_out);
      64                 :          0 :         conn->msg_out += length;
      65                 :            : 
      66                 :          0 :         count = rte_graph_feature_arc_names_get(NULL);
      67                 :            : 
      68                 :          0 :         if (count) {
      69                 :          0 :                 names = malloc(count);
      70                 :          0 :                 if (!names) {
      71                 :          0 :                         snprintf(conn->msg_out, conn->msg_out_len_max, "Failed to allocate memory\n");
      72                 :          0 :                         return;
      73                 :            :                 }
      74                 :          0 :                 count = rte_graph_feature_arc_names_get(names);
      75                 :          0 :                 snprintf(conn->msg_out, conn->msg_out_len_max, "\n%s\n",
      76                 :            :                          "----------------------------- feature arcs -----------------------------");
      77                 :          0 :                 for (i = 0; i < count; i++)
      78                 :          0 :                         feature_show(names[i]);
      79                 :          0 :                 free(names);
      80                 :            :         }
      81                 :          0 :         length = strlen(conn->msg_out);
      82                 :          0 :         conn->msg_out_len_max -= length;
      83                 :            : }
      84                 :            : 
      85                 :            : void
      86                 :          0 : cmd_feature_parsed(void *parsed_result, __rte_unused struct cmdline *cl,
      87                 :            :                    __rte_unused void *data)
      88                 :            : {
      89                 :            :         struct cmd_feature_result *res = parsed_result;
      90                 :            : 
      91                 :          0 :         feature_show(res->name);
      92                 :          0 : }
      93                 :            : 
      94                 :            : 
      95                 :            : void
      96                 :          0 : cmd_feature_arcs_parsed(__rte_unused void *parsed_result, __rte_unused struct cmdline *cl,
      97                 :            :                         __rte_unused void *data)
      98                 :            : {
      99                 :          0 :                 feature_arcs_show();
     100                 :          0 : }
     101                 :            : 
     102                 :            : void
     103                 :          0 : cmd_feature_enable_parsed(void *parsed_result, __rte_unused struct cmdline *cl,
     104                 :            :                           __rte_unused void *data)
     105                 :            : {
     106                 :            :         struct cmd_feature_enable_result *res = parsed_result;
     107                 :            :         rte_graph_feature_arc_t arc;
     108                 :            : 
     109                 :          0 :         if (!rte_graph_feature_arc_lookup_by_name(res->arc_name, &arc))
     110                 :          0 :                 rte_graph_feature_enable(arc, res->interface, res->feature_name,
     111                 :          0 :                                          res->interface, NULL);
     112                 :          0 : }
     113                 :            : 
     114                 :            : void
     115                 :          0 : cmd_feature_disable_parsed(void *parsed_result, __rte_unused struct cmdline *cl,
     116                 :            :                            __rte_unused void *data)
     117                 :            : {
     118                 :            :         struct cmd_feature_disable_result *res = parsed_result;
     119                 :            :         rte_graph_feature_arc_t arc;
     120                 :            : 
     121                 :          0 :         if (!rte_graph_feature_arc_lookup_by_name(res->arc_name, &arc))
     122                 :          0 :                 rte_graph_feature_disable(arc, res->interface, res->feature_name, NULL);
     123                 :            : 
     124                 :          0 : }
     125                 :            : 
     126                 :            : void
     127                 :          0 : cmd_help_feature_parsed(__rte_unused void *parsed_result, __rte_unused struct cmdline *cl,
     128                 :            :                         __rte_unused void *data)
     129                 :            : {
     130                 :            :         size_t len;
     131                 :            : 
     132                 :          0 :         len = strlen(conn->msg_out);
     133                 :          0 :         conn->msg_out += len;
     134                 :          0 :         snprintf(conn->msg_out, conn->msg_out_len_max, "\n%s\n%s\n%s\n%s\n%s\n",
     135                 :            :                  "----------------------------- feature command help -----------------------------",
     136                 :            :                  cmd_feature_arcs_help, cmd_feature_show_help, cmd_feature_enable_help,
     137                 :            :                  cmd_feature_disable_help);
     138                 :            : 
     139                 :          0 :         len = strlen(conn->msg_out);
     140                 :          0 :         conn->msg_out_len_max -= len;
     141                 :          0 : }

Generated by: LCOV version 1.14