LCOV - code coverage report
Current view: top level - app/test-pmd - cmdline.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 2373 0.0 %
Date: 2025-03-01 20:23:48 Functions: 0 188 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) 2010-2016 Intel Corporation.
       3                 :            :  * Copyright(c) 2014 6WIND S.A.
       4                 :            :  */
       5                 :            : 
       6                 :            : #include <ctype.h>
       7                 :            : #include <stdarg.h>
       8                 :            : #include <errno.h>
       9                 :            : #include <fcntl.h>
      10                 :            : #include <stdio.h>
      11                 :            : #include <stdint.h>
      12                 :            : #include <stdlib.h>
      13                 :            : #include <string.h>
      14                 :            : #include <unistd.h>
      15                 :            : #include <inttypes.h>
      16                 :            : #include <sys/queue.h>
      17                 :            : 
      18                 :            : #include <rte_common.h>
      19                 :            : #include <rte_byteorder.h>
      20                 :            : #include <rte_log.h>
      21                 :            : #include <rte_debug.h>
      22                 :            : #include <rte_cycles.h>
      23                 :            : #include <rte_memory.h>
      24                 :            : #include <rte_memzone.h>
      25                 :            : #include <rte_malloc.h>
      26                 :            : #include <rte_launch.h>
      27                 :            : #include <rte_eal.h>
      28                 :            : #include <rte_per_lcore.h>
      29                 :            : #include <rte_lcore.h>
      30                 :            : #include <rte_branch_prediction.h>
      31                 :            : #include <rte_ring.h>
      32                 :            : #include <rte_mempool.h>
      33                 :            : #include <rte_interrupts.h>
      34                 :            : #include <rte_ether.h>
      35                 :            : #include <rte_ethdev.h>
      36                 :            : #include <rte_string_fns.h>
      37                 :            : #include <rte_devargs.h>
      38                 :            : #include <rte_flow.h>
      39                 :            : #ifdef RTE_LIB_GRO
      40                 :            : #include <rte_gro.h>
      41                 :            : #endif
      42                 :            : #include <rte_mbuf_dyn.h>
      43                 :            : #include <rte_trace.h>
      44                 :            : 
      45                 :            : #include <cmdline_rdline.h>
      46                 :            : #include <cmdline_parse.h>
      47                 :            : #include <cmdline_parse_num.h>
      48                 :            : #include <cmdline_parse_bool.h>
      49                 :            : #include <cmdline_parse_string.h>
      50                 :            : #include <cmdline_parse_ipaddr.h>
      51                 :            : #include <cmdline_parse_etheraddr.h>
      52                 :            : #include <cmdline_socket.h>
      53                 :            : #include <cmdline.h>
      54                 :            : #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
      55                 :            : #include <rte_pmd_dpaa.h>
      56                 :            : #endif
      57                 :            : #ifdef RTE_NET_IXGBE
      58                 :            : #include <rte_pmd_ixgbe.h>
      59                 :            : #endif
      60                 :            : #ifdef RTE_NET_I40E
      61                 :            : #include <rte_pmd_i40e.h>
      62                 :            : #endif
      63                 :            : #ifdef RTE_NET_BNXT
      64                 :            : #include <rte_pmd_bnxt.h>
      65                 :            : #endif
      66                 :            : #include "testpmd.h"
      67                 :            : #include "cmdline_cman.h"
      68                 :            : #include "cmdline_mtr.h"
      69                 :            : #include "cmdline_tm.h"
      70                 :            : #include "bpf_cmd.h"
      71                 :            : 
      72                 :            : static struct cmdline *testpmd_cl;
      73                 :            : static cmdline_parse_ctx_t *main_ctx;
      74                 :            : static TAILQ_HEAD(, testpmd_driver_commands) driver_commands_head =
      75                 :            :         TAILQ_HEAD_INITIALIZER(driver_commands_head);
      76                 :            : 
      77                 :            : /* *** Help command with introduction. *** */
      78                 :            : struct cmd_help_brief_result {
      79                 :            :         cmdline_fixed_string_t help;
      80                 :            : };
      81                 :            : 
      82                 :          0 : static void cmd_help_brief_parsed(__rte_unused void *parsed_result,
      83                 :            :                                   struct cmdline *cl,
      84                 :            :                                   __rte_unused void *data)
      85                 :            : {
      86                 :          0 :         cmdline_printf(
      87                 :            :                 cl,
      88                 :            :                 "\n"
      89                 :            :                 "Help is available for the following sections:\n\n"
      90                 :            :                 "    help control                    : Start and stop forwarding.\n"
      91                 :            :                 "    help display                    : Displaying port, stats and config "
      92                 :            :                 "information.\n"
      93                 :            :                 "    help config                     : Configuration information.\n"
      94                 :            :                 "    help ports                      : Configuring ports.\n"
      95                 :            :                 "    help filters                    : Filters configuration help.\n"
      96                 :            :                 "    help traffic_management         : Traffic Management commands.\n"
      97                 :            :                 "    help devices                    : Device related commands.\n"
      98                 :            :                 "    help drivers                    : Driver specific commands.\n"
      99                 :            :                 "    help all                        : All of the above sections.\n\n"
     100                 :            :         );
     101                 :            : 
     102                 :          0 : }
     103                 :            : 
     104                 :            : static cmdline_parse_token_string_t cmd_help_brief_help =
     105                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
     106                 :            : 
     107                 :            : static cmdline_parse_inst_t cmd_help_brief = {
     108                 :            :         .f = cmd_help_brief_parsed,
     109                 :            :         .data = NULL,
     110                 :            :         .help_str = "help: Show help",
     111                 :            :         .tokens = {
     112                 :            :                 (void *)&cmd_help_brief_help,
     113                 :            :                 NULL,
     114                 :            :         },
     115                 :            : };
     116                 :            : 
     117                 :            : /* *** Help command with help sections. *** */
     118                 :            : struct cmd_help_long_result {
     119                 :            :         cmdline_fixed_string_t help;
     120                 :            :         cmdline_fixed_string_t section;
     121                 :            : };
     122                 :            : 
     123                 :          0 : static void cmd_help_long_parsed(void *parsed_result,
     124                 :            :                                  struct cmdline *cl,
     125                 :            :                                  __rte_unused void *data)
     126                 :            : {
     127                 :            :         int show_all = 0;
     128                 :            :         struct cmd_help_long_result *res = parsed_result;
     129                 :            : 
     130                 :          0 :         if (!strcmp(res->section, "all"))
     131                 :            :                 show_all = 1;
     132                 :            : 
     133                 :          0 :         if (show_all || !strcmp(res->section, "control")) {
     134                 :            : 
     135                 :          0 :                 cmdline_printf(
     136                 :            :                         cl,
     137                 :            :                         "\n"
     138                 :            :                         "Control forwarding:\n"
     139                 :            :                         "-------------------\n\n"
     140                 :            : 
     141                 :            :                         "start\n"
     142                 :            :                         "    Start packet forwarding with current configuration.\n\n"
     143                 :            : 
     144                 :            :                         "start tx_first\n"
     145                 :            :                         "    Start packet forwarding with current config"
     146                 :            :                         " after sending one burst of packets.\n\n"
     147                 :            : 
     148                 :            :                         "stop\n"
     149                 :            :                         "    Stop packet forwarding, and display accumulated"
     150                 :            :                         " statistics.\n\n"
     151                 :            : 
     152                 :            :                         "quit\n"
     153                 :            :                         "    Quit to prompt.\n\n"
     154                 :            :                 );
     155                 :            :         }
     156                 :            : 
     157                 :          0 :         if (show_all || !strcmp(res->section, "display")) {
     158                 :            : 
     159                 :          0 :                 cmdline_printf(
     160                 :            :                         cl,
     161                 :            :                         "\n"
     162                 :            :                         "Display:\n"
     163                 :            :                         "--------\n\n"
     164                 :            : 
     165                 :            :                         "show port (info|stats|summary|xstats|fdir|dcb_tc) (port_id|all)\n"
     166                 :            :                         "    Display information for port_id, or all.\n\n"
     167                 :            : 
     168                 :            :                         "show port info (port_id) representor\n"
     169                 :            :                         "    Show supported representors for a specific port\n\n"
     170                 :            : 
     171                 :            :                         "show port port_id (module_eeprom|eeprom)\n"
     172                 :            :                         "    Display the module EEPROM or EEPROM information for port_id.\n\n"
     173                 :            : 
     174                 :            :                         "set port (port_id) eeprom (accept_risk) magic (magic_num)"
     175                 :            :                         " value (value) offset (offset)\n"
     176                 :            :                         "    Set the device eeprom for certain port.\nNote:\n"
     177                 :            :                         "    This is a high-risk command and its misuse may"
     178                 :            :                         " result in unexpected behaviour from the NIC.\n"
     179                 :            :                         "    By inserting \"accept_risk\" into the command, the"
     180                 :            :                         " user is acknowledging and taking responsibility for"
     181                 :            :                         " this risk.\n\n"
     182                 :            : 
     183                 :            :                         "show port X rss reta (size) (mask0,mask1,...)\n"
     184                 :            :                         "    Display the rss redirection table entry indicated"
     185                 :            :                         " by masks on port X. size is used to indicate the"
     186                 :            :                         " hardware supported reta size\n\n"
     187                 :            : 
     188                 :            :                         "show port (port_id) rss-hash [key | algorithm]\n"
     189                 :            :                         "    Display the RSS hash functions, RSS hash key and RSS hash algorithms of port\n\n"
     190                 :            : 
     191                 :            :                         "clear port (info|stats|xstats|fdir) (port_id|all)\n"
     192                 :            :                         "    Clear information for port_id, or all.\n\n"
     193                 :            : 
     194                 :            :                         "show (rxq|txq) info (port_id) (queue_id)\n"
     195                 :            :                         "    Display information for configured RX/TX queue.\n\n"
     196                 :            : 
     197                 :            :                         "show config (rxtx|cores|fwd|rxoffs|rxpkts|rxhdrs|txpkts)\n"
     198                 :            :                         "    Display the given configuration.\n\n"
     199                 :            : 
     200                 :            :                         "read rxd (port_id) (queue_id) (rxd_id)\n"
     201                 :            :                         "    Display an RX descriptor of a port RX queue.\n\n"
     202                 :            : 
     203                 :            :                         "read txd (port_id) (queue_id) (txd_id)\n"
     204                 :            :                         "    Display a TX descriptor of a port TX queue.\n\n"
     205                 :            : 
     206                 :            :                         "show vf stats (port_id) (vf_id)\n"
     207                 :            :                         "    Display a VF's statistics.\n\n"
     208                 :            : 
     209                 :            :                         "clear vf stats (port_id) (vf_id)\n"
     210                 :            :                         "    Reset a VF's statistics.\n\n"
     211                 :            : 
     212                 :            :                         "show port meter stats (port_id) (meter_id) (clear)\n"
     213                 :            :                         "    Get meter stats on a port\n\n"
     214                 :            : 
     215                 :            :                         "show fwd stats all\n"
     216                 :            :                         "    Display statistics for all fwd engines.\n\n"
     217                 :            : 
     218                 :            :                         "clear fwd stats all\n"
     219                 :            :                         "    Clear statistics for all fwd engines.\n\n"
     220                 :            : 
     221                 :            :                         "show port (port_id) rx_offload capabilities\n"
     222                 :            :                         "    List all per queue and per port Rx offloading"
     223                 :            :                         " capabilities of a port\n\n"
     224                 :            : 
     225                 :            :                         "show port (port_id) rx_offload configuration\n"
     226                 :            :                         "    List port level and all queue level"
     227                 :            :                         " Rx offloading configuration\n\n"
     228                 :            : 
     229                 :            :                         "show port (port_id) tx_offload capabilities\n"
     230                 :            :                         "    List all per queue and per port"
     231                 :            :                         " Tx offloading capabilities of a port\n\n"
     232                 :            : 
     233                 :            :                         "show port (port_id) tx_offload configuration\n"
     234                 :            :                         "    List port level and all queue level"
     235                 :            :                         " Tx offloading configuration\n\n"
     236                 :            : 
     237                 :            :                         "show port (port_id) tx_metadata\n"
     238                 :            :                         "    Show Tx metadata value set"
     239                 :            :                         " for a specific port\n\n"
     240                 :            : 
     241                 :            :                         "show port (port_id) ptypes\n"
     242                 :            :                         "    Show port supported ptypes"
     243                 :            :                         " for a specific port\n\n"
     244                 :            : 
     245                 :            :                         "show device info (<identifier>|all)"
     246                 :            :                         "       Show general information about devices probed.\n\n"
     247                 :            : 
     248                 :            :                         "show port (port_id) rxq|txq (queue_id) desc (desc_id) status"
     249                 :            :                         "       Show status of rx|tx descriptor.\n\n"
     250                 :            : 
     251                 :            :                         "show port (port_id) rxq|txq (queue_id) desc used count\n"
     252                 :            :                         "    Show current number of used descriptor count for rx|tx.\n\n"
     253                 :            : 
     254                 :            :                         "show port (port_id) macs|mcast_macs"
     255                 :            :                         "       Display list of mac addresses added to port.\n\n"
     256                 :            : 
     257                 :            :                         "show port (port_id) flow transfer proxy\n"
     258                 :            :                         "  Display proxy port to manage transfer flows\n\n"
     259                 :            : 
     260                 :            :                         "show port (port_id) fec capabilities"
     261                 :            :                         "  Show fec capabilities of a port.\n\n"
     262                 :            : 
     263                 :            :                         "show port (port_id) fec_mode"
     264                 :            :                         "  Show fec mode of a port.\n\n"
     265                 :            : 
     266                 :            :                         "show port (port_id) flow_ctrl"
     267                 :            :                         "  Show flow control info of a port.\n\n"
     268                 :            : 
     269                 :            :                         "dump_physmem\n"
     270                 :            :                         "    Dumps all physical memory segment layouts\n\n"
     271                 :            : 
     272                 :            :                         "dump_socket_mem\n"
     273                 :            :                         "    Dumps the memory usage of all sockets\n\n"
     274                 :            : 
     275                 :            :                         "dump_memzone\n"
     276                 :            :                         "    Dumps the layout of all memory zones\n\n"
     277                 :            : 
     278                 :            :                         "dump_struct_sizes\n"
     279                 :            :                         "    Dumps the size of all memory structures\n\n"
     280                 :            : 
     281                 :            :                         "dump_ring\n"
     282                 :            :                         "    Dumps the status of all or specific element in DPDK rings\n\n"
     283                 :            : 
     284                 :            :                         "dump_mempool\n"
     285                 :            :                         "    Dumps the statistics of all or specific memory pool\n\n"
     286                 :            : 
     287                 :            :                         "dump_devargs\n"
     288                 :            :                         "    Dumps the user device list\n\n"
     289                 :            : 
     290                 :            :                         "dump_lcores\n"
     291                 :            :                         "    Dumps the logical cores list\n\n"
     292                 :            : 
     293                 :            :                         "dump_trace\n"
     294                 :            :                         "    Dumps the tracing data to the folder according to the current EAL settings\n\n"
     295                 :            : 
     296                 :            :                         "dump_log_types\n"
     297                 :            :                         "    Dumps the log level for all the dpdk modules\n\n"
     298                 :            : 
     299                 :            :                         "show port (port_id) speed_lanes capabilities"
     300                 :            :                         "  Show speed lanes capabilities of a port.\n\n"
     301                 :            :                 );
     302                 :            :         }
     303                 :            : 
     304                 :          0 :         if (show_all || !strcmp(res->section, "config")) {
     305                 :          0 :                 cmdline_printf(
     306                 :            :                         cl,
     307                 :            :                         "\n"
     308                 :            :                         "Configuration:\n"
     309                 :            :                         "--------------\n"
     310                 :            :                         "Configuration changes only become active when"
     311                 :            :                         " forwarding is started/restarted.\n\n"
     312                 :            : 
     313                 :            :                         "set default\n"
     314                 :            :                         "    Reset forwarding to the default configuration.\n\n"
     315                 :            : 
     316                 :            :                         "set verbose (level)\n"
     317                 :            :                         "    Set the debug verbosity level X.\n\n"
     318                 :            : 
     319                 :            :                         "set log global|(type) (level)\n"
     320                 :            :                         "    Set the log level.\n\n"
     321                 :            : 
     322                 :            :                         "set nbport (num)\n"
     323                 :            :                         "    Set number of ports.\n\n"
     324                 :            : 
     325                 :            :                         "set nbcore (num)\n"
     326                 :            :                         "    Set number of cores.\n\n"
     327                 :            : 
     328                 :            :                         "set coremask (mask)\n"
     329                 :            :                         "    Set the forwarding cores hexadecimal mask.\n\n"
     330                 :            : 
     331                 :            :                         "set portmask (mask)\n"
     332                 :            :                         "    Set the forwarding ports hexadecimal mask.\n\n"
     333                 :            : 
     334                 :            :                         "set burst (num)\n"
     335                 :            :                         "    Set number of packets per burst.\n\n"
     336                 :            : 
     337                 :            :                         "set burst tx delay (microseconds) retry (num)\n"
     338                 :            :                         "    Set the transmit delay time and number of retries,"
     339                 :            :                         " effective when retry is enabled.\n\n"
     340                 :            : 
     341                 :            :                         "set rxoffs (x[,y]*)\n"
     342                 :            :                         "    Set the offset of each packet segment on"
     343                 :            :                         " receiving if split feature is engaged."
     344                 :            :                         " Affects only the queues configured with split"
     345                 :            :                         " offloads.\n\n"
     346                 :            : 
     347                 :            :                         "set rxpkts (x[,y]*)\n"
     348                 :            :                         "    Set the length of each segment to scatter"
     349                 :            :                         " packets on receiving if split feature is engaged."
     350                 :            :                         " Affects only the queues configured with split"
     351                 :            :                         " offloads.\n\n"
     352                 :            : 
     353                 :            :                         "set rxhdrs (eth[,ipv4])*\n"
     354                 :            :                         "    Set the protocol hdr of each segment to scatter"
     355                 :            :                         " packets on receiving if split feature is engaged."
     356                 :            :                         " Affects only the queues configured with split"
     357                 :            :                         " offloads.\n"
     358                 :            :                         "    Supported values: eth|ipv4|ipv6|ipv4-tcp|ipv6-tcp|"
     359                 :            :                         "ipv4-udp|ipv6-udp|ipv4-sctp|ipv6-sctp|"
     360                 :            :                         "grenat|inner-eth|inner-ipv4|inner-ipv6|inner-ipv4-tcp|"
     361                 :            :                         "inner-ipv6-tcp|inner-ipv4-udp|inner-ipv6-udp|"
     362                 :            :                         "inner-ipv4-sctp|inner-ipv6-sctp\n\n"
     363                 :            : 
     364                 :            :                         "set txpkts (x[,y]*)\n"
     365                 :            :                         "    Set the length of each segment of TXONLY"
     366                 :            :                         " and optionally CSUM packets.\n\n"
     367                 :            : 
     368                 :            :                         "set txsplit (off|on|rand)\n"
     369                 :            :                         "    Set the split policy for the TX packets."
     370                 :            :                         " Right now only applicable for CSUM and TXONLY"
     371                 :            :                         " modes\n\n"
     372                 :            : 
     373                 :            :                         "set txtimes (x, y)\n"
     374                 :            :                         "    Set the scheduling on timestamps"
     375                 :            :                         " timings for the TXONLY mode\n\n"
     376                 :            : 
     377                 :            :                         "set corelist (x[,y]*)\n"
     378                 :            :                         "    Set the list of forwarding cores.\n\n"
     379                 :            : 
     380                 :            :                         "set portlist (x[,y]*)\n"
     381                 :            :                         "    Set the list of forwarding ports.\n\n"
     382                 :            : 
     383                 :            :                         "set port setup on (iterator|event)\n"
     384                 :            :                         "    Select how attached port is retrieved for setup.\n\n"
     385                 :            : 
     386                 :            :                         "set tx loopback (port_id) (on|off)\n"
     387                 :            :                         "    Enable or disable tx loopback.\n\n"
     388                 :            : 
     389                 :            :                         "set all queues drop (port_id) (on|off)\n"
     390                 :            :                         "    Set drop enable bit for all queues.\n\n"
     391                 :            : 
     392                 :            :                         "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
     393                 :            :                         "    Set MAC antispoof for a VF from the PF.\n\n"
     394                 :            : 
     395                 :            :                         "vlan set stripq (on|off) (port_id,queue_id)\n"
     396                 :            :                         "    Set the VLAN strip for a queue on a port.\n\n"
     397                 :            : 
     398                 :            :                         "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
     399                 :            :                         "    Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
     400                 :            : 
     401                 :            :                         "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
     402                 :            :                         "    Set VLAN insert for a VF from the PF.\n\n"
     403                 :            : 
     404                 :            :                         "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
     405                 :            :                         "    Set VLAN antispoof for a VF from the PF.\n\n"
     406                 :            : 
     407                 :            :                         "vlan set (strip|filter|qinq_strip|extend) (on|off) (port_id)\n"
     408                 :            :                         "    Set the VLAN strip or filter or qinq strip or extend\n\n"
     409                 :            : 
     410                 :            :                         "vlan set (inner|outer) tpid (value) (port_id)\n"
     411                 :            :                         "    Set the VLAN TPID for Packet Filtering on"
     412                 :            :                         " a port\n\n"
     413                 :            : 
     414                 :            :                         "rx_vlan add (vlan_id|all) (port_id)\n"
     415                 :            :                         "    Add a vlan_id, or all identifiers, to the set"
     416                 :            :                         " of VLAN identifiers filtered by port_id.\n\n"
     417                 :            : 
     418                 :            :                         "rx_vlan rm (vlan_id|all) (port_id)\n"
     419                 :            :                         "    Remove a vlan_id, or all identifiers, from the set"
     420                 :            :                         " of VLAN identifiers filtered by port_id.\n\n"
     421                 :            : 
     422                 :            :                         "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
     423                 :            :                         "    Add a vlan_id, to the set of VLAN identifiers"
     424                 :            :                         "filtered for VF(s) from port_id.\n\n"
     425                 :            : 
     426                 :            :                         "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
     427                 :            :                         "    Remove a vlan_id, to the set of VLAN identifiers"
     428                 :            :                         "filtered for VF(s) from port_id.\n\n"
     429                 :            : 
     430                 :            :                         "rx_vxlan_port add (udp_port) (port_id)\n"
     431                 :            :                         "    Add an UDP port for VXLAN packet filter on a port\n\n"
     432                 :            : 
     433                 :            :                         "rx_vxlan_port rm (udp_port) (port_id)\n"
     434                 :            :                         "    Remove an UDP port for VXLAN packet filter on a port\n\n"
     435                 :            : 
     436                 :            :                         "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
     437                 :            :                         "    Set hardware insertion of VLAN IDs (single or double VLAN "
     438                 :            :                         "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
     439                 :            : 
     440                 :            :                         "tx_vlan set pvid port_id vlan_id (on|off)\n"
     441                 :            :                         "    Set port based TX VLAN insertion.\n\n"
     442                 :            : 
     443                 :            :                         "tx_vlan reset (port_id)\n"
     444                 :            :                         "    Disable hardware insertion of a VLAN header in"
     445                 :            :                         " packets sent on a port.\n\n"
     446                 :            : 
     447                 :            :                         "csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n"
     448                 :            :                         "    Select hardware or software calculation of the"
     449                 :            :                         " checksum when transmitting a packet using the"
     450                 :            :                         " csum forward engine.\n"
     451                 :            :                         "    ip|udp|tcp|sctp always concern the inner layer.\n"
     452                 :            :                         "    outer-ip concerns the outer IP layer in"
     453                 :            :                         "    outer-udp concerns the outer UDP layer in"
     454                 :            :                         " case the packet is recognized as a tunnel packet by"
     455                 :            :                         " the forward engine (vxlan, gre and ipip are supported)\n"
     456                 :            :                         "    Please check the NIC datasheet for HW limits.\n\n"
     457                 :            : 
     458                 :            :                         "csum parse-tunnel (on|off) (tx_port_id)\n"
     459                 :            :                         "    If disabled, treat tunnel packets as non-tunneled"
     460                 :            :                         " packets (treat inner headers as payload). The port\n"
     461                 :            :                         "    argument is the port used for TX in csum forward"
     462                 :            :                         " engine.\n\n"
     463                 :            : 
     464                 :            :                         "csum show (port_id)\n"
     465                 :            :                         "    Display tx checksum offload configuration\n\n"
     466                 :            : 
     467                 :            :                         "tso set (segsize) (portid)\n"
     468                 :            :                         "    Enable TCP Segmentation Offload in csum forward"
     469                 :            :                         " engine.\n"
     470                 :            :                         "    Please check the NIC datasheet for HW limits.\n\n"
     471                 :            : 
     472                 :            :                         "tso show (portid)"
     473                 :            :                         "    Display the status of TCP Segmentation Offload.\n\n"
     474                 :            : 
     475                 :            : #ifdef RTE_LIB_GRO
     476                 :            :                         "set port (port_id) gro on|off\n"
     477                 :            :                         "    Enable or disable Generic Receive Offload in"
     478                 :            :                         " csum forwarding engine.\n\n"
     479                 :            : 
     480                 :            :                         "show port (port_id) gro\n"
     481                 :            :                         "    Display GRO configuration.\n\n"
     482                 :            : 
     483                 :            :                         "set gro flush (cycles)\n"
     484                 :            :                         "    Set the cycle to flush GROed packets from"
     485                 :            :                         " reassembly tables.\n\n"
     486                 :            : #endif
     487                 :            : 
     488                 :            : #ifdef RTE_LIB_GSO
     489                 :            :                         "set port (port_id) gso (on|off)"
     490                 :            :                         "    Enable or disable Generic Segmentation Offload in"
     491                 :            :                         " csum forwarding engine.\n\n"
     492                 :            : 
     493                 :            :                         "set gso segsz (length)\n"
     494                 :            :                         "    Set max packet length for output GSO segments,"
     495                 :            :                         " including packet header and payload.\n\n"
     496                 :            : 
     497                 :            :                         "show port (port_id) gso\n"
     498                 :            :                         "    Show GSO configuration.\n\n"
     499                 :            : #endif
     500                 :            : 
     501                 :            :                         "set fwd (%s)\n"
     502                 :            :                         "    Set packet forwarding mode.\n\n"
     503                 :            : 
     504                 :            :                         "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
     505                 :            :                         "    Add a MAC address on port_id.\n\n"
     506                 :            : 
     507                 :            :                         "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
     508                 :            :                         "    Remove a MAC address from port_id.\n\n"
     509                 :            : 
     510                 :            :                         "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
     511                 :            :                         "    Set the default MAC address for port_id.\n\n"
     512                 :            : 
     513                 :            :                         "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
     514                 :            :                         "    Add a MAC address for a VF on the port.\n\n"
     515                 :            : 
     516                 :            :                         "mcast_addr add (port_id) (mcast_addr)\n"
     517                 :            :                         "    Add a multicast MAC addresses on port_id.\n\n"
     518                 :            : 
     519                 :            :                         "mcast_addr remove (port_id) (mcast_addr)\n"
     520                 :            :                         "    Remove a multicast MAC address from port_id.\n\n"
     521                 :            : 
     522                 :            :                         "mcast_addr flush (port_id)\n"
     523                 :            :                         "    Flush all multicast MAC addresses on port_id.\n\n"
     524                 :            : 
     525                 :            :                         "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
     526                 :            :                         "    Set the MAC address for a VF from the PF.\n\n"
     527                 :            : 
     528                 :            :                         "set eth-peer (port_id) (peer_addr)\n"
     529                 :            :                         "    set the peer address for certain port.\n\n"
     530                 :            : 
     531                 :            :                         "set port (port_id) uta (mac_address|all) (on|off)\n"
     532                 :            :                         "    Add/Remove a or all unicast hash filter(s)"
     533                 :            :                         "from port X.\n\n"
     534                 :            : 
     535                 :            :                         "set promisc (port_id|all) (on|off)\n"
     536                 :            :                         "    Set the promiscuous mode on port_id, or all.\n\n"
     537                 :            : 
     538                 :            :                         "set allmulti (port_id|all) (on|off)\n"
     539                 :            :                         "    Set the allmulti mode on port_id, or all.\n\n"
     540                 :            : 
     541                 :            :                         "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
     542                 :            :                         " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
     543                 :            :                         " (on|off) autoneg (on|off) (port_id)\n"
     544                 :            :                         "set flow_ctrl rx (on|off) (portid)\n"
     545                 :            :                         "set flow_ctrl tx (on|off) (portid)\n"
     546                 :            :                         "set flow_ctrl high_water (high_water) (portid)\n"
     547                 :            :                         "set flow_ctrl low_water (low_water) (portid)\n"
     548                 :            :                         "set flow_ctrl pause_time (pause_time) (portid)\n"
     549                 :            :                         "set flow_ctrl send_xon (send_xon) (portid)\n"
     550                 :            :                         "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
     551                 :            :                         "set flow_ctrl autoneg (on|off) (port_id)\n"
     552                 :            :                         "    Set the link flow control parameter on a port.\n\n"
     553                 :            : 
     554                 :            :                         "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
     555                 :            :                         " (low_water) (pause_time) (priority) (port_id)\n"
     556                 :            :                         "    Set the priority flow control parameter on a"
     557                 :            :                         " port.\n\n"
     558                 :            : 
     559                 :            :                         "set pfc_queue_ctrl (port_id) rx (on|off) (tx_qid)"
     560                 :            :                         " (tx_tc) tx (on|off) (rx_qid) (rx_tc) (pause_time)\n"
     561                 :            :                         "    Set the queue priority flow control parameter on a"
     562                 :            :                         " given Rx and Tx queues of a port.\n\n"
     563                 :            : 
     564                 :            :                         "set port (port_id) rxq (queue_id) avail_thresh (0..99)>\n "
     565                 :            :                         "    set available descriptors threshold for Rx queue\n\n"
     566                 :            : 
     567                 :            :                         "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
     568                 :            :                         "    Set statistics mapping (qmapping 0..15) for RX/TX"
     569                 :            :                         " queue on port.\n"
     570                 :            :                         "    e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
     571                 :            :                         " on port 0 to mapping 5.\n\n"
     572                 :            : 
     573                 :            :                         "set xstats-hide-zero on|off\n"
     574                 :            :                         "    Set the option to hide the zero values"
     575                 :            :                         " for xstats display.\n"
     576                 :            : 
     577                 :            :                         "set record-core-cycles on|off\n"
     578                 :            :                         "    Set the option to enable measurement of CPU cycles.\n"
     579                 :            : 
     580                 :            :                         "set record-burst-stats on|off\n"
     581                 :            :                         "    Set the option to enable display of RX and TX bursts.\n"
     582                 :            : 
     583                 :            :                         "set port (port_id) vf (vf_id) rx|tx on|off\n"
     584                 :            :                         "    Enable/Disable a VF receive/transmit from a port\n\n"
     585                 :            : 
     586                 :            :                         "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
     587                 :            :                         "|MPE) (on|off)\n"
     588                 :            :                         "    AUPE:accepts untagged VLAN;"
     589                 :            :                         "ROPE:accept unicast hash\n\n"
     590                 :            :                         "    BAM:accepts broadcast packets;"
     591                 :            :                         "MPE:accepts all multicast packets\n\n"
     592                 :            :                         "    Enable/Disable a VF receive mode of a port\n\n"
     593                 :            : 
     594                 :            :                         "set port (port_id) queue (queue_id) rate (rate_num)\n"
     595                 :            :                         "    Set rate limit for a queue of a port\n\n"
     596                 :            : 
     597                 :            :                         "set port (port_id) vf (vf_id) rate (rate_num) "
     598                 :            :                         "queue_mask (queue_mask_value)\n"
     599                 :            :                         "    Set rate limit for queues in VF of a port\n\n"
     600                 :            : 
     601                 :            :                         "set flush_rx (on|off)\n"
     602                 :            :                         "   Flush (default) or don't flush RX streams before"
     603                 :            :                         " forwarding. Mainly used with PCAP drivers.\n\n"
     604                 :            : 
     605                 :            :                         "set link-up port (port_id)\n"
     606                 :            :                         "  Set link up for a port.\n\n"
     607                 :            : 
     608                 :            :                         "set link-down port (port_id)\n"
     609                 :            :                         "  Set link down for a port.\n\n"
     610                 :            : 
     611                 :            :                         "set port (port_id) ptype_mask (ptype_mask)\n"
     612                 :            :                         "    set packet types classification for a specific port\n\n"
     613                 :            : 
     614                 :            :                         "show port meter cap (port_id)\n"
     615                 :            :                         "    Show port meter capability information\n\n"
     616                 :            : 
     617                 :            :                         "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs) (packet_mode)\n"
     618                 :            :                         "    meter profile add - srtcm rfc 2697\n\n"
     619                 :            : 
     620                 :            :                         "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs) (packet_mode)\n"
     621                 :            :                         "    meter profile add - trtcm rfc 2698\n\n"
     622                 :            : 
     623                 :            :                         "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs) (packet_mode)\n"
     624                 :            :                         "    meter profile add - trtcm rfc 4115\n\n"
     625                 :            : 
     626                 :            :                         "del port meter profile (port_id) (profile_id)\n"
     627                 :            :                         "    meter profile delete\n\n"
     628                 :            : 
     629                 :            :                         "create port meter (port_id) (mtr_id) (profile_id) (policy_id) (meter_enable)\n"
     630                 :            :                         "(stats_mask) (shared) (use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
     631                 :            :                         "(dscp_tbl_entry63)]\n"
     632                 :            :                         "    meter create\n\n"
     633                 :            : 
     634                 :            :                         "enable port meter (port_id) (mtr_id)\n"
     635                 :            :                         "    meter enable\n\n"
     636                 :            : 
     637                 :            :                         "disable port meter (port_id) (mtr_id)\n"
     638                 :            :                         "    meter disable\n\n"
     639                 :            : 
     640                 :            :                         "del port meter (port_id) (mtr_id)\n"
     641                 :            :                         "    meter delete\n\n"
     642                 :            : 
     643                 :            :                         "add port meter policy (port_id) (policy_id) g_actions (actions)\n"
     644                 :            :                         "y_actions (actions) r_actions (actions)\n"
     645                 :            :                         "    meter policy add\n\n"
     646                 :            : 
     647                 :            :                         "del port meter policy (port_id) (policy_id)\n"
     648                 :            :                         "    meter policy delete\n\n"
     649                 :            : 
     650                 :            :                         "set port meter profile (port_id) (mtr_id) (profile_id)\n"
     651                 :            :                         "    meter update meter profile\n\n"
     652                 :            : 
     653                 :            :                         "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
     654                 :            :                         "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
     655                 :            :                         "    update meter dscp table entries\n\n"
     656                 :            : 
     657                 :            :                         "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
     658                 :            :                         "(action0) [(action1) (action2)]\n"
     659                 :            :                         "    meter update policer action\n\n"
     660                 :            : 
     661                 :            :                         "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
     662                 :            :                         "    meter update stats\n\n"
     663                 :            : 
     664                 :            :                         "set port (port_id) fec_mode auto|off|rs|baser\n"
     665                 :            :                         "    set fec mode for a specific port\n\n"
     666                 :            : 
     667                 :            :                         "show port cman capa (port_id)\n"
     668                 :            :                         "    Show congestion management capabilities\n\n"
     669                 :            : 
     670                 :            :                         "show port cman config (port_id)\n"
     671                 :            :                         "    Show congestion management configuration\n\n"
     672                 :            : 
     673                 :            :                         "set port cman config (port_id) (queue_id) default | "
     674                 :            :                         "[obj (queue|queue_mempool) mode red (min_thresh) "
     675                 :            :                         "(max_thresh) (prob_inv)]\n"
     676                 :            :                         "    Set congestion management configuration\n\n"
     677                 :            : 
     678                 :            :                         "set port (port_id) led (on|off)\n"
     679                 :            :                         "    Set a controllable LED associated with a certain"
     680                 :            :                         " port on or off.\n\n"
     681                 :            : 
     682                 :            :                         , list_pkt_forwarding_modes()
     683                 :            :                 );
     684                 :            :         }
     685                 :            : 
     686                 :          0 :         if (show_all || !strcmp(res->section, "ports")) {
     687                 :            : 
     688                 :          0 :                 cmdline_printf(
     689                 :            :                         cl,
     690                 :            :                         "\n"
     691                 :            :                         "Port Operations:\n"
     692                 :            :                         "----------------\n\n"
     693                 :            : 
     694                 :            :                         "port start (port_id|all)\n"
     695                 :            :                         "    Start all ports or port_id.\n\n"
     696                 :            : 
     697                 :            :                         "port stop (port_id|all)\n"
     698                 :            :                         "    Stop all ports or port_id.\n\n"
     699                 :            : 
     700                 :            :                         "port close (port_id|all)\n"
     701                 :            :                         "    Close all ports or port_id.\n\n"
     702                 :            : 
     703                 :            :                         "port reset (port_id|all)\n"
     704                 :            :                         "    Reset all ports or port_id.\n\n"
     705                 :            : 
     706                 :            :                         "port attach (ident)\n"
     707                 :            :                         "    Attach physical or virtual dev by pci address or virtual device name\n\n"
     708                 :            : 
     709                 :            :                         "port detach (port_id)\n"
     710                 :            :                         "    Detach physical or virtual dev by port_id\n\n"
     711                 :            : 
     712                 :            :                         "port config (port_id|all)"
     713                 :            :                         " speed (10|100|1000|2500|5000|10000|25000|40000|50000|100000|200000|400000|auto)"
     714                 :            :                         " duplex (half|full|auto)\n"
     715                 :            :                         "    Set speed and duplex for all ports or port_id\n\n"
     716                 :            : 
     717                 :            :                         "port config (port_id|all) loopback (mode)\n"
     718                 :            :                         "    Set loopback mode for all ports or port_id\n\n"
     719                 :            : 
     720                 :            :                         "port config all (rxq|txq|rxd|txd) (value)\n"
     721                 :            :                         "    Set number for rxq/txq/rxd/txd.\n\n"
     722                 :            : 
     723                 :            :                         "port config all max-pkt-len (value)\n"
     724                 :            :                         "    Set the max packet length.\n\n"
     725                 :            : 
     726                 :            :                         "port config all max-lro-pkt-size (value)\n"
     727                 :            :                         "    Set the max LRO aggregated packet size.\n\n"
     728                 :            : 
     729                 :            :                         "port config all drop-en (on|off)\n"
     730                 :            :                         "    Enable or disable packet drop on all RX queues of all ports when no "
     731                 :            :                         "receive buffers available.\n\n"
     732                 :            : 
     733                 :            :                         "port config all rss (all|default|level-default|level-outer|level-inner|"
     734                 :            :                         "ip|tcp|udp|sctp|tunnel|vlan|none|"
     735                 :            :                         "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
     736                 :            :                         "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|ipv6-flow-label|"
     737                 :            :                         "l2-payload|port|vxlan|geneve|nvgre|gtpu|eth|s-vlan|c-vlan|"
     738                 :            :                         "esp|ah|l2tpv3|pfcp|pppoe|ecpri|mpls|ipv4-chksum|l4-chksum|"
     739                 :            :                         "l2tpv2|l3-pre96|l3-pre64|l3-pre56|l3-pre48|l3-pre40|l3-pre32|"
     740                 :            :                         "l2-dst-only|l2-src-only|l4-dst-only|l4-src-only|l3-dst-only|l3-src-only|<rsstype_id>)\n"
     741                 :            :                         "    Set the RSS mode.\n\n"
     742                 :            : 
     743                 :            :                         "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
     744                 :            :                         "    Set the RSS redirection table.\n\n"
     745                 :            : 
     746                 :            :                         "port config (port_id) rss-hash-algo (default|simple_xor|toeplitz|"
     747                 :            :                         "symmetric_toeplitz|symmetric_toeplitz_sort)\n"
     748                 :            :                         "    Set the RSS hash algorithm.\n\n"
     749                 :            : 
     750                 :            :                         "port config (port_id) dcb vt (on|off) (traffic_class)"
     751                 :            :                         " pfc (on|off)\n"
     752                 :            :                         "    Set the DCB mode.\n\n"
     753                 :            : 
     754                 :            :                         "port config all burst (value)\n"
     755                 :            :                         "    Set the number of packets per burst.\n\n"
     756                 :            : 
     757                 :            :                         "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
     758                 :            :                         " (value)\n"
     759                 :            :                         "    Set the ring prefetch/host/writeback threshold"
     760                 :            :                         " for tx/rx queue.\n\n"
     761                 :            : 
     762                 :            :                         "port config all (txfreet|txrst|rxfreet) (value)\n"
     763                 :            :                         "    Set free threshold for rx/tx, or set"
     764                 :            :                         " tx rs bit threshold.\n\n"
     765                 :            :                         "port config mtu X value\n"
     766                 :            :                         "    Set the MTU of port X to a given value\n\n"
     767                 :            : 
     768                 :            :                         "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
     769                 :            :                         "    Set a rx/tx queue's ring size configuration, the new"
     770                 :            :                         " value will take effect after command that (re-)start the port"
     771                 :            :                         " or command that setup the specific queue\n\n"
     772                 :            : 
     773                 :            :                         "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
     774                 :            :                         "    Start/stop a rx/tx queue of port X. Only take effect"
     775                 :            :                         " when port X is started\n\n"
     776                 :            : 
     777                 :            :                         "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
     778                 :            :                         "    Switch on/off a deferred start of port X rx/tx queue. Only"
     779                 :            :                         " take effect when port X is stopped.\n\n"
     780                 :            : 
     781                 :            :                         "port (port_id) (rxq|txq) (queue_id) setup\n"
     782                 :            :                         "    Setup a rx/tx queue of port X.\n\n"
     783                 :            : 
     784                 :            :                         "port config (port_id) udp_tunnel_port add|rm vxlan|geneve|ecpri (udp_port)\n\n"
     785                 :            :                         "    Add/remove UDP tunnel port for tunneling offload\n\n"
     786                 :            : 
     787                 :            :                         "port config (port_id|all) rx_offload all|vlan_strip|"
     788                 :            :                         "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
     789                 :            :                         "outer_ipv4_cksum|macsec_strip|"
     790                 :            :                         "vlan_filter|vlan_extend|scatter|"
     791                 :            :                         "buffer_split|timestamp|security|keep_crc on|off\n"
     792                 :            :                         "     Enable or disable a per port Rx offloading"
     793                 :            :                         " on all Rx queues of a port\n\n"
     794                 :            : 
     795                 :            :                         "port (port_id) rxq (queue_id) rx_offload all|vlan_strip|"
     796                 :            :                         "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
     797                 :            :                         "outer_ipv4_cksum|macsec_strip|"
     798                 :            :                         "vlan_filter|vlan_extend|scatter|"
     799                 :            :                         "buffer_split|timestamp|security|keep_crc on|off\n"
     800                 :            :                         "    Enable or disable a per queue Rx offloading"
     801                 :            :                         " only on a specific Rx queue\n\n"
     802                 :            : 
     803                 :            :                         "port config (port_id|all) tx_offload all|vlan_insert|"
     804                 :            :                         "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
     805                 :            :                         "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
     806                 :            :                         "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|"
     807                 :            :                         "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
     808                 :            :                         "security on|off\n"
     809                 :            :                         "    Enable or disable a per port Tx offloading"
     810                 :            :                         " on all Tx queues of a port\n\n"
     811                 :            : 
     812                 :            :                         "port (port_id) txq (queue_id) tx_offload all|vlan_insert|"
     813                 :            :                         "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
     814                 :            :                         "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
     815                 :            :                         "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
     816                 :            :                         "|mt_lockfree|multi_segs|mbuf_fast_free|security"
     817                 :            :                         " on|off\n"
     818                 :            :                         "    Enable or disable a per queue Tx offloading"
     819                 :            :                         " only on a specific Tx queue\n\n"
     820                 :            : 
     821                 :            :                         "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
     822                 :            :                         "    Load an eBPF program as a callback"
     823                 :            :                         " for particular RX/TX queue\n\n"
     824                 :            : 
     825                 :            :                         "bpf-unload rx|tx (port) (queue)\n"
     826                 :            :                         "    Unload previously loaded eBPF program"
     827                 :            :                         " for particular RX/TX queue\n\n"
     828                 :            : 
     829                 :            :                         "port config (port_id) tx_metadata (value)\n"
     830                 :            :                         "    Set Tx metadata value per port. Testpmd will add this value"
     831                 :            :                         " to any Tx packet sent from this port\n\n"
     832                 :            : 
     833                 :            :                         "port config (port_id) dynf (name) set|clear\n"
     834                 :            :                         "    Register a dynf and Set/clear this flag on Tx. "
     835                 :            :                         "Testpmd will set this value to any Tx packet "
     836                 :            :                         "sent from this port\n\n"
     837                 :            : 
     838                 :            :                         "port cleanup (port_id) txq (queue_id) (free_cnt)\n"
     839                 :            :                         "    Cleanup txq mbufs for a specific Tx queue\n\n"
     840                 :            : 
     841                 :            :                         "port config (port_id) txq (queue_id) affinity (value)\n"
     842                 :            :                         "    Map a Tx queue with an aggregated port "
     843                 :            :                         "of the DPDK port\n\n"
     844                 :            : 
     845                 :            :                         "port config (port_id|all) speed_lanes (value)\n"
     846                 :            :                         "    Set number of lanes for all ports or port_id for a forced speed\n\n"
     847                 :            :                 );
     848                 :            :         }
     849                 :            : 
     850                 :          0 :         if (show_all || !strcmp(res->section, "filters")) {
     851                 :            : 
     852                 :          0 :                 cmdline_printf(
     853                 :            :                         cl,
     854                 :            :                         "\n"
     855                 :            :                         "filters:\n"
     856                 :            :                         "--------\n\n"
     857                 :            : 
     858                 :            :                         "flow validate {port_id}"
     859                 :            :                         " [group {group_id}] [priority {level}]"
     860                 :            :                         " [ingress] [egress]"
     861                 :            :                         " pattern {item} [/ {item} [...]] / end"
     862                 :            :                         " actions {action} [/ {action} [...]] / end\n"
     863                 :            :                         "    Check whether a flow rule can be created.\n\n"
     864                 :            : 
     865                 :            :                         "flow create {port_id}"
     866                 :            :                         " [group {group_id}] [priority {level}]"
     867                 :            :                         " [ingress] [egress]"
     868                 :            :                         " pattern {item} [/ {item} [...]] / end"
     869                 :            :                         " actions {action} [/ {action} [...]] / end\n"
     870                 :            :                         "    Create a flow rule.\n\n"
     871                 :            : 
     872                 :            :                         "flow destroy {port_id} rule {rule_id} [...]\n"
     873                 :            :                         "    Destroy specific flow rules.\n\n"
     874                 :            : 
     875                 :            :                         "flow update {port_id} {rule_id}"
     876                 :            :                         " actions {action} [/ {action} [...]] / end [user_id]\n"
     877                 :            :                         "    Update a flow rule with new actions.\n\n"
     878                 :            : 
     879                 :            :                         "flow flush {port_id}\n"
     880                 :            :                         "    Destroy all flow rules.\n\n"
     881                 :            : 
     882                 :            :                         "flow query {port_id} {rule_id} {action}\n"
     883                 :            :                         "    Query an existing flow rule.\n\n"
     884                 :            : 
     885                 :            :                         "flow list {port_id} [group {group_id}] [...]\n"
     886                 :            :                         "    List existing flow rules sorted by priority,"
     887                 :            :                         " filtered by group identifiers.\n\n"
     888                 :            : 
     889                 :            :                         "flow isolate {port_id} {boolean}\n"
     890                 :            :                         "    Restrict ingress traffic to the defined"
     891                 :            :                         " flow rules\n\n"
     892                 :            : 
     893                 :            :                         "flow aged {port_id} [destroy]\n"
     894                 :            :                         "    List and destroy aged flows"
     895                 :            :                         " flow rules\n\n"
     896                 :            : 
     897                 :            :                         "flow indirect_action {port_id} create"
     898                 :            :                         " [action_id {indirect_action_id}]"
     899                 :            :                         " [ingress] [egress]"
     900                 :            :                         " action {action} / end\n"
     901                 :            :                         "    Create indirect action.\n\n"
     902                 :            : 
     903                 :            :                         "flow indirect_action {port_id} update"
     904                 :            :                         " {indirect_action_id} action {action} / end\n"
     905                 :            :                         "    Update indirect action.\n\n"
     906                 :            : 
     907                 :            :                         "flow indirect_action {port_id} destroy"
     908                 :            :                         " action_id {indirect_action_id} [...]\n"
     909                 :            :                         "    Destroy specific indirect actions.\n\n"
     910                 :            : 
     911                 :            :                         "flow indirect_action {port_id} query"
     912                 :            :                         " {indirect_action_id}\n"
     913                 :            :                         "    Query an existing indirect action.\n\n"
     914                 :            : 
     915                 :            :                         "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
     916                 :            :                         " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
     917                 :            :                         " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
     918                 :            :                         "       Configure the VXLAN encapsulation for flows.\n\n"
     919                 :            : 
     920                 :            :                         "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
     921                 :            :                         " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
     922                 :            :                         " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
     923                 :            :                         " eth-dst (eth-dst)\n"
     924                 :            :                         "       Configure the VXLAN encapsulation for flows.\n\n"
     925                 :            : 
     926                 :            :                         "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
     927                 :            :                         " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
     928                 :            :                         " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
     929                 :            :                         " eth-dst (eth-dst)\n"
     930                 :            :                         "       Configure the VXLAN encapsulation for flows.\n\n"
     931                 :            : 
     932                 :            :                         "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
     933                 :            :                         " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
     934                 :            :                         " (eth-dst)\n"
     935                 :            :                         "       Configure the NVGRE encapsulation for flows.\n\n"
     936                 :            : 
     937                 :            :                         "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
     938                 :            :                         " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
     939                 :            :                         " eth-src (eth-src) eth-dst (eth-dst)\n"
     940                 :            :                         "       Configure the NVGRE encapsulation for flows.\n\n"
     941                 :            : 
     942                 :            :                         "set raw_encap {flow items}\n"
     943                 :            :                         "  Configure the encapsulation with raw data.\n\n"
     944                 :            : 
     945                 :            :                         "set raw_decap {flow items}\n"
     946                 :            :                         "  Configure the decapsulation with raw data.\n\n"
     947                 :            : 
     948                 :            :                 );
     949                 :            :         }
     950                 :            : 
     951                 :          0 :         if (show_all || !strcmp(res->section, "traffic_management")) {
     952                 :          0 :                 cmdline_printf(
     953                 :            :                         cl,
     954                 :            :                         "\n"
     955                 :            :                         "Traffic Management:\n"
     956                 :            :                         "--------------\n"
     957                 :            :                         "show port tm cap (port_id)\n"
     958                 :            :                         "       Display the port TM capability.\n\n"
     959                 :            : 
     960                 :            :                         "show port tm level cap (port_id) (level_id)\n"
     961                 :            :                         "       Display the port TM hierarchical level capability.\n\n"
     962                 :            : 
     963                 :            :                         "show port tm node cap (port_id) (node_id)\n"
     964                 :            :                         "       Display the port TM node capability.\n\n"
     965                 :            : 
     966                 :            :                         "show port tm node type (port_id) (node_id)\n"
     967                 :            :                         "       Display the port TM node type.\n\n"
     968                 :            : 
     969                 :            :                         "show port tm node stats (port_id) (node_id) (clear)\n"
     970                 :            :                         "       Display the port TM node stats.\n\n"
     971                 :            : 
     972                 :            :                         "add port tm node shaper profile (port_id) (shaper_profile_id)"
     973                 :            :                         " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
     974                 :            :                         " (packet_length_adjust) (packet_mode)\n"
     975                 :            :                         "       Add port tm node private shaper profile.\n\n"
     976                 :            : 
     977                 :            :                         "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
     978                 :            :                         "       Delete port tm node private shaper profile.\n\n"
     979                 :            : 
     980                 :            :                         "add port tm node shared shaper (port_id) (shared_shaper_id)"
     981                 :            :                         " (shaper_profile_id)\n"
     982                 :            :                         "       Add/update port tm node shared shaper.\n\n"
     983                 :            : 
     984                 :            :                         "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
     985                 :            :                         "       Delete port tm node shared shaper.\n\n"
     986                 :            : 
     987                 :            :                         "set port tm node shaper profile (port_id) (node_id)"
     988                 :            :                         " (shaper_profile_id)\n"
     989                 :            :                         "       Set port tm node shaper profile.\n\n"
     990                 :            : 
     991                 :            :                         "add port tm node wred profile (port_id) (wred_profile_id)"
     992                 :            :                         " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
     993                 :            :                         " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
     994                 :            :                         " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
     995                 :            :                         "       Add port tm node wred profile.\n\n"
     996                 :            : 
     997                 :            :                         "del port tm node wred profile (port_id) (wred_profile_id)\n"
     998                 :            :                         "       Delete port tm node wred profile.\n\n"
     999                 :            : 
    1000                 :            :                         "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
    1001                 :            :                         " (priority) (weight) (level_id) (shaper_profile_id)"
    1002                 :            :                         " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
    1003                 :            :                         " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
    1004                 :            :                         "       Add port tm nonleaf node.\n\n"
    1005                 :            : 
    1006                 :            :                         "add port tm nonleaf node pktmode (port_id) (node_id) (parent_node_id)"
    1007                 :            :                         " (priority) (weight) (level_id) (shaper_profile_id)"
    1008                 :            :                         " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
    1009                 :            :                         " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
    1010                 :            :                         "       Add port tm nonleaf node with pkt mode enabled.\n\n"
    1011                 :            : 
    1012                 :            :                         "add port tm leaf node (port_id) (node_id) (parent_node_id)"
    1013                 :            :                         " (priority) (weight) (level_id) (shaper_profile_id)"
    1014                 :            :                         " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
    1015                 :            :                         " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
    1016                 :            :                         "       Add port tm leaf node.\n\n"
    1017                 :            : 
    1018                 :            :                         "del port tm node (port_id) (node_id)\n"
    1019                 :            :                         "       Delete port tm node.\n\n"
    1020                 :            : 
    1021                 :            :                         "set port tm node parent (port_id) (node_id) (parent_node_id)"
    1022                 :            :                         " (priority) (weight)\n"
    1023                 :            :                         "       Set port tm node parent.\n\n"
    1024                 :            : 
    1025                 :            :                         "suspend port tm node (port_id) (node_id)"
    1026                 :            :                         "       Suspend tm node.\n\n"
    1027                 :            : 
    1028                 :            :                         "resume port tm node (port_id) (node_id)"
    1029                 :            :                         "       Resume tm node.\n\n"
    1030                 :            : 
    1031                 :            :                         "port tm hierarchy commit (port_id) (clean_on_fail)\n"
    1032                 :            :                         "       Commit tm hierarchy.\n\n"
    1033                 :            : 
    1034                 :            :                         "set port tm mark ip_ecn (port) (green) (yellow)"
    1035                 :            :                         " (red)\n"
    1036                 :            :                         "    Enables/Disables the traffic management marking"
    1037                 :            :                         " for IP ECN (Explicit Congestion Notification)"
    1038                 :            :                         " packets on a given port\n\n"
    1039                 :            : 
    1040                 :            :                         "set port tm mark ip_dscp (port) (green) (yellow)"
    1041                 :            :                         " (red)\n"
    1042                 :            :                         "    Enables/Disables the traffic management marking"
    1043                 :            :                         " on the port for IP dscp packets\n\n"
    1044                 :            : 
    1045                 :            :                         "set port tm mark vlan_dei (port) (green) (yellow)"
    1046                 :            :                         " (red)\n"
    1047                 :            :                         "    Enables/Disables the traffic management marking"
    1048                 :            :                         " on the port for VLAN packets with DEI enabled\n\n"
    1049                 :            :                 );
    1050                 :            :         }
    1051                 :            : 
    1052                 :          0 :         if (show_all || !strcmp(res->section, "devices")) {
    1053                 :          0 :                 cmdline_printf(
    1054                 :            :                         cl,
    1055                 :            :                         "\n"
    1056                 :            :                         "Device Operations:\n"
    1057                 :            :                         "--------------\n"
    1058                 :            :                         "device detach (identifier)\n"
    1059                 :            :                         "       Detach device by identifier.\n\n"
    1060                 :            :                 );
    1061                 :            :         }
    1062                 :            : 
    1063                 :          0 :         if (show_all || !strcmp(res->section, "drivers")) {
    1064                 :            :                 struct testpmd_driver_commands *c;
    1065                 :            :                 unsigned int i;
    1066                 :            : 
    1067                 :          0 :                 cmdline_printf(
    1068                 :            :                         cl,
    1069                 :            :                         "\n"
    1070                 :            :                         "Driver specific:\n"
    1071                 :            :                         "----------------\n"
    1072                 :            :                 );
    1073                 :          0 :                 TAILQ_FOREACH(c, &driver_commands_head, next) {
    1074                 :          0 :                         for (i = 0; c->commands[i].ctx != NULL; i++)
    1075                 :          0 :                                 cmdline_printf(cl, "%s\n", c->commands[i].help);
    1076                 :            :                 }
    1077                 :            :         }
    1078                 :          0 : }
    1079                 :            : 
    1080                 :            : static cmdline_parse_token_string_t cmd_help_long_help =
    1081                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
    1082                 :            : 
    1083                 :            : static cmdline_parse_token_string_t cmd_help_long_section =
    1084                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
    1085                 :            :                 "all#control#display#config#ports#"
    1086                 :            :                 "filters#traffic_management#devices#drivers");
    1087                 :            : 
    1088                 :            : static cmdline_parse_inst_t cmd_help_long = {
    1089                 :            :         .f = cmd_help_long_parsed,
    1090                 :            :         .data = NULL,
    1091                 :            :         .help_str = "help all|control|display|config|ports|"
    1092                 :            :                 "filters|traffic_management|devices|drivers: "
    1093                 :            :                 "Show help",
    1094                 :            :         .tokens = {
    1095                 :            :                 (void *)&cmd_help_long_help,
    1096                 :            :                 (void *)&cmd_help_long_section,
    1097                 :            :                 NULL,
    1098                 :            :         },
    1099                 :            : };
    1100                 :            : 
    1101                 :            : 
    1102                 :            : /* *** start/stop/close all ports *** */
    1103                 :            : struct cmd_operate_port_result {
    1104                 :            :         cmdline_fixed_string_t keyword;
    1105                 :            :         cmdline_fixed_string_t name;
    1106                 :            :         cmdline_fixed_string_t value;
    1107                 :            : };
    1108                 :            : 
    1109                 :          0 : static void cmd_operate_port_parsed(void *parsed_result,
    1110                 :            :                                 __rte_unused struct cmdline *cl,
    1111                 :            :                                 __rte_unused void *data)
    1112                 :            : {
    1113                 :            :         struct cmd_operate_port_result *res = parsed_result;
    1114                 :            : 
    1115                 :          0 :         if (!strcmp(res->name, "start"))
    1116                 :          0 :                 start_port(RTE_PORT_ALL);
    1117                 :          0 :         else if (!strcmp(res->name, "stop"))
    1118                 :          0 :                 stop_port(RTE_PORT_ALL);
    1119                 :          0 :         else if (!strcmp(res->name, "close"))
    1120                 :          0 :                 close_port(RTE_PORT_ALL);
    1121                 :          0 :         else if (!strcmp(res->name, "reset"))
    1122                 :          0 :                 reset_port(RTE_PORT_ALL);
    1123                 :            :         else
    1124                 :          0 :                 fprintf(stderr, "Unknown parameter\n");
    1125                 :          0 : }
    1126                 :            : 
    1127                 :            : static cmdline_parse_token_string_t cmd_operate_port_all_cmd =
    1128                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
    1129                 :            :                                                                 "port");
    1130                 :            : static cmdline_parse_token_string_t cmd_operate_port_all_port =
    1131                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
    1132                 :            :                                                 "start#stop#close#reset");
    1133                 :            : static cmdline_parse_token_string_t cmd_operate_port_all_all =
    1134                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
    1135                 :            : 
    1136                 :            : static cmdline_parse_inst_t cmd_operate_port = {
    1137                 :            :         .f = cmd_operate_port_parsed,
    1138                 :            :         .data = NULL,
    1139                 :            :         .help_str = "port start|stop|close|reset all: Start/Stop/Close/Reset all ports",
    1140                 :            :         .tokens = {
    1141                 :            :                 (void *)&cmd_operate_port_all_cmd,
    1142                 :            :                 (void *)&cmd_operate_port_all_port,
    1143                 :            :                 (void *)&cmd_operate_port_all_all,
    1144                 :            :                 NULL,
    1145                 :            :         },
    1146                 :            : };
    1147                 :            : 
    1148                 :            : /* *** start/stop/close specific port *** */
    1149                 :            : struct cmd_operate_specific_port_result {
    1150                 :            :         cmdline_fixed_string_t keyword;
    1151                 :            :         cmdline_fixed_string_t name;
    1152                 :            :         uint8_t value;
    1153                 :            : };
    1154                 :            : 
    1155                 :          0 : static void cmd_operate_specific_port_parsed(void *parsed_result,
    1156                 :            :                         __rte_unused struct cmdline *cl,
    1157                 :            :                                 __rte_unused void *data)
    1158                 :            : {
    1159                 :            :         struct cmd_operate_specific_port_result *res = parsed_result;
    1160                 :            : 
    1161                 :          0 :         if (!strcmp(res->name, "start"))
    1162                 :          0 :                 start_port(res->value);
    1163                 :          0 :         else if (!strcmp(res->name, "stop"))
    1164                 :          0 :                 stop_port(res->value);
    1165                 :          0 :         else if (!strcmp(res->name, "close"))
    1166                 :          0 :                 close_port(res->value);
    1167                 :          0 :         else if (!strcmp(res->name, "reset"))
    1168                 :          0 :                 reset_port(res->value);
    1169                 :            :         else
    1170                 :          0 :                 fprintf(stderr, "Unknown parameter\n");
    1171                 :          0 : }
    1172                 :            : 
    1173                 :            : static cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
    1174                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
    1175                 :            :                                                         keyword, "port");
    1176                 :            : static cmdline_parse_token_string_t cmd_operate_specific_port_port =
    1177                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
    1178                 :            :                                                 name, "start#stop#close#reset");
    1179                 :            : static cmdline_parse_token_num_t cmd_operate_specific_port_id =
    1180                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
    1181                 :            :                                                         value, RTE_UINT8);
    1182                 :            : 
    1183                 :            : static cmdline_parse_inst_t cmd_operate_specific_port = {
    1184                 :            :         .f = cmd_operate_specific_port_parsed,
    1185                 :            :         .data = NULL,
    1186                 :            :         .help_str = "port start|stop|close|reset <port_id>: Start/Stop/Close/Reset port_id",
    1187                 :            :         .tokens = {
    1188                 :            :                 (void *)&cmd_operate_specific_port_cmd,
    1189                 :            :                 (void *)&cmd_operate_specific_port_port,
    1190                 :            :                 (void *)&cmd_operate_specific_port_id,
    1191                 :            :                 NULL,
    1192                 :            :         },
    1193                 :            : };
    1194                 :            : 
    1195                 :            : /* *** enable port setup (after attach) via iterator or event *** */
    1196                 :            : struct cmd_set_port_setup_on_result {
    1197                 :            :         cmdline_fixed_string_t set;
    1198                 :            :         cmdline_fixed_string_t port;
    1199                 :            :         cmdline_fixed_string_t setup;
    1200                 :            :         cmdline_fixed_string_t on;
    1201                 :            :         cmdline_fixed_string_t mode;
    1202                 :            : };
    1203                 :            : 
    1204                 :          0 : static void cmd_set_port_setup_on_parsed(void *parsed_result,
    1205                 :            :                                 __rte_unused struct cmdline *cl,
    1206                 :            :                                 __rte_unused void *data)
    1207                 :            : {
    1208                 :            :         struct cmd_set_port_setup_on_result *res = parsed_result;
    1209                 :            : 
    1210                 :          0 :         if (strcmp(res->mode, "event") == 0)
    1211                 :          0 :                 setup_on_probe_event = true;
    1212                 :          0 :         else if (strcmp(res->mode, "iterator") == 0)
    1213                 :          0 :                 setup_on_probe_event = false;
    1214                 :            :         else
    1215                 :          0 :                 fprintf(stderr, "Unknown mode\n");
    1216                 :          0 : }
    1217                 :            : 
    1218                 :            : static cmdline_parse_token_string_t cmd_set_port_setup_on_set =
    1219                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
    1220                 :            :                         set, "set");
    1221                 :            : static cmdline_parse_token_string_t cmd_set_port_setup_on_port =
    1222                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
    1223                 :            :                         port, "port");
    1224                 :            : static cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
    1225                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
    1226                 :            :                         setup, "setup");
    1227                 :            : static cmdline_parse_token_string_t cmd_set_port_setup_on_on =
    1228                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
    1229                 :            :                         on, "on");
    1230                 :            : static cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
    1231                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
    1232                 :            :                         mode, "iterator#event");
    1233                 :            : 
    1234                 :            : static cmdline_parse_inst_t cmd_set_port_setup_on = {
    1235                 :            :         .f = cmd_set_port_setup_on_parsed,
    1236                 :            :         .data = NULL,
    1237                 :            :         .help_str = "set port setup on iterator|event",
    1238                 :            :         .tokens = {
    1239                 :            :                 (void *)&cmd_set_port_setup_on_set,
    1240                 :            :                 (void *)&cmd_set_port_setup_on_port,
    1241                 :            :                 (void *)&cmd_set_port_setup_on_setup,
    1242                 :            :                 (void *)&cmd_set_port_setup_on_on,
    1243                 :            :                 (void *)&cmd_set_port_setup_on_mode,
    1244                 :            :                 NULL,
    1245                 :            :         },
    1246                 :            : };
    1247                 :            : 
    1248                 :            : /* *** attach a specified port *** */
    1249                 :            : struct cmd_operate_attach_port_result {
    1250                 :            :         cmdline_fixed_string_t port;
    1251                 :            :         cmdline_fixed_string_t keyword;
    1252                 :            :         cmdline_multi_string_t identifier;
    1253                 :            : };
    1254                 :            : 
    1255                 :          0 : static void cmd_operate_attach_port_parsed(void *parsed_result,
    1256                 :            :                                 __rte_unused struct cmdline *cl,
    1257                 :            :                                 __rte_unused void *data)
    1258                 :            : {
    1259                 :            :         struct cmd_operate_attach_port_result *res = parsed_result;
    1260                 :            : 
    1261                 :          0 :         if (!strcmp(res->keyword, "attach"))
    1262                 :          0 :                 attach_port(res->identifier);
    1263                 :            :         else
    1264                 :          0 :                 fprintf(stderr, "Unknown parameter\n");
    1265                 :          0 : }
    1266                 :            : 
    1267                 :            : static cmdline_parse_token_string_t cmd_operate_attach_port_port =
    1268                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
    1269                 :            :                         port, "port");
    1270                 :            : static cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
    1271                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
    1272                 :            :                         keyword, "attach");
    1273                 :            : static cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
    1274                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
    1275                 :            :                         identifier, TOKEN_STRING_MULTI);
    1276                 :            : 
    1277                 :            : static cmdline_parse_inst_t cmd_operate_attach_port = {
    1278                 :            :         .f = cmd_operate_attach_port_parsed,
    1279                 :            :         .data = NULL,
    1280                 :            :         .help_str = "port attach <identifier>: "
    1281                 :            :                 "(identifier: pci address or virtual dev name)",
    1282                 :            :         .tokens = {
    1283                 :            :                 (void *)&cmd_operate_attach_port_port,
    1284                 :            :                 (void *)&cmd_operate_attach_port_keyword,
    1285                 :            :                 (void *)&cmd_operate_attach_port_identifier,
    1286                 :            :                 NULL,
    1287                 :            :         },
    1288                 :            : };
    1289                 :            : 
    1290                 :            : /* *** detach a specified port *** */
    1291                 :            : struct cmd_operate_detach_port_result {
    1292                 :            :         cmdline_fixed_string_t port;
    1293                 :            :         cmdline_fixed_string_t keyword;
    1294                 :            :         portid_t port_id;
    1295                 :            : };
    1296                 :            : 
    1297                 :          0 : static void cmd_operate_detach_port_parsed(void *parsed_result,
    1298                 :            :                                 __rte_unused struct cmdline *cl,
    1299                 :            :                                 __rte_unused void *data)
    1300                 :            : {
    1301                 :            :         struct cmd_operate_detach_port_result *res = parsed_result;
    1302                 :            : 
    1303                 :          0 :         if (!strcmp(res->keyword, "detach")) {
    1304                 :          0 :                 RTE_ETH_VALID_PORTID_OR_RET(res->port_id);
    1305                 :          0 :                 detach_port_device(res->port_id);
    1306                 :            :         } else {
    1307                 :          0 :                 fprintf(stderr, "Unknown parameter\n");
    1308                 :            :         }
    1309                 :            : }
    1310                 :            : 
    1311                 :            : static cmdline_parse_token_string_t cmd_operate_detach_port_port =
    1312                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
    1313                 :            :                         port, "port");
    1314                 :            : static cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
    1315                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
    1316                 :            :                         keyword, "detach");
    1317                 :            : static cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
    1318                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
    1319                 :            :                         port_id, RTE_UINT16);
    1320                 :            : 
    1321                 :            : static cmdline_parse_inst_t cmd_operate_detach_port = {
    1322                 :            :         .f = cmd_operate_detach_port_parsed,
    1323                 :            :         .data = NULL,
    1324                 :            :         .help_str = "port detach <port_id>",
    1325                 :            :         .tokens = {
    1326                 :            :                 (void *)&cmd_operate_detach_port_port,
    1327                 :            :                 (void *)&cmd_operate_detach_port_keyword,
    1328                 :            :                 (void *)&cmd_operate_detach_port_port_id,
    1329                 :            :                 NULL,
    1330                 :            :         },
    1331                 :            : };
    1332                 :            : 
    1333                 :            : /* *** detach device by identifier *** */
    1334                 :            : struct cmd_operate_detach_device_result {
    1335                 :            :         cmdline_fixed_string_t device;
    1336                 :            :         cmdline_fixed_string_t keyword;
    1337                 :            :         cmdline_fixed_string_t identifier;
    1338                 :            : };
    1339                 :            : 
    1340                 :          0 : static void cmd_operate_detach_device_parsed(void *parsed_result,
    1341                 :            :                                 __rte_unused struct cmdline *cl,
    1342                 :            :                                 __rte_unused void *data)
    1343                 :            : {
    1344                 :            :         struct cmd_operate_detach_device_result *res = parsed_result;
    1345                 :            : 
    1346                 :          0 :         if (!strcmp(res->keyword, "detach"))
    1347                 :          0 :                 detach_devargs(res->identifier);
    1348                 :            :         else
    1349                 :          0 :                 fprintf(stderr, "Unknown parameter\n");
    1350                 :          0 : }
    1351                 :            : 
    1352                 :            : static cmdline_parse_token_string_t cmd_operate_detach_device_device =
    1353                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
    1354                 :            :                         device, "device");
    1355                 :            : static cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
    1356                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
    1357                 :            :                         keyword, "detach");
    1358                 :            : static cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
    1359                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
    1360                 :            :                         identifier, NULL);
    1361                 :            : 
    1362                 :            : static cmdline_parse_inst_t cmd_operate_detach_device = {
    1363                 :            :         .f = cmd_operate_detach_device_parsed,
    1364                 :            :         .data = NULL,
    1365                 :            :         .help_str = "device detach <identifier>:"
    1366                 :            :                 "(identifier: pci address or virtual dev name)",
    1367                 :            :         .tokens = {
    1368                 :            :                 (void *)&cmd_operate_detach_device_device,
    1369                 :            :                 (void *)&cmd_operate_detach_device_keyword,
    1370                 :            :                 (void *)&cmd_operate_detach_device_identifier,
    1371                 :            :                 NULL,
    1372                 :            :         },
    1373                 :            : };
    1374                 :            : /* *** configure speed for all ports *** */
    1375                 :            : struct cmd_config_speed_all {
    1376                 :            :         cmdline_fixed_string_t port;
    1377                 :            :         cmdline_fixed_string_t keyword;
    1378                 :            :         cmdline_fixed_string_t all;
    1379                 :            :         cmdline_fixed_string_t item1;
    1380                 :            :         cmdline_fixed_string_t item2;
    1381                 :            :         cmdline_fixed_string_t value1;
    1382                 :            :         cmdline_fixed_string_t value2;
    1383                 :            : };
    1384                 :            : 
    1385                 :            : static int
    1386                 :          0 : parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
    1387                 :            : {
    1388                 :            : 
    1389                 :            :         int duplex;
    1390                 :            : 
    1391                 :          0 :         if (!strcmp(duplexstr, "half")) {
    1392                 :            :                 duplex = RTE_ETH_LINK_HALF_DUPLEX;
    1393                 :          0 :         } else if (!strcmp(duplexstr, "full")) {
    1394                 :            :                 duplex = RTE_ETH_LINK_FULL_DUPLEX;
    1395                 :          0 :         } else if (!strcmp(duplexstr, "auto")) {
    1396                 :            :                 duplex = RTE_ETH_LINK_FULL_DUPLEX;
    1397                 :            :         } else {
    1398                 :          0 :                 fprintf(stderr, "Unknown duplex parameter\n");
    1399                 :          0 :                 return -1;
    1400                 :            :         }
    1401                 :            : 
    1402                 :          0 :         if (!strcmp(speedstr, "10")) {
    1403                 :          0 :                 *speed = (duplex == RTE_ETH_LINK_HALF_DUPLEX) ?
    1404                 :          0 :                                 RTE_ETH_LINK_SPEED_10M_HD : RTE_ETH_LINK_SPEED_10M;
    1405                 :          0 :         } else if (!strcmp(speedstr, "100")) {
    1406                 :          0 :                 *speed = (duplex == RTE_ETH_LINK_HALF_DUPLEX) ?
    1407                 :          0 :                                 RTE_ETH_LINK_SPEED_100M_HD : RTE_ETH_LINK_SPEED_100M;
    1408                 :            :         } else {
    1409                 :          0 :                 if (duplex != RTE_ETH_LINK_FULL_DUPLEX) {
    1410                 :          0 :                         fprintf(stderr, "Invalid speed/duplex parameters\n");
    1411                 :          0 :                         return -1;
    1412                 :            :                 }
    1413                 :          0 :                 if (!strcmp(speedstr, "1000")) {
    1414                 :          0 :                         *speed = RTE_ETH_LINK_SPEED_1G;
    1415                 :          0 :                 } else if (!strcmp(speedstr, "2500")) {
    1416                 :          0 :                         *speed = RTE_ETH_LINK_SPEED_2_5G;
    1417                 :          0 :                 } else if (!strcmp(speedstr, "5000")) {
    1418                 :          0 :                         *speed = RTE_ETH_LINK_SPEED_5G;
    1419                 :          0 :                 } else if (!strcmp(speedstr, "10000")) {
    1420                 :          0 :                         *speed = RTE_ETH_LINK_SPEED_10G;
    1421                 :          0 :                 } else if (!strcmp(speedstr, "25000")) {
    1422                 :          0 :                         *speed = RTE_ETH_LINK_SPEED_25G;
    1423                 :          0 :                 } else if (!strcmp(speedstr, "40000")) {
    1424                 :          0 :                         *speed = RTE_ETH_LINK_SPEED_40G;
    1425                 :          0 :                 } else if (!strcmp(speedstr, "50000")) {
    1426                 :          0 :                         *speed = RTE_ETH_LINK_SPEED_50G;
    1427                 :          0 :                 } else if (!strcmp(speedstr, "100000")) {
    1428                 :          0 :                         *speed = RTE_ETH_LINK_SPEED_100G;
    1429                 :          0 :                 } else if (!strcmp(speedstr, "200000")) {
    1430                 :          0 :                         *speed = RTE_ETH_LINK_SPEED_200G;
    1431                 :          0 :                 } else if (!strcmp(speedstr, "400000")) {
    1432                 :          0 :                         *speed = RTE_ETH_LINK_SPEED_400G;
    1433                 :          0 :                 } else if (!strcmp(speedstr, "auto")) {
    1434                 :          0 :                         *speed = RTE_ETH_LINK_SPEED_AUTONEG;
    1435                 :            :                 } else {
    1436                 :          0 :                         fprintf(stderr, "Unknown speed parameter\n");
    1437                 :          0 :                         return -1;
    1438                 :            :                 }
    1439                 :            :         }
    1440                 :            : 
    1441                 :          0 :         if (*speed != RTE_ETH_LINK_SPEED_AUTONEG)
    1442                 :          0 :                 *speed |= RTE_ETH_LINK_SPEED_FIXED;
    1443                 :            : 
    1444                 :            :         return 0;
    1445                 :            : }
    1446                 :            : 
    1447                 :            : static void
    1448                 :          0 : cmd_config_speed_all_parsed(void *parsed_result,
    1449                 :            :                         __rte_unused struct cmdline *cl,
    1450                 :            :                         __rte_unused void *data)
    1451                 :            : {
    1452                 :            :         struct cmd_config_speed_all *res = parsed_result;
    1453                 :            :         uint32_t link_speed;
    1454                 :            :         portid_t pid;
    1455                 :            : 
    1456                 :          0 :         if (!all_ports_stopped()) {
    1457                 :          0 :                 fprintf(stderr, "Please stop all ports first\n");
    1458                 :          0 :                 return;
    1459                 :            :         }
    1460                 :            : 
    1461                 :          0 :         if (parse_and_check_speed_duplex(res->value1, res->value2,
    1462                 :            :                         &link_speed) < 0)
    1463                 :            :                 return;
    1464                 :            : 
    1465                 :          0 :         RTE_ETH_FOREACH_DEV(pid) {
    1466                 :          0 :                 ports[pid].dev_conf.link_speeds = link_speed;
    1467                 :            :         }
    1468                 :            : 
    1469                 :          0 :         cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
    1470                 :            : }
    1471                 :            : 
    1472                 :            : static cmdline_parse_token_string_t cmd_config_speed_all_port =
    1473                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
    1474                 :            : static cmdline_parse_token_string_t cmd_config_speed_all_keyword =
    1475                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
    1476                 :            :                                                         "config");
    1477                 :            : static cmdline_parse_token_string_t cmd_config_speed_all_all =
    1478                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
    1479                 :            : static cmdline_parse_token_string_t cmd_config_speed_all_item1 =
    1480                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
    1481                 :            : static cmdline_parse_token_string_t cmd_config_speed_all_value1 =
    1482                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
    1483                 :            :                                 "10#100#1000#2500#5000#10000#25000#40000#50000#100000#200000#400000#auto");
    1484                 :            : static cmdline_parse_token_string_t cmd_config_speed_all_item2 =
    1485                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
    1486                 :            : static cmdline_parse_token_string_t cmd_config_speed_all_value2 =
    1487                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
    1488                 :            :                                                 "half#full#auto");
    1489                 :            : 
    1490                 :            : static cmdline_parse_inst_t cmd_config_speed_all = {
    1491                 :            :         .f = cmd_config_speed_all_parsed,
    1492                 :            :         .data = NULL,
    1493                 :            :         .help_str = "port config all speed "
    1494                 :            :                 "10|100|1000|2500|5000|10000|25000|40000|50000|100000|200000|400000|auto duplex "
    1495                 :            :                                                         "half|full|auto",
    1496                 :            :         .tokens = {
    1497                 :            :                 (void *)&cmd_config_speed_all_port,
    1498                 :            :                 (void *)&cmd_config_speed_all_keyword,
    1499                 :            :                 (void *)&cmd_config_speed_all_all,
    1500                 :            :                 (void *)&cmd_config_speed_all_item1,
    1501                 :            :                 (void *)&cmd_config_speed_all_value1,
    1502                 :            :                 (void *)&cmd_config_speed_all_item2,
    1503                 :            :                 (void *)&cmd_config_speed_all_value2,
    1504                 :            :                 NULL,
    1505                 :            :         },
    1506                 :            : };
    1507                 :            : 
    1508                 :            : /* *** configure speed for specific port *** */
    1509                 :            : struct cmd_config_speed_specific {
    1510                 :            :         cmdline_fixed_string_t port;
    1511                 :            :         cmdline_fixed_string_t keyword;
    1512                 :            :         portid_t id;
    1513                 :            :         cmdline_fixed_string_t item1;
    1514                 :            :         cmdline_fixed_string_t item2;
    1515                 :            :         cmdline_fixed_string_t value1;
    1516                 :            :         cmdline_fixed_string_t value2;
    1517                 :            : };
    1518                 :            : 
    1519                 :            : static void
    1520                 :          0 : cmd_config_speed_specific_parsed(void *parsed_result,
    1521                 :            :                                 __rte_unused struct cmdline *cl,
    1522                 :            :                                 __rte_unused void *data)
    1523                 :            : {
    1524                 :            :         struct cmd_config_speed_specific *res = parsed_result;
    1525                 :            :         uint32_t link_speed;
    1526                 :            : 
    1527                 :          0 :         if (port_id_is_invalid(res->id, ENABLED_WARN))
    1528                 :          0 :                 return;
    1529                 :            : 
    1530                 :          0 :         if (!port_is_stopped(res->id)) {
    1531                 :          0 :                 fprintf(stderr, "Please stop port %d first\n", res->id);
    1532                 :          0 :                 return;
    1533                 :            :         }
    1534                 :            : 
    1535                 :          0 :         if (parse_and_check_speed_duplex(res->value1, res->value2,
    1536                 :            :                         &link_speed) < 0)
    1537                 :            :                 return;
    1538                 :            : 
    1539                 :          0 :         ports[res->id].dev_conf.link_speeds = link_speed;
    1540                 :            : 
    1541                 :          0 :         cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
    1542                 :            : }
    1543                 :            : 
    1544                 :            : 
    1545                 :            : static cmdline_parse_token_string_t cmd_config_speed_specific_port =
    1546                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
    1547                 :            :                                                                 "port");
    1548                 :            : static cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
    1549                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
    1550                 :            :                                                                 "config");
    1551                 :            : static cmdline_parse_token_num_t cmd_config_speed_specific_id =
    1552                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, RTE_UINT16);
    1553                 :            : static cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
    1554                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
    1555                 :            :                                                                 "speed");
    1556                 :            : static cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
    1557                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
    1558                 :            :                                 "10#100#1000#2500#5000#10000#25000#40000#50000#100000#200000#400000#auto");
    1559                 :            : static cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
    1560                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
    1561                 :            :                                                                 "duplex");
    1562                 :            : static cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
    1563                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
    1564                 :            :                                                         "half#full#auto");
    1565                 :            : 
    1566                 :            : static cmdline_parse_inst_t cmd_config_speed_specific = {
    1567                 :            :         .f = cmd_config_speed_specific_parsed,
    1568                 :            :         .data = NULL,
    1569                 :            :         .help_str = "port config <port_id> speed "
    1570                 :            :                 "10|100|1000|2500|5000|10000|25000|40000|50000|100000|200000|400000|auto duplex "
    1571                 :            :                                                         "half|full|auto",
    1572                 :            :         .tokens = {
    1573                 :            :                 (void *)&cmd_config_speed_specific_port,
    1574                 :            :                 (void *)&cmd_config_speed_specific_keyword,
    1575                 :            :                 (void *)&cmd_config_speed_specific_id,
    1576                 :            :                 (void *)&cmd_config_speed_specific_item1,
    1577                 :            :                 (void *)&cmd_config_speed_specific_value1,
    1578                 :            :                 (void *)&cmd_config_speed_specific_item2,
    1579                 :            :                 (void *)&cmd_config_speed_specific_value2,
    1580                 :            :                 NULL,
    1581                 :            :         },
    1582                 :            : };
    1583                 :            : 
    1584                 :            : static int
    1585                 :          0 : parse_speed_lanes_cfg(portid_t pid, uint32_t lanes)
    1586                 :            : {
    1587                 :            :         int ret;
    1588                 :            : 
    1589                 :          0 :         ret = rte_eth_speed_lanes_set(pid, lanes);
    1590                 :          0 :         if (ret == -ENOTSUP) {
    1591                 :          0 :                 fprintf(stderr, "Function not implemented\n");
    1592                 :          0 :                 return -1;
    1593                 :          0 :         } else if (ret < 0) {
    1594                 :          0 :                 fprintf(stderr, "Set speed lanes failed\n");
    1595                 :          0 :                 return -1;
    1596                 :            :         }
    1597                 :            : 
    1598                 :            :         return 0;
    1599                 :            : }
    1600                 :            : 
    1601                 :            : static void
    1602                 :          0 : show_speed_lanes_capability(unsigned int num, struct rte_eth_speed_lanes_capa *speed_lanes_capa)
    1603                 :            : {
    1604                 :            :         unsigned int i;
    1605                 :            :         uint32_t capa;
    1606                 :            : 
    1607                 :            :         printf("\n%-15s %-10s", "Supported-speeds", "Valid-lanes");
    1608                 :            :         printf("\n-----------------------------------\n");
    1609                 :          0 :         for (i = 0; i < num; i++) {
    1610                 :          0 :                 printf("%-17s ",
    1611                 :          0 :                        rte_eth_link_speed_to_str(speed_lanes_capa[i].speed));
    1612                 :          0 :                 capa = speed_lanes_capa[i].capa;
    1613                 :            :                 int s = 0;
    1614                 :            : 
    1615                 :          0 :                 while (capa) {
    1616                 :          0 :                         if (capa & 0x1)
    1617                 :            :                                 printf("%-2d ", s);
    1618                 :          0 :                         s++;
    1619                 :          0 :                         capa = capa >> 1;
    1620                 :            :                 }
    1621                 :            :                 printf("\n");
    1622                 :            :         }
    1623                 :          0 : }
    1624                 :            : 
    1625                 :            : /* *** display speed lanes per port capabilities *** */
    1626                 :            : struct cmd_show_speed_lanes_result {
    1627                 :            :         cmdline_fixed_string_t cmd_show;
    1628                 :            :         cmdline_fixed_string_t cmd_port;
    1629                 :            :         cmdline_fixed_string_t cmd_keyword;
    1630                 :            :         portid_t cmd_pid;
    1631                 :            : };
    1632                 :            : 
    1633                 :            : static void
    1634                 :          0 : cmd_show_speed_lanes_parsed(void *parsed_result,
    1635                 :            :                             __rte_unused struct cmdline *cl,
    1636                 :            :                             __rte_unused void *data)
    1637                 :            : {
    1638                 :            :         struct cmd_show_speed_lanes_result *res = parsed_result;
    1639                 :            :         struct rte_eth_speed_lanes_capa *speed_lanes_capa;
    1640                 :            :         unsigned int num;
    1641                 :            :         int ret;
    1642                 :            : 
    1643                 :          0 :         if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
    1644                 :          0 :                 fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
    1645                 :          0 :                 return;
    1646                 :            :         }
    1647                 :            : 
    1648                 :          0 :         ret = rte_eth_speed_lanes_get_capability(res->cmd_pid, NULL, 0);
    1649                 :          0 :         if (ret == -ENOTSUP) {
    1650                 :          0 :                 fprintf(stderr, "Function not implemented\n");
    1651                 :          0 :                 return;
    1652                 :          0 :         } else if (ret < 0) {
    1653                 :          0 :                 fprintf(stderr, "Get speed lanes capability failed: %d\n", ret);
    1654                 :          0 :                 return;
    1655                 :            :         }
    1656                 :            : 
    1657                 :          0 :         num = (unsigned int)ret;
    1658                 :          0 :         speed_lanes_capa = calloc(num, sizeof(*speed_lanes_capa));
    1659                 :          0 :         if (speed_lanes_capa == NULL) {
    1660                 :          0 :                 fprintf(stderr, "Failed to alloc speed lanes capability buffer\n");
    1661                 :          0 :                 return;
    1662                 :            :         }
    1663                 :            : 
    1664                 :          0 :         ret = rte_eth_speed_lanes_get_capability(res->cmd_pid, speed_lanes_capa, num);
    1665                 :          0 :         if (ret < 0) {
    1666                 :          0 :                 fprintf(stderr, "Error getting speed lanes capability: %d\n", ret);
    1667                 :          0 :                 goto out;
    1668                 :            :         }
    1669                 :            : 
    1670                 :          0 :         show_speed_lanes_capability(num, speed_lanes_capa);
    1671                 :          0 : out:
    1672                 :          0 :         free(speed_lanes_capa);
    1673                 :            : }
    1674                 :            : 
    1675                 :            : static cmdline_parse_token_string_t cmd_show_speed_lanes_show =
    1676                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_show_speed_lanes_result,
    1677                 :            :                                  cmd_show, "show");
    1678                 :            : static cmdline_parse_token_string_t cmd_show_speed_lanes_port =
    1679                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_show_speed_lanes_result,
    1680                 :            :                                  cmd_port, "port");
    1681                 :            : static cmdline_parse_token_num_t cmd_show_speed_lanes_pid =
    1682                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_show_speed_lanes_result,
    1683                 :            :                               cmd_pid, RTE_UINT16);
    1684                 :            : static cmdline_parse_token_string_t cmd_show_speed_lanes_keyword =
    1685                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_show_speed_lanes_result,
    1686                 :            :                                  cmd_keyword, "speed_lanes");
    1687                 :            : static cmdline_parse_token_string_t cmd_show_speed_lanes_cap_keyword =
    1688                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_show_speed_lanes_result,
    1689                 :            :                                  cmd_keyword, "capabilities");
    1690                 :            : 
    1691                 :            : static cmdline_parse_inst_t cmd_show_speed_lanes = {
    1692                 :            :         .f = cmd_show_speed_lanes_parsed,
    1693                 :            :         .data = NULL,
    1694                 :            :         .help_str = "show port <port_id> speed_lanes capabilities",
    1695                 :            :         .tokens = {
    1696                 :            :                 (void *)&cmd_show_speed_lanes_show,
    1697                 :            :                 (void *)&cmd_show_speed_lanes_port,
    1698                 :            :                 (void *)&cmd_show_speed_lanes_pid,
    1699                 :            :                 (void *)&cmd_show_speed_lanes_keyword,
    1700                 :            :                 (void *)&cmd_show_speed_lanes_cap_keyword,
    1701                 :            :                 NULL,
    1702                 :            :         },
    1703                 :            : };
    1704                 :            : 
    1705                 :            : /* *** configure speed_lanes for all ports *** */
    1706                 :            : struct cmd_config_speed_lanes_all {
    1707                 :            :         cmdline_fixed_string_t port;
    1708                 :            :         cmdline_fixed_string_t keyword;
    1709                 :            :         cmdline_fixed_string_t all;
    1710                 :            :         cmdline_fixed_string_t item;
    1711                 :            :         uint32_t lanes;
    1712                 :            : };
    1713                 :            : 
    1714                 :            : static void
    1715                 :          0 : cmd_config_speed_lanes_all_parsed(void *parsed_result,
    1716                 :            :                                   __rte_unused struct cmdline *cl,
    1717                 :            :                                   __rte_unused void *data)
    1718                 :            : {
    1719                 :            :         struct cmd_config_speed_lanes_all *res = parsed_result;
    1720                 :            :         portid_t pid;
    1721                 :            : 
    1722                 :          0 :         if (!all_ports_stopped()) {
    1723                 :          0 :                 fprintf(stderr, "Please stop all ports first\n");
    1724                 :          0 :                 return;
    1725                 :            :         }
    1726                 :            : 
    1727                 :          0 :         RTE_ETH_FOREACH_DEV(pid) {
    1728                 :          0 :                 if (parse_speed_lanes_cfg(pid, res->lanes))
    1729                 :            :                         return;
    1730                 :            :         }
    1731                 :            : 
    1732                 :          0 :         cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
    1733                 :            : }
    1734                 :            : 
    1735                 :            : static cmdline_parse_token_string_t cmd_config_speed_lanes_all_port =
    1736                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_all, port, "port");
    1737                 :            : static cmdline_parse_token_string_t cmd_config_speed_lanes_all_keyword =
    1738                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_all, keyword,
    1739                 :            :                                  "config");
    1740                 :            : static cmdline_parse_token_string_t cmd_config_speed_lanes_all_all =
    1741                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_all, all, "all");
    1742                 :            : static cmdline_parse_token_string_t cmd_config_speed_lanes_all_item =
    1743                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_all, item,
    1744                 :            :                                  "speed_lanes");
    1745                 :            : static cmdline_parse_token_num_t cmd_config_speed_lanes_all_lanes =
    1746                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_config_speed_lanes_all, lanes, RTE_UINT32);
    1747                 :            : 
    1748                 :            : static cmdline_parse_inst_t cmd_config_speed_lanes_all = {
    1749                 :            :         .f = cmd_config_speed_lanes_all_parsed,
    1750                 :            :         .data = NULL,
    1751                 :            :         .help_str = "port config all speed_lanes <value>",
    1752                 :            :         .tokens = {
    1753                 :            :                 (void *)&cmd_config_speed_lanes_all_port,
    1754                 :            :                 (void *)&cmd_config_speed_lanes_all_keyword,
    1755                 :            :                 (void *)&cmd_config_speed_lanes_all_all,
    1756                 :            :                 (void *)&cmd_config_speed_lanes_all_item,
    1757                 :            :                 (void *)&cmd_config_speed_lanes_all_lanes,
    1758                 :            :                 NULL,
    1759                 :            :         },
    1760                 :            : };
    1761                 :            : 
    1762                 :            : /* *** configure speed_lanes for specific port *** */
    1763                 :            : struct cmd_config_speed_lanes_specific {
    1764                 :            :         cmdline_fixed_string_t port;
    1765                 :            :         cmdline_fixed_string_t keyword;
    1766                 :            :         uint16_t port_id;
    1767                 :            :         cmdline_fixed_string_t item;
    1768                 :            :         uint32_t lanes;
    1769                 :            : };
    1770                 :            : 
    1771                 :            : static void
    1772                 :          0 : cmd_config_speed_lanes_specific_parsed(void *parsed_result,
    1773                 :            :                                        __rte_unused struct cmdline *cl,
    1774                 :            :                                        __rte_unused void *data)
    1775                 :            : {
    1776                 :            :         struct cmd_config_speed_lanes_specific *res = parsed_result;
    1777                 :            : 
    1778                 :          0 :         if (port_id_is_invalid(res->port_id, ENABLED_WARN))
    1779                 :            :                 return;
    1780                 :            : 
    1781                 :          0 :         if (!port_is_stopped(res->port_id)) {
    1782                 :          0 :                 fprintf(stderr, "Please stop port %u first\n", res->port_id);
    1783                 :          0 :                 return;
    1784                 :            :         }
    1785                 :            : 
    1786                 :          0 :         if (parse_speed_lanes_cfg(res->port_id, res->lanes))
    1787                 :            :                 return;
    1788                 :            : 
    1789                 :          0 :         cmd_reconfig_device_queue(res->port_id, 1, 1);
    1790                 :            : }
    1791                 :            : 
    1792                 :            : static cmdline_parse_token_string_t cmd_config_speed_lanes_specific_port =
    1793                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_specific, port,
    1794                 :            :                                  "port");
    1795                 :            : static cmdline_parse_token_string_t cmd_config_speed_lanes_specific_keyword =
    1796                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_specific, keyword,
    1797                 :            :                                  "config");
    1798                 :            : static cmdline_parse_token_num_t cmd_config_speed_lanes_specific_id =
    1799                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_config_speed_lanes_specific, port_id,
    1800                 :            :                               RTE_UINT16);
    1801                 :            : static cmdline_parse_token_string_t cmd_config_speed_lanes_specific_item =
    1802                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_specific, item,
    1803                 :            :                                  "speed_lanes");
    1804                 :            : static cmdline_parse_token_num_t cmd_config_speed_lanes_specific_lanes =
    1805                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_config_speed_lanes_specific, lanes,
    1806                 :            :                               RTE_UINT32);
    1807                 :            : 
    1808                 :            : static cmdline_parse_inst_t cmd_config_speed_lanes_specific = {
    1809                 :            :         .f = cmd_config_speed_lanes_specific_parsed,
    1810                 :            :         .data = NULL,
    1811                 :            :         .help_str = "port config <port_id> speed_lanes <value>",
    1812                 :            :         .tokens = {
    1813                 :            :                 (void *)&cmd_config_speed_lanes_specific_port,
    1814                 :            :                 (void *)&cmd_config_speed_lanes_specific_keyword,
    1815                 :            :                 (void *)&cmd_config_speed_lanes_specific_id,
    1816                 :            :                 (void *)&cmd_config_speed_lanes_specific_item,
    1817                 :            :                 (void *)&cmd_config_speed_lanes_specific_lanes,
    1818                 :            :                 NULL,
    1819                 :            :         },
    1820                 :            : };
    1821                 :            : 
    1822                 :            : /* *** configure loopback for all ports *** */
    1823                 :            : struct cmd_config_loopback_all {
    1824                 :            :         cmdline_fixed_string_t port;
    1825                 :            :         cmdline_fixed_string_t keyword;
    1826                 :            :         cmdline_fixed_string_t all;
    1827                 :            :         cmdline_fixed_string_t item;
    1828                 :            :         uint32_t mode;
    1829                 :            : };
    1830                 :            : 
    1831                 :            : static void
    1832                 :          0 : cmd_config_loopback_all_parsed(void *parsed_result,
    1833                 :            :                         __rte_unused struct cmdline *cl,
    1834                 :            :                         __rte_unused void *data)
    1835                 :            : {
    1836                 :            :         struct cmd_config_loopback_all *res = parsed_result;
    1837                 :            :         portid_t pid;
    1838                 :            : 
    1839                 :          0 :         if (!all_ports_stopped()) {
    1840                 :          0 :                 fprintf(stderr, "Please stop all ports first\n");
    1841                 :          0 :                 return;
    1842                 :            :         }
    1843                 :            : 
    1844                 :          0 :         RTE_ETH_FOREACH_DEV(pid) {
    1845                 :          0 :                 ports[pid].dev_conf.lpbk_mode = res->mode;
    1846                 :            :         }
    1847                 :            : 
    1848                 :          0 :         cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
    1849                 :            : }
    1850                 :            : 
    1851                 :            : static cmdline_parse_token_string_t cmd_config_loopback_all_port =
    1852                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
    1853                 :            : static cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
    1854                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
    1855                 :            :                                                         "config");
    1856                 :            : static cmdline_parse_token_string_t cmd_config_loopback_all_all =
    1857                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
    1858                 :            : static cmdline_parse_token_string_t cmd_config_loopback_all_item =
    1859                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
    1860                 :            :                                                         "loopback");
    1861                 :            : static cmdline_parse_token_num_t cmd_config_loopback_all_mode =
    1862                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, RTE_UINT32);
    1863                 :            : 
    1864                 :            : static cmdline_parse_inst_t cmd_config_loopback_all = {
    1865                 :            :         .f = cmd_config_loopback_all_parsed,
    1866                 :            :         .data = NULL,
    1867                 :            :         .help_str = "port config all loopback <mode>",
    1868                 :            :         .tokens = {
    1869                 :            :                 (void *)&cmd_config_loopback_all_port,
    1870                 :            :                 (void *)&cmd_config_loopback_all_keyword,
    1871                 :            :                 (void *)&cmd_config_loopback_all_all,
    1872                 :            :                 (void *)&cmd_config_loopback_all_item,
    1873                 :            :                 (void *)&cmd_config_loopback_all_mode,
    1874                 :            :                 NULL,
    1875                 :            :         },
    1876                 :            : };
    1877                 :            : 
    1878                 :            : /* *** configure loopback for specific port *** */
    1879                 :            : struct cmd_config_loopback_specific {
    1880                 :            :         cmdline_fixed_string_t port;
    1881                 :            :         cmdline_fixed_string_t keyword;
    1882                 :            :         uint16_t port_id;
    1883                 :            :         cmdline_fixed_string_t item;
    1884                 :            :         uint32_t mode;
    1885                 :            : };
    1886                 :            : 
    1887                 :            : static void
    1888                 :          0 : cmd_config_loopback_specific_parsed(void *parsed_result,
    1889                 :            :                                 __rte_unused struct cmdline *cl,
    1890                 :            :                                 __rte_unused void *data)
    1891                 :            : {
    1892                 :            :         struct cmd_config_loopback_specific *res = parsed_result;
    1893                 :            : 
    1894                 :          0 :         if (port_id_is_invalid(res->port_id, ENABLED_WARN))
    1895                 :            :                 return;
    1896                 :            : 
    1897                 :          0 :         if (!port_is_stopped(res->port_id)) {
    1898                 :          0 :                 fprintf(stderr, "Please stop port %u first\n", res->port_id);
    1899                 :          0 :                 return;
    1900                 :            :         }
    1901                 :            : 
    1902                 :          0 :         ports[res->port_id].dev_conf.lpbk_mode = res->mode;
    1903                 :            : 
    1904                 :          0 :         cmd_reconfig_device_queue(res->port_id, 1, 1);
    1905                 :            : }
    1906                 :            : 
    1907                 :            : static cmdline_parse_token_string_t cmd_config_loopback_specific_port =
    1908                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
    1909                 :            :                                                                 "port");
    1910                 :            : static cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
    1911                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
    1912                 :            :                                                                 "config");
    1913                 :            : static cmdline_parse_token_num_t cmd_config_loopback_specific_id =
    1914                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
    1915                 :            :                                                                 RTE_UINT16);
    1916                 :            : static cmdline_parse_token_string_t cmd_config_loopback_specific_item =
    1917                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
    1918                 :            :                                                                 "loopback");
    1919                 :            : static cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
    1920                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
    1921                 :            :                               RTE_UINT32);
    1922                 :            : 
    1923                 :            : static cmdline_parse_inst_t cmd_config_loopback_specific = {
    1924                 :            :         .f = cmd_config_loopback_specific_parsed,
    1925                 :            :         .data = NULL,
    1926                 :            :         .help_str = "port config <port_id> loopback <mode>",
    1927                 :            :         .tokens = {
    1928                 :            :                 (void *)&cmd_config_loopback_specific_port,
    1929                 :            :                 (void *)&cmd_config_loopback_specific_keyword,
    1930                 :            :                 (void *)&cmd_config_loopback_specific_id,
    1931                 :            :                 (void *)&cmd_config_loopback_specific_item,
    1932                 :            :                 (void *)&cmd_config_loopback_specific_mode,
    1933                 :            :                 NULL,
    1934                 :            :         },
    1935                 :            : };
    1936                 :            : 
    1937                 :            : /* *** configure txq/rxq, txd/rxd *** */
    1938                 :            : struct cmd_config_rx_tx {
    1939                 :            :         cmdline_fixed_string_t port;
    1940                 :            :         cmdline_fixed_string_t keyword;
    1941                 :            :         cmdline_fixed_string_t all;
    1942                 :            :         cmdline_fixed_string_t name;
    1943                 :            :         uint16_t value;
    1944                 :            : };
    1945                 :            : 
    1946                 :            : static void
    1947                 :          0 : cmd_config_rx_tx_parsed(void *parsed_result,
    1948                 :            :                         __rte_unused struct cmdline *cl,
    1949                 :            :                         __rte_unused void *data)
    1950                 :            : {
    1951                 :            :         struct cmd_config_rx_tx *res = parsed_result;
    1952                 :            : 
    1953                 :          0 :         if (!all_ports_stopped()) {
    1954                 :          0 :                 fprintf(stderr, "Please stop all ports first\n");
    1955                 :          0 :                 return;
    1956                 :            :         }
    1957                 :          0 :         if (!strcmp(res->name, "rxq")) {
    1958                 :          0 :                 if (!res->value && !nb_txq) {
    1959                 :          0 :                         fprintf(stderr, "Warning: Either rx or tx queues should be non zero\n");
    1960                 :          0 :                         return;
    1961                 :            :                 }
    1962                 :          0 :                 if (check_nb_rxq(res->value) != 0)
    1963                 :            :                         return;
    1964                 :          0 :                 nb_rxq = res->value;
    1965                 :            :         }
    1966                 :          0 :         else if (!strcmp(res->name, "txq")) {
    1967                 :          0 :                 if (!res->value && !nb_rxq) {
    1968                 :          0 :                         fprintf(stderr, "Warning: Either rx or tx queues should be non zero\n");
    1969                 :          0 :                         return;
    1970                 :            :                 }
    1971                 :          0 :                 if (check_nb_txq(res->value) != 0)
    1972                 :            :                         return;
    1973                 :          0 :                 nb_txq = res->value;
    1974                 :            :         }
    1975                 :          0 :         else if (!strcmp(res->name, "rxd")) {
    1976                 :          0 :                 if (check_nb_rxd(res->value) != 0)
    1977                 :            :                         return;
    1978                 :          0 :                 nb_rxd = res->value;
    1979                 :          0 :         } else if (!strcmp(res->name, "txd")) {
    1980                 :          0 :                 if (check_nb_txd(res->value) != 0)
    1981                 :            :                         return;
    1982                 :            : 
    1983                 :          0 :                 nb_txd = res->value;
    1984                 :            :         } else {
    1985                 :          0 :                 fprintf(stderr, "Unknown parameter\n");
    1986                 :          0 :                 return;
    1987                 :            :         }
    1988                 :            : 
    1989                 :          0 :         fwd_config_setup();
    1990                 :            : 
    1991                 :          0 :         init_port_config();
    1992                 :            : 
    1993                 :          0 :         cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
    1994                 :            : }
    1995                 :            : 
    1996                 :            : static cmdline_parse_token_string_t cmd_config_rx_tx_port =
    1997                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
    1998                 :            : static cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
    1999                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
    2000                 :            : static cmdline_parse_token_string_t cmd_config_rx_tx_all =
    2001                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
    2002                 :            : static cmdline_parse_token_string_t cmd_config_rx_tx_name =
    2003                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
    2004                 :            :                                                 "rxq#txq#rxd#txd");
    2005                 :            : static cmdline_parse_token_num_t cmd_config_rx_tx_value =
    2006                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, RTE_UINT16);
    2007                 :            : 
    2008                 :            : static cmdline_parse_inst_t cmd_config_rx_tx = {
    2009                 :            :         .f = cmd_config_rx_tx_parsed,
    2010                 :            :         .data = NULL,
    2011                 :            :         .help_str = "port config all rxq|txq|rxd|txd <value>",
    2012                 :            :         .tokens = {
    2013                 :            :                 (void *)&cmd_config_rx_tx_port,
    2014                 :            :                 (void *)&cmd_config_rx_tx_keyword,
    2015                 :            :                 (void *)&cmd_config_rx_tx_all,
    2016                 :            :                 (void *)&cmd_config_rx_tx_name,
    2017                 :            :                 (void *)&cmd_config_rx_tx_value,
    2018                 :            :                 NULL,
    2019                 :            :         },
    2020                 :            : };
    2021                 :            : 
    2022                 :            : /* *** config max packet length *** */
    2023                 :            : struct cmd_config_max_pkt_len_result {
    2024                 :            :         cmdline_fixed_string_t port;
    2025                 :            :         cmdline_fixed_string_t keyword;
    2026                 :            :         cmdline_fixed_string_t all;
    2027                 :            :         cmdline_fixed_string_t name;
    2028                 :            :         uint32_t value;
    2029                 :            : };
    2030                 :            : 
    2031                 :            : static void
    2032                 :          0 : cmd_config_max_pkt_len_parsed(void *parsed_result,
    2033                 :            :                                 __rte_unused struct cmdline *cl,
    2034                 :            :                                 __rte_unused void *data)
    2035                 :            : {
    2036                 :            :         struct cmd_config_max_pkt_len_result *res = parsed_result;
    2037                 :            :         portid_t port_id;
    2038                 :            :         int ret;
    2039                 :            : 
    2040                 :          0 :         if (strcmp(res->name, "max-pkt-len") != 0) {
    2041                 :            :                 printf("Unknown parameter\n");
    2042                 :          0 :                 return;
    2043                 :            :         }
    2044                 :            : 
    2045                 :          0 :         if (!all_ports_stopped()) {
    2046                 :          0 :                 fprintf(stderr, "Please stop all ports first\n");
    2047                 :          0 :                 return;
    2048                 :            :         }
    2049                 :            : 
    2050                 :          0 :         RTE_ETH_FOREACH_DEV(port_id) {
    2051                 :          0 :                 struct rte_port *port = &ports[port_id];
    2052                 :            : 
    2053                 :          0 :                 if (res->value < RTE_ETHER_MIN_LEN) {
    2054                 :          0 :                         fprintf(stderr,
    2055                 :            :                                 "max-pkt-len can not be less than %d\n",
    2056                 :            :                                 RTE_ETHER_MIN_LEN);
    2057                 :          0 :                         return;
    2058                 :            :                 }
    2059                 :            : 
    2060                 :          0 :                 ret = eth_dev_info_get_print_err(port_id, &port->dev_info);
    2061                 :          0 :                 if (ret != 0) {
    2062                 :          0 :                         fprintf(stderr,
    2063                 :            :                                 "rte_eth_dev_info_get() failed for port %u\n",
    2064                 :            :                                 port_id);
    2065                 :          0 :                         return;
    2066                 :            :                 }
    2067                 :            : 
    2068                 :          0 :                 update_mtu_from_frame_size(port_id, res->value);
    2069                 :            :         }
    2070                 :            : 
    2071                 :          0 :         init_port_config();
    2072                 :            : 
    2073                 :          0 :         cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
    2074                 :            : }
    2075                 :            : 
    2076                 :            : static cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
    2077                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
    2078                 :            :                                                                 "port");
    2079                 :            : static cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
    2080                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
    2081                 :            :                                                                 "config");
    2082                 :            : static cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
    2083                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
    2084                 :            :                                                                 "all");
    2085                 :            : static cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
    2086                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
    2087                 :            :                                                                 "max-pkt-len");
    2088                 :            : static cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
    2089                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
    2090                 :            :                                                                 RTE_UINT32);
    2091                 :            : 
    2092                 :            : static cmdline_parse_inst_t cmd_config_max_pkt_len = {
    2093                 :            :         .f = cmd_config_max_pkt_len_parsed,
    2094                 :            :         .data = NULL,
    2095                 :            :         .help_str = "port config all max-pkt-len <value>",
    2096                 :            :         .tokens = {
    2097                 :            :                 (void *)&cmd_config_max_pkt_len_port,
    2098                 :            :                 (void *)&cmd_config_max_pkt_len_keyword,
    2099                 :            :                 (void *)&cmd_config_max_pkt_len_all,
    2100                 :            :                 (void *)&cmd_config_max_pkt_len_name,
    2101                 :            :                 (void *)&cmd_config_max_pkt_len_value,
    2102                 :            :                 NULL,
    2103                 :            :         },
    2104                 :            : };
    2105                 :            : 
    2106                 :            : /* *** config max LRO aggregated packet size *** */
    2107                 :            : struct cmd_config_max_lro_pkt_size_result {
    2108                 :            :         cmdline_fixed_string_t port;
    2109                 :            :         cmdline_fixed_string_t keyword;
    2110                 :            :         cmdline_fixed_string_t all;
    2111                 :            :         cmdline_fixed_string_t name;
    2112                 :            :         uint32_t value;
    2113                 :            : };
    2114                 :            : 
    2115                 :            : static void
    2116                 :          0 : cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
    2117                 :            :                                 __rte_unused struct cmdline *cl,
    2118                 :            :                                 __rte_unused void *data)
    2119                 :            : {
    2120                 :            :         struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
    2121                 :            :         portid_t pid;
    2122                 :            : 
    2123                 :          0 :         if (!all_ports_stopped()) {
    2124                 :          0 :                 fprintf(stderr, "Please stop all ports first\n");
    2125                 :          0 :                 return;
    2126                 :            :         }
    2127                 :            : 
    2128                 :          0 :         RTE_ETH_FOREACH_DEV(pid) {
    2129                 :          0 :                 struct rte_port *port = &ports[pid];
    2130                 :            : 
    2131                 :          0 :                 if (!strcmp(res->name, "max-lro-pkt-size")) {
    2132                 :          0 :                         if (res->value ==
    2133                 :          0 :                                         port->dev_conf.rxmode.max_lro_pkt_size)
    2134                 :            :                                 return;
    2135                 :            : 
    2136                 :          0 :                         port->dev_conf.rxmode.max_lro_pkt_size = res->value;
    2137                 :            :                 } else {
    2138                 :          0 :                         fprintf(stderr, "Unknown parameter\n");
    2139                 :          0 :                         return;
    2140                 :            :                 }
    2141                 :            :         }
    2142                 :            : 
    2143                 :          0 :         init_port_config();
    2144                 :            : 
    2145                 :          0 :         cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
    2146                 :            : }
    2147                 :            : 
    2148                 :            : static cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
    2149                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
    2150                 :            :                                  port, "port");
    2151                 :            : static cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword =
    2152                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
    2153                 :            :                                  keyword, "config");
    2154                 :            : static cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all =
    2155                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
    2156                 :            :                                  all, "all");
    2157                 :            : static cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
    2158                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
    2159                 :            :                                  name, "max-lro-pkt-size");
    2160                 :            : static cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
    2161                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
    2162                 :            :                               value, RTE_UINT32);
    2163                 :            : 
    2164                 :            : static cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
    2165                 :            :         .f = cmd_config_max_lro_pkt_size_parsed,
    2166                 :            :         .data = NULL,
    2167                 :            :         .help_str = "port config all max-lro-pkt-size <value>",
    2168                 :            :         .tokens = {
    2169                 :            :                 (void *)&cmd_config_max_lro_pkt_size_port,
    2170                 :            :                 (void *)&cmd_config_max_lro_pkt_size_keyword,
    2171                 :            :                 (void *)&cmd_config_max_lro_pkt_size_all,
    2172                 :            :                 (void *)&cmd_config_max_lro_pkt_size_name,
    2173                 :            :                 (void *)&cmd_config_max_lro_pkt_size_value,
    2174                 :            :                 NULL,
    2175                 :            :         },
    2176                 :            : };
    2177                 :            : 
    2178                 :            : /* *** configure port MTU *** */
    2179                 :            : struct cmd_config_mtu_result {
    2180                 :            :         cmdline_fixed_string_t port;
    2181                 :            :         cmdline_fixed_string_t keyword;
    2182                 :            :         cmdline_fixed_string_t mtu;
    2183                 :            :         portid_t port_id;
    2184                 :            :         uint16_t value;
    2185                 :            : };
    2186                 :            : 
    2187                 :            : static void
    2188                 :          0 : cmd_config_mtu_parsed(void *parsed_result,
    2189                 :            :                       __rte_unused struct cmdline *cl,
    2190                 :            :                       __rte_unused void *data)
    2191                 :            : {
    2192                 :            :         struct cmd_config_mtu_result *res = parsed_result;
    2193                 :            : 
    2194                 :          0 :         port_mtu_set(res->port_id, res->value);
    2195                 :          0 : }
    2196                 :            : 
    2197                 :            : static cmdline_parse_token_string_t cmd_config_mtu_port =
    2198                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
    2199                 :            :                                  "port");
    2200                 :            : static cmdline_parse_token_string_t cmd_config_mtu_keyword =
    2201                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
    2202                 :            :                                  "config");
    2203                 :            : static cmdline_parse_token_string_t cmd_config_mtu_mtu =
    2204                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
    2205                 :            :                                  "mtu");
    2206                 :            : static cmdline_parse_token_num_t cmd_config_mtu_port_id =
    2207                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id,
    2208                 :            :                                  RTE_UINT16);
    2209                 :            : static cmdline_parse_token_num_t cmd_config_mtu_value =
    2210                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value,
    2211                 :            :                                  RTE_UINT16);
    2212                 :            : 
    2213                 :            : static cmdline_parse_inst_t cmd_config_mtu = {
    2214                 :            :         .f = cmd_config_mtu_parsed,
    2215                 :            :         .data = NULL,
    2216                 :            :         .help_str = "port config mtu <port_id> <value>",
    2217                 :            :         .tokens = {
    2218                 :            :                 (void *)&cmd_config_mtu_port,
    2219                 :            :                 (void *)&cmd_config_mtu_keyword,
    2220                 :            :                 (void *)&cmd_config_mtu_mtu,
    2221                 :            :                 (void *)&cmd_config_mtu_port_id,
    2222                 :            :                 (void *)&cmd_config_mtu_value,
    2223                 :            :                 NULL,
    2224                 :            :         },
    2225                 :            : };
    2226                 :            : 
    2227                 :            : /* *** configure rx mode *** */
    2228                 :            : struct cmd_config_rx_mode_flag {
    2229                 :            :         cmdline_fixed_string_t port;
    2230                 :            :         cmdline_fixed_string_t keyword;
    2231                 :            :         cmdline_fixed_string_t all;
    2232                 :            :         cmdline_fixed_string_t name;
    2233                 :            :         cmdline_fixed_string_t value;
    2234                 :            : };
    2235                 :            : 
    2236                 :            : static void
    2237                 :          0 : cmd_config_rx_mode_flag_parsed(void *parsed_result,
    2238                 :            :                                 __rte_unused struct cmdline *cl,
    2239                 :            :                                 __rte_unused void *data)
    2240                 :            : {
    2241                 :            :         struct cmd_config_rx_mode_flag *res = parsed_result;
    2242                 :            : 
    2243                 :          0 :         if (!all_ports_stopped()) {
    2244                 :          0 :                 fprintf(stderr, "Please stop all ports first\n");
    2245                 :          0 :                 return;
    2246                 :            :         }
    2247                 :            : 
    2248                 :          0 :         if (!strcmp(res->name, "drop-en")) {
    2249                 :          0 :                 if (!strcmp(res->value, "on"))
    2250                 :          0 :                         rx_drop_en = 1;
    2251                 :          0 :                 else if (!strcmp(res->value, "off"))
    2252                 :          0 :                         rx_drop_en = 0;
    2253                 :            :                 else {
    2254                 :          0 :                         fprintf(stderr, "Unknown parameter\n");
    2255                 :          0 :                         return;
    2256                 :            :                 }
    2257                 :            :         } else {
    2258                 :          0 :                 fprintf(stderr, "Unknown parameter\n");
    2259                 :          0 :                 return;
    2260                 :            :         }
    2261                 :            : 
    2262                 :          0 :         init_port_config();
    2263                 :            : 
    2264                 :          0 :         cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
    2265                 :            : }
    2266                 :            : 
    2267                 :            : static cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
    2268                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
    2269                 :            : static cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
    2270                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
    2271                 :            :                                                                 "config");
    2272                 :            : static cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
    2273                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
    2274                 :            : static cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
    2275                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
    2276                 :            :                                         "drop-en");
    2277                 :            : static cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
    2278                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
    2279                 :            :                                                         "on#off");
    2280                 :            : 
    2281                 :            : static cmdline_parse_inst_t cmd_config_rx_mode_flag = {
    2282                 :            :         .f = cmd_config_rx_mode_flag_parsed,
    2283                 :            :         .data = NULL,
    2284                 :            :         .help_str = "port config all drop-en on|off",
    2285                 :            :         .tokens = {
    2286                 :            :                 (void *)&cmd_config_rx_mode_flag_port,
    2287                 :            :                 (void *)&cmd_config_rx_mode_flag_keyword,
    2288                 :            :                 (void *)&cmd_config_rx_mode_flag_all,
    2289                 :            :                 (void *)&cmd_config_rx_mode_flag_name,
    2290                 :            :                 (void *)&cmd_config_rx_mode_flag_value,
    2291                 :            :                 NULL,
    2292                 :            :         },
    2293                 :            : };
    2294                 :            : 
    2295                 :            : /* *** configure rss *** */
    2296                 :            : struct cmd_config_rss {
    2297                 :            :         cmdline_fixed_string_t port;
    2298                 :            :         cmdline_fixed_string_t keyword;
    2299                 :            :         cmdline_fixed_string_t all;
    2300                 :            :         cmdline_fixed_string_t name;
    2301                 :            :         cmdline_fixed_string_t value;
    2302                 :            : };
    2303                 :            : 
    2304                 :            : static void
    2305                 :          0 : cmd_config_rss_parsed(void *parsed_result,
    2306                 :            :                         __rte_unused struct cmdline *cl,
    2307                 :            :                         __rte_unused void *data)
    2308                 :            : {
    2309                 :            :         struct cmd_config_rss *res = parsed_result;
    2310                 :            :         struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
    2311                 :          0 :         struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
    2312                 :            :         int use_default = 0;
    2313                 :            :         int all_updated = 1;
    2314                 :            :         int diag;
    2315                 :            :         uint16_t i;
    2316                 :            :         int ret;
    2317                 :            : 
    2318                 :          0 :         if (!strcmp(res->value, "level-default")) {
    2319                 :          0 :                 rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
    2320                 :            :                 rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_PMD_DEFAULT);
    2321                 :          0 :         } else if (!strcmp(res->value, "level-outer")) {
    2322                 :          0 :                 rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
    2323                 :          0 :                 rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_OUTERMOST);
    2324                 :          0 :         } else if (!strcmp(res->value, "level-inner")) {
    2325                 :          0 :                 rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
    2326                 :          0 :                 rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_INNERMOST);
    2327                 :          0 :         } else if (!strcmp(res->value, "default")) {
    2328                 :            :                 use_default = 1;
    2329                 :          0 :         } else if (isdigit(res->value[0])) {
    2330                 :            :                 int value = atoi(res->value);
    2331                 :          0 :                 if (value > 0 && value < 64)
    2332                 :          0 :                         rss_conf.rss_hf = 1ULL << (uint8_t)value;
    2333                 :            :                 else {
    2334                 :          0 :                         fprintf(stderr, "flowtype_id should be greater than 0 and less than 64.\n");
    2335                 :          0 :                         return;
    2336                 :            :                 }
    2337                 :          0 :         } else if (!strcmp(res->value, "none")) {
    2338                 :            :                 rss_conf.rss_hf = 0;
    2339                 :            :         } else {
    2340                 :          0 :                 rss_conf.rss_hf = str_to_rsstypes(res->value);
    2341                 :          0 :                 if (rss_conf.rss_hf == 0) {
    2342                 :          0 :                         fprintf(stderr, "Unknown parameter\n");
    2343                 :          0 :                         return;
    2344                 :            :                 }
    2345                 :            :         }
    2346                 :            :         rss_conf.rss_key = NULL;
    2347                 :            :         /* Update global configuration for RSS types. */
    2348                 :          0 :         RTE_ETH_FOREACH_DEV(i) {
    2349                 :            :                 struct rte_eth_rss_conf local_rss_conf;
    2350                 :            : 
    2351                 :          0 :                 ret = eth_dev_info_get_print_err(i, &dev_info);
    2352                 :          0 :                 if (ret != 0)
    2353                 :          0 :                         return;
    2354                 :            : 
    2355                 :          0 :                 if (use_default)
    2356                 :          0 :                         rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
    2357                 :            : 
    2358                 :          0 :                 local_rss_conf = rss_conf;
    2359                 :          0 :                 local_rss_conf.rss_hf = rss_conf.rss_hf &
    2360                 :          0 :                         dev_info.flow_type_rss_offloads;
    2361                 :          0 :                 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
    2362                 :            :                         printf("Port %u modified RSS hash function based on hardware support,"
    2363                 :            :                                 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
    2364                 :            :                                 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
    2365                 :            :                 }
    2366                 :          0 :                 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
    2367                 :          0 :                 if (diag < 0) {
    2368                 :            :                         all_updated = 0;
    2369                 :          0 :                         fprintf(stderr,
    2370                 :            :                                 "Configuration of RSS hash at ethernet port %d failed with error (%d): %s.\n",
    2371                 :            :                                 i, -diag, strerror(-diag));
    2372                 :            :                 }
    2373                 :            :         }
    2374                 :          0 :         if (all_updated && !use_default) {
    2375                 :          0 :                 rss_hf = rss_conf.rss_hf;
    2376                 :            :                 printf("rss_hf %#"PRIx64"\n", rss_hf);
    2377                 :            :         }
    2378                 :            : }
    2379                 :            : 
    2380                 :            : static cmdline_parse_token_string_t cmd_config_rss_port =
    2381                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
    2382                 :            : static cmdline_parse_token_string_t cmd_config_rss_keyword =
    2383                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
    2384                 :            : static cmdline_parse_token_string_t cmd_config_rss_all =
    2385                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
    2386                 :            : static cmdline_parse_token_string_t cmd_config_rss_name =
    2387                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
    2388                 :            : static cmdline_parse_token_string_t cmd_config_rss_value =
    2389                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
    2390                 :            : 
    2391                 :            : static cmdline_parse_inst_t cmd_config_rss = {
    2392                 :            :         .f = cmd_config_rss_parsed,
    2393                 :            :         .data = NULL,
    2394                 :            :         .help_str = "port config all rss "
    2395                 :            :                 "all|default|level-default|level-outer|level-inner|"
    2396                 :            :                 "ip|tcp|udp|sctp|tunnel|vlan|none|"
    2397                 :            :                 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
    2398                 :            :                 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|ipv6-flow-label|"
    2399                 :            :                 "l2-payload|port|vxlan|geneve|nvgre|gtpu|eth|s-vlan|c-vlan|"
    2400                 :            :                 "esp|ah|l2tpv3|pfcp|pppoe|ecpri|mpls|ipv4-chksum|l4-chksum|"
    2401                 :            :                 "l2tpv2|l3-pre96|l3-pre64|l3-pre56|l3-pre48|l3-pre40|l3-pre32|"
    2402                 :            :                 "l2-dst-only|l2-src-only|l4-dst-only|l4-src-only|l3-dst-only|l3-src-only|<rsstype_id>",
    2403                 :            :         .tokens = {
    2404                 :            :                 (void *)&cmd_config_rss_port,
    2405                 :            :                 (void *)&cmd_config_rss_keyword,
    2406                 :            :                 (void *)&cmd_config_rss_all,
    2407                 :            :                 (void *)&cmd_config_rss_name,
    2408                 :            :                 (void *)&cmd_config_rss_value,
    2409                 :            :                 NULL,
    2410                 :            :         },
    2411                 :            : };
    2412                 :            : 
    2413                 :            : /* *** configure rss hash key *** */
    2414                 :            : struct cmd_config_rss_hash_key {
    2415                 :            :         cmdline_fixed_string_t port;
    2416                 :            :         cmdline_fixed_string_t config;
    2417                 :            :         portid_t port_id;
    2418                 :            :         cmdline_fixed_string_t rss_hash_key;
    2419                 :            :         cmdline_fixed_string_t rss_type;
    2420                 :            :         cmdline_fixed_string_t key;
    2421                 :            : };
    2422                 :            : 
    2423                 :            : static uint8_t
    2424                 :            : hexa_digit_to_value(char hexa_digit)
    2425                 :            : {
    2426                 :          0 :         if ((hexa_digit >= '0') && (hexa_digit <= '9'))
    2427                 :            :                 return (uint8_t) (hexa_digit - '0');
    2428                 :          0 :         if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
    2429                 :          0 :                 return (uint8_t) ((hexa_digit - 'a') + 10);
    2430                 :          0 :         if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
    2431                 :          0 :                 return (uint8_t) ((hexa_digit - 'A') + 10);
    2432                 :            :         /* Invalid hexa digit */
    2433                 :            :         return 0xFF;
    2434                 :            : }
    2435                 :            : 
    2436                 :            : static uint8_t
    2437                 :          0 : parse_and_check_key_hexa_digit(char *key, int idx)
    2438                 :            : {
    2439                 :            :         uint8_t hexa_v;
    2440                 :            : 
    2441                 :          0 :         hexa_v = hexa_digit_to_value(key[idx]);
    2442                 :            :         if (hexa_v == 0xFF)
    2443                 :          0 :                 fprintf(stderr,
    2444                 :            :                         "invalid key: character %c at position %d is not a valid hexa digit\n",
    2445                 :            :                         key[idx], idx);
    2446                 :          0 :         return hexa_v;
    2447                 :            : }
    2448                 :            : 
    2449                 :            : static void
    2450                 :          0 : cmd_config_rss_hash_key_parsed(void *parsed_result,
    2451                 :            :                                __rte_unused struct cmdline *cl,
    2452                 :            :                                __rte_unused void *data)
    2453                 :            : {
    2454                 :            :         struct cmd_config_rss_hash_key *res = parsed_result;
    2455                 :            :         uint8_t hash_key[RSS_HASH_KEY_LENGTH];
    2456                 :            :         uint8_t xdgt0;
    2457                 :            :         uint8_t xdgt1;
    2458                 :            :         int i;
    2459                 :            :         struct rte_eth_dev_info dev_info;
    2460                 :            :         uint8_t hash_key_size;
    2461                 :            :         uint32_t key_len;
    2462                 :            :         int ret;
    2463                 :            : 
    2464                 :          0 :         ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
    2465                 :          0 :         if (ret != 0)
    2466                 :          0 :                 return;
    2467                 :            : 
    2468                 :          0 :         if (dev_info.hash_key_size > 0 &&
    2469                 :            :                         dev_info.hash_key_size <= sizeof(hash_key))
    2470                 :            :                 hash_key_size = dev_info.hash_key_size;
    2471                 :            :         else {
    2472                 :          0 :                 fprintf(stderr,
    2473                 :            :                         "dev_info did not provide a valid hash key size\n");
    2474                 :          0 :                 return;
    2475                 :            :         }
    2476                 :            :         /* Check the length of the RSS hash key */
    2477                 :          0 :         key_len = strlen(res->key);
    2478                 :          0 :         if (key_len != (hash_key_size * 2)) {
    2479                 :          0 :                 fprintf(stderr,
    2480                 :            :                         "key length: %d invalid - key must be a string of %d hexa-decimal numbers\n",
    2481                 :            :                         (int)key_len, hash_key_size * 2);
    2482                 :          0 :                 return;
    2483                 :            :         }
    2484                 :            :         /* Translate RSS hash key into binary representation */
    2485                 :          0 :         for (i = 0; i < hash_key_size; i++) {
    2486                 :          0 :                 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
    2487                 :          0 :                 if (xdgt0 == 0xFF)
    2488                 :            :                         return;
    2489                 :          0 :                 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
    2490                 :          0 :                 if (xdgt1 == 0xFF)
    2491                 :            :                         return;
    2492                 :          0 :                 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
    2493                 :            :         }
    2494                 :          0 :         port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
    2495                 :            :                         hash_key_size);
    2496                 :            : }
    2497                 :            : 
    2498                 :            : static cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
    2499                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
    2500                 :            : static cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
    2501                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
    2502                 :            :                                  "config");
    2503                 :            : static cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
    2504                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id,
    2505                 :            :                                  RTE_UINT16);
    2506                 :            : static cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
    2507                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
    2508                 :            :                                  rss_hash_key, "rss-hash-key");
    2509                 :            : static cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
    2510                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
    2511                 :            :                                  "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
    2512                 :            :                                  "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
    2513                 :            :                                  "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
    2514                 :            :                                  "ipv6-tcp-ex#ipv6-udp-ex#ipv6-flow-label#"
    2515                 :            :                                  "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#"
    2516                 :            :                                  "l2-src-only#l2-dst-only#s-vlan#c-vlan#"
    2517                 :            :                                  "l2tpv3#esp#ah#pfcp#pppoe#gtpu#ecpri#mpls#l2tpv2");
    2518                 :            : static cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
    2519                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
    2520                 :            : 
    2521                 :            : static cmdline_parse_inst_t cmd_config_rss_hash_key = {
    2522                 :            :         .f = cmd_config_rss_hash_key_parsed,
    2523                 :            :         .data = NULL,
    2524                 :            :         .help_str = "port config <port_id> rss-hash-key "
    2525                 :            :                 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
    2526                 :            :                 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
    2527                 :            :                 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|ipv6-flow-label|"
    2528                 :            :                 "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|"
    2529                 :            :                 "l2-src-only|l2-dst-only|s-vlan|c-vlan|"
    2530                 :            :                 "l2tpv3|esp|ah|pfcp|pppoe|gtpu|ecpri|mpls|l2tpv2 "
    2531                 :            :                 "<string of hex digits (variable length, NIC dependent)>",
    2532                 :            :         .tokens = {
    2533                 :            :                 (void *)&cmd_config_rss_hash_key_port,
    2534                 :            :                 (void *)&cmd_config_rss_hash_key_config,
    2535                 :            :                 (void *)&cmd_config_rss_hash_key_port_id,
    2536                 :            :                 (void *)&cmd_config_rss_hash_key_rss_hash_key,
    2537                 :            :                 (void *)&cmd_config_rss_hash_key_rss_type,
    2538                 :            :                 (void *)&cmd_config_rss_hash_key_value,
    2539                 :            :                 NULL,
    2540                 :            :         },
    2541                 :            : };
    2542                 :            : 
    2543                 :            : /* *** configure rss hash algorithm *** */
    2544                 :            : struct cmd_config_rss_hash_algo {
    2545                 :            :         cmdline_fixed_string_t port;
    2546                 :            :         cmdline_fixed_string_t config;
    2547                 :            :         portid_t port_id;
    2548                 :            :         cmdline_fixed_string_t rss_hash_algo;
    2549                 :            :         cmdline_fixed_string_t algo;
    2550                 :            : };
    2551                 :            : 
    2552                 :            : static void
    2553                 :          0 : cmd_config_rss_hash_algo_parsed(void *parsed_result,
    2554                 :            :                                 __rte_unused struct cmdline *cl,
    2555                 :            :                                 __rte_unused void *data)
    2556                 :            : {
    2557                 :            :         struct cmd_config_rss_hash_algo *res = parsed_result;
    2558                 :            :         uint8_t rss_key[RSS_HASH_KEY_LENGTH];
    2559                 :            :         struct rte_eth_rss_conf rss_conf;
    2560                 :            :         uint32_t algorithm;
    2561                 :            :         int ret;
    2562                 :            : 
    2563                 :          0 :         rss_conf.rss_key_len = RSS_HASH_KEY_LENGTH;
    2564                 :          0 :         rss_conf.rss_key = rss_key;
    2565                 :          0 :         ret = rte_eth_dev_rss_hash_conf_get(res->port_id, &rss_conf);
    2566                 :          0 :         if (ret != 0) {
    2567                 :          0 :                 fprintf(stderr, "failed to get port %u RSS configuration\n",
    2568                 :          0 :                         res->port_id);
    2569                 :          0 :                 return;
    2570                 :            :         }
    2571                 :            : 
    2572                 :          0 :         algorithm = (uint32_t)rss_conf.algorithm;
    2573                 :          0 :         ret = rte_eth_find_rss_algo(res->algo, &algorithm);
    2574                 :          0 :         if (ret != 0) {
    2575                 :          0 :                 fprintf(stderr, "port %u configured invalid RSS hash algorithm: %s\n",
    2576                 :          0 :                         res->port_id, res->algo);
    2577                 :          0 :                 return;
    2578                 :            :         }
    2579                 :            : 
    2580                 :          0 :         rss_conf.algorithm = algorithm;
    2581                 :          0 :         ret = rte_eth_dev_rss_hash_update(res->port_id, &rss_conf);
    2582                 :          0 :         if (ret != 0) {
    2583                 :          0 :                 fprintf(stderr, "failed to set port %u RSS hash algorithm\n",
    2584                 :          0 :                         res->port_id);
    2585                 :          0 :                 return;
    2586                 :            :         }
    2587                 :            : }
    2588                 :            : 
    2589                 :            : static cmdline_parse_token_string_t cmd_config_rss_hash_algo_port =
    2590                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_algo, port, "port");
    2591                 :            : static cmdline_parse_token_string_t cmd_config_rss_hash_algo_config =
    2592                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_algo, config,
    2593                 :            :                                  "config");
    2594                 :            : static cmdline_parse_token_num_t cmd_config_rss_hash_algo_port_id =
    2595                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_algo, port_id,
    2596                 :            :                               RTE_UINT16);
    2597                 :            : static cmdline_parse_token_string_t cmd_config_rss_hash_algo_rss_hash_algo =
    2598                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_algo,
    2599                 :            :                                  rss_hash_algo, "rss-hash-algo");
    2600                 :            : static cmdline_parse_token_string_t cmd_config_rss_hash_algo_algo =
    2601                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_algo, algo,
    2602                 :            :                                  "default#simple_xor#toeplitz#"
    2603                 :            :                                  "symmetric_toeplitz#symmetric_toeplitz_sort");
    2604                 :            : 
    2605                 :            : static cmdline_parse_inst_t cmd_config_rss_hash_algo = {
    2606                 :            :         .f = cmd_config_rss_hash_algo_parsed,
    2607                 :            :         .data = NULL,
    2608                 :            :         .help_str = "port config <port_id> rss-hash-algo "
    2609                 :            :                 "default|simple_xor|toeplitz|symmetric_toeplitz|symmetric_toeplitz_sort",
    2610                 :            :         .tokens = {
    2611                 :            :                 (void *)&cmd_config_rss_hash_algo_port,
    2612                 :            :                 (void *)&cmd_config_rss_hash_algo_config,
    2613                 :            :                 (void *)&cmd_config_rss_hash_algo_port_id,
    2614                 :            :                 (void *)&cmd_config_rss_hash_algo_rss_hash_algo,
    2615                 :            :                 (void *)&cmd_config_rss_hash_algo_algo,
    2616                 :            :                 NULL,
    2617                 :            :         },
    2618                 :            : };
    2619                 :            : 
    2620                 :            : /* *** cleanup txq mbufs *** */
    2621                 :            : struct cmd_cleanup_txq_mbufs_result {
    2622                 :            :         cmdline_fixed_string_t port;
    2623                 :            :         cmdline_fixed_string_t keyword;
    2624                 :            :         cmdline_fixed_string_t name;
    2625                 :            :         uint16_t port_id;
    2626                 :            :         uint16_t queue_id;
    2627                 :            :         uint32_t free_cnt;
    2628                 :            : };
    2629                 :            : 
    2630                 :            : static void
    2631                 :          0 : cmd_cleanup_txq_mbufs_parsed(void *parsed_result,
    2632                 :            :                              __rte_unused struct cmdline *cl,
    2633                 :            :                              __rte_unused void *data)
    2634                 :            : {
    2635                 :            :         struct cmd_cleanup_txq_mbufs_result *res = parsed_result;
    2636                 :          0 :         uint16_t port_id = res->port_id;
    2637                 :          0 :         uint16_t queue_id = res->queue_id;
    2638                 :          0 :         uint32_t free_cnt = res->free_cnt;
    2639                 :            :         struct rte_eth_txq_info qinfo;
    2640                 :            :         int ret;
    2641                 :            : 
    2642                 :          0 :         if (test_done == 0) {
    2643                 :          0 :                 fprintf(stderr, "Please stop forwarding first\n");
    2644                 :          0 :                 return;
    2645                 :            :         }
    2646                 :            : 
    2647                 :          0 :         if (rte_eth_tx_queue_info_get(port_id, queue_id, &qinfo)) {
    2648                 :          0 :                 fprintf(stderr, "Failed to get port %u Tx queue %u info\n",
    2649                 :            :                         port_id, queue_id);
    2650                 :          0 :                 return;
    2651                 :            :         }
    2652                 :            : 
    2653                 :          0 :         if (qinfo.queue_state != RTE_ETH_QUEUE_STATE_STARTED) {
    2654                 :          0 :                 fprintf(stderr, "Tx queue %u not started\n", queue_id);
    2655                 :          0 :                 return;
    2656                 :            :         }
    2657                 :            : 
    2658                 :          0 :         ret = rte_eth_tx_done_cleanup(port_id, queue_id, free_cnt);
    2659                 :          0 :         if (ret < 0) {
    2660                 :          0 :                 fprintf(stderr,
    2661                 :            :                         "Failed to cleanup mbuf for port %u Tx queue %u error desc: %s(%d)\n",
    2662                 :            :                         port_id, queue_id, strerror(-ret), ret);
    2663                 :          0 :                 return;
    2664                 :            :         }
    2665                 :            : 
    2666                 :            :         printf("Cleanup port %u Tx queue %u mbuf nums: %u\n",
    2667                 :            :                port_id, queue_id, ret);
    2668                 :            : }
    2669                 :            : 
    2670                 :            : static cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_port =
    2671                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port,
    2672                 :            :                                  "port");
    2673                 :            : static cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_cleanup =
    2674                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, keyword,
    2675                 :            :                                  "cleanup");
    2676                 :            : static cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_port_id =
    2677                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port_id,
    2678                 :            :                               RTE_UINT16);
    2679                 :            : static cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_txq =
    2680                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, name,
    2681                 :            :                                  "txq");
    2682                 :            : static cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_queue_id =
    2683                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, queue_id,
    2684                 :            :                               RTE_UINT16);
    2685                 :            : static cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_free_cnt =
    2686                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, free_cnt,
    2687                 :            :                               RTE_UINT32);
    2688                 :            : 
    2689                 :            : static cmdline_parse_inst_t cmd_cleanup_txq_mbufs = {
    2690                 :            :         .f = cmd_cleanup_txq_mbufs_parsed,
    2691                 :            :         .data = NULL,
    2692                 :            :         .help_str = "port cleanup <port_id> txq <queue_id> <free_cnt>",
    2693                 :            :         .tokens = {
    2694                 :            :                 (void *)&cmd_cleanup_txq_mbufs_port,
    2695                 :            :                 (void *)&cmd_cleanup_txq_mbufs_cleanup,
    2696                 :            :                 (void *)&cmd_cleanup_txq_mbufs_port_id,
    2697                 :            :                 (void *)&cmd_cleanup_txq_mbufs_txq,
    2698                 :            :                 (void *)&cmd_cleanup_txq_mbufs_queue_id,
    2699                 :            :                 (void *)&cmd_cleanup_txq_mbufs_free_cnt,
    2700                 :            :                 NULL,
    2701                 :            :         },
    2702                 :            : };
    2703                 :            : 
    2704                 :            : /* *** configure port rxq/txq ring size *** */
    2705                 :            : struct cmd_config_rxtx_ring_size {
    2706                 :            :         cmdline_fixed_string_t port;
    2707                 :            :         cmdline_fixed_string_t config;
    2708                 :            :         portid_t portid;
    2709                 :            :         cmdline_fixed_string_t rxtxq;
    2710                 :            :         uint16_t qid;
    2711                 :            :         cmdline_fixed_string_t rsize;
    2712                 :            :         uint16_t size;
    2713                 :            : };
    2714                 :            : 
    2715                 :            : static void
    2716                 :          0 : cmd_config_rxtx_ring_size_parsed(void *parsed_result,
    2717                 :            :                                  __rte_unused struct cmdline *cl,
    2718                 :            :                                  __rte_unused void *data)
    2719                 :            : {
    2720                 :            :         struct cmd_config_rxtx_ring_size *res = parsed_result;
    2721                 :            :         struct rte_port *port;
    2722                 :            :         uint8_t isrx;
    2723                 :            : 
    2724                 :          0 :         if (port_id_is_invalid(res->portid, ENABLED_WARN))
    2725                 :            :                 return;
    2726                 :            : 
    2727                 :          0 :         if (res->portid == (portid_t)RTE_PORT_ALL) {
    2728                 :          0 :                 fprintf(stderr, "Invalid port id\n");
    2729                 :          0 :                 return;
    2730                 :            :         }
    2731                 :            : 
    2732                 :          0 :         port = &ports[res->portid];
    2733                 :            : 
    2734                 :          0 :         if (!strcmp(res->rxtxq, "rxq"))
    2735                 :            :                 isrx = 1;
    2736                 :          0 :         else if (!strcmp(res->rxtxq, "txq"))
    2737                 :            :                 isrx = 0;
    2738                 :            :         else {
    2739                 :          0 :                 fprintf(stderr, "Unknown parameter\n");
    2740                 :          0 :                 return;
    2741                 :            :         }
    2742                 :            : 
    2743                 :          0 :         if (isrx && rx_queue_id_is_invalid(res->qid))
    2744                 :            :                 return;
    2745                 :          0 :         else if (!isrx && tx_queue_id_is_invalid(res->qid))
    2746                 :            :                 return;
    2747                 :            : 
    2748                 :          0 :         if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
    2749                 :          0 :                 fprintf(stderr,
    2750                 :            :                         "Invalid rx ring_size, must > rx_free_thresh: %d\n",
    2751                 :            :                         rx_free_thresh);
    2752                 :          0 :                 return;
    2753                 :            :         }
    2754                 :            : 
    2755                 :          0 :         if (isrx)
    2756                 :          0 :                 port->nb_rx_desc[res->qid] = res->size;
    2757                 :            :         else
    2758                 :          0 :                 port->nb_tx_desc[res->qid] = res->size;
    2759                 :            : 
    2760                 :          0 :         cmd_reconfig_device_queue(res->portid, 0, 1);
    2761                 :            : }
    2762                 :            : 
    2763                 :            : static cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
    2764                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
    2765                 :            :                                  port, "port");
    2766                 :            : static cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
    2767                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
    2768                 :            :                                  config, "config");
    2769                 :            : static cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
    2770                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
    2771                 :            :                                  portid, RTE_UINT16);
    2772                 :            : static cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
    2773                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
    2774                 :            :                                  rxtxq, "rxq#txq");
    2775                 :            : static cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
    2776                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
    2777                 :            :                               qid, RTE_UINT16);
    2778                 :            : static cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
    2779                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
    2780                 :            :                                  rsize, "ring_size");
    2781                 :            : static cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
    2782                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
    2783                 :            :                               size, RTE_UINT16);
    2784                 :            : 
    2785                 :            : static cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
    2786                 :            :         .f = cmd_config_rxtx_ring_size_parsed,
    2787                 :            :         .data = NULL,
    2788                 :            :         .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
    2789                 :            :         .tokens = {
    2790                 :            :                 (void *)&cmd_config_rxtx_ring_size_port,
    2791                 :            :                 (void *)&cmd_config_rxtx_ring_size_config,
    2792                 :            :                 (void *)&cmd_config_rxtx_ring_size_portid,
    2793                 :            :                 (void *)&cmd_config_rxtx_ring_size_rxtxq,
    2794                 :            :                 (void *)&cmd_config_rxtx_ring_size_qid,
    2795                 :            :                 (void *)&cmd_config_rxtx_ring_size_rsize,
    2796                 :            :                 (void *)&cmd_config_rxtx_ring_size_size,
    2797                 :            :                 NULL,
    2798                 :            :         },
    2799                 :            : };
    2800                 :            : 
    2801                 :            : /* *** configure port rxq/txq start/stop *** */
    2802                 :            : struct cmd_config_rxtx_queue {
    2803                 :            :         cmdline_fixed_string_t port;
    2804                 :            :         portid_t portid;
    2805                 :            :         cmdline_fixed_string_t rxtxq;
    2806                 :            :         uint16_t qid;
    2807                 :            :         cmdline_fixed_string_t opname;
    2808                 :            : };
    2809                 :            : 
    2810                 :            : static void
    2811                 :          0 : cmd_config_rxtx_queue_parsed(void *parsed_result,
    2812                 :            :                         __rte_unused struct cmdline *cl,
    2813                 :            :                         __rte_unused void *data)
    2814                 :            : {
    2815                 :            :         struct cmd_config_rxtx_queue *res = parsed_result;
    2816                 :            :         struct rte_port *port;
    2817                 :            :         uint8_t isrx;
    2818                 :            :         uint8_t isstart;
    2819                 :            :         uint8_t *state;
    2820                 :            :         int ret = 0;
    2821                 :            : 
    2822                 :          0 :         if (test_done == 0) {
    2823                 :          0 :                 fprintf(stderr, "Please stop forwarding first\n");
    2824                 :          0 :                 return;
    2825                 :            :         }
    2826                 :            : 
    2827                 :          0 :         if (port_id_is_invalid(res->portid, ENABLED_WARN))
    2828                 :            :                 return;
    2829                 :            : 
    2830                 :          0 :         if (port_is_started(res->portid) != 1) {
    2831                 :          0 :                 fprintf(stderr, "Please start port %u first\n", res->portid);
    2832                 :          0 :                 return;
    2833                 :            :         }
    2834                 :            : 
    2835                 :          0 :         if (!strcmp(res->rxtxq, "rxq"))
    2836                 :            :                 isrx = 1;
    2837                 :          0 :         else if (!strcmp(res->rxtxq, "txq"))
    2838                 :            :                 isrx = 0;
    2839                 :            :         else {
    2840                 :          0 :                 fprintf(stderr, "Unknown parameter\n");
    2841                 :          0 :                 return;
    2842                 :            :         }
    2843                 :            : 
    2844                 :          0 :         if (isrx && rx_queue_id_is_invalid(res->qid))
    2845                 :            :                 return;
    2846                 :          0 :         else if (!isrx && tx_queue_id_is_invalid(res->qid))
    2847                 :            :                 return;
    2848                 :            : 
    2849                 :          0 :         if (!strcmp(res->opname, "start"))
    2850                 :            :                 isstart = 1;
    2851                 :          0 :         else if (!strcmp(res->opname, "stop"))
    2852                 :            :                 isstart = 0;
    2853                 :            :         else {
    2854                 :          0 :                 fprintf(stderr, "Unknown parameter\n");
    2855                 :          0 :                 return;
    2856                 :            :         }
    2857                 :            : 
    2858                 :          0 :         if (isstart && isrx)
    2859                 :          0 :                 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
    2860                 :          0 :         else if (!isstart && isrx)
    2861                 :          0 :                 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
    2862                 :          0 :         else if (isstart && !isrx)
    2863                 :          0 :                 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
    2864                 :            :         else
    2865                 :          0 :                 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
    2866                 :            : 
    2867                 :          0 :         if (ret == -ENOTSUP) {
    2868                 :          0 :                 fprintf(stderr, "Function not supported in PMD\n");
    2869                 :          0 :                 return;
    2870                 :            :         }
    2871                 :            : 
    2872                 :          0 :         port = &ports[res->portid];
    2873                 :          0 :         state = isrx ? &port->rxq[res->qid].state : &port->txq[res->qid].state;
    2874                 :          0 :         *state = isstart ? RTE_ETH_QUEUE_STATE_STARTED :
    2875                 :            :                            RTE_ETH_QUEUE_STATE_STOPPED;
    2876                 :            : }
    2877                 :            : 
    2878                 :            : static cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
    2879                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
    2880                 :            : static cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
    2881                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, RTE_UINT16);
    2882                 :            : static cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
    2883                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
    2884                 :            : static cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
    2885                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, RTE_UINT16);
    2886                 :            : static cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
    2887                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
    2888                 :            :                                                 "start#stop");
    2889                 :            : 
    2890                 :            : static cmdline_parse_inst_t cmd_config_rxtx_queue = {
    2891                 :            :         .f = cmd_config_rxtx_queue_parsed,
    2892                 :            :         .data = NULL,
    2893                 :            :         .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
    2894                 :            :         .tokens = {
    2895                 :            :                 (void *)&cmd_config_rxtx_queue_port,
    2896                 :            :                 (void *)&cmd_config_rxtx_queue_portid,
    2897                 :            :                 (void *)&cmd_config_rxtx_queue_rxtxq,
    2898                 :            :                 (void *)&cmd_config_rxtx_queue_qid,
    2899                 :            :                 (void *)&cmd_config_rxtx_queue_opname,
    2900                 :            :                 NULL,
    2901                 :            :         },
    2902                 :            : };
    2903                 :            : 
    2904                 :            : /* *** configure port rxq/txq deferred start on/off *** */
    2905                 :            : struct cmd_config_deferred_start_rxtx_queue {
    2906                 :            :         cmdline_fixed_string_t port;
    2907                 :            :         portid_t port_id;
    2908                 :            :         cmdline_fixed_string_t rxtxq;
    2909                 :            :         uint16_t qid;
    2910                 :            :         cmdline_fixed_string_t opname;
    2911                 :            :         cmdline_fixed_string_t state;
    2912                 :            : };
    2913                 :            : 
    2914                 :            : static void
    2915                 :          0 : cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
    2916                 :            :                         __rte_unused struct cmdline *cl,
    2917                 :            :                         __rte_unused void *data)
    2918                 :            : {
    2919                 :            :         struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
    2920                 :            :         struct rte_port *port;
    2921                 :            :         uint8_t isrx;
    2922                 :            :         uint8_t ison;
    2923                 :            :         uint8_t needreconfig = 0;
    2924                 :            : 
    2925                 :          0 :         if (port_id_is_invalid(res->port_id, ENABLED_WARN))
    2926                 :            :                 return;
    2927                 :            : 
    2928                 :          0 :         if (port_is_started(res->port_id) != 0) {
    2929                 :          0 :                 fprintf(stderr, "Please stop port %u first\n", res->port_id);
    2930                 :          0 :                 return;
    2931                 :            :         }
    2932                 :            : 
    2933                 :          0 :         port = &ports[res->port_id];
    2934                 :            : 
    2935                 :          0 :         isrx = !strcmp(res->rxtxq, "rxq");
    2936                 :            : 
    2937                 :          0 :         if (isrx && rx_queue_id_is_invalid(res->qid))
    2938                 :            :                 return;
    2939                 :          0 :         else if (!isrx && tx_queue_id_is_invalid(res->qid))
    2940                 :            :                 return;
    2941                 :            : 
    2942                 :          0 :         ison = !strcmp(res->state, "on");
    2943                 :            : 
    2944                 :          0 :         if (isrx && port->rxq[res->qid].conf.rx_deferred_start != ison) {
    2945                 :          0 :                 port->rxq[res->qid].conf.rx_deferred_start = ison;
    2946                 :            :                 needreconfig = 1;
    2947                 :          0 :         } else if (!isrx && port->txq[res->qid].conf.tx_deferred_start != ison) {
    2948                 :          0 :                 port->txq[res->qid].conf.tx_deferred_start = ison;
    2949                 :            :                 needreconfig = 1;
    2950                 :            :         }
    2951                 :            : 
    2952                 :            :         if (needreconfig)
    2953                 :          0 :                 cmd_reconfig_device_queue(res->port_id, 0, 1);
    2954                 :            : }
    2955                 :            : 
    2956                 :            : static cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
    2957                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
    2958                 :            :                                                 port, "port");
    2959                 :            : static cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
    2960                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
    2961                 :            :                                                 port_id, RTE_UINT16);
    2962                 :            : static cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
    2963                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
    2964                 :            :                                                 rxtxq, "rxq#txq");
    2965                 :            : static cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
    2966                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
    2967                 :            :                                                 qid, RTE_UINT16);
    2968                 :            : static cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
    2969                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
    2970                 :            :                                                 opname, "deferred_start");
    2971                 :            : static cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
    2972                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
    2973                 :            :                                                 state, "on#off");
    2974                 :            : 
    2975                 :            : static cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
    2976                 :            :         .f = cmd_config_deferred_start_rxtx_queue_parsed,
    2977                 :            :         .data = NULL,
    2978                 :            :         .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
    2979                 :            :         .tokens = {
    2980                 :            :                 (void *)&cmd_config_deferred_start_rxtx_queue_port,
    2981                 :            :                 (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
    2982                 :            :                 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
    2983                 :            :                 (void *)&cmd_config_deferred_start_rxtx_queue_qid,
    2984                 :            :                 (void *)&cmd_config_deferred_start_rxtx_queue_opname,
    2985                 :            :                 (void *)&cmd_config_deferred_start_rxtx_queue_state,
    2986                 :            :                 NULL,
    2987                 :            :         },
    2988                 :            : };
    2989                 :            : 
    2990                 :            : /* *** configure port rxq/txq setup *** */
    2991                 :            : struct cmd_setup_rxtx_queue {
    2992                 :            :         cmdline_fixed_string_t port;
    2993                 :            :         portid_t portid;
    2994                 :            :         cmdline_fixed_string_t rxtxq;
    2995                 :            :         uint16_t qid;
    2996                 :            :         cmdline_fixed_string_t setup;
    2997                 :            : };
    2998                 :            : 
    2999                 :            : /* Common CLI fields for queue setup */
    3000                 :            : static cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
    3001                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
    3002                 :            : static cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
    3003                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, RTE_UINT16);
    3004                 :            : static cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
    3005                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
    3006                 :            : static cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
    3007                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, RTE_UINT16);
    3008                 :            : static cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
    3009                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
    3010                 :            : 
    3011                 :            : static void
    3012                 :          0 : cmd_setup_rxtx_queue_parsed(
    3013                 :            :         void *parsed_result,
    3014                 :            :         __rte_unused struct cmdline *cl,
    3015                 :            :         __rte_unused void *data)
    3016                 :            : {
    3017                 :            :         struct cmd_setup_rxtx_queue *res = parsed_result;
    3018                 :            :         struct rte_port *port;
    3019                 :            :         struct rte_mempool *mp;
    3020                 :            :         unsigned int socket_id;
    3021                 :            :         uint8_t isrx = 0;
    3022                 :            :         int ret;
    3023                 :            : 
    3024                 :          0 :         if (port_id_is_invalid(res->portid, ENABLED_WARN))
    3025                 :            :                 return;
    3026                 :            : 
    3027                 :          0 :         if (res->portid == (portid_t)RTE_PORT_ALL) {
    3028                 :          0 :                 fprintf(stderr, "Invalid port id\n");
    3029                 :          0 :                 return;
    3030                 :            :         }
    3031                 :            : 
    3032                 :          0 :         if (!strcmp(res->rxtxq, "rxq"))
    3033                 :            :                 isrx = 1;
    3034                 :          0 :         else if (!strcmp(res->rxtxq, "txq"))
    3035                 :            :                 isrx = 0;
    3036                 :            :         else {
    3037                 :          0 :                 fprintf(stderr, "Unknown parameter\n");
    3038                 :          0 :                 return;
    3039                 :            :         }
    3040                 :            : 
    3041                 :          0 :         if (isrx && rx_queue_id_is_invalid(res->qid)) {
    3042                 :          0 :                 fprintf(stderr, "Invalid rx queue\n");
    3043                 :          0 :                 return;
    3044                 :          0 :         } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
    3045                 :          0 :                 fprintf(stderr, "Invalid tx queue\n");
    3046                 :          0 :                 return;
    3047                 :            :         }
    3048                 :            : 
    3049                 :          0 :         port = &ports[res->portid];
    3050                 :          0 :         if (isrx) {
    3051                 :          0 :                 socket_id = rxring_numa[res->portid];
    3052                 :          0 :                 if (!numa_support || socket_id == NUMA_NO_CONFIG)
    3053                 :          0 :                         socket_id = port->socket_id;
    3054                 :            : 
    3055                 :            :                 mp = mbuf_pool_find(socket_id, 0);
    3056                 :          0 :                 if (mp == NULL) {
    3057                 :          0 :                         fprintf(stderr,
    3058                 :            :                                 "Failed to setup RX queue: No mempool allocation on the socket %d\n",
    3059                 :          0 :                                 rxring_numa[res->portid]);
    3060                 :          0 :                         return;
    3061                 :            :                 }
    3062                 :          0 :                 ret = rx_queue_setup(res->portid,
    3063                 :            :                                      res->qid,
    3064                 :          0 :                                      port->nb_rx_desc[res->qid],
    3065                 :            :                                      socket_id,
    3066                 :          0 :                                      &port->rxq[res->qid].conf,
    3067                 :            :                                      mp);
    3068                 :          0 :                 if (ret)
    3069                 :          0 :                         fprintf(stderr, "Failed to setup RX queue\n");
    3070                 :            :         } else {
    3071                 :          0 :                 socket_id = txring_numa[res->portid];
    3072                 :          0 :                 if (!numa_support || socket_id == NUMA_NO_CONFIG)
    3073                 :          0 :                         socket_id = port->socket_id;
    3074                 :            : 
    3075                 :          0 :                 if (port->nb_tx_desc[res->qid] < tx_pkt_nb_segs) {
    3076                 :          0 :                         fprintf(stderr,
    3077                 :            :                                 "Failed to setup TX queue: not enough descriptors\n");
    3078                 :          0 :                         return;
    3079                 :            :                 }
    3080                 :          0 :                 ret = rte_eth_tx_queue_setup(res->portid,
    3081                 :            :                                              res->qid,
    3082                 :            :                                              port->nb_tx_desc[res->qid],
    3083                 :            :                                              socket_id,
    3084                 :          0 :                                              &port->txq[res->qid].conf);
    3085                 :          0 :                 if (ret)
    3086                 :          0 :                         fprintf(stderr, "Failed to setup TX queue\n");
    3087                 :            :         }
    3088                 :            : }
    3089                 :            : 
    3090                 :            : static cmdline_parse_inst_t cmd_setup_rxtx_queue = {
    3091                 :            :         .f = cmd_setup_rxtx_queue_parsed,
    3092                 :            :         .data = NULL,
    3093                 :            :         .help_str = "port <port_id> rxq|txq <queue_idx> setup",
    3094                 :            :         .tokens = {
    3095                 :            :                 (void *)&cmd_setup_rxtx_queue_port,
    3096                 :            :                 (void *)&cmd_setup_rxtx_queue_portid,
    3097                 :            :                 (void *)&cmd_setup_rxtx_queue_rxtxq,
    3098                 :            :                 (void *)&cmd_setup_rxtx_queue_qid,
    3099                 :            :                 (void *)&cmd_setup_rxtx_queue_setup,
    3100                 :            :                 NULL,
    3101                 :            :         },
    3102                 :            : };
    3103                 :            : 
    3104                 :            : 
    3105                 :            : /* *** Configure RSS RETA *** */
    3106                 :            : struct cmd_config_rss_reta {
    3107                 :            :         cmdline_fixed_string_t port;
    3108                 :            :         cmdline_fixed_string_t keyword;
    3109                 :            :         portid_t port_id;
    3110                 :            :         cmdline_fixed_string_t name;
    3111                 :            :         cmdline_fixed_string_t list_name;
    3112                 :            :         cmdline_fixed_string_t list_of_items;
    3113                 :            : };
    3114                 :            : 
    3115                 :            : static int
    3116                 :          0 : parse_reta_config(const char *str,
    3117                 :            :                   struct rte_eth_rss_reta_entry64 *reta_conf,
    3118                 :            :                   uint16_t nb_entries)
    3119                 :            : {
    3120                 :            :         int i;
    3121                 :            :         unsigned size;
    3122                 :            :         uint16_t hash_index, idx, shift;
    3123                 :            :         uint16_t nb_queue;
    3124                 :            :         char s[256];
    3125                 :            :         const char *p, *p0 = str;
    3126                 :            :         char *end;
    3127                 :            :         enum fieldnames {
    3128                 :            :                 FLD_HASH_INDEX = 0,
    3129                 :            :                 FLD_QUEUE,
    3130                 :            :                 _NUM_FLD
    3131                 :            :         };
    3132                 :            :         unsigned long int_fld[_NUM_FLD];
    3133                 :            :         char *str_fld[_NUM_FLD];
    3134                 :            : 
    3135                 :          0 :         while ((p = strchr(p0,'(')) != NULL) {
    3136                 :          0 :                 ++p;
    3137                 :          0 :                 if((p0 = strchr(p,')')) == NULL)
    3138                 :            :                         return -1;
    3139                 :            : 
    3140                 :          0 :                 size = p0 - p;
    3141                 :          0 :                 if(size >= sizeof(s))
    3142                 :            :                         return -1;
    3143                 :            : 
    3144                 :            :                 snprintf(s, sizeof(s), "%.*s", size, p);
    3145                 :          0 :                 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
    3146                 :            :                         return -1;
    3147                 :          0 :                 for (i = 0; i < _NUM_FLD; i++) {
    3148                 :          0 :                         errno = 0;
    3149                 :          0 :                         int_fld[i] = strtoul(str_fld[i], &end, 0);
    3150                 :          0 :                         if (errno != 0 || end == str_fld[i] ||
    3151                 :            :                                         int_fld[i] > 65535)
    3152                 :            :                                 return -1;
    3153                 :            :                 }
    3154                 :            : 
    3155                 :          0 :                 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
    3156                 :          0 :                 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
    3157                 :            : 
    3158                 :          0 :                 if (hash_index >= nb_entries) {
    3159                 :          0 :                         fprintf(stderr, "Invalid RETA hash index=%d\n",
    3160                 :            :                                 hash_index);
    3161                 :          0 :                         return -1;
    3162                 :            :                 }
    3163                 :            : 
    3164                 :          0 :                 idx = hash_index / RTE_ETH_RETA_GROUP_SIZE;
    3165                 :          0 :                 shift = hash_index % RTE_ETH_RETA_GROUP_SIZE;
    3166                 :          0 :                 reta_conf[idx].mask |= (1ULL << shift);
    3167                 :          0 :                 reta_conf[idx].reta[shift] = nb_queue;
    3168                 :            :         }
    3169                 :            : 
    3170                 :            :         return 0;
    3171                 :            : }
    3172                 :            : 
    3173                 :            : static void
    3174                 :          0 : cmd_set_rss_reta_parsed(void *parsed_result,
    3175                 :            :                         __rte_unused struct cmdline *cl,
    3176                 :            :                         __rte_unused void *data)
    3177                 :            : {
    3178                 :            :         int ret;
    3179                 :            :         struct rte_eth_dev_info dev_info;
    3180                 :            :         struct rte_eth_rss_reta_entry64 reta_conf[8];
    3181                 :            :         struct cmd_config_rss_reta *res = parsed_result;
    3182                 :            : 
    3183                 :          0 :         ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
    3184                 :          0 :         if (ret != 0)
    3185                 :          0 :                 return;
    3186                 :            : 
    3187                 :          0 :         if (dev_info.reta_size == 0) {
    3188                 :          0 :                 fprintf(stderr,
    3189                 :            :                         "Redirection table size is 0 which is invalid for RSS\n");
    3190                 :          0 :                 return;
    3191                 :            :         } else
    3192                 :          0 :                 printf("The reta size of port %d is %u\n",
    3193                 :          0 :                         res->port_id, dev_info.reta_size);
    3194                 :          0 :         if (dev_info.reta_size > RTE_ETH_RSS_RETA_SIZE_512) {
    3195                 :          0 :                 fprintf(stderr,
    3196                 :            :                         "Currently do not support more than %u entries of redirection table\n",
    3197                 :            :                         RTE_ETH_RSS_RETA_SIZE_512);
    3198                 :          0 :                 return;
    3199                 :            :         }
    3200                 :            : 
    3201                 :            :         memset(reta_conf, 0, sizeof(reta_conf));
    3202                 :          0 :         if (!strcmp(res->list_name, "reta")) {
    3203                 :          0 :                 if (parse_reta_config(res->list_of_items, reta_conf,
    3204                 :            :                                                 dev_info.reta_size)) {
    3205                 :          0 :                         fprintf(stderr,
    3206                 :            :                                 "Invalid RSS Redirection Table config entered\n");
    3207                 :          0 :                         return;
    3208                 :            :                 }
    3209                 :          0 :                 ret = rte_eth_dev_rss_reta_update(res->port_id,
    3210                 :          0 :                                 reta_conf, dev_info.reta_size);
    3211                 :          0 :                 if (ret != 0)
    3212                 :          0 :                         fprintf(stderr,
    3213                 :            :                                 "Bad redirection table parameter, return code = %d\n",
    3214                 :            :                                 ret);
    3215                 :            :         }
    3216                 :            : }
    3217                 :            : 
    3218                 :            : static cmdline_parse_token_string_t cmd_config_rss_reta_port =
    3219                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
    3220                 :            : static cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
    3221                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
    3222                 :            : static cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
    3223                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, RTE_UINT16);
    3224                 :            : static cmdline_parse_token_string_t cmd_config_rss_reta_name =
    3225                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
    3226                 :            : static cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
    3227                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
    3228                 :            : static cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
    3229                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
    3230                 :            :                                  NULL);
    3231                 :            : static cmdline_parse_inst_t cmd_config_rss_reta = {
    3232                 :            :         .f = cmd_set_rss_reta_parsed,
    3233                 :            :         .data = NULL,
    3234                 :            :         .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
    3235                 :            :         .tokens = {
    3236                 :            :                 (void *)&cmd_config_rss_reta_port,
    3237                 :            :                 (void *)&cmd_config_rss_reta_keyword,
    3238                 :            :                 (void *)&cmd_config_rss_reta_port_id,
    3239                 :            :                 (void *)&cmd_config_rss_reta_name,
    3240                 :            :                 (void *)&cmd_config_rss_reta_list_name,
    3241                 :            :                 (void *)&cmd_config_rss_reta_list_of_items,
    3242                 :            :                 NULL,
    3243                 :            :         },
    3244                 :            : };
    3245                 :            : 
    3246                 :            : /* *** SHOW PORT RETA INFO *** */
    3247                 :            : struct cmd_showport_reta {
    3248                 :            :         cmdline_fixed_string_t show;
    3249                 :            :         cmdline_fixed_string_t port;
    3250                 :            :         portid_t port_id;
    3251                 :            :         cmdline_fixed_string_t rss;
    3252                 :            :         cmdline_fixed_string_t reta;
    3253                 :            :         uint16_t size;
    3254                 :            :         cmdline_fixed_string_t list_of_items;
    3255                 :            : };
    3256                 :            : 
    3257                 :            : static int
    3258                 :          0 : showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
    3259                 :            :                            uint16_t nb_entries,
    3260                 :            :                            char *str)
    3261                 :            : {
    3262                 :            :         uint32_t size;
    3263                 :            :         const char *p, *p0 = str;
    3264                 :            :         char s[256];
    3265                 :            :         char *end;
    3266                 :            :         char *str_fld[8];
    3267                 :            :         uint16_t i;
    3268                 :          0 :         uint16_t num = (nb_entries + RTE_ETH_RETA_GROUP_SIZE - 1) /
    3269                 :            :                         RTE_ETH_RETA_GROUP_SIZE;
    3270                 :            :         int ret;
    3271                 :            : 
    3272                 :          0 :         p = strchr(p0, '(');
    3273                 :          0 :         if (p == NULL)
    3274                 :            :                 return -1;
    3275                 :          0 :         p++;
    3276                 :          0 :         p0 = strchr(p, ')');
    3277                 :          0 :         if (p0 == NULL)
    3278                 :            :                 return -1;
    3279                 :          0 :         size = p0 - p;
    3280                 :          0 :         if (size >= sizeof(s)) {
    3281                 :          0 :                 fprintf(stderr,
    3282                 :            :                         "The string size exceeds the internal buffer size\n");
    3283                 :          0 :                 return -1;
    3284                 :            :         }
    3285                 :            :         snprintf(s, sizeof(s), "%.*s", size, p);
    3286                 :          0 :         ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
    3287                 :          0 :         if (ret <= 0 || ret != num) {
    3288                 :          0 :                 fprintf(stderr,
    3289                 :            :                         "The bits of masks do not match the number of reta entries: %u\n",
    3290                 :            :                         num);
    3291                 :          0 :                 return -1;
    3292                 :            :         }
    3293                 :          0 :         for (i = 0; i < ret; i++)
    3294                 :          0 :                 conf[i].mask = (uint64_t)strtoull(str_fld[i], &end, 0);
    3295                 :            : 
    3296                 :            :         return 0;
    3297                 :            : }
    3298                 :            : 
    3299                 :            : static void
    3300                 :          0 : cmd_showport_reta_parsed(void *parsed_result,
    3301                 :            :                          __rte_unused struct cmdline *cl,
    3302                 :            :                          __rte_unused void *data)
    3303                 :            : {
    3304                 :            :         struct cmd_showport_reta *res = parsed_result;
    3305                 :            :         struct rte_eth_rss_reta_entry64 reta_conf[8];
    3306                 :            :         struct rte_eth_dev_info dev_info;
    3307                 :            :         uint16_t max_reta_size;
    3308                 :            :         int ret;
    3309                 :            : 
    3310                 :          0 :         ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
    3311                 :          0 :         if (ret != 0)
    3312                 :          0 :                 return;
    3313                 :            : 
    3314                 :          0 :         max_reta_size = RTE_MIN(dev_info.reta_size, RTE_ETH_RSS_RETA_SIZE_512);
    3315                 :          0 :         if (res->size == 0 || res->size > max_reta_size) {
    3316                 :          0 :                 fprintf(stderr, "Invalid redirection table size: %u (1-%u)\n",
    3317                 :            :                         res->size, max_reta_size);
    3318                 :          0 :                 return;
    3319                 :            :         }
    3320                 :            : 
    3321                 :            :         memset(reta_conf, 0, sizeof(reta_conf));
    3322                 :          0 :         if (showport_parse_reta_config(reta_conf, res->size,
    3323                 :          0 :                                 res->list_of_items) < 0) {
    3324                 :          0 :                 fprintf(stderr, "Invalid string: %s for reta masks\n",
    3325                 :            :                         res->list_of_items);
    3326                 :          0 :                 return;
    3327                 :            :         }
    3328                 :          0 :         port_rss_reta_info(res->port_id, reta_conf, res->size);
    3329                 :            : }
    3330                 :            : 
    3331                 :            : static cmdline_parse_token_string_t cmd_showport_reta_show =
    3332                 :            :         TOKEN_STRING_INITIALIZER(struct  cmd_showport_reta, show, "show");
    3333                 :            : static cmdline_parse_token_string_t cmd_showport_reta_port =
    3334                 :            :         TOKEN_STRING_INITIALIZER(struct  cmd_showport_reta, port, "port");
    3335                 :            : static cmdline_parse_token_num_t cmd_showport_reta_port_id =
    3336                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, RTE_UINT16);
    3337                 :            : static cmdline_parse_token_string_t cmd_showport_reta_rss =
    3338                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
    3339                 :            : static cmdline_parse_token_string_t cmd_showport_reta_reta =
    3340                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
    3341                 :            : static cmdline_parse_token_num_t cmd_showport_reta_size =
    3342                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, RTE_UINT16);
    3343                 :            : static cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
    3344                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
    3345                 :            :                                         list_of_items, NULL);
    3346                 :            : 
    3347                 :            : static cmdline_parse_inst_t cmd_showport_reta = {
    3348                 :            :         .f = cmd_showport_reta_parsed,
    3349                 :            :         .data = NULL,
    3350                 :            :         .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
    3351                 :            :         .tokens = {
    3352                 :            :                 (void *)&cmd_showport_reta_show,
    3353                 :            :                 (void *)&cmd_showport_reta_port,
    3354                 :            :                 (void *)&cmd_showport_reta_port_id,
    3355                 :            :                 (void *)&cmd_showport_reta_rss,
    3356                 :            :                 (void *)&cmd_showport_reta_reta,
    3357                 :            :                 (void *)&cmd_showport_reta_size,
    3358                 :            :                 (void *)&cmd_showport_reta_list_of_items,
    3359                 :            :                 NULL,
    3360                 :            :         },
    3361                 :            : };
    3362                 :            : 
    3363                 :            : /* *** Show RSS hash configuration *** */
    3364                 :            : struct cmd_showport_rss_hash {
    3365                 :            :         cmdline_fixed_string_t show;
    3366                 :            :         cmdline_fixed_string_t port;
    3367                 :            :         portid_t port_id;
    3368                 :            :         cmdline_fixed_string_t rss_hash;
    3369                 :            :         cmdline_fixed_string_t rss_type;
    3370                 :            :         cmdline_fixed_string_t key; /* optional argument */
    3371                 :            :         cmdline_fixed_string_t algorithm; /* optional argument */
    3372                 :            : };
    3373                 :            : 
    3374                 :          0 : static void cmd_showport_rss_hash_parsed(void *parsed_result,
    3375                 :            :                                 __rte_unused struct cmdline *cl,
    3376                 :            :                                 __rte_unused void *data)
    3377                 :            : {
    3378                 :            :         struct cmd_showport_rss_hash *res = parsed_result;
    3379                 :            : 
    3380                 :          0 :         port_rss_hash_conf_show(res->port_id,
    3381                 :          0 :                 !strcmp(res->key, "key"), !strcmp(res->algorithm, "algorithm"));
    3382                 :          0 : }
    3383                 :            : 
    3384                 :            : static cmdline_parse_token_string_t cmd_showport_rss_hash_show =
    3385                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
    3386                 :            : static cmdline_parse_token_string_t cmd_showport_rss_hash_port =
    3387                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
    3388                 :            : static cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
    3389                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id,
    3390                 :            :                                  RTE_UINT16);
    3391                 :            : static cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
    3392                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
    3393                 :            :                                  "rss-hash");
    3394                 :            : static cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
    3395                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
    3396                 :            : static cmdline_parse_token_string_t cmd_showport_rss_hash_rss_algo =
    3397                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, algorithm, "algorithm");
    3398                 :            : 
    3399                 :            : static cmdline_parse_inst_t cmd_showport_rss_hash = {
    3400                 :            :         .f = cmd_showport_rss_hash_parsed,
    3401                 :            :         .data = NULL,
    3402                 :            :         .help_str = "show port <port_id> rss-hash",
    3403                 :            :         .tokens = {
    3404                 :            :                 (void *)&cmd_showport_rss_hash_show,
    3405                 :            :                 (void *)&cmd_showport_rss_hash_port,
    3406                 :            :                 (void *)&cmd_showport_rss_hash_port_id,
    3407                 :            :                 (void *)&cmd_showport_rss_hash_rss_hash,
    3408                 :            :                 NULL,
    3409                 :            :         },
    3410                 :            : };
    3411                 :            : 
    3412                 :            : static cmdline_parse_inst_t cmd_showport_rss_hash_key = {
    3413                 :            :         .f = cmd_showport_rss_hash_parsed,
    3414                 :            :         .data = NULL,
    3415                 :            :         .help_str = "show port <port_id> rss-hash key",
    3416                 :            :         .tokens = {
    3417                 :            :                 (void *)&cmd_showport_rss_hash_show,
    3418                 :            :                 (void *)&cmd_showport_rss_hash_port,
    3419                 :            :                 (void *)&cmd_showport_rss_hash_port_id,
    3420                 :            :                 (void *)&cmd_showport_rss_hash_rss_hash,
    3421                 :            :                 (void *)&cmd_showport_rss_hash_rss_key,
    3422                 :            :                 NULL,
    3423                 :            :         },
    3424                 :            : };
    3425                 :            : 
    3426                 :            : static cmdline_parse_inst_t cmd_showport_rss_hash_algo = {
    3427                 :            :         .f = cmd_showport_rss_hash_parsed,
    3428                 :            :         .data = NULL,
    3429                 :            :         .help_str = "show port <port_id> rss-hash algorithm",
    3430                 :            :         .tokens = {
    3431                 :            :                 (void *)&cmd_showport_rss_hash_show,
    3432                 :            :                 (void *)&cmd_showport_rss_hash_port,
    3433                 :            :                 (void *)&cmd_showport_rss_hash_port_id,
    3434                 :            :                 (void *)&cmd_showport_rss_hash_rss_hash,
    3435                 :            :                 (void *)&cmd_showport_rss_hash_rss_algo,
    3436                 :            :                 NULL,
    3437                 :            :         },
    3438                 :            : };
    3439                 :            : 
    3440                 :            : /* *** Configure DCB *** */
    3441                 :            : struct cmd_config_dcb {
    3442                 :            :         cmdline_fixed_string_t port;
    3443                 :            :         cmdline_fixed_string_t config;
    3444                 :            :         portid_t port_id;
    3445                 :            :         cmdline_fixed_string_t dcb;
    3446                 :            :         cmdline_fixed_string_t vt;
    3447                 :            :         cmdline_fixed_string_t vt_en;
    3448                 :            :         uint8_t num_tcs;
    3449                 :            :         cmdline_fixed_string_t pfc;
    3450                 :            :         cmdline_fixed_string_t pfc_en;
    3451                 :            : };
    3452                 :            : 
    3453                 :            : static void
    3454                 :          0 : cmd_config_dcb_parsed(void *parsed_result,
    3455                 :            :                         __rte_unused struct cmdline *cl,
    3456                 :            :                         __rte_unused void *data)
    3457                 :            : {
    3458                 :            :         struct cmd_config_dcb *res = parsed_result;
    3459                 :            :         struct rte_eth_dcb_info dcb_info;
    3460                 :          0 :         portid_t port_id = res->port_id;
    3461                 :            :         struct rte_port *port;
    3462                 :            :         uint8_t pfc_en;
    3463                 :            :         int ret;
    3464                 :            : 
    3465                 :          0 :         port = &ports[port_id];
    3466                 :            :         /** Check if the port is not started **/
    3467                 :          0 :         if (port->port_status != RTE_PORT_STOPPED) {
    3468                 :          0 :                 fprintf(stderr, "Please stop port %d first\n", port_id);
    3469                 :          0 :                 return;
    3470                 :            :         }
    3471                 :            : 
    3472                 :          0 :         if ((res->num_tcs != RTE_ETH_4_TCS) && (res->num_tcs != RTE_ETH_8_TCS)) {
    3473                 :          0 :                 fprintf(stderr,
    3474                 :            :                         "The invalid number of traffic class, only 4 or 8 allowed.\n");
    3475                 :          0 :                 return;
    3476                 :            :         }
    3477                 :            : 
    3478                 :          0 :         if (nb_fwd_lcores < res->num_tcs) {
    3479                 :          0 :                 fprintf(stderr,
    3480                 :            :                         "nb_cores shouldn't be less than number of TCs.\n");
    3481                 :          0 :                 return;
    3482                 :            :         }
    3483                 :            : 
    3484                 :            :         /* Check whether the port supports the report of DCB info. */
    3485                 :          0 :         ret = rte_eth_dev_get_dcb_info(port_id, &dcb_info);
    3486                 :          0 :         if (ret == -ENOTSUP) {
    3487                 :          0 :                 fprintf(stderr, "rte_eth_dev_get_dcb_info not supported.\n");
    3488                 :          0 :                 return;
    3489                 :            :         }
    3490                 :            : 
    3491                 :          0 :         if (!strncmp(res->pfc_en, "on", 2))
    3492                 :            :                 pfc_en = 1;
    3493                 :            :         else
    3494                 :            :                 pfc_en = 0;
    3495                 :            : 
    3496                 :            :         /* DCB in VT mode */
    3497                 :          0 :         if (!strncmp(res->vt_en, "on", 2))
    3498                 :          0 :                 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
    3499                 :          0 :                                 (enum rte_eth_nb_tcs)res->num_tcs,
    3500                 :            :                                 pfc_en);
    3501                 :            :         else
    3502                 :          0 :                 ret = init_port_dcb_config(port_id, DCB_ENABLED,
    3503                 :          0 :                                 (enum rte_eth_nb_tcs)res->num_tcs,
    3504                 :            :                                 pfc_en);
    3505                 :          0 :         if (ret != 0) {
    3506                 :          0 :                 fprintf(stderr, "Cannot initialize network ports.\n");
    3507                 :          0 :                 return;
    3508                 :            :         }
    3509                 :            : 
    3510                 :          0 :         fwd_config_setup();
    3511                 :            : 
    3512                 :          0 :         cmd_reconfig_device_queue(port_id, 1, 1);
    3513                 :            : }
    3514                 :            : 
    3515                 :            : static cmdline_parse_token_string_t cmd_config_dcb_port =
    3516                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
    3517                 :            : static cmdline_parse_token_string_t cmd_config_dcb_config =
    3518                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
    3519                 :            : static cmdline_parse_token_num_t cmd_config_dcb_port_id =
    3520                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, RTE_UINT16);
    3521                 :            : static cmdline_parse_token_string_t cmd_config_dcb_dcb =
    3522                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
    3523                 :            : static cmdline_parse_token_string_t cmd_config_dcb_vt =
    3524                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
    3525                 :            : static cmdline_parse_token_string_t cmd_config_dcb_vt_en =
    3526                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
    3527                 :            : static cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
    3528                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, RTE_UINT8);
    3529                 :            : static cmdline_parse_token_string_t cmd_config_dcb_pfc =
    3530                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
    3531                 :            : static cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
    3532                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
    3533                 :            : 
    3534                 :            : static cmdline_parse_inst_t cmd_config_dcb = {
    3535                 :            :         .f = cmd_config_dcb_parsed,
    3536                 :            :         .data = NULL,
    3537                 :            :         .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
    3538                 :            :         .tokens = {
    3539                 :            :                 (void *)&cmd_config_dcb_port,
    3540                 :            :                 (void *)&cmd_config_dcb_config,
    3541                 :            :                 (void *)&cmd_config_dcb_port_id,
    3542                 :            :                 (void *)&cmd_config_dcb_dcb,
    3543                 :            :                 (void *)&cmd_config_dcb_vt,
    3544                 :            :                 (void *)&cmd_config_dcb_vt_en,
    3545                 :            :                 (void *)&cmd_config_dcb_num_tcs,
    3546                 :            :                 (void *)&cmd_config_dcb_pfc,
    3547                 :            :                 (void *)&cmd_config_dcb_pfc_en,
    3548                 :            :                 NULL,
    3549                 :            :         },
    3550                 :            : };
    3551                 :            : 
    3552                 :            : /* *** configure number of packets per burst *** */
    3553                 :            : struct cmd_config_burst {
    3554                 :            :         cmdline_fixed_string_t port;
    3555                 :            :         cmdline_fixed_string_t keyword;
    3556                 :            :         cmdline_fixed_string_t all;
    3557                 :            :         cmdline_fixed_string_t name;
    3558                 :            :         uint16_t value;
    3559                 :            : };
    3560                 :            : 
    3561                 :            : static void
    3562                 :          0 : cmd_config_burst_parsed(void *parsed_result,
    3563                 :            :                         __rte_unused struct cmdline *cl,
    3564                 :            :                         __rte_unused void *data)
    3565                 :            : {
    3566                 :            :         struct cmd_config_burst *res = parsed_result;
    3567                 :            :         struct rte_eth_dev_info dev_info;
    3568                 :            :         uint16_t rec_nb_pkts;
    3569                 :            :         int ret;
    3570                 :            : 
    3571                 :          0 :         if (!all_ports_stopped()) {
    3572                 :          0 :                 fprintf(stderr, "Please stop all ports first\n");
    3573                 :          0 :                 return;
    3574                 :            :         }
    3575                 :            : 
    3576                 :          0 :         if (!strcmp(res->name, "burst")) {
    3577                 :          0 :                 if (res->value == 0) {
    3578                 :            :                         /* If user gives a value of zero, query the PMD for
    3579                 :            :                          * its recommended Rx burst size. Testpmd uses a single
    3580                 :            :                          * size for all ports, so assume all ports are the same
    3581                 :            :                          * NIC model and use the values from Port 0.
    3582                 :            :                          */
    3583                 :          0 :                         ret = eth_dev_info_get_print_err(0, &dev_info);
    3584                 :          0 :                         if (ret != 0)
    3585                 :            :                                 return;
    3586                 :            : 
    3587                 :          0 :                         rec_nb_pkts = dev_info.default_rxportconf.burst_size;
    3588                 :            : 
    3589                 :          0 :                         if (rec_nb_pkts == 0) {
    3590                 :            :                                 printf("PMD does not recommend a burst size.\n"
    3591                 :            :                                         "User provided value must be between"
    3592                 :            :                                         " 1 and %d\n", MAX_PKT_BURST);
    3593                 :          0 :                                 return;
    3594                 :          0 :                         } else if (rec_nb_pkts > MAX_PKT_BURST) {
    3595                 :          0 :                                 printf("PMD recommended burst size of %d"
    3596                 :            :                                         " exceeds maximum value of %d\n",
    3597                 :            :                                         rec_nb_pkts, MAX_PKT_BURST);
    3598                 :          0 :                                 return;
    3599                 :            :                         }
    3600                 :          0 :                         printf("Using PMD-provided burst value of %d\n",
    3601                 :            :                                 rec_nb_pkts);
    3602                 :          0 :                         nb_pkt_per_burst = rec_nb_pkts;
    3603                 :          0 :                 } else if (res->value > MAX_PKT_BURST) {
    3604                 :          0 :                         fprintf(stderr, "burst must be >= 1 && <= %d\n",
    3605                 :            :                                 MAX_PKT_BURST);
    3606                 :          0 :                         return;
    3607                 :            :                 } else
    3608                 :          0 :                         nb_pkt_per_burst = res->value;
    3609                 :            :         } else {
    3610                 :          0 :                 fprintf(stderr, "Unknown parameter\n");
    3611                 :          0 :                 return;
    3612                 :            :         }
    3613                 :            : 
    3614                 :          0 :         init_port_config();
    3615                 :            : 
    3616                 :          0 :         cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
    3617                 :            : }
    3618                 :            : 
    3619                 :            : static cmdline_parse_token_string_t cmd_config_burst_port =
    3620                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
    3621                 :            : static cmdline_parse_token_string_t cmd_config_burst_keyword =
    3622                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
    3623                 :            : static cmdline_parse_token_string_t cmd_config_burst_all =
    3624                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
    3625                 :            : static cmdline_parse_token_string_t cmd_config_burst_name =
    3626                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
    3627                 :            : static cmdline_parse_token_num_t cmd_config_burst_value =
    3628                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, RTE_UINT16);
    3629                 :            : 
    3630                 :            : static cmdline_parse_inst_t cmd_config_burst = {
    3631                 :            :         .f = cmd_config_burst_parsed,
    3632                 :            :         .data = NULL,
    3633                 :            :         .help_str = "port config all burst <value>",
    3634                 :            :         .tokens = {
    3635                 :            :                 (void *)&cmd_config_burst_port,
    3636                 :            :                 (void *)&cmd_config_burst_keyword,
    3637                 :            :                 (void *)&cmd_config_burst_all,
    3638                 :            :                 (void *)&cmd_config_burst_name,
    3639                 :            :                 (void *)&cmd_config_burst_value,
    3640                 :            :                 NULL,
    3641                 :            :         },
    3642                 :            : };
    3643                 :            : 
    3644                 :            : /* *** configure rx/tx queues *** */
    3645                 :            : struct cmd_config_thresh {
    3646                 :            :         cmdline_fixed_string_t port;
    3647                 :            :         cmdline_fixed_string_t keyword;
    3648                 :            :         cmdline_fixed_string_t all;
    3649                 :            :         cmdline_fixed_string_t name;
    3650                 :            :         uint8_t value;
    3651                 :            : };
    3652                 :            : 
    3653                 :            : static void
    3654                 :          0 : cmd_config_thresh_parsed(void *parsed_result,
    3655                 :            :                         __rte_unused struct cmdline *cl,
    3656                 :            :                         __rte_unused void *data)
    3657                 :            : {
    3658                 :            :         struct cmd_config_thresh *res = parsed_result;
    3659                 :            : 
    3660                 :          0 :         if (!all_ports_stopped()) {
    3661                 :          0 :                 fprintf(stderr, "Please stop all ports first\n");
    3662                 :          0 :                 return;
    3663                 :            :         }
    3664                 :            : 
    3665                 :          0 :         if (!strcmp(res->name, "txpt"))
    3666                 :          0 :                 tx_pthresh = res->value;
    3667                 :          0 :         else if(!strcmp(res->name, "txht"))
    3668                 :          0 :                 tx_hthresh = res->value;
    3669                 :          0 :         else if(!strcmp(res->name, "txwt"))
    3670                 :          0 :                 tx_wthresh = res->value;
    3671                 :          0 :         else if(!strcmp(res->name, "rxpt"))
    3672                 :          0 :                 rx_pthresh = res->value;
    3673                 :          0 :         else if(!strcmp(res->name, "rxht"))
    3674                 :          0 :                 rx_hthresh = res->value;
    3675                 :          0 :         else if(!strcmp(res->name, "rxwt"))
    3676                 :          0 :                 rx_wthresh = res->value;
    3677                 :            :         else {
    3678                 :          0 :                 fprintf(stderr, "Unknown parameter\n");
    3679                 :          0 :                 return;
    3680                 :            :         }
    3681                 :            : 
    3682                 :          0 :         init_port_config();
    3683                 :            : 
    3684                 :          0 :         cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
    3685                 :            : }
    3686                 :            : 
    3687                 :            : static cmdline_parse_token_string_t cmd_config_thresh_port =
    3688                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
    3689                 :            : static cmdline_parse_token_string_t cmd_config_thresh_keyword =
    3690                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
    3691                 :            : static cmdline_parse_token_string_t cmd_config_thresh_all =
    3692                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
    3693                 :            : static cmdline_parse_token_string_t cmd_config_thresh_name =
    3694                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
    3695                 :            :                                 "txpt#txht#txwt#rxpt#rxht#rxwt");
    3696                 :            : static cmdline_parse_token_num_t cmd_config_thresh_value =
    3697                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, RTE_UINT8);
    3698                 :            : 
    3699                 :            : static cmdline_parse_inst_t cmd_config_thresh = {
    3700                 :            :         .f = cmd_config_thresh_parsed,
    3701                 :            :         .data = NULL,
    3702                 :            :         .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
    3703                 :            :         .tokens = {
    3704                 :            :                 (void *)&cmd_config_thresh_port,
    3705                 :            :                 (void *)&cmd_config_thresh_keyword,
    3706                 :            :                 (void *)&cmd_config_thresh_all,
    3707                 :            :                 (void *)&cmd_config_thresh_name,
    3708                 :            :                 (void *)&cmd_config_thresh_value,
    3709                 :            :                 NULL,
    3710                 :            :         },
    3711                 :            : };
    3712                 :            : 
    3713                 :            : /* *** configure free/rs threshold *** */
    3714                 :            : struct cmd_config_threshold {
    3715                 :            :         cmdline_fixed_string_t port;
    3716                 :            :         cmdline_fixed_string_t keyword;
    3717                 :            :         cmdline_fixed_string_t all;
    3718                 :            :         cmdline_fixed_string_t name;
    3719                 :            :         uint16_t value;
    3720                 :            : };
    3721                 :            : 
    3722                 :            : static void
    3723                 :          0 : cmd_config_threshold_parsed(void *parsed_result,
    3724                 :            :                         __rte_unused struct cmdline *cl,
    3725                 :            :                         __rte_unused void *data)
    3726                 :            : {
    3727                 :            :         struct cmd_config_threshold *res = parsed_result;
    3728                 :            : 
    3729                 :          0 :         if (!all_ports_stopped()) {
    3730                 :          0 :                 fprintf(stderr, "Please stop all ports first\n");
    3731                 :          0 :                 return;
    3732                 :            :         }
    3733                 :            : 
    3734                 :          0 :         if (!strcmp(res->name, "txfreet"))
    3735                 :          0 :                 tx_free_thresh = res->value;
    3736                 :          0 :         else if (!strcmp(res->name, "txrst"))
    3737                 :          0 :                 tx_rs_thresh = res->value;
    3738                 :          0 :         else if (!strcmp(res->name, "rxfreet"))
    3739                 :          0 :                 rx_free_thresh = res->value;
    3740                 :            :         else {
    3741                 :          0 :                 fprintf(stderr, "Unknown parameter\n");
    3742                 :          0 :                 return;
    3743                 :            :         }
    3744                 :            : 
    3745                 :          0 :         init_port_config();
    3746                 :            : 
    3747                 :          0 :         cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
    3748                 :            : }
    3749                 :            : 
    3750                 :            : static cmdline_parse_token_string_t cmd_config_threshold_port =
    3751                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
    3752                 :            : static cmdline_parse_token_string_t cmd_config_threshold_keyword =
    3753                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
    3754                 :            :                                                                 "config");
    3755                 :            : static cmdline_parse_token_string_t cmd_config_threshold_all =
    3756                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
    3757                 :            : static cmdline_parse_token_string_t cmd_config_threshold_name =
    3758                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
    3759                 :            :                                                 "txfreet#txrst#rxfreet");
    3760                 :            : static cmdline_parse_token_num_t cmd_config_threshold_value =
    3761                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, RTE_UINT16);
    3762                 :            : 
    3763                 :            : static cmdline_parse_inst_t cmd_config_threshold = {
    3764                 :            :         .f = cmd_config_threshold_parsed,
    3765                 :            :         .data = NULL,
    3766                 :            :         .help_str = "port config all txfreet|txrst|rxfreet <value>",
    3767                 :            :         .tokens = {
    3768                 :            :                 (void *)&cmd_config_threshold_port,
    3769                 :            :                 (void *)&cmd_config_threshold_keyword,
    3770                 :            :                 (void *)&cmd_config_threshold_all,
    3771                 :            :                 (void *)&cmd_config_threshold_name,
    3772                 :            :                 (void *)&cmd_config_threshold_value,
    3773                 :            :                 NULL,
    3774                 :            :         },
    3775                 :            : };
    3776                 :            : 
    3777                 :            : /* *** stop *** */
    3778                 :            : struct cmd_stop_result {
    3779                 :            :         cmdline_fixed_string_t stop;
    3780                 :            : };
    3781                 :            : 
    3782                 :          0 : static void cmd_stop_parsed(__rte_unused void *parsed_result,
    3783                 :            :                             __rte_unused struct cmdline *cl,
    3784                 :            :                             __rte_unused void *data)
    3785                 :            : {
    3786                 :          0 :         stop_packet_forwarding();
    3787                 :          0 : }
    3788                 :            : 
    3789                 :            : static cmdline_parse_token_string_t cmd_stop_stop =
    3790                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
    3791                 :            : 
    3792                 :            : static cmdline_parse_inst_t cmd_stop = {
    3793                 :            :         .f = cmd_stop_parsed,
    3794                 :            :         .data = NULL,
    3795                 :            :         .help_str = "stop: Stop packet forwarding",
    3796                 :            :         .tokens = {
    3797                 :            :                 (void *)&cmd_stop_stop,
    3798                 :            :                 NULL,
    3799                 :            :         },
    3800                 :            : };
    3801                 :            : 
    3802                 :            : static unsigned int
    3803                 :          0 : get_ptype(char *value)
    3804                 :            : {
    3805                 :            :         uint32_t protocol;
    3806                 :            : 
    3807                 :          0 :         if (!strcmp(value, "eth"))
    3808                 :            :                 protocol = RTE_PTYPE_L2_ETHER;
    3809                 :          0 :         else if (!strcmp(value, "ipv4"))
    3810                 :            :                 protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN;
    3811                 :          0 :         else if (!strcmp(value, "ipv6"))
    3812                 :            :                 protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN;
    3813                 :          0 :         else if (!strcmp(value, "ipv4-tcp"))
    3814                 :            :                 protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_TCP;
    3815                 :          0 :         else if (!strcmp(value, "ipv4-udp"))
    3816                 :            :                 protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_UDP;
    3817                 :          0 :         else if (!strcmp(value, "ipv4-sctp"))
    3818                 :            :                 protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_SCTP;
    3819                 :          0 :         else if (!strcmp(value, "ipv6-tcp"))
    3820                 :            :                 protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_TCP;
    3821                 :          0 :         else if (!strcmp(value, "ipv6-udp"))
    3822                 :            :                 protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_UDP;
    3823                 :          0 :         else if (!strcmp(value, "ipv6-sctp"))
    3824                 :            :                 protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_SCTP;
    3825                 :          0 :         else if (!strcmp(value, "grenat"))
    3826                 :            :                 protocol = RTE_PTYPE_TUNNEL_GRENAT;
    3827                 :          0 :         else if (!strcmp(value, "inner-eth"))
    3828                 :            :                 protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER;
    3829                 :          0 :         else if (!strcmp(value, "inner-ipv4"))
    3830                 :            :                 protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
    3831                 :            :                                 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN;
    3832                 :          0 :         else if (!strcmp(value, "inner-ipv6"))
    3833                 :            :                 protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
    3834                 :            :                                 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN;
    3835                 :          0 :         else if (!strcmp(value, "inner-ipv4-tcp"))
    3836                 :            :                 protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
    3837                 :            :                                 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_TCP;
    3838                 :          0 :         else if (!strcmp(value, "inner-ipv4-udp"))
    3839                 :            :                 protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
    3840                 :            :                                 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_UDP;
    3841                 :          0 :         else if (!strcmp(value, "inner-ipv4-sctp"))
    3842                 :            :                 protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
    3843                 :            :                                 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_SCTP;
    3844                 :          0 :         else if (!strcmp(value, "inner-ipv6-tcp"))
    3845                 :            :                 protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
    3846                 :            :                                 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_TCP;
    3847                 :          0 :         else if (!strcmp(value, "inner-ipv6-udp"))
    3848                 :            :                 protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
    3849                 :            :                                 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_UDP;
    3850                 :          0 :         else if (!strcmp(value, "inner-ipv6-sctp"))
    3851                 :            :                 protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
    3852                 :            :                                 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_SCTP;
    3853                 :            :         else {
    3854                 :          0 :                 fprintf(stderr, "Unsupported protocol: %s\n", value);
    3855                 :            :                 protocol = RTE_PTYPE_UNKNOWN;
    3856                 :            :         }
    3857                 :            : 
    3858                 :          0 :         return protocol;
    3859                 :            : }
    3860                 :            : 
    3861                 :            : /* *** SET RXHDRSLIST *** */
    3862                 :            : 
    3863                 :            : unsigned int
    3864                 :          0 : parse_hdrs_list(const char *str, const char *item_name, unsigned int max_items,
    3865                 :            :                                 unsigned int *parsed_items)
    3866                 :            : {
    3867                 :            :         unsigned int nb_item;
    3868                 :            :         char *cur;
    3869                 :            :         char *tmp;
    3870                 :            : 
    3871                 :            :         nb_item = 0;
    3872                 :          0 :         char *str2 = strdup(str);
    3873                 :          0 :         if (str2 == NULL)
    3874                 :            :                 return nb_item;
    3875                 :          0 :         cur = strtok_r(str2, ",", &tmp);
    3876                 :          0 :         while (cur != NULL) {
    3877                 :          0 :                 parsed_items[nb_item] = get_ptype(cur);
    3878                 :          0 :                 cur = strtok_r(NULL, ",", &tmp);
    3879                 :          0 :                 nb_item++;
    3880                 :            :         }
    3881                 :          0 :         if (nb_item > max_items)
    3882                 :          0 :                 fprintf(stderr, "Number of %s = %u > %u (maximum items)\n",
    3883                 :            :                         item_name, nb_item + 1, max_items);
    3884                 :          0 :         free(str2);
    3885                 :          0 :         return nb_item;
    3886                 :            : }
    3887                 :            : 
    3888                 :            : /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
    3889                 :            : 
    3890                 :            : unsigned int
    3891                 :          0 : parse_item_list(const char *str, const char *item_name, unsigned int max_items,
    3892                 :            :                 unsigned int *parsed_items, int check_unique_values)
    3893                 :            : {
    3894                 :            :         unsigned int nb_item;
    3895                 :            :         unsigned int value;
    3896                 :            :         unsigned int i;
    3897                 :            :         unsigned int j;
    3898                 :            :         int value_ok;
    3899                 :            :         char c;
    3900                 :            : 
    3901                 :            :         /*
    3902                 :            :          * First parse all items in the list and store their value.
    3903                 :            :          */
    3904                 :            :         value = 0;
    3905                 :            :         nb_item = 0;
    3906                 :            :         value_ok = 0;
    3907                 :          0 :         for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
    3908                 :          0 :                 c = str[i];
    3909                 :          0 :                 if ((c >= '0') && (c <= '9')) {
    3910                 :          0 :                         value = (unsigned int) (value * 10 + (c - '0'));
    3911                 :            :                         value_ok = 1;
    3912                 :          0 :                         continue;
    3913                 :            :                 }
    3914                 :          0 :                 if (c != ',') {
    3915                 :          0 :                         fprintf(stderr, "character %c is not a decimal digit\n", c);
    3916                 :          0 :                         return 0;
    3917                 :            :                 }
    3918                 :          0 :                 if (! value_ok) {
    3919                 :          0 :                         fprintf(stderr, "No valid value before comma\n");
    3920                 :          0 :                         return 0;
    3921                 :            :                 }
    3922                 :          0 :                 if (nb_item < max_items) {
    3923                 :          0 :                         parsed_items[nb_item] = value;
    3924                 :            :                         value_ok = 0;
    3925                 :            :                         value = 0;
    3926                 :            :                 }
    3927                 :          0 :                 nb_item++;
    3928                 :            :         }
    3929                 :          0 :         if (nb_item >= max_items) {
    3930                 :          0 :                 fprintf(stderr, "Number of %s = %u > %u (maximum items)\n",
    3931                 :            :                         item_name, nb_item + 1, max_items);
    3932                 :          0 :                 return 0;
    3933                 :            :         }
    3934                 :          0 :         parsed_items[nb_item++] = value;
    3935                 :          0 :         if (! check_unique_values)
    3936                 :            :                 return nb_item;
    3937                 :            : 
    3938                 :            :         /*
    3939                 :            :          * Then, check that all values in the list are different.
    3940                 :            :          * No optimization here...
    3941                 :            :          */
    3942                 :          0 :         for (i = 0; i < nb_item; i++) {
    3943                 :          0 :                 for (j = i + 1; j < nb_item; j++) {
    3944                 :          0 :                         if (parsed_items[j] == parsed_items[i]) {
    3945                 :          0 :                                 fprintf(stderr,
    3946                 :            :                                         "duplicated %s %u at index %u and %u\n",
    3947                 :            :                                         item_name, parsed_items[i], i, j);
    3948                 :          0 :                                 return 0;
    3949                 :            :                         }
    3950                 :            :                 }
    3951                 :            :         }
    3952                 :            :         return nb_item;
    3953                 :            : }
    3954                 :            : 
    3955                 :            : struct cmd_set_list_result {
    3956                 :            :         cmdline_fixed_string_t cmd_keyword;
    3957                 :            :         cmdline_fixed_string_t list_name;
    3958                 :            :         cmdline_fixed_string_t list_of_items;
    3959                 :            : };
    3960                 :            : 
    3961                 :          0 : static void cmd_set_list_parsed(void *parsed_result,
    3962                 :            :                                 __rte_unused struct cmdline *cl,
    3963                 :            :                                 __rte_unused void *data)
    3964                 :            : {
    3965                 :            :         struct cmd_set_list_result *res;
    3966                 :            :         union {
    3967                 :            :                 unsigned int lcorelist[RTE_MAX_LCORE];
    3968                 :            :                 unsigned int portlist[RTE_MAX_ETHPORTS];
    3969                 :            :         } parsed_items;
    3970                 :            :         unsigned int nb_item;
    3971                 :            : 
    3972                 :          0 :         if (test_done == 0) {
    3973                 :          0 :                 fprintf(stderr, "Please stop forwarding first\n");
    3974                 :          0 :                 return;
    3975                 :            :         }
    3976                 :            : 
    3977                 :            :         res = parsed_result;
    3978                 :          0 :         if (!strcmp(res->list_name, "corelist")) {
    3979                 :          0 :                 nb_item = parse_item_list(res->list_of_items, "core",
    3980                 :            :                                           RTE_MAX_LCORE,
    3981                 :            :                                           parsed_items.lcorelist, 1);
    3982                 :          0 :                 if (nb_item > 0) {
    3983                 :          0 :                         set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
    3984                 :          0 :                         fwd_config_setup();
    3985                 :            :                 }
    3986                 :          0 :                 return;
    3987                 :            :         }
    3988                 :          0 :         if (!strcmp(res->list_name, "portlist")) {
    3989                 :          0 :                 nb_item = parse_item_list(res->list_of_items, "port",
    3990                 :            :                                           RTE_MAX_ETHPORTS,
    3991                 :            :                                           parsed_items.portlist, 1);
    3992                 :          0 :                 if (nb_item > 0) {
    3993                 :          0 :                         set_fwd_ports_list(parsed_items.portlist, nb_item);
    3994                 :          0 :                         fwd_config_setup();
    3995                 :            :                 }
    3996                 :            :         }
    3997                 :            : }
    3998                 :            : 
    3999                 :            : static cmdline_parse_token_string_t cmd_set_list_keyword =
    4000                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
    4001                 :            :                                  "set");
    4002                 :            : static cmdline_parse_token_string_t cmd_set_list_name =
    4003                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
    4004                 :            :                                  "corelist#portlist");
    4005                 :            : static cmdline_parse_token_string_t cmd_set_list_of_items =
    4006                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
    4007                 :            :                                  NULL);
    4008                 :            : 
    4009                 :            : static cmdline_parse_inst_t cmd_set_fwd_list = {
    4010                 :            :         .f = cmd_set_list_parsed,
    4011                 :            :         .data = NULL,
    4012                 :            :         .help_str = "set corelist|portlist <list0[,list1]*>",
    4013                 :            :         .tokens = {
    4014                 :            :                 (void *)&cmd_set_list_keyword,
    4015                 :            :                 (void *)&cmd_set_list_name,
    4016                 :            :                 (void *)&cmd_set_list_of_items,
    4017                 :            :                 NULL,
    4018                 :            :         },
    4019                 :            : };
    4020                 :            : 
    4021                 :            : /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
    4022                 :            : 
    4023                 :            : struct cmd_setmask_result {
    4024                 :            :         cmdline_fixed_string_t set;
    4025                 :            :         cmdline_fixed_string_t mask;
    4026                 :            :         uint64_t hexavalue;
    4027                 :            : };
    4028                 :            : 
    4029                 :          0 : static void cmd_set_mask_parsed(void *parsed_result,
    4030                 :            :                                 __rte_unused struct cmdline *cl,
    4031                 :            :                                 __rte_unused void *data)
    4032                 :            : {
    4033                 :            :         struct cmd_setmask_result *res = parsed_result;
    4034                 :            : 
    4035                 :          0 :         if (test_done == 0) {
    4036                 :          0 :                 fprintf(stderr, "Please stop forwarding first\n");
    4037                 :          0 :                 return;
    4038                 :            :         }
    4039                 :          0 :         if (!strcmp(res->mask, "coremask")) {
    4040                 :          0 :                 set_fwd_lcores_mask(res->hexavalue);
    4041                 :          0 :                 fwd_config_setup();
    4042                 :          0 :         } else if (!strcmp(res->mask, "portmask")) {
    4043                 :          0 :                 set_fwd_ports_mask(res->hexavalue);
    4044                 :          0 :                 fwd_config_setup();
    4045                 :            :         }
    4046                 :            : }
    4047                 :            : 
    4048                 :            : static cmdline_parse_token_string_t cmd_setmask_set =
    4049                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
    4050                 :            : static cmdline_parse_token_string_t cmd_setmask_mask =
    4051                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
    4052                 :            :                                  "coremask#portmask");
    4053                 :            : static cmdline_parse_token_num_t cmd_setmask_value =
    4054                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, RTE_UINT64);
    4055                 :            : 
    4056                 :            : static cmdline_parse_inst_t cmd_set_fwd_mask = {
    4057                 :            :         .f = cmd_set_mask_parsed,
    4058                 :            :         .data = NULL,
    4059                 :            :         .help_str = "set coremask|portmask <hexadecimal value>",
    4060                 :            :         .tokens = {
    4061                 :            :                 (void *)&cmd_setmask_set,
    4062                 :            :                 (void *)&cmd_setmask_mask,
    4063                 :            :                 (void *)&cmd_setmask_value,
    4064                 :            :                 NULL,
    4065                 :            :         },
    4066                 :            : };
    4067                 :            : 
    4068                 :            : /*
    4069                 :            :  * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
    4070                 :            :  */
    4071                 :            : struct cmd_set_result {
    4072                 :            :         cmdline_fixed_string_t set;
    4073                 :            :         cmdline_fixed_string_t what;
    4074                 :            :         uint16_t value;
    4075                 :            : };
    4076                 :            : 
    4077                 :          0 : static void cmd_set_parsed(void *parsed_result,
    4078                 :            :                            __rte_unused struct cmdline *cl,
    4079                 :            :                            __rte_unused void *data)
    4080                 :            : {
    4081                 :            :         struct cmd_set_result *res = parsed_result;
    4082                 :          0 :         if (!strcmp(res->what, "nbport")) {
    4083                 :          0 :                 set_fwd_ports_number(res->value);
    4084                 :          0 :                 fwd_config_setup();
    4085                 :          0 :         } else if (!strcmp(res->what, "nbcore")) {
    4086                 :          0 :                 set_fwd_lcores_number(res->value);
    4087                 :          0 :                 fwd_config_setup();
    4088                 :          0 :         } else if (!strcmp(res->what, "burst"))
    4089                 :          0 :                 set_nb_pkt_per_burst(res->value);
    4090                 :          0 :         else if (!strcmp(res->what, "verbose"))
    4091                 :          0 :                 set_verbose_level(res->value);
    4092                 :          0 : }
    4093                 :            : 
    4094                 :            : static cmdline_parse_token_string_t cmd_set_set =
    4095                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
    4096                 :            : static cmdline_parse_token_string_t cmd_set_what =
    4097                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
    4098                 :            :                                  "nbport#nbcore#burst#verbose");
    4099                 :            : static cmdline_parse_token_num_t cmd_set_value =
    4100                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, RTE_UINT16);
    4101                 :            : 
    4102                 :            : static cmdline_parse_inst_t cmd_set_numbers = {
    4103                 :            :         .f = cmd_set_parsed,
    4104                 :            :         .data = NULL,
    4105                 :            :         .help_str = "set nbport|nbcore|burst|verbose <value>",
    4106                 :            :         .tokens = {
    4107                 :            :                 (void *)&cmd_set_set,
    4108                 :            :                 (void *)&cmd_set_what,
    4109                 :            :                 (void *)&cmd_set_value,
    4110                 :            :                 NULL,
    4111                 :            :         },
    4112                 :            : };
    4113                 :            : 
    4114                 :            : /* *** SET LOG LEVEL CONFIGURATION *** */
    4115                 :            : 
    4116                 :            : struct cmd_set_log_result {
    4117                 :            :         cmdline_fixed_string_t set;
    4118                 :            :         cmdline_fixed_string_t log;
    4119                 :            :         cmdline_fixed_string_t type;
    4120                 :            :         uint32_t level;
    4121                 :            : };
    4122                 :            : 
    4123                 :            : static void
    4124                 :          0 : cmd_set_log_parsed(void *parsed_result,
    4125                 :            :                    __rte_unused struct cmdline *cl,
    4126                 :            :                    __rte_unused void *data)
    4127                 :            : {
    4128                 :            :         struct cmd_set_log_result *res;
    4129                 :            :         int ret;
    4130                 :            : 
    4131                 :            :         res = parsed_result;
    4132                 :          0 :         if (!strcmp(res->type, "global"))
    4133                 :          0 :                 rte_log_set_global_level(res->level);
    4134                 :            :         else {
    4135                 :          0 :                 ret = rte_log_set_level_regexp(res->type, res->level);
    4136                 :          0 :                 if (ret < 0)
    4137                 :          0 :                         fprintf(stderr, "Unable to set log level\n");
    4138                 :            :         }
    4139                 :          0 : }
    4140                 :            : 
    4141                 :            : static cmdline_parse_token_string_t cmd_set_log_set =
    4142                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
    4143                 :            : static cmdline_parse_token_string_t cmd_set_log_log =
    4144                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
    4145                 :            : static cmdline_parse_token_string_t cmd_set_log_type =
    4146                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
    4147                 :            : static cmdline_parse_token_num_t cmd_set_log_level =
    4148                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, RTE_UINT32);
    4149                 :            : 
    4150                 :            : static cmdline_parse_inst_t cmd_set_log = {
    4151                 :            :         .f = cmd_set_log_parsed,
    4152                 :            :         .data = NULL,
    4153                 :            :         .help_str = "set log global|<type> <level>",
    4154                 :            :         .tokens = {
    4155                 :            :                 (void *)&cmd_set_log_set,
    4156                 :            :                 (void *)&cmd_set_log_log,
    4157                 :            :                 (void *)&cmd_set_log_type,
    4158                 :            :                 (void *)&cmd_set_log_level,
    4159                 :            :                 NULL,
    4160                 :            :         },
    4161                 :            : };
    4162                 :            : 
    4163                 :            : /* *** SET SEGMENT OFFSETS OF RX PACKETS SPLIT *** */
    4164                 :            : 
    4165                 :            : struct cmd_set_rxoffs_result {
    4166                 :            :         cmdline_fixed_string_t cmd_keyword;
    4167                 :            :         cmdline_fixed_string_t rxoffs;
    4168                 :            :         cmdline_fixed_string_t seg_offsets;
    4169                 :            : };
    4170                 :            : 
    4171                 :            : static void
    4172                 :          0 : cmd_set_rxoffs_parsed(void *parsed_result,
    4173                 :            :                       __rte_unused struct cmdline *cl,
    4174                 :            :                       __rte_unused void *data)
    4175                 :            : {
    4176                 :            :         struct cmd_set_rxoffs_result *res;
    4177                 :            :         unsigned int seg_offsets[MAX_SEGS_BUFFER_SPLIT];
    4178                 :            :         unsigned int nb_segs;
    4179                 :            : 
    4180                 :            :         res = parsed_result;
    4181                 :          0 :         nb_segs = parse_item_list(res->seg_offsets, "segment offsets",
    4182                 :            :                                   MAX_SEGS_BUFFER_SPLIT, seg_offsets, 0);
    4183                 :          0 :         if (nb_segs > 0)
    4184                 :          0 :                 set_rx_pkt_offsets(seg_offsets, nb_segs);
    4185                 :          0 :         cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
    4186                 :          0 : }
    4187                 :            : 
    4188                 :            : static cmdline_parse_token_string_t cmd_set_rxoffs_keyword =
    4189                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
    4190                 :            :                                  cmd_keyword, "set");
    4191                 :            : static cmdline_parse_token_string_t cmd_set_rxoffs_name =
    4192                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
    4193                 :            :                                  rxoffs, "rxoffs");
    4194                 :            : static cmdline_parse_token_string_t cmd_set_rxoffs_offsets =
    4195                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
    4196                 :            :                                  seg_offsets, NULL);
    4197                 :            : 
    4198                 :            : static cmdline_parse_inst_t cmd_set_rxoffs = {
    4199                 :            :         .f = cmd_set_rxoffs_parsed,
    4200                 :            :         .data = NULL,
    4201                 :            :         .help_str = "set rxoffs <len0[,len1]*>",
    4202                 :            :         .tokens = {
    4203                 :            :                 (void *)&cmd_set_rxoffs_keyword,
    4204                 :            :                 (void *)&cmd_set_rxoffs_name,
    4205                 :            :                 (void *)&cmd_set_rxoffs_offsets,
    4206                 :            :                 NULL,
    4207                 :            :         },
    4208                 :            : };
    4209                 :            : 
    4210                 :            : /* *** SET SEGMENT LENGTHS OF RX PACKETS SPLIT *** */
    4211                 :            : 
    4212                 :            : struct cmd_set_rxpkts_result {
    4213                 :            :         cmdline_fixed_string_t cmd_keyword;
    4214                 :            :         cmdline_fixed_string_t rxpkts;
    4215                 :            :         cmdline_fixed_string_t seg_lengths;
    4216                 :            : };
    4217                 :            : 
    4218                 :            : static void
    4219                 :          0 : cmd_set_rxpkts_parsed(void *parsed_result,
    4220                 :            :                       __rte_unused struct cmdline *cl,
    4221                 :            :                       __rte_unused void *data)
    4222                 :            : {
    4223                 :            :         struct cmd_set_rxpkts_result *res;
    4224                 :            :         unsigned int seg_lengths[MAX_SEGS_BUFFER_SPLIT];
    4225                 :            :         unsigned int nb_segs;
    4226                 :            : 
    4227                 :            :         res = parsed_result;
    4228                 :          0 :         nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
    4229                 :            :                                   MAX_SEGS_BUFFER_SPLIT, seg_lengths, 0);
    4230                 :          0 :         if (nb_segs > 0)
    4231                 :          0 :                 set_rx_pkt_segments(seg_lengths, nb_segs);
    4232                 :          0 :         cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
    4233                 :          0 : }
    4234                 :            : 
    4235                 :            : static cmdline_parse_token_string_t cmd_set_rxpkts_keyword =
    4236                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
    4237                 :            :                                  cmd_keyword, "set");
    4238                 :            : static cmdline_parse_token_string_t cmd_set_rxpkts_name =
    4239                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
    4240                 :            :                                  rxpkts, "rxpkts");
    4241                 :            : static cmdline_parse_token_string_t cmd_set_rxpkts_lengths =
    4242                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
    4243                 :            :                                  seg_lengths, NULL);
    4244                 :            : 
    4245                 :            : static cmdline_parse_inst_t cmd_set_rxpkts = {
    4246                 :            :         .f = cmd_set_rxpkts_parsed,
    4247                 :            :         .data = NULL,
    4248                 :            :         .help_str = "set rxpkts <len0[,len1]*>",
    4249                 :            :         .tokens = {
    4250                 :            :                 (void *)&cmd_set_rxpkts_keyword,
    4251                 :            :                 (void *)&cmd_set_rxpkts_name,
    4252                 :            :                 (void *)&cmd_set_rxpkts_lengths,
    4253                 :            :                 NULL,
    4254                 :            :         },
    4255                 :            : };
    4256                 :            : 
    4257                 :            : /* *** SET SEGMENT HEADERS OF RX PACKETS SPLIT *** */
    4258                 :            : struct cmd_set_rxhdrs_result {
    4259                 :            :         cmdline_fixed_string_t set;
    4260                 :            :         cmdline_fixed_string_t rxhdrs;
    4261                 :            :         cmdline_fixed_string_t values;
    4262                 :            : };
    4263                 :            : 
    4264                 :            : static void
    4265                 :          0 : cmd_set_rxhdrs_parsed(void *parsed_result,
    4266                 :            :                       __rte_unused struct cmdline *cl,
    4267                 :            :                       __rte_unused void *data)
    4268                 :            : {
    4269                 :            :         struct cmd_set_rxhdrs_result *res;
    4270                 :            :         unsigned int seg_hdrs[MAX_SEGS_BUFFER_SPLIT];
    4271                 :            :         unsigned int nb_segs;
    4272                 :            : 
    4273                 :            :         res = parsed_result;
    4274                 :          0 :         nb_segs = parse_hdrs_list(res->values, "segment hdrs",
    4275                 :            :                                   MAX_SEGS_BUFFER_SPLIT, seg_hdrs);
    4276                 :          0 :         if (nb_segs > 0)
    4277                 :          0 :                 set_rx_pkt_hdrs(seg_hdrs, nb_segs);
    4278                 :          0 :         cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
    4279                 :          0 : }
    4280                 :            : 
    4281                 :            : static cmdline_parse_token_string_t cmd_set_rxhdrs_set =
    4282                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result,
    4283                 :            :                                 set, "set");
    4284                 :            : static cmdline_parse_token_string_t cmd_set_rxhdrs_rxhdrs =
    4285                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result,
    4286                 :            :                                 rxhdrs, "rxhdrs");
    4287                 :            : static cmdline_parse_token_string_t cmd_set_rxhdrs_values =
    4288                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result,
    4289                 :            :                                 values, NULL);
    4290                 :            : 
    4291                 :            : static cmdline_parse_inst_t cmd_set_rxhdrs = {
    4292                 :            :         .f = cmd_set_rxhdrs_parsed,
    4293                 :            :         .data = NULL,
    4294                 :            :         .help_str = "set rxhdrs <eth[,ipv4]*>",
    4295                 :            :         .tokens = {
    4296                 :            :                 (void *)&cmd_set_rxhdrs_set,
    4297                 :            :                 (void *)&cmd_set_rxhdrs_rxhdrs,
    4298                 :            :                 (void *)&cmd_set_rxhdrs_values,
    4299                 :            :                 NULL,
    4300                 :            :         },
    4301                 :            : };
    4302                 :            : 
    4303                 :            : /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
    4304                 :            : 
    4305                 :            : struct cmd_set_txpkts_result {
    4306                 :            :         cmdline_fixed_string_t cmd_keyword;
    4307                 :            :         cmdline_fixed_string_t txpkts;
    4308                 :            :         cmdline_fixed_string_t seg_lengths;
    4309                 :            : };
    4310                 :            : 
    4311                 :            : static void
    4312                 :          0 : cmd_set_txpkts_parsed(void *parsed_result,
    4313                 :            :                       __rte_unused struct cmdline *cl,
    4314                 :            :                       __rte_unused void *data)
    4315                 :            : {
    4316                 :            :         struct cmd_set_txpkts_result *res;
    4317                 :            :         unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
    4318                 :            :         unsigned int nb_segs;
    4319                 :            : 
    4320                 :            :         res = parsed_result;
    4321                 :          0 :         nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
    4322                 :            :                                   RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
    4323                 :          0 :         if (nb_segs > 0)
    4324                 :          0 :                 set_tx_pkt_segments(seg_lengths, nb_segs);
    4325                 :          0 : }
    4326                 :            : 
    4327                 :            : static cmdline_parse_token_string_t cmd_set_txpkts_keyword =
    4328                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
    4329                 :            :                                  cmd_keyword, "set");
    4330                 :            : static cmdline_parse_token_string_t cmd_set_txpkts_name =
    4331                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
    4332                 :            :                                  txpkts, "txpkts");
    4333                 :            : static cmdline_parse_token_string_t cmd_set_txpkts_lengths =
    4334                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
    4335                 :            :                                  seg_lengths, NULL);
    4336                 :            : 
    4337                 :            : static cmdline_parse_inst_t cmd_set_txpkts = {
    4338                 :            :         .f = cmd_set_txpkts_parsed,
    4339                 :            :         .data = NULL,
    4340                 :            :         .help_str = "set txpkts <len0[,len1]*>",
    4341                 :            :         .tokens = {
    4342                 :            :                 (void *)&cmd_set_txpkts_keyword,
    4343                 :            :                 (void *)&cmd_set_txpkts_name,
    4344                 :            :                 (void *)&cmd_set_txpkts_lengths,
    4345                 :            :                 NULL,
    4346                 :            :         },
    4347                 :            : };
    4348                 :            : 
    4349                 :            : /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
    4350                 :            : 
    4351                 :            : struct cmd_set_txsplit_result {
    4352                 :            :         cmdline_fixed_string_t cmd_keyword;
    4353                 :            :         cmdline_fixed_string_t txsplit;
    4354                 :            :         cmdline_fixed_string_t mode;
    4355                 :            : };
    4356                 :            : 
    4357                 :            : static void
    4358                 :          0 : cmd_set_txsplit_parsed(void *parsed_result,
    4359                 :            :                       __rte_unused struct cmdline *cl,
    4360                 :            :                       __rte_unused void *data)
    4361                 :            : {
    4362                 :            :         struct cmd_set_txsplit_result *res;
    4363                 :            : 
    4364                 :            :         res = parsed_result;
    4365                 :          0 :         set_tx_pkt_split(res->mode);
    4366                 :          0 : }
    4367                 :            : 
    4368                 :            : static cmdline_parse_token_string_t cmd_set_txsplit_keyword =
    4369                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
    4370                 :            :                                  cmd_keyword, "set");
    4371                 :            : static cmdline_parse_token_string_t cmd_set_txsplit_name =
    4372                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
    4373                 :            :                                  txsplit, "txsplit");
    4374                 :            : static cmdline_parse_token_string_t cmd_set_txsplit_mode =
    4375                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
    4376                 :            :                                  mode, NULL);
    4377                 :            : 
    4378                 :            : static cmdline_parse_inst_t cmd_set_txsplit = {
    4379                 :            :         .f = cmd_set_txsplit_parsed,
    4380                 :            :         .data = NULL,
    4381                 :            :         .help_str = "set txsplit on|off|rand",
    4382                 :            :         .tokens = {
    4383                 :            :                 (void *)&cmd_set_txsplit_keyword,
    4384                 :            :                 (void *)&cmd_set_txsplit_name,
    4385                 :            :                 (void *)&cmd_set_txsplit_mode,
    4386                 :            :                 NULL,
    4387                 :            :         },
    4388                 :            : };
    4389                 :            : 
    4390                 :            : /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */
    4391                 :            : 
    4392                 :            : struct cmd_set_txtimes_result {
    4393                 :            :         cmdline_fixed_string_t cmd_keyword;
    4394                 :            :         cmdline_fixed_string_t txtimes;
    4395                 :            :         cmdline_fixed_string_t tx_times;
    4396                 :            : };
    4397                 :            : 
    4398                 :            : static void
    4399                 :          0 : cmd_set_txtimes_parsed(void *parsed_result,
    4400                 :            :                        __rte_unused struct cmdline *cl,
    4401                 :            :                        __rte_unused void *data)
    4402                 :            : {
    4403                 :            :         struct cmd_set_txtimes_result *res;
    4404                 :          0 :         unsigned int tx_times[2] = {0, 0};
    4405                 :            :         unsigned int n_times;
    4406                 :            : 
    4407                 :            :         res = parsed_result;
    4408                 :          0 :         n_times = parse_item_list(res->tx_times, "tx times",
    4409                 :            :                                   2, tx_times, 0);
    4410                 :          0 :         if (n_times == 2)
    4411                 :          0 :                 set_tx_pkt_times(tx_times);
    4412                 :          0 : }
    4413                 :            : 
    4414                 :            : static cmdline_parse_token_string_t cmd_set_txtimes_keyword =
    4415                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
    4416                 :            :                                  cmd_keyword, "set");
    4417                 :            : static cmdline_parse_token_string_t cmd_set_txtimes_name =
    4418                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
    4419                 :            :                                  txtimes, "txtimes");
    4420                 :            : static cmdline_parse_token_string_t cmd_set_txtimes_value =
    4421                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
    4422                 :            :                                  tx_times, NULL);
    4423                 :            : 
    4424                 :            : static cmdline_parse_inst_t cmd_set_txtimes = {
    4425                 :            :         .f = cmd_set_txtimes_parsed,
    4426                 :            :         .data = NULL,
    4427                 :            :         .help_str = "set txtimes <inter_burst>,<intra_burst>",
    4428                 :            :         .tokens = {
    4429                 :            :                 (void *)&cmd_set_txtimes_keyword,
    4430                 :            :                 (void *)&cmd_set_txtimes_name,
    4431                 :            :                 (void *)&cmd_set_txtimes_value,
    4432                 :            :                 NULL,
    4433                 :            :         },
    4434                 :            : };
    4435                 :            : 
    4436                 :            : /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
    4437                 :            : struct cmd_rx_vlan_filter_all_result {
    4438                 :            :         cmdline_fixed_string_t rx_vlan;
    4439                 :            :         cmdline_fixed_string_t what;
    4440                 :            :         cmdline_fixed_string_t all;
    4441                 :            :         portid_t port_id;
    4442                 :            : };
    4443                 :            : 
    4444                 :            : static void
    4445                 :          0 : cmd_rx_vlan_filter_all_parsed(void *parsed_result,
    4446                 :            :                               __rte_unused struct cmdline *cl,
    4447                 :            :                               __rte_unused void *data)
    4448                 :            : {
    4449                 :            :         struct cmd_rx_vlan_filter_all_result *res = parsed_result;
    4450                 :            : 
    4451                 :          0 :         if (!strcmp(res->what, "add"))
    4452                 :          0 :                 rx_vlan_all_filter_set(res->port_id, 1);
    4453                 :            :         else
    4454                 :          0 :                 rx_vlan_all_filter_set(res->port_id, 0);
    4455                 :          0 : }
    4456                 :            : 
    4457                 :            : static cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
    4458                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
    4459                 :            :                                  rx_vlan, "rx_vlan");
    4460                 :            : static cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
    4461                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
    4462                 :            :                                  what, "add#rm");
    4463                 :            : static cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
    4464                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
    4465                 :            :                                  all, "all");
    4466                 :            : static cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
    4467                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
    4468                 :            :                               port_id, RTE_UINT16);
    4469                 :            : 
    4470                 :            : static cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
    4471                 :            :         .f = cmd_rx_vlan_filter_all_parsed,
    4472                 :            :         .data = NULL,
    4473                 :            :         .help_str = "rx_vlan add|rm all <port_id>: "
    4474                 :            :                 "Add/Remove all identifiers to/from the set of VLAN "
    4475                 :            :                 "identifiers filtered by a port",
    4476                 :            :         .tokens = {
    4477                 :            :                 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
    4478                 :            :                 (void *)&cmd_rx_vlan_filter_all_what,
    4479                 :            :                 (void *)&cmd_rx_vlan_filter_all_all,
    4480                 :            :                 (void *)&cmd_rx_vlan_filter_all_portid,
    4481                 :            :                 NULL,
    4482                 :            :         },
    4483                 :            : };
    4484                 :            : 
    4485                 :            : /* *** VLAN OFFLOAD SET ON A PORT *** */
    4486                 :            : struct cmd_vlan_offload_result {
    4487                 :            :         cmdline_fixed_string_t vlan;
    4488                 :            :         cmdline_fixed_string_t set;
    4489                 :            :         cmdline_fixed_string_t vlan_type;
    4490                 :            :         cmdline_fixed_string_t what;
    4491                 :            :         cmdline_fixed_string_t on;
    4492                 :            :         cmdline_fixed_string_t port_id;
    4493                 :            : };
    4494                 :            : 
    4495                 :            : static void
    4496                 :          0 : cmd_vlan_offload_parsed(void *parsed_result,
    4497                 :            :                           __rte_unused struct cmdline *cl,
    4498                 :            :                           __rte_unused void *data)
    4499                 :            : {
    4500                 :            :         int on;
    4501                 :            :         struct cmd_vlan_offload_result *res = parsed_result;
    4502                 :            :         char *str;
    4503                 :            :         int i, len = 0;
    4504                 :            :         portid_t port_id = 0;
    4505                 :            :         unsigned int tmp;
    4506                 :            : 
    4507                 :          0 :         str = res->port_id;
    4508                 :          0 :         len = strnlen(str, STR_TOKEN_SIZE);
    4509                 :            :         i = 0;
    4510                 :            :         /* Get port_id first */
    4511                 :          0 :         while(i < len){
    4512                 :          0 :                 if(str[i] == ',')
    4513                 :            :                         break;
    4514                 :            : 
    4515                 :          0 :                 i++;
    4516                 :            :         }
    4517                 :          0 :         str[i]='\0';
    4518                 :          0 :         tmp = strtoul(str, NULL, 0);
    4519                 :            :         /* If port_id greater that what portid_t can represent, return */
    4520                 :          0 :         if(tmp >= RTE_MAX_ETHPORTS)
    4521                 :            :                 return;
    4522                 :          0 :         port_id = (portid_t)tmp;
    4523                 :            : 
    4524                 :          0 :         if (!strcmp(res->on, "on"))
    4525                 :            :                 on = 1;
    4526                 :            :         else
    4527                 :            :                 on = 0;
    4528                 :            : 
    4529                 :          0 :         if (!strcmp(res->what, "strip"))
    4530                 :          0 :                 rx_vlan_strip_set(port_id,  on);
    4531                 :          0 :         else if(!strcmp(res->what, "stripq")){
    4532                 :            :                 uint16_t queue_id = 0;
    4533                 :            : 
    4534                 :            :                 /* No queue_id, return */
    4535                 :          0 :                 if(i + 1 >= len) {
    4536                 :          0 :                         fprintf(stderr, "must specify (port,queue_id)\n");
    4537                 :          0 :                         return;
    4538                 :            :                 }
    4539                 :          0 :                 tmp = strtoul(str + i + 1, NULL, 0);
    4540                 :            :                 /* If queue_id greater that what 16-bits can represent, return */
    4541                 :          0 :                 if(tmp > 0xffff)
    4542                 :            :                         return;
    4543                 :            : 
    4544                 :          0 :                 queue_id = (uint16_t)tmp;
    4545                 :          0 :                 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
    4546                 :            :         }
    4547                 :          0 :         else if (!strcmp(res->what, "filter"))
    4548                 :          0 :                 rx_vlan_filter_set(port_id, on);
    4549                 :          0 :         else if (!strcmp(res->what, "qinq_strip"))
    4550                 :          0 :                 rx_vlan_qinq_strip_set(port_id, on);
    4551                 :            :         else
    4552                 :          0 :                 vlan_extend_set(port_id, on);
    4553                 :            : 
    4554                 :            :         return;
    4555                 :            : }
    4556                 :            : 
    4557                 :            : static cmdline_parse_token_string_t cmd_vlan_offload_vlan =
    4558                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
    4559                 :            :                                  vlan, "vlan");
    4560                 :            : static cmdline_parse_token_string_t cmd_vlan_offload_set =
    4561                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
    4562                 :            :                                  set, "set");
    4563                 :            : static cmdline_parse_token_string_t cmd_vlan_offload_what =
    4564                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
    4565                 :            :                                 what, "strip#filter#qinq_strip#extend#stripq");
    4566                 :            : static cmdline_parse_token_string_t cmd_vlan_offload_on =
    4567                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
    4568                 :            :                               on, "on#off");
    4569                 :            : static cmdline_parse_token_string_t cmd_vlan_offload_portid =
    4570                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
    4571                 :            :                               port_id, NULL);
    4572                 :            : 
    4573                 :            : static cmdline_parse_inst_t cmd_vlan_offload = {
    4574                 :            :         .f = cmd_vlan_offload_parsed,
    4575                 :            :         .data = NULL,
    4576                 :            :         .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
    4577                 :            :                 "<port_id[,queue_id]>: "
    4578                 :            :                 "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
    4579                 :            :         .tokens = {
    4580                 :            :                 (void *)&cmd_vlan_offload_vlan,
    4581                 :            :                 (void *)&cmd_vlan_offload_set,
    4582                 :            :                 (void *)&cmd_vlan_offload_what,
    4583                 :            :                 (void *)&cmd_vlan_offload_on,
    4584                 :            :                 (void *)&cmd_vlan_offload_portid,
    4585                 :            :                 NULL,
    4586                 :            :         },
    4587                 :            : };
    4588                 :            : 
    4589                 :            : /* *** VLAN TPID SET ON A PORT *** */
    4590                 :            : struct cmd_vlan_tpid_result {
    4591                 :            :         cmdline_fixed_string_t vlan;
    4592                 :            :         cmdline_fixed_string_t set;
    4593                 :            :         cmdline_fixed_string_t vlan_type;
    4594                 :            :         cmdline_fixed_string_t what;
    4595                 :            :         uint16_t tp_id;
    4596                 :            :         portid_t port_id;
    4597                 :            : };
    4598                 :            : 
    4599                 :            : static void
    4600                 :          0 : cmd_vlan_tpid_parsed(void *parsed_result,
    4601                 :            :                           __rte_unused struct cmdline *cl,
    4602                 :            :                           __rte_unused void *data)
    4603                 :            : {
    4604                 :            :         struct cmd_vlan_tpid_result *res = parsed_result;
    4605                 :            :         enum rte_vlan_type vlan_type;
    4606                 :            : 
    4607                 :          0 :         if (!strcmp(res->vlan_type, "inner"))
    4608                 :            :                 vlan_type = RTE_ETH_VLAN_TYPE_INNER;
    4609                 :          0 :         else if (!strcmp(res->vlan_type, "outer"))
    4610                 :            :                 vlan_type = RTE_ETH_VLAN_TYPE_OUTER;
    4611                 :            :         else {
    4612                 :          0 :                 fprintf(stderr, "Unknown vlan type\n");
    4613                 :          0 :                 return;
    4614                 :            :         }
    4615                 :          0 :         vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
    4616                 :            : }
    4617                 :            : 
    4618                 :            : static cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
    4619                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
    4620                 :            :                                  vlan, "vlan");
    4621                 :            : static cmdline_parse_token_string_t cmd_vlan_tpid_set =
    4622                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
    4623                 :            :                                  set, "set");
    4624                 :            : static cmdline_parse_token_string_t cmd_vlan_type =
    4625                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
    4626                 :            :                                  vlan_type, "inner#outer");
    4627                 :            : static cmdline_parse_token_string_t cmd_vlan_tpid_what =
    4628                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
    4629                 :            :                                  what, "tpid");
    4630                 :            : static cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
    4631                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
    4632                 :            :                               tp_id, RTE_UINT16);
    4633                 :            : static cmdline_parse_token_num_t cmd_vlan_tpid_portid =
    4634                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
    4635                 :            :                               port_id, RTE_UINT16);
    4636                 :            : 
    4637                 :            : static cmdline_parse_inst_t cmd_vlan_tpid = {
    4638                 :            :         .f = cmd_vlan_tpid_parsed,
    4639                 :            :         .data = NULL,
    4640                 :            :         .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
    4641                 :            :                 "Set the VLAN Ether type",
    4642                 :            :         .tokens = {
    4643                 :            :                 (void *)&cmd_vlan_tpid_vlan,
    4644                 :            :                 (void *)&cmd_vlan_tpid_set,
    4645                 :            :                 (void *)&cmd_vlan_type,
    4646                 :            :                 (void *)&cmd_vlan_tpid_what,
    4647                 :            :                 (void *)&cmd_vlan_tpid_tpid,
    4648                 :            :                 (void *)&cmd_vlan_tpid_portid,
    4649                 :            :                 NULL,
    4650                 :            :         },
    4651                 :            : };
    4652                 :            : 
    4653                 :            : /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
    4654                 :            : struct cmd_rx_vlan_filter_result {
    4655                 :            :         cmdline_fixed_string_t rx_vlan;
    4656                 :            :         cmdline_fixed_string_t what;
    4657                 :            :         uint16_t vlan_id;
    4658                 :            :         portid_t port_id;
    4659                 :            : };
    4660                 :            : 
    4661                 :            : static void
    4662                 :          0 : cmd_rx_vlan_filter_parsed(void *parsed_result,
    4663                 :            :                           __rte_unused struct cmdline *cl,
    4664                 :            :                           __rte_unused void *data)
    4665                 :            : {
    4666                 :            :         struct cmd_rx_vlan_filter_result *res = parsed_result;
    4667                 :            : 
    4668                 :          0 :         if (!strcmp(res->what, "add"))
    4669                 :          0 :                 rx_vft_set(res->port_id, res->vlan_id, 1);
    4670                 :            :         else
    4671                 :          0 :                 rx_vft_set(res->port_id, res->vlan_id, 0);
    4672                 :          0 : }
    4673                 :            : 
    4674                 :            : static cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
    4675                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
    4676                 :            :                                  rx_vlan, "rx_vlan");
    4677                 :            : static cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
    4678                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
    4679                 :            :                                  what, "add#rm");
    4680                 :            : static cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
    4681                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
    4682                 :            :                               vlan_id, RTE_UINT16);
    4683                 :            : static cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
    4684                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
    4685                 :            :                               port_id, RTE_UINT16);
    4686                 :            : 
    4687                 :            : static cmdline_parse_inst_t cmd_rx_vlan_filter = {
    4688                 :            :         .f = cmd_rx_vlan_filter_parsed,
    4689                 :            :         .data = NULL,
    4690                 :            :         .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
    4691                 :            :                 "Add/Remove a VLAN identifier to/from the set of VLAN "
    4692                 :            :                 "identifiers filtered by a port",
    4693                 :            :         .tokens = {
    4694                 :            :                 (void *)&cmd_rx_vlan_filter_rx_vlan,
    4695                 :            :                 (void *)&cmd_rx_vlan_filter_what,
    4696                 :            :                 (void *)&cmd_rx_vlan_filter_vlanid,
    4697                 :            :                 (void *)&cmd_rx_vlan_filter_portid,
    4698                 :            :                 NULL,
    4699                 :            :         },
    4700                 :            : };
    4701                 :            : 
    4702                 :            : /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
    4703                 :            : struct cmd_tx_vlan_set_result {
    4704                 :            :         cmdline_fixed_string_t tx_vlan;
    4705                 :            :         cmdline_fixed_string_t set;
    4706                 :            :         portid_t port_id;
    4707                 :            :         uint16_t vlan_id;
    4708                 :            : };
    4709                 :            : 
    4710                 :            : static void
    4711                 :          0 : cmd_tx_vlan_set_parsed(void *parsed_result,
    4712                 :            :                        __rte_unused struct cmdline *cl,
    4713                 :            :                        __rte_unused void *data)
    4714                 :            : {
    4715                 :            :         struct cmd_tx_vlan_set_result *res = parsed_result;
    4716                 :            : 
    4717                 :          0 :         if (port_id_is_invalid(res->port_id, ENABLED_WARN))
    4718                 :            :                 return;
    4719                 :            : 
    4720                 :          0 :         if (!port_is_stopped(res->port_id)) {
    4721                 :          0 :                 fprintf(stderr, "Please stop port %d first\n", res->port_id);
    4722                 :          0 :                 return;
    4723                 :            :         }
    4724                 :            : 
    4725                 :          0 :         tx_vlan_set(res->port_id, res->vlan_id);
    4726                 :            : 
    4727                 :          0 :         cmd_reconfig_device_queue(res->port_id, 1, 1);
    4728                 :            : }
    4729                 :            : 
    4730                 :            : static cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
    4731                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
    4732                 :            :                                  tx_vlan, "tx_vlan");
    4733                 :            : static cmdline_parse_token_string_t cmd_tx_vlan_set_set =
    4734                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
    4735                 :            :                                  set, "set");
    4736                 :            : static cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
    4737                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
    4738                 :            :                               port_id, RTE_UINT16);
    4739                 :            : static cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
    4740                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
    4741                 :            :                               vlan_id, RTE_UINT16);
    4742                 :            : 
    4743                 :            : static cmdline_parse_inst_t cmd_tx_vlan_set = {
    4744                 :            :         .f = cmd_tx_vlan_set_parsed,
    4745                 :            :         .data = NULL,
    4746                 :            :         .help_str = "tx_vlan set <port_id> <vlan_id>: "
    4747                 :            :                 "Enable hardware insertion of a single VLAN header "
    4748                 :            :                 "with a given TAG Identifier in packets sent on a port",
    4749                 :            :         .tokens = {
    4750                 :            :                 (void *)&cmd_tx_vlan_set_tx_vlan,
    4751                 :            :                 (void *)&cmd_tx_vlan_set_set,
    4752                 :            :                 (void *)&cmd_tx_vlan_set_portid,
    4753                 :            :                 (void *)&cmd_tx_vlan_set_vlanid,
    4754                 :            :                 NULL,
    4755                 :            :         },
    4756                 :            : };
    4757                 :            : 
    4758                 :            : /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
    4759                 :            : struct cmd_tx_vlan_set_qinq_result {
    4760                 :            :         cmdline_fixed_string_t tx_vlan;
    4761                 :            :         cmdline_fixed_string_t set;
    4762                 :            :         portid_t port_id;
    4763                 :            :         uint16_t vlan_id;
    4764                 :            :         uint16_t vlan_id_outer;
    4765                 :            : };
    4766                 :            : 
    4767                 :            : static void
    4768                 :          0 : cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
    4769                 :            :                             __rte_unused struct cmdline *cl,
    4770                 :            :                             __rte_unused void *data)
    4771                 :            : {
    4772                 :            :         struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
    4773                 :            : 
    4774                 :          0 :         if (port_id_is_invalid(res->port_id, ENABLED_WARN))
    4775                 :            :                 return;
    4776                 :            : 
    4777                 :          0 :         if (!port_is_stopped(res->port_id)) {
    4778                 :          0 :                 fprintf(stderr, "Please stop port %d first\n", res->port_id);
    4779                 :          0 :                 return;
    4780                 :            :         }
    4781                 :            : 
    4782                 :          0 :         tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
    4783                 :            : 
    4784                 :          0 :         cmd_reconfig_device_queue(res->port_id, 1, 1);
    4785                 :            : }
    4786                 :            : 
    4787                 :            : static cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
    4788                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
    4789                 :            :                 tx_vlan, "tx_vlan");
    4790                 :            : static cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
    4791                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
    4792                 :            :                 set, "set");
    4793                 :            : static cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
    4794                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
    4795                 :            :                 port_id, RTE_UINT16);
    4796                 :            : static cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
    4797                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
    4798                 :            :                 vlan_id, RTE_UINT16);
    4799                 :            : static cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
    4800                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
    4801                 :            :                 vlan_id_outer, RTE_UINT16);
    4802                 :            : 
    4803                 :            : static cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
    4804                 :            :         .f = cmd_tx_vlan_set_qinq_parsed,
    4805                 :            :         .data = NULL,
    4806                 :            :         .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
    4807                 :            :                 "Enable hardware insertion of double VLAN header "
    4808                 :            :                 "with given TAG Identifiers in packets sent on a port",
    4809                 :            :         .tokens = {
    4810                 :            :                 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
    4811                 :            :                 (void *)&cmd_tx_vlan_set_qinq_set,
    4812                 :            :                 (void *)&cmd_tx_vlan_set_qinq_portid,
    4813                 :            :                 (void *)&cmd_tx_vlan_set_qinq_vlanid,
    4814                 :            :                 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
    4815                 :            :                 NULL,
    4816                 :            :         },
    4817                 :            : };
    4818                 :            : 
    4819                 :            : /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
    4820                 :            : struct cmd_tx_vlan_set_pvid_result {
    4821                 :            :         cmdline_fixed_string_t tx_vlan;
    4822                 :            :         cmdline_fixed_string_t set;
    4823                 :            :         cmdline_fixed_string_t pvid;
    4824                 :            :         portid_t port_id;
    4825                 :            :         uint16_t vlan_id;
    4826                 :            :         cmdline_fixed_string_t mode;
    4827                 :            : };
    4828                 :            : 
    4829                 :            : static void
    4830                 :          0 : cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
    4831                 :            :                             __rte_unused struct cmdline *cl,
    4832                 :            :                             __rte_unused void *data)
    4833                 :            : {
    4834                 :            :         struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
    4835                 :            : 
    4836                 :          0 :         if (strcmp(res->mode, "on") == 0)
    4837                 :          0 :                 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
    4838                 :            :         else
    4839                 :          0 :                 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
    4840                 :          0 : }
    4841                 :            : 
    4842                 :            : static cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
    4843                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
    4844                 :            :                                  tx_vlan, "tx_vlan");
    4845                 :            : static cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
    4846                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
    4847                 :            :                                  set, "set");
    4848                 :            : static cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
    4849                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
    4850                 :            :                                  pvid, "pvid");
    4851                 :            : static cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
    4852                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
    4853                 :            :                              port_id, RTE_UINT16);
    4854                 :            : static cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
    4855                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
    4856                 :            :                               vlan_id, RTE_UINT16);
    4857                 :            : static cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
    4858                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
    4859                 :            :                                  mode, "on#off");
    4860                 :            : 
    4861                 :            : static cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
    4862                 :            :         .f = cmd_tx_vlan_set_pvid_parsed,
    4863                 :            :         .data = NULL,
    4864                 :            :         .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
    4865                 :            :         .tokens = {
    4866                 :            :                 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
    4867                 :            :                 (void *)&cmd_tx_vlan_set_pvid_set,
    4868                 :            :                 (void *)&cmd_tx_vlan_set_pvid_pvid,
    4869                 :            :                 (void *)&cmd_tx_vlan_set_pvid_port_id,
    4870                 :            :                 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
    4871                 :            :                 (void *)&cmd_tx_vlan_set_pvid_mode,
    4872                 :            :                 NULL,
    4873                 :            :         },
    4874                 :            : };
    4875                 :            : 
    4876                 :            : /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
    4877                 :            : struct cmd_tx_vlan_reset_result {
    4878                 :            :         cmdline_fixed_string_t tx_vlan;
    4879                 :            :         cmdline_fixed_string_t reset;
    4880                 :            :         portid_t port_id;
    4881                 :            : };
    4882                 :            : 
    4883                 :            : static void
    4884                 :          0 : cmd_tx_vlan_reset_parsed(void *parsed_result,
    4885                 :            :                          __rte_unused struct cmdline *cl,
    4886                 :            :                          __rte_unused void *data)
    4887                 :            : {
    4888                 :            :         struct cmd_tx_vlan_reset_result *res = parsed_result;
    4889                 :            : 
    4890                 :          0 :         if (port_id_is_invalid(res->port_id, ENABLED_WARN))
    4891                 :            :                 return;
    4892                 :            : 
    4893                 :          0 :         if (!port_is_stopped(res->port_id)) {
    4894                 :          0 :                 fprintf(stderr, "Please stop port %d first\n", res->port_id);
    4895                 :          0 :                 return;
    4896                 :            :         }
    4897                 :            : 
    4898                 :          0 :         tx_vlan_reset(res->port_id);
    4899                 :            : 
    4900                 :          0 :         cmd_reconfig_device_queue(res->port_id, 1, 1);
    4901                 :            : }
    4902                 :            : 
    4903                 :            : static cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
    4904                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
    4905                 :            :                                  tx_vlan, "tx_vlan");
    4906                 :            : static cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
    4907                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
    4908                 :            :                                  reset, "reset");
    4909                 :            : static cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
    4910                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
    4911                 :            :                               port_id, RTE_UINT16);
    4912                 :            : 
    4913                 :            : static cmdline_parse_inst_t cmd_tx_vlan_reset = {
    4914                 :            :         .f = cmd_tx_vlan_reset_parsed,
    4915                 :            :         .data = NULL,
    4916                 :            :         .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
    4917                 :            :                 "VLAN header in packets sent on a port",
    4918                 :            :         .tokens = {
    4919                 :            :                 (void *)&cmd_tx_vlan_reset_tx_vlan,
    4920                 :            :                 (void *)&cmd_tx_vlan_reset_reset,
    4921                 :            :                 (void *)&cmd_tx_vlan_reset_portid,
    4922                 :            :                 NULL,
    4923                 :            :         },
    4924                 :            : };
    4925                 :            : 
    4926                 :            : 
    4927                 :            : /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
    4928                 :            : struct cmd_csum_result {
    4929                 :            :         cmdline_fixed_string_t csum;
    4930                 :            :         cmdline_fixed_string_t mode;
    4931                 :            :         cmdline_fixed_string_t proto;
    4932                 :            :         cmdline_fixed_string_t hwsw;
    4933                 :            :         portid_t port_id;
    4934                 :            : };
    4935                 :            : 
    4936                 :            : static void
    4937                 :          0 : csum_show(int port_id)
    4938                 :            : {
    4939                 :            :         struct rte_eth_dev_info dev_info;
    4940                 :            :         uint64_t tx_offloads;
    4941                 :            :         int ret;
    4942                 :            : 
    4943                 :          0 :         tx_offloads = ports[port_id].dev_conf.txmode.offloads;
    4944                 :          0 :         printf("Parse tunnel is %s\n",
    4945                 :          0 :                 (ports[port_id].parse_tunnel) ? "on" : "off");
    4946                 :          0 :         printf("IP checksum offload is %s\n",
    4947                 :          0 :                 (tx_offloads & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
    4948                 :          0 :         printf("UDP checksum offload is %s\n",
    4949                 :          0 :                 (tx_offloads & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
    4950                 :          0 :         printf("TCP checksum offload is %s\n",
    4951                 :          0 :                 (tx_offloads & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
    4952                 :          0 :         printf("SCTP checksum offload is %s\n",
    4953                 :          0 :                 (tx_offloads & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
    4954                 :          0 :         printf("Outer-Ip checksum offload is %s\n",
    4955                 :          0 :                 (tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
    4956                 :          0 :         printf("Outer-Udp checksum offload is %s\n",
    4957                 :          0 :                 (tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
    4958                 :            : 
    4959                 :            :         /* display warnings if configuration is not supported by the NIC */
    4960                 :          0 :         ret = eth_dev_info_get_print_err(port_id, &dev_info);
    4961                 :          0 :         if (ret != 0)
    4962                 :          0 :                 return;
    4963                 :            : 
    4964                 :          0 :         if ((tx_offloads & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) &&
    4965                 :          0 :                 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) == 0) {
    4966                 :          0 :                 fprintf(stderr,
    4967                 :            :                         "Warning: hardware IP checksum enabled but not supported by port %d\n",
    4968                 :            :                         port_id);
    4969                 :            :         }
    4970                 :          0 :         if ((tx_offloads & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) &&
    4971                 :          0 :                 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) == 0) {
    4972                 :          0 :                 fprintf(stderr,
    4973                 :            :                         "Warning: hardware UDP checksum enabled but not supported by port %d\n",
    4974                 :            :                         port_id);
    4975                 :            :         }
    4976                 :          0 :         if ((tx_offloads & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) &&
    4977                 :          0 :                 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) == 0) {
    4978                 :          0 :                 fprintf(stderr,
    4979                 :            :                         "Warning: hardware TCP checksum enabled but not supported by port %d\n",
    4980                 :            :                         port_id);
    4981                 :            :         }
    4982                 :          0 :         if ((tx_offloads & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) &&
    4983                 :          0 :                 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) == 0) {
    4984                 :          0 :                 fprintf(stderr,
    4985                 :            :                         "Warning: hardware SCTP checksum enabled but not supported by port %d\n",
    4986                 :            :                         port_id);
    4987                 :            :         }
    4988                 :          0 :         if ((tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
    4989                 :          0 :                 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
    4990                 :          0 :                 fprintf(stderr,
    4991                 :            :                         "Warning: hardware outer IP checksum enabled but not supported by port %d\n",
    4992                 :            :                         port_id);
    4993                 :            :         }
    4994                 :          0 :         if ((tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
    4995                 :          0 :                 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM)
    4996                 :            :                         == 0) {
    4997                 :          0 :                 fprintf(stderr,
    4998                 :            :                         "Warning: hardware outer UDP checksum enabled but not supported by port %d\n",
    4999                 :            :                         port_id);
    5000                 :            :         }
    5001                 :            : }
    5002                 :            : 
    5003                 :            : static void
    5004                 :            : cmd_config_queue_tx_offloads(struct rte_port *port)
    5005                 :            : {
    5006                 :            :         int k;
    5007                 :            : 
    5008                 :            :         /* Apply queue tx offloads configuration */
    5009                 :          0 :         for (k = 0; k < port->dev_info.max_tx_queues; k++)
    5010                 :          0 :                 port->txq[k].conf.offloads =
    5011                 :          0 :                         port->dev_conf.txmode.offloads;
    5012                 :            : }
    5013                 :            : 
    5014                 :            : static void
    5015                 :          0 : cmd_csum_parsed(void *parsed_result,
    5016                 :            :                        __rte_unused struct cmdline *cl,
    5017                 :            :                        __rte_unused void *data)
    5018                 :            : {
    5019                 :            :         struct cmd_csum_result *res = parsed_result;
    5020                 :            :         int hw = 0;
    5021                 :            :         uint64_t csum_offloads = 0;
    5022                 :            :         struct rte_eth_dev_info dev_info;
    5023                 :            :         int ret;
    5024                 :            : 
    5025                 :          0 :         if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
    5026                 :          0 :                 fprintf(stderr, "invalid port %d\n", res->port_id);
    5027                 :          0 :                 return;
    5028                 :            :         }
    5029                 :          0 :         if (!port_is_stopped(res->port_id)) {
    5030                 :          0 :                 fprintf(stderr, "Please stop port %d first\n", res->port_id);
    5031                 :          0 :                 return;
    5032                 :            :         }
    5033                 :            : 
    5034                 :          0 :         ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
    5035                 :          0 :         if (ret != 0)
    5036                 :            :                 return;
    5037                 :            : 
    5038                 :          0 :         if (!strcmp(res->mode, "set")) {
    5039                 :            : 
    5040                 :          0 :                 if (!strcmp(res->hwsw, "hw"))
    5041                 :            :                         hw = 1;
    5042                 :            : 
    5043                 :          0 :                 if (!strcmp(res->proto, "ip")) {
    5044                 :          0 :                         if (hw == 0 || (dev_info.tx_offload_capa &
    5045                 :            :                                                 RTE_ETH_TX_OFFLOAD_IPV4_CKSUM)) {
    5046                 :            :                                 csum_offloads |= RTE_ETH_TX_OFFLOAD_IPV4_CKSUM;
    5047                 :            :                         } else {
    5048                 :          0 :                                 fprintf(stderr,
    5049                 :            :                                         "IP checksum offload is not supported by port %u\n",
    5050                 :          0 :                                         res->port_id);
    5051                 :            :                         }
    5052                 :          0 :                 } else if (!strcmp(res->proto, "udp")) {
    5053                 :          0 :                         if (hw == 0 || (dev_info.tx_offload_capa &
    5054                 :            :                                                 RTE_ETH_TX_OFFLOAD_UDP_CKSUM)) {
    5055                 :            :                                 csum_offloads |= RTE_ETH_TX_OFFLOAD_UDP_CKSUM;
    5056                 :            :                         } else {
    5057                 :          0 :                                 fprintf(stderr,
    5058                 :            :                                         "UDP checksum offload is not supported by port %u\n",
    5059                 :          0 :                                         res->port_id);
    5060                 :            :                         }
    5061                 :          0 :                 } else if (!strcmp(res->proto, "tcp")) {
    5062                 :          0 :                         if (hw == 0 || (dev_info.tx_offload_capa &
    5063                 :            :                                                 RTE_ETH_TX_OFFLOAD_TCP_CKSUM)) {
    5064                 :            :                                 csum_offloads |= RTE_ETH_TX_OFFLOAD_TCP_CKSUM;
    5065                 :            :                         } else {
    5066                 :          0 :                                 fprintf(stderr,
    5067                 :            :                                         "TCP checksum offload is not supported by port %u\n",
    5068                 :          0 :                                         res->port_id);
    5069                 :            :                         }
    5070                 :          0 :                 } else if (!strcmp(res->proto, "sctp")) {
    5071                 :          0 :                         if (hw == 0 || (dev_info.tx_offload_capa &
    5072                 :            :                                                 RTE_ETH_TX_OFFLOAD_SCTP_CKSUM)) {
    5073                 :            :                                 csum_offloads |= RTE_ETH_TX_OFFLOAD_SCTP_CKSUM;
    5074                 :            :                         } else {
    5075                 :          0 :                                 fprintf(stderr,
    5076                 :            :                                         "SCTP checksum offload is not supported by port %u\n",
    5077                 :          0 :                                         res->port_id);
    5078                 :            :                         }
    5079                 :          0 :                 } else if (!strcmp(res->proto, "outer-ip")) {
    5080                 :          0 :                         if (hw == 0 || (dev_info.tx_offload_capa &
    5081                 :            :                                         RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
    5082                 :            :                                 csum_offloads |=
    5083                 :            :                                                 RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM;
    5084                 :            :                         } else {
    5085                 :          0 :                                 fprintf(stderr,
    5086                 :            :                                         "Outer IP checksum offload is not supported by port %u\n",
    5087                 :          0 :                                         res->port_id);
    5088                 :            :                         }
    5089                 :          0 :                 } else if (!strcmp(res->proto, "outer-udp")) {
    5090                 :          0 :                         if (hw == 0 || (dev_info.tx_offload_capa &
    5091                 :            :                                         RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
    5092                 :            :                                 csum_offloads |=
    5093                 :            :                                                 RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM;
    5094                 :            :                         } else {
    5095                 :          0 :                                 fprintf(stderr,
    5096                 :            :                                         "Outer UDP checksum offload is not supported by port %u\n",
    5097                 :          0 :                                         res->port_id);
    5098                 :            :                         }
    5099                 :            :                 }
    5100                 :            : 
    5101                 :          0 :                 if (hw) {
    5102                 :          0 :                         ports[res->port_id].dev_conf.txmode.offloads |=
    5103                 :            :                                                         csum_offloads;
    5104                 :            :                 } else {
    5105                 :          0 :                         ports[res->port_id].dev_conf.txmode.offloads &=
    5106                 :          0 :                                                         (~csum_offloads);
    5107                 :            :                 }
    5108                 :          0 :                 cmd_config_queue_tx_offloads(&ports[res->port_id]);
    5109                 :            :         }
    5110                 :          0 :         csum_show(res->port_id);
    5111                 :            : 
    5112                 :          0 :         cmd_reconfig_device_queue(res->port_id, 1, 1);
    5113                 :            : }
    5114                 :            : 
    5115                 :            : static cmdline_parse_token_string_t cmd_csum_csum =
    5116                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
    5117                 :            :                                 csum, "csum");
    5118                 :            : static cmdline_parse_token_string_t cmd_csum_mode =
    5119                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
    5120                 :            :                                 mode, "set");
    5121                 :            : static cmdline_parse_token_string_t cmd_csum_proto =
    5122                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
    5123                 :            :                                 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
    5124                 :            : static cmdline_parse_token_string_t cmd_csum_hwsw =
    5125                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
    5126                 :            :                                 hwsw, "hw#sw");
    5127                 :            : static cmdline_parse_token_num_t cmd_csum_portid =
    5128                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
    5129                 :            :                                 port_id, RTE_UINT16);
    5130                 :            : 
    5131                 :            : static cmdline_parse_inst_t cmd_csum_set = {
    5132                 :            :         .f = cmd_csum_parsed,
    5133                 :            :         .data = NULL,
    5134                 :            :         .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
    5135                 :            :                 "Enable/Disable hardware calculation of L3/L4 checksum when "
    5136                 :            :                 "using csum forward engine",
    5137                 :            :         .tokens = {
    5138                 :            :                 (void *)&cmd_csum_csum,
    5139                 :            :                 (void *)&cmd_csum_mode,
    5140                 :            :                 (void *)&cmd_csum_proto,
    5141                 :            :                 (void *)&cmd_csum_hwsw,
    5142                 :            :                 (void *)&cmd_csum_portid,
    5143                 :            :                 NULL,
    5144                 :            :         },
    5145                 :            : };
    5146                 :            : 
    5147                 :            : static cmdline_parse_token_string_t cmd_csum_mode_show =
    5148                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
    5149                 :            :                                 mode, "show");
    5150                 :            : 
    5151                 :            : static cmdline_parse_inst_t cmd_csum_show = {
    5152                 :            :         .f = cmd_csum_parsed,
    5153                 :            :         .data = NULL,
    5154                 :            :         .help_str = "csum show <port_id>: Show checksum offload configuration",
    5155                 :            :         .tokens = {
    5156                 :            :                 (void *)&cmd_csum_csum,
    5157                 :            :                 (void *)&cmd_csum_mode_show,
    5158                 :            :                 (void *)&cmd_csum_portid,
    5159                 :            :                 NULL,
    5160                 :            :         },
    5161                 :            : };
    5162                 :            : 
    5163                 :            : /* Enable/disable tunnel parsing */
    5164                 :            : struct cmd_csum_tunnel_result {
    5165                 :            :         cmdline_fixed_string_t csum;
    5166                 :            :         cmdline_fixed_string_t parse;
    5167                 :            :         cmdline_fixed_string_t onoff;
    5168                 :            :         portid_t port_id;
    5169                 :            : };
    5170                 :            : 
    5171                 :            : static void
    5172                 :          0 : cmd_csum_tunnel_parsed(void *parsed_result,
    5173                 :            :                        __rte_unused struct cmdline *cl,
    5174                 :            :                        __rte_unused void *data)
    5175                 :            : {
    5176                 :            :         struct cmd_csum_tunnel_result *res = parsed_result;
    5177                 :            : 
    5178                 :          0 :         if (port_id_is_invalid(res->port_id, ENABLED_WARN))
    5179                 :            :                 return;
    5180                 :            : 
    5181                 :          0 :         if (!strcmp(res->onoff, "on"))
    5182                 :          0 :                 ports[res->port_id].parse_tunnel = 1;
    5183                 :            :         else
    5184                 :          0 :                 ports[res->port_id].parse_tunnel = 0;
    5185                 :            : 
    5186                 :          0 :         csum_show(res->port_id);
    5187                 :            : }
    5188                 :            : 
    5189                 :            : static cmdline_parse_token_string_t cmd_csum_tunnel_csum =
    5190                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
    5191                 :            :                                 csum, "csum");
    5192                 :            : static cmdline_parse_token_string_t cmd_csum_tunnel_parse =
    5193                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
    5194                 :            :                                 parse, "parse-tunnel");
    5195                 :            : static cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
    5196                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
    5197                 :            :                                 onoff, "on#off");
    5198                 :            : static cmdline_parse_token_num_t cmd_csum_tunnel_portid =
    5199                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
    5200                 :            :                                 port_id, RTE_UINT16);
    5201                 :            : 
    5202                 :            : static cmdline_parse_inst_t cmd_csum_tunnel = {
    5203                 :            :         .f = cmd_csum_tunnel_parsed,
    5204                 :            :         .data = NULL,
    5205                 :            :         .help_str = "csum parse-tunnel on|off <port_id>: "
    5206                 :            :                 "Enable/Disable parsing of tunnels for csum engine",
    5207                 :            :         .tokens = {
    5208                 :            :                 (void *)&cmd_csum_tunnel_csum,
    5209                 :            :                 (void *)&cmd_csum_tunnel_parse,
    5210                 :            :                 (void *)&cmd_csum_tunnel_onoff,
    5211                 :            :                 (void *)&cmd_csum_tunnel_portid,
    5212                 :            :                 NULL,
    5213                 :            :         },
    5214                 :            : };
    5215                 :            : 
    5216                 :            : struct cmd_csum_mac_swap_result {
    5217                 :            :         cmdline_fixed_string_t csum;
    5218                 :            :         cmdline_fixed_string_t parse;
    5219                 :            :         cmdline_fixed_string_t onoff;
    5220                 :            :         portid_t port_id;
    5221                 :            : };
    5222                 :            : 
    5223                 :            : static void
    5224                 :          0 : cmd_csum_mac_swap_parsed(void *parsed_result,
    5225                 :            :                        __rte_unused struct cmdline *cl,
    5226                 :            :                        __rte_unused void *data)
    5227                 :            : {
    5228                 :            :         struct cmd_csum_mac_swap_result *res = parsed_result;
    5229                 :            : 
    5230                 :          0 :         if (port_id_is_invalid(res->port_id, ENABLED_WARN))
    5231                 :            :                 return;
    5232                 :          0 :         if (strcmp(res->onoff, "on") == 0)
    5233                 :          0 :                 ports[res->port_id].fwd_mac_swap = 1;
    5234                 :            :         else
    5235                 :          0 :                 ports[res->port_id].fwd_mac_swap = 0;
    5236                 :            : }
    5237                 :            : 
    5238                 :            : static cmdline_parse_token_string_t cmd_csum_mac_swap_csum =
    5239                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_csum_mac_swap_result,
    5240                 :            :                                  csum, "csum");
    5241                 :            : static cmdline_parse_token_string_t cmd_csum_mac_swap_parse =
    5242                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_csum_mac_swap_result,
    5243                 :            :                                  parse, "mac-swap");
    5244                 :            : static cmdline_parse_token_string_t cmd_csum_mac_swap_onoff =
    5245                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_csum_mac_swap_result,
    5246                 :            :                                  onoff, "on#off");
    5247                 :            : static cmdline_parse_token_num_t cmd_csum_mac_swap_portid =
    5248                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_csum_mac_swap_result,
    5249                 :            :                               port_id, RTE_UINT16);
    5250                 :            : 
    5251                 :            : static cmdline_parse_inst_t cmd_csum_mac_swap = {
    5252                 :            :         .f = cmd_csum_mac_swap_parsed,
    5253                 :            :         .data = NULL,
    5254                 :            :         .help_str = "csum mac-swap on|off <port_id>: "
    5255                 :            :                     "Enable/Disable forward mac address swap",
    5256                 :            :         .tokens = {
    5257                 :            :                 (void *)&cmd_csum_mac_swap_csum,
    5258                 :            :                 (void *)&cmd_csum_mac_swap_parse,
    5259                 :            :                 (void *)&cmd_csum_mac_swap_onoff,
    5260                 :            :                 (void *)&cmd_csum_mac_swap_portid,
    5261                 :            :                 NULL,
    5262                 :            :         },
    5263                 :            : };
    5264                 :            : 
    5265                 :            : /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
    5266                 :            : struct cmd_tso_set_result {
    5267                 :            :         cmdline_fixed_string_t tso;
    5268                 :            :         cmdline_fixed_string_t mode;
    5269                 :            :         uint16_t tso_segsz;
    5270                 :            :         portid_t port_id;
    5271                 :            : };
    5272                 :            : 
    5273                 :            : static void
    5274                 :          0 : cmd_tso_set_parsed(void *parsed_result,
    5275                 :            :                        __rte_unused struct cmdline *cl,
    5276                 :            :                        __rte_unused void *data)
    5277                 :            : {
    5278                 :            :         struct cmd_tso_set_result *res = parsed_result;
    5279                 :            :         struct rte_eth_dev_info dev_info;
    5280                 :            :         uint64_t offloads;
    5281                 :            :         int ret;
    5282                 :            : 
    5283                 :          0 :         if (port_id_is_invalid(res->port_id, ENABLED_WARN))
    5284                 :          0 :                 return;
    5285                 :          0 :         if (!port_is_stopped(res->port_id)) {
    5286                 :          0 :                 fprintf(stderr, "Please stop port %d first\n", res->port_id);
    5287                 :          0 :                 return;
    5288                 :            :         }
    5289                 :            : 
    5290                 :          0 :         if (!strcmp(res->mode, "set"))
    5291                 :          0 :                 ports[res->port_id].tso_segsz = res->tso_segsz;
    5292                 :            : 
    5293                 :          0 :         ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
    5294                 :          0 :         if (ret != 0)
    5295                 :            :                 return;
    5296                 :            : 
    5297                 :          0 :         if (ports[res->port_id].tso_segsz != 0) {
    5298                 :          0 :                 if ((dev_info.tx_offload_capa & (RTE_ETH_TX_OFFLOAD_TCP_TSO |
    5299                 :            :                                 RTE_ETH_TX_OFFLOAD_UDP_TSO)) == 0) {
    5300                 :          0 :                         fprintf(stderr, "Error: both TSO and UFO are not supported by port %d\n",
    5301                 :            :                                 res->port_id);
    5302                 :          0 :                         return;
    5303                 :            :                 }
    5304                 :            :                 /* display warnings if configuration is not supported by the NIC */
    5305                 :          0 :                 if ((dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_TSO) == 0)
    5306                 :          0 :                         printf("Warning: port %d doesn't support TSO\n", res->port_id);
    5307                 :          0 :                 if ((dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_TSO) == 0)
    5308                 :          0 :                         printf("Warning: port %d doesn't support UFO\n", res->port_id);
    5309                 :            :         }
    5310                 :            : 
    5311                 :          0 :         if (ports[res->port_id].tso_segsz == 0) {
    5312                 :          0 :                 ports[res->port_id].dev_conf.txmode.offloads &=
    5313                 :            :                         ~(RTE_ETH_TX_OFFLOAD_TCP_TSO | RTE_ETH_TX_OFFLOAD_UDP_TSO);
    5314                 :            :                 printf("TSO and UFO for non-tunneled packets is disabled\n");
    5315                 :            :         } else {
    5316                 :          0 :                 offloads = (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_TSO) ?
    5317                 :            :                                         RTE_ETH_TX_OFFLOAD_TCP_TSO : 0;
    5318                 :          0 :                 offloads |= (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_TSO) ?
    5319                 :          0 :                                         RTE_ETH_TX_OFFLOAD_UDP_TSO : 0;
    5320                 :          0 :                 ports[res->port_id].dev_conf.txmode.offloads |= offloads;
    5321                 :          0 :                 printf("segment size for non-tunneled packets is %d\n",
    5322                 :            :                         ports[res->port_id].tso_segsz);
    5323                 :            :         }
    5324                 :          0 :         cmd_config_queue_tx_offloads(&ports[res->port_id]);
    5325                 :          0 :         cmd_reconfig_device_queue(res->port_id, 1, 1);
    5326                 :            : }
    5327                 :            : 
    5328                 :            : static cmdline_parse_token_string_t cmd_tso_set_tso =
    5329                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
    5330                 :            :                                 tso, "tso");
    5331                 :            : static cmdline_parse_token_string_t cmd_tso_set_mode =
    5332                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
    5333                 :            :                                 mode, "set");
    5334                 :            : static cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
    5335                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
    5336                 :            :                                 tso_segsz, RTE_UINT16);
    5337                 :            : static cmdline_parse_token_num_t cmd_tso_set_portid =
    5338                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
    5339                 :            :                                 port_id, RTE_UINT16);
    5340                 :            : 
    5341                 :            : static cmdline_parse_inst_t cmd_tso_set = {
    5342                 :            :         .f = cmd_tso_set_parsed,
    5343                 :            :         .data = NULL,
    5344                 :            :         .help_str = "tso set <tso_segsz> <port_id>: "
    5345                 :            :                 "Set TSO segment size of non-tunneled packets for csum engine "
    5346                 :            :                 "(0 to disable)",
    5347                 :            :         .tokens = {
    5348                 :            :                 (void *)&cmd_tso_set_tso,
    5349                 :            :                 (void *)&cmd_tso_set_mode,
    5350                 :            :                 (void *)&cmd_tso_set_tso_segsz,
    5351                 :            :                 (void *)&cmd_tso_set_portid,
    5352                 :            :                 NULL,
    5353                 :            :         },
    5354                 :            : };
    5355                 :            : 
    5356                 :            : static cmdline_parse_token_string_t cmd_tso_show_mode =
    5357                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
    5358                 :            :                                 mode, "show");
    5359                 :            : 
    5360                 :            : 
    5361                 :            : static cmdline_parse_inst_t cmd_tso_show = {
    5362                 :            :         .f = cmd_tso_set_parsed,
    5363                 :            :         .data = NULL,
    5364                 :            :         .help_str = "tso show <port_id>: "
    5365                 :            :                 "Show TSO segment size of non-tunneled packets for csum engine",
    5366                 :            :         .tokens = {
    5367                 :            :                 (void *)&cmd_tso_set_tso,
    5368                 :            :                 (void *)&cmd_tso_show_mode,
    5369                 :            :                 (void *)&cmd_tso_set_portid,
    5370                 :            :                 NULL,
    5371                 :            :         },
    5372                 :            : };
    5373                 :            : 
    5374                 :            : /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
    5375                 :            : struct cmd_tunnel_tso_set_result {
    5376                 :            :         cmdline_fixed_string_t tso;
    5377                 :            :         cmdline_fixed_string_t mode;
    5378                 :            :         uint16_t tso_segsz;
    5379                 :            :         portid_t port_id;
    5380                 :            : };
    5381                 :            : 
    5382                 :            : static void
    5383                 :          0 : check_tunnel_tso_nic_support(portid_t port_id, uint64_t tx_offload_capa)
    5384                 :            : {
    5385                 :          0 :         if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO))
    5386                 :          0 :                 printf("Warning: VXLAN TUNNEL TSO not supported therefore not enabled for port %d\n",
    5387                 :            :                         port_id);
    5388                 :          0 :         if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO))
    5389                 :          0 :                 printf("Warning: GRE TUNNEL TSO not supported therefore not enabled for port %d\n",
    5390                 :            :                         port_id);
    5391                 :          0 :         if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO))
    5392                 :          0 :                 printf("Warning: IPIP TUNNEL TSO not supported therefore not enabled for port %d\n",
    5393                 :            :                         port_id);
    5394                 :          0 :         if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO))
    5395                 :          0 :                 printf("Warning: GENEVE TUNNEL TSO not supported therefore not enabled for port %d\n",
    5396                 :            :                         port_id);
    5397                 :          0 :         if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_IP_TNL_TSO))
    5398                 :          0 :                 printf("Warning: IP TUNNEL TSO not supported therefore not enabled for port %d\n",
    5399                 :            :                         port_id);
    5400                 :          0 :         if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO))
    5401                 :          0 :                 printf("Warning: UDP TUNNEL TSO not supported therefore not enabled for port %d\n",
    5402                 :            :                         port_id);
    5403                 :          0 : }
    5404                 :            : 
    5405                 :            : static void
    5406                 :          0 : cmd_tunnel_tso_set_parsed(void *parsed_result,
    5407                 :            :                           __rte_unused struct cmdline *cl,
    5408                 :            :                           __rte_unused void *data)
    5409                 :            : {
    5410                 :            :         struct cmd_tunnel_tso_set_result *res = parsed_result;
    5411                 :            :         struct rte_eth_dev_info dev_info;
    5412                 :            :         uint64_t all_tunnel_tso = RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO |
    5413                 :            :                                 RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO |
    5414                 :            :                                 RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO |
    5415                 :            :                                 RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO |
    5416                 :            :                                 RTE_ETH_TX_OFFLOAD_IP_TNL_TSO |
    5417                 :            :                                 RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO;
    5418                 :            :         int ret;
    5419                 :            : 
    5420                 :          0 :         if (port_id_is_invalid(res->port_id, ENABLED_WARN))
    5421                 :          0 :                 return;
    5422                 :          0 :         if (!port_is_stopped(res->port_id)) {
    5423                 :          0 :                 fprintf(stderr, "Please stop port %d first\n", res->port_id);
    5424                 :          0 :                 return;
    5425                 :            :         }
    5426                 :            : 
    5427                 :          0 :         if (!strcmp(res->mode, "set"))
    5428                 :          0 :                 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
    5429                 :            : 
    5430                 :          0 :         if (ports[res->port_id].tunnel_tso_segsz == 0) {
    5431                 :          0 :                 ports[res->port_id].dev_conf.txmode.offloads &= ~all_tunnel_tso;
    5432                 :            :                 printf("TSO for tunneled packets is disabled\n");
    5433                 :            :         } else {
    5434                 :          0 :                 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
    5435                 :          0 :                 if (ret != 0)
    5436                 :            :                         return;
    5437                 :            : 
    5438                 :          0 :                 if ((all_tunnel_tso & dev_info.tx_offload_capa) == 0) {
    5439                 :          0 :                         fprintf(stderr, "Error: port=%u don't support tunnel TSO offloads.\n",
    5440                 :          0 :                                 res->port_id);
    5441                 :          0 :                         return;
    5442                 :            :                 }
    5443                 :            : 
    5444                 :            :                 /* Below conditions are needed to make it work:
    5445                 :            :                  * (1) tunnel TSO is supported by the NIC;
    5446                 :            :                  * (2) "csum parse_tunnel" must be set so that tunneled pkts
    5447                 :            :                  * are recognized;
    5448                 :            :                  * (3) for tunneled pkts with outer L3 of IPv4,
    5449                 :            :                  * "csum set outer-ip" must be set to hw, because after tso,
    5450                 :            :                  * total_len of outer IP header is changed, and the checksum
    5451                 :            :                  * of outer IP header calculated by sw should be wrong; that
    5452                 :            :                  * is not necessary for IPv6 tunneled pkts because there's no
    5453                 :            :                  * checksum in IP header anymore.
    5454                 :            :                  */
    5455                 :          0 :                 if (!ports[res->port_id].parse_tunnel) {
    5456                 :          0 :                         fprintf(stderr,
    5457                 :            :                                 "Error: csum parse_tunnel must be set so that tunneled packets are recognized\n");
    5458                 :          0 :                         return;
    5459                 :            :                 }
    5460                 :          0 :                 if (!(ports[res->port_id].dev_conf.txmode.offloads &
    5461                 :            :                       RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
    5462                 :          0 :                         fprintf(stderr,
    5463                 :            :                                 "Error: csum set outer-ip must be set to hw if outer L3 is IPv4; not necessary for IPv6\n");
    5464                 :          0 :                         return;
    5465                 :            :                 }
    5466                 :            : 
    5467                 :          0 :                 check_tunnel_tso_nic_support(res->port_id, dev_info.tx_offload_capa);
    5468                 :          0 :                 ports[res->port_id].dev_conf.txmode.offloads |=
    5469                 :          0 :                                 (all_tunnel_tso & dev_info.tx_offload_capa);
    5470                 :          0 :                 printf("TSO segment size for tunneled packets is %d\n",
    5471                 :          0 :                         ports[res->port_id].tunnel_tso_segsz);
    5472                 :            :         }
    5473                 :            : 
    5474                 :          0 :         cmd_config_queue_tx_offloads(&ports[res->port_id]);
    5475                 :          0 :         cmd_reconfig_device_queue(res->port_id, 1, 1);
    5476                 :            : }
    5477                 :            : 
    5478                 :            : static cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
    5479                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
    5480                 :            :                                 tso, "tunnel_tso");
    5481                 :            : static cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
    5482                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
    5483                 :            :                                 mode, "set");
    5484                 :            : static cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
    5485                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
    5486                 :            :                                 tso_segsz, RTE_UINT16);
    5487                 :            : static cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
    5488                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
    5489                 :            :                                 port_id, RTE_UINT16);
    5490                 :            : 
    5491                 :            : static cmdline_parse_inst_t cmd_tunnel_tso_set = {
    5492                 :            :         .f = cmd_tunnel_tso_set_parsed,
    5493                 :            :         .data = NULL,
    5494                 :            :         .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
    5495                 :            :                 "Set TSO segment size of tunneled packets for csum engine "
    5496                 :            :                 "(0 to disable)",
    5497                 :            :         .tokens = {
    5498                 :            :                 (void *)&cmd_tunnel_tso_set_tso,
    5499                 :            :                 (void *)&cmd_tunnel_tso_set_mode,
    5500                 :            :                 (void *)&cmd_tunnel_tso_set_tso_segsz,
    5501                 :            :                 (void *)&cmd_tunnel_tso_set_portid,
    5502                 :            :                 NULL,
    5503                 :            :         },
    5504                 :            : };
    5505                 :            : 
    5506                 :            : static cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
    5507                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
    5508                 :            :                                 mode, "show");
    5509                 :            : 
    5510                 :            : 
    5511                 :            : static cmdline_parse_inst_t cmd_tunnel_tso_show = {
    5512                 :            :         .f = cmd_tunnel_tso_set_parsed,
    5513                 :            :         .data = NULL,
    5514                 :            :         .help_str = "tunnel_tso show <port_id> "
    5515                 :            :                 "Show TSO segment size of tunneled packets for csum engine",
    5516                 :            :         .tokens = {
    5517                 :            :                 (void *)&cmd_tunnel_tso_set_tso,
    5518                 :            :                 (void *)&cmd_tunnel_tso_show_mode,
    5519                 :            :                 (void *)&cmd_tunnel_tso_set_portid,
    5520                 :            :                 NULL,
    5521                 :            :         },
    5522                 :            : };
    5523                 :            : 
    5524                 :            : #ifdef RTE_LIB_GRO
    5525                 :            : /* *** SET GRO FOR A PORT *** */
    5526                 :            : struct cmd_gro_enable_result {
    5527                 :            :         cmdline_fixed_string_t cmd_set;
    5528                 :            :         cmdline_fixed_string_t cmd_port;
    5529                 :            :         cmdline_fixed_string_t cmd_keyword;
    5530                 :            :         cmdline_fixed_string_t cmd_onoff;
    5531                 :            :         portid_t cmd_pid;
    5532                 :            : };
    5533                 :            : 
    5534                 :            : static void
    5535                 :          0 : cmd_gro_enable_parsed(void *parsed_result,
    5536                 :            :                 __rte_unused struct cmdline *cl,
    5537                 :            :                 __rte_unused void *data)
    5538                 :            : {
    5539                 :            :         struct cmd_gro_enable_result *res;
    5540                 :            : 
    5541                 :            :         res = parsed_result;
    5542                 :          0 :         if (!strcmp(res->cmd_keyword, "gro"))
    5543                 :          0 :                 setup_gro(res->cmd_onoff, res->cmd_pid);
    5544                 :          0 : }
    5545                 :            : 
    5546                 :            : static cmdline_parse_token_string_t cmd_gro_enable_set =
    5547                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
    5548                 :            :                         cmd_set, "set");
    5549                 :            : static cmdline_parse_token_string_t cmd_gro_enable_port =
    5550                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
    5551                 :            :                         cmd_keyword, "port");
    5552                 :            : static cmdline_parse_token_num_t cmd_gro_enable_pid =
    5553                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
    5554                 :            :                         cmd_pid, RTE_UINT16);
    5555                 :            : static cmdline_parse_token_string_t cmd_gro_enable_keyword =
    5556                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
    5557                 :            :                         cmd_keyword, "gro");
    5558                 :            : static cmdline_parse_token_string_t cmd_gro_enable_onoff =
    5559                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
    5560                 :            :                         cmd_onoff, "on#off");
    5561                 :            : 
    5562                 :            : static cmdline_parse_inst_t cmd_gro_enable = {
    5563                 :            :         .f = cmd_gro_enable_parsed,
    5564                 :            :         .data = NULL,
    5565                 :            :         .help_str = "set port <port_id> gro on|off",
    5566                 :            :         .tokens = {
    5567                 :            :                 (void *)&cmd_gro_enable_set,
    5568                 :            :                 (void *)&cmd_gro_enable_port,
    5569                 :            :                 (void *)&cmd_gro_enable_pid,
    5570                 :            :                 (void *)&cmd_gro_enable_keyword,
    5571                 :            :                 (void *)&cmd_gro_enable_onoff,
    5572                 :            :                 NULL,
    5573                 :            :         },
    5574                 :            : };
    5575                 :            : 
    5576                 :            : /* *** DISPLAY GRO CONFIGURATION *** */
    5577                 :            : struct cmd_gro_show_result {
    5578                 :            :         cmdline_fixed_string_t cmd_show;
    5579                 :            :         cmdline_fixed_string_t cmd_port;
    5580                 :            :         cmdline_fixed_string_t cmd_keyword;
    5581                 :            :         portid_t cmd_pid;
    5582                 :            : };
    5583                 :            : 
    5584                 :            : static void
    5585                 :          0 : cmd_gro_show_parsed(void *parsed_result,
    5586                 :            :                 __rte_unused struct cmdline *cl,
    5587                 :            :                 __rte_unused void *data)
    5588                 :            : {
    5589                 :            :         struct cmd_gro_show_result *res;
    5590                 :            : 
    5591                 :            :         res = parsed_result;
    5592                 :          0 :         if (!strcmp(res->cmd_keyword, "gro"))
    5593                 :          0 :                 show_gro(res->cmd_pid);
    5594                 :          0 : }
    5595                 :            : 
    5596                 :            : static cmdline_parse_token_string_t cmd_gro_show_show =
    5597                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
    5598                 :            :                         cmd_show, "show");
    5599                 :            : static cmdline_parse_token_string_t cmd_gro_show_port =
    5600                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
    5601                 :            :                         cmd_port, "port");
    5602                 :            : static cmdline_parse_token_num_t cmd_gro_show_pid =
    5603                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
    5604                 :            :                         cmd_pid, RTE_UINT16);
    5605                 :            : static cmdline_parse_token_string_t cmd_gro_show_keyword =
    5606                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
    5607                 :            :                         cmd_keyword, "gro");
    5608                 :            : 
    5609                 :            : static cmdline_parse_inst_t cmd_gro_show = {
    5610                 :            :         .f = cmd_gro_show_parsed,
    5611                 :            :         .data = NULL,
    5612                 :            :         .help_str = "show port <port_id> gro",
    5613                 :            :         .tokens = {
    5614                 :            :                 (void *)&cmd_gro_show_show,
    5615                 :            :                 (void *)&cmd_gro_show_port,
    5616                 :            :                 (void *)&cmd_gro_show_pid,
    5617                 :            :                 (void *)&cmd_gro_show_keyword,
    5618                 :            :                 NULL,
    5619                 :            :         },
    5620                 :            : };
    5621                 :            : 
    5622                 :            : /* *** SET FLUSH CYCLES FOR GRO *** */
    5623                 :            : struct cmd_gro_flush_result {
    5624                 :            :         cmdline_fixed_string_t cmd_set;
    5625                 :            :         cmdline_fixed_string_t cmd_keyword;
    5626                 :            :         cmdline_fixed_string_t cmd_flush;
    5627                 :            :         uint8_t cmd_cycles;
    5628                 :            : };
    5629                 :            : 
    5630                 :            : static void
    5631                 :          0 : cmd_gro_flush_parsed(void *parsed_result,
    5632                 :            :                 __rte_unused struct cmdline *cl,
    5633                 :            :                 __rte_unused void *data)
    5634                 :            : {
    5635                 :            :         struct cmd_gro_flush_result *res;
    5636                 :            : 
    5637                 :            :         res = parsed_result;
    5638                 :          0 :         if ((!strcmp(res->cmd_keyword, "gro")) &&
    5639                 :          0 :                         (!strcmp(res->cmd_flush, "flush")))
    5640                 :          0 :                 setup_gro_flush_cycles(res->cmd_cycles);
    5641                 :          0 : }
    5642                 :            : 
    5643                 :            : static cmdline_parse_token_string_t cmd_gro_flush_set =
    5644                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
    5645                 :            :                         cmd_set, "set");
    5646                 :            : static cmdline_parse_token_string_t cmd_gro_flush_keyword =
    5647                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
    5648                 :            :                         cmd_keyword, "gro");
    5649                 :            : static cmdline_parse_token_string_t cmd_gro_flush_flush =
    5650                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
    5651                 :            :                         cmd_flush, "flush");
    5652                 :            : static cmdline_parse_token_num_t cmd_gro_flush_cycles =
    5653                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
    5654                 :            :                         cmd_cycles, RTE_UINT8);
    5655                 :            : 
    5656                 :            : static cmdline_parse_inst_t cmd_gro_flush = {
    5657                 :            :         .f = cmd_gro_flush_parsed,
    5658                 :            :         .data = NULL,
    5659                 :            :         .help_str = "set gro flush <cycles>",
    5660                 :            :         .tokens = {
    5661                 :            :                 (void *)&cmd_gro_flush_set,
    5662                 :            :                 (void *)&cmd_gro_flush_keyword,
    5663                 :            :                 (void *)&cmd_gro_flush_flush,
    5664                 :            :                 (void *)&cmd_gro_flush_cycles,
    5665                 :            :                 NULL,
    5666                 :            :         },
    5667                 :            : };
    5668                 :            : #endif /* RTE_LIB_GRO */
    5669                 :            : 
    5670                 :            : #ifdef RTE_LIB_GSO
    5671                 :            : /* *** ENABLE/DISABLE GSO *** */
    5672                 :            : struct cmd_gso_enable_result {
    5673                 :            :         cmdline_fixed_string_t cmd_set;
    5674                 :            :         cmdline_fixed_string_t cmd_port;
    5675                 :            :         cmdline_fixed_string_t cmd_keyword;
    5676                 :            :         cmdline_fixed_string_t cmd_mode;
    5677                 :            :         portid_t cmd_pid;
    5678                 :            : };
    5679                 :            : 
    5680                 :            : static void
    5681                 :          0 : cmd_gso_enable_parsed(void *parsed_result,
    5682                 :            :                 __rte_unused struct cmdline *cl,
    5683                 :            :                 __rte_unused void *data)
    5684                 :            : {
    5685                 :            :         struct cmd_gso_enable_result *res;
    5686                 :            : 
    5687                 :            :         res = parsed_result;
    5688                 :          0 :         if (!strcmp(res->cmd_keyword, "gso"))
    5689                 :          0 :                 setup_gso(res->cmd_mode, res->cmd_pid);
    5690                 :          0 : }
    5691                 :            : 
    5692                 :            : static cmdline_parse_token_string_t cmd_gso_enable_set =
    5693                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
    5694                 :            :                         cmd_set, "set");
    5695                 :            : static cmdline_parse_token_string_t cmd_gso_enable_port =
    5696                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
    5697                 :            :                         cmd_port, "port");
    5698                 :            : static cmdline_parse_token_string_t cmd_gso_enable_keyword =
    5699                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
    5700                 :            :                         cmd_keyword, "gso");
    5701                 :            : static cmdline_parse_token_string_t cmd_gso_enable_mode =
    5702                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
    5703                 :            :                         cmd_mode, "on#off");
    5704                 :            : static cmdline_parse_token_num_t cmd_gso_enable_pid =
    5705                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
    5706                 :            :                         cmd_pid, RTE_UINT16);
    5707                 :            : 
    5708                 :            : static cmdline_parse_inst_t cmd_gso_enable = {
    5709                 :            :         .f = cmd_gso_enable_parsed,
    5710                 :            :         .data = NULL,
    5711                 :            :         .help_str = "set port <port_id> gso on|off",
    5712                 :            :         .tokens = {
    5713                 :            :                 (void *)&cmd_gso_enable_set,
    5714                 :            :                 (void *)&cmd_gso_enable_port,
    5715                 :            :                 (void *)&cmd_gso_enable_pid,
    5716                 :            :                 (void *)&cmd_gso_enable_keyword,
    5717                 :            :                 (void *)&cmd_gso_enable_mode,
    5718                 :            :                 NULL,
    5719                 :            :         },
    5720                 :            : };
    5721                 :            : 
    5722                 :            : /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
    5723                 :            : struct cmd_gso_size_result {
    5724                 :            :         cmdline_fixed_string_t cmd_set;
    5725                 :            :         cmdline_fixed_string_t cmd_keyword;
    5726                 :            :         cmdline_fixed_string_t cmd_segsz;
    5727                 :            :         uint16_t cmd_size;
    5728                 :            : };
    5729                 :            : 
    5730                 :            : static void
    5731                 :          0 : cmd_gso_size_parsed(void *parsed_result,
    5732                 :            :                        __rte_unused struct cmdline *cl,
    5733                 :            :                        __rte_unused void *data)
    5734                 :            : {
    5735                 :            :         struct cmd_gso_size_result *res = parsed_result;
    5736                 :            : 
    5737                 :          0 :         if (test_done == 0) {
    5738                 :          0 :                 fprintf(stderr,
    5739                 :            :                         "Before setting GSO segsz, please first stop forwarding\n");
    5740                 :          0 :                 return;
    5741                 :            :         }
    5742                 :            : 
    5743                 :          0 :         if (!strcmp(res->cmd_keyword, "gso") &&
    5744                 :          0 :                         !strcmp(res->cmd_segsz, "segsz")) {
    5745                 :          0 :                 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
    5746                 :          0 :                         fprintf(stderr,
    5747                 :            :                                 "gso_size should be larger than %zu. Please input a legal value\n",
    5748                 :            :                                 RTE_GSO_SEG_SIZE_MIN);
    5749                 :            :                 else
    5750                 :          0 :                         gso_max_segment_size = res->cmd_size;
    5751                 :            :         }
    5752                 :            : }
    5753                 :            : 
    5754                 :            : static cmdline_parse_token_string_t cmd_gso_size_set =
    5755                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
    5756                 :            :                                 cmd_set, "set");
    5757                 :            : static cmdline_parse_token_string_t cmd_gso_size_keyword =
    5758                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
    5759                 :            :                                 cmd_keyword, "gso");
    5760                 :            : static cmdline_parse_token_string_t cmd_gso_size_segsz =
    5761                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
    5762                 :            :                                 cmd_segsz, "segsz");
    5763                 :            : static cmdline_parse_token_num_t cmd_gso_size_size =
    5764                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
    5765                 :            :                                 cmd_size, RTE_UINT16);
    5766                 :            : 
    5767                 :            : static cmdline_parse_inst_t cmd_gso_size = {
    5768                 :            :         .f = cmd_gso_size_parsed,
    5769                 :            :         .data = NULL,
    5770                 :            :         .help_str = "set gso segsz <length>",
    5771                 :            :         .tokens = {
    5772                 :            :                 (void *)&cmd_gso_size_set,
    5773                 :            :                 (void *)&cmd_gso_size_keyword,
    5774                 :            :                 (void *)&cmd_gso_size_segsz,
    5775                 :            :                 (void *)&cmd_gso_size_size,
    5776                 :            :                 NULL,
    5777                 :            :         },
    5778                 :            : };
    5779                 :            : 
    5780                 :            : /* *** SHOW GSO CONFIGURATION *** */
    5781                 :            : struct cmd_gso_show_result {
    5782                 :            :         cmdline_fixed_string_t cmd_show;
    5783                 :            :         cmdline_fixed_string_t cmd_port;
    5784                 :            :         cmdline_fixed_string_t cmd_keyword;
    5785                 :            :         portid_t cmd_pid;
    5786                 :            : };
    5787                 :            : 
    5788                 :            : static void
    5789                 :          0 : cmd_gso_show_parsed(void *parsed_result,
    5790                 :            :                        __rte_unused struct cmdline *cl,
    5791                 :            :                        __rte_unused void *data)
    5792                 :            : {
    5793                 :            :         struct cmd_gso_show_result *res = parsed_result;
    5794                 :            : 
    5795                 :          0 :         if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
    5796                 :          0 :                 fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
    5797                 :          0 :                 return;
    5798                 :            :         }
    5799                 :          0 :         if (!strcmp(res->cmd_keyword, "gso")) {
    5800                 :          0 :                 if (gso_ports[res->cmd_pid].enable) {
    5801                 :          0 :                         printf("Max GSO'd packet size: %uB\n"
    5802                 :            :                                         "Supported GSO types: TCP/IPv4, "
    5803                 :            :                                         "UDP/IPv4, VxLAN with inner "
    5804                 :            :                                         "TCP/IPv4 packet, GRE with inner "
    5805                 :            :                                         "TCP/IPv4 packet\n",
    5806                 :            :                                         gso_max_segment_size);
    5807                 :            :                 } else
    5808                 :            :                         printf("GSO is not enabled on Port %u\n", res->cmd_pid);
    5809                 :            :         }
    5810                 :            : }
    5811                 :            : 
    5812                 :            : static cmdline_parse_token_string_t cmd_gso_show_show =
    5813                 :            : TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
    5814                 :            :                 cmd_show, "show");
    5815                 :            : static cmdline_parse_token_string_t cmd_gso_show_port =
    5816                 :            : TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
    5817                 :            :                 cmd_port, "port");
    5818                 :            : static cmdline_parse_token_string_t cmd_gso_show_keyword =
    5819                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
    5820                 :            :                                 cmd_keyword, "gso");
    5821                 :            : static cmdline_parse_token_num_t cmd_gso_show_pid =
    5822                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
    5823                 :            :                                 cmd_pid, RTE_UINT16);
    5824                 :            : 
    5825                 :            : static cmdline_parse_inst_t cmd_gso_show = {
    5826                 :            :         .f = cmd_gso_show_parsed,
    5827                 :            :         .data = NULL,
    5828                 :            :         .help_str = "show port <port_id> gso",
    5829                 :            :         .tokens = {
    5830                 :            :                 (void *)&cmd_gso_show_show,
    5831                 :            :                 (void *)&cmd_gso_show_port,
    5832                 :            :                 (void *)&cmd_gso_show_pid,
    5833                 :            :                 (void *)&cmd_gso_show_keyword,
    5834                 :            :                 NULL,
    5835                 :            :         },
    5836                 :            : };
    5837                 :            : #endif /* RTE_LIB_GSO */
    5838                 :            : 
    5839                 :            : /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
    5840                 :            : struct cmd_set_flush_rx {
    5841                 :            :         cmdline_fixed_string_t set;
    5842                 :            :         cmdline_fixed_string_t flush_rx;
    5843                 :            :         cmdline_fixed_string_t mode;
    5844                 :            : };
    5845                 :            : 
    5846                 :            : static void
    5847                 :          0 : cmd_set_flush_rx_parsed(void *parsed_result,
    5848                 :            :                 __rte_unused struct cmdline *cl,
    5849                 :            :                 __rte_unused void *data)
    5850                 :            : {
    5851                 :            :         struct cmd_set_flush_rx *res = parsed_result;
    5852                 :            : 
    5853                 :          0 :         if (num_procs > 1 && (strcmp(res->mode, "on") == 0)) {
    5854                 :            :                 printf("multi-process doesn't support to flush Rx queues.\n");
    5855                 :          0 :                 return;
    5856                 :            :         }
    5857                 :            : 
    5858                 :          0 :         no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
    5859                 :            : }
    5860                 :            : 
    5861                 :            : static cmdline_parse_token_string_t cmd_setflushrx_set =
    5862                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
    5863                 :            :                         set, "set");
    5864                 :            : static cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
    5865                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
    5866                 :            :                         flush_rx, "flush_rx");
    5867                 :            : static cmdline_parse_token_string_t cmd_setflushrx_mode =
    5868                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
    5869                 :            :                         mode, "on#off");
    5870                 :            : 
    5871                 :            : 
    5872                 :            : static cmdline_parse_inst_t cmd_set_flush_rx = {
    5873                 :            :         .f = cmd_set_flush_rx_parsed,
    5874                 :            :         .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
    5875                 :            :         .data = NULL,
    5876                 :            :         .tokens = {
    5877                 :            :                 (void *)&cmd_setflushrx_set,
    5878                 :            :                 (void *)&cmd_setflushrx_flush_rx,
    5879                 :            :                 (void *)&cmd_setflushrx_mode,
    5880                 :            :                 NULL,
    5881                 :            :         },
    5882                 :            : };
    5883                 :            : 
    5884                 :            : /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
    5885                 :            : struct cmd_set_link_check {
    5886                 :            :         cmdline_fixed_string_t set;
    5887                 :            :         cmdline_fixed_string_t link_check;
    5888                 :            :         cmdline_fixed_string_t mode;
    5889                 :            : };
    5890                 :            : 
    5891                 :            : static void
    5892                 :          0 : cmd_set_link_check_parsed(void *parsed_result,
    5893                 :            :                 __rte_unused struct cmdline *cl,
    5894                 :            :                 __rte_unused void *data)
    5895                 :            : {
    5896                 :            :         struct cmd_set_link_check *res = parsed_result;
    5897                 :          0 :         no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
    5898                 :          0 : }
    5899                 :            : 
    5900                 :            : static cmdline_parse_token_string_t cmd_setlinkcheck_set =
    5901                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
    5902                 :            :                         set, "set");
    5903                 :            : static cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
    5904                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
    5905                 :            :                         link_check, "link_check");
    5906                 :            : static cmdline_parse_token_string_t cmd_setlinkcheck_mode =
    5907                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
    5908                 :            :                         mode, "on#off");
    5909                 :            : 
    5910                 :            : 
    5911                 :            : static cmdline_parse_inst_t cmd_set_link_check = {
    5912                 :            :         .f = cmd_set_link_check_parsed,
    5913                 :            :         .help_str = "set link_check on|off: Enable/Disable link status check "
    5914                 :            :                     "when starting/stopping a port",
    5915                 :            :         .data = NULL,
    5916                 :            :         .tokens = {
    5917                 :            :                 (void *)&cmd_setlinkcheck_set,
    5918                 :            :                 (void *)&cmd_setlinkcheck_link_check,
    5919                 :            :                 (void *)&cmd_setlinkcheck_mode,
    5920                 :            :                 NULL,
    5921                 :            :         },
    5922                 :            : };
    5923                 :            : 
    5924                 :            : /* *** SET FORWARDING MODE *** */
    5925                 :            : struct cmd_set_fwd_mode_result {
    5926                 :            :         cmdline_fixed_string_t set;
    5927                 :            :         cmdline_fixed_string_t fwd;
    5928                 :            :         cmdline_fixed_string_t mode;
    5929                 :            : };
    5930                 :            : 
    5931                 :          0 : static void cmd_set_fwd_mode_parsed(void *parsed_result,
    5932                 :            :                                     __rte_unused struct cmdline *cl,
    5933                 :            :                                     __rte_unused void *data)
    5934                 :            : {
    5935                 :            :         struct cmd_set_fwd_mode_result *res = parsed_result;
    5936                 :            : 
    5937                 :          0 :         retry_enabled = 0;
    5938                 :          0 :         set_pkt_forwarding_mode(res->mode);
    5939                 :          0 : }
    5940                 :            : 
    5941                 :            : static cmdline_parse_token_string_t cmd_setfwd_set =
    5942                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
    5943                 :            : static cmdline_parse_token_string_t cmd_setfwd_fwd =
    5944                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
    5945                 :            : static cmdline_parse_token_string_t cmd_setfwd_mode =
    5946                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
    5947                 :            :                 "" /* defined at init */);
    5948                 :            : 
    5949                 :            : static cmdline_parse_inst_t cmd_set_fwd_mode = {
    5950                 :            :         .f = cmd_set_fwd_mode_parsed,
    5951                 :            :         .data = NULL,
    5952                 :            :         .help_str = NULL, /* defined at init */
    5953                 :            :         .tokens = {
    5954                 :            :                 (void *)&cmd_setfwd_set,
    5955                 :            :                 (void *)&cmd_setfwd_fwd,
    5956                 :            :                 (void *)&cmd_setfwd_mode,
    5957                 :            :                 NULL,
    5958                 :            :         },
    5959                 :            : };
    5960                 :            : 
    5961                 :          0 : static void cmd_set_fwd_mode_init(void)
    5962                 :            : {
    5963                 :            :         char *modes, *c;
    5964                 :            :         static char token[128];
    5965                 :            :         static char help[256];
    5966                 :            :         cmdline_parse_token_string_t *token_struct;
    5967                 :            : 
    5968                 :          0 :         modes = list_pkt_forwarding_modes();
    5969                 :            :         snprintf(help, sizeof(help), "set fwd %s: "
    5970                 :            :                 "Set packet forwarding mode", modes);
    5971                 :          0 :         cmd_set_fwd_mode.help_str = help;
    5972                 :            : 
    5973                 :            :         /* string token separator is # */
    5974                 :          0 :         for (c = token; *modes != '\0'; modes++)
    5975                 :          0 :                 if (*modes == '|')
    5976                 :          0 :                         *c++ = '#';
    5977                 :            :                 else
    5978                 :          0 :                         *c++ = *modes;
    5979                 :          0 :         token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
    5980                 :          0 :         token_struct->string_data.str = token;
    5981                 :          0 : }
    5982                 :            : 
    5983                 :            : /* *** SET RETRY FORWARDING MODE *** */
    5984                 :            : struct cmd_set_fwd_retry_mode_result {
    5985                 :            :         cmdline_fixed_string_t set;
    5986                 :            :         cmdline_fixed_string_t fwd;
    5987                 :            :         cmdline_fixed_string_t mode;
    5988                 :            :         cmdline_fixed_string_t retry;
    5989                 :            : };
    5990                 :            : 
    5991                 :          0 : static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
    5992                 :            :                             __rte_unused struct cmdline *cl,
    5993                 :            :                             __rte_unused void *data)
    5994                 :            : {
    5995                 :            :         struct cmd_set_fwd_retry_mode_result *res = parsed_result;
    5996                 :            : 
    5997                 :          0 :         retry_enabled = 1;
    5998                 :          0 :         set_pkt_forwarding_mode(res->mode);
    5999                 :          0 : }
    6000                 :            : 
    6001                 :            : static cmdline_parse_token_string_t cmd_setfwd_retry_set =
    6002                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
    6003                 :            :                         set, "set");
    6004                 :            : static cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
    6005                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
    6006                 :            :                         fwd, "fwd");
    6007                 :            : static cmdline_parse_token_string_t cmd_setfwd_retry_mode =
    6008                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
    6009                 :            :                         mode,
    6010                 :            :                 "" /* defined at init */);
    6011                 :            : static cmdline_parse_token_string_t cmd_setfwd_retry_retry =
    6012                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
    6013                 :            :                         retry, "retry");
    6014                 :            : 
    6015                 :            : static cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
    6016                 :            :         .f = cmd_set_fwd_retry_mode_parsed,
    6017                 :            :         .data = NULL,
    6018                 :            :         .help_str = NULL, /* defined at init */
    6019                 :            :         .tokens = {
    6020                 :            :                 (void *)&cmd_setfwd_retry_set,
    6021                 :            :                 (void *)&cmd_setfwd_retry_fwd,
    6022                 :            :                 (void *)&cmd_setfwd_retry_mode,
    6023                 :            :                 (void *)&cmd_setfwd_retry_retry,
    6024                 :            :                 NULL,
    6025                 :            :         },
    6026                 :            : };
    6027                 :            : 
    6028                 :          0 : static void cmd_set_fwd_retry_mode_init(void)
    6029                 :            : {
    6030                 :            :         char *modes, *c;
    6031                 :            :         static char token[128];
    6032                 :            :         static char help[256];
    6033                 :            :         cmdline_parse_token_string_t *token_struct;
    6034                 :            : 
    6035                 :          0 :         modes = list_pkt_forwarding_retry_modes();
    6036                 :            :         snprintf(help, sizeof(help), "set fwd %s retry: "
    6037                 :            :                 "Set packet forwarding mode with retry", modes);
    6038                 :          0 :         cmd_set_fwd_retry_mode.help_str = help;
    6039                 :            : 
    6040                 :            :         /* string token separator is # */
    6041                 :          0 :         for (c = token; *modes != '\0'; modes++)
    6042                 :          0 :                 if (*modes == '|')
    6043                 :          0 :                         *c++ = '#';
    6044                 :            :                 else
    6045                 :          0 :                         *c++ = *modes;
    6046                 :          0 :         token_struct = (cmdline_parse_token_string_t *)
    6047                 :            :                 cmd_set_fwd_retry_mode.tokens[2];
    6048                 :          0 :         token_struct->string_data.str = token;
    6049                 :          0 : }
    6050                 :            : 
    6051                 :            : /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
    6052                 :            : struct cmd_set_burst_tx_retry_result {
    6053                 :            :         cmdline_fixed_string_t set;
    6054                 :            :         cmdline_fixed_string_t burst;
    6055                 :            :         cmdline_fixed_string_t tx;
    6056                 :            :         cmdline_fixed_string_t delay;
    6057                 :            :         uint32_t time;
    6058                 :            :         cmdline_fixed_string_t retry;
    6059                 :            :         uint32_t retry_num;
    6060                 :            : };
    6061                 :            : 
    6062                 :          0 : static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
    6063                 :            :                                         __rte_unused struct cmdline *cl,
    6064                 :            :                                         __rte_unused void *data)
    6065                 :            : {
    6066                 :            :         struct cmd_set_burst_tx_retry_result *res = parsed_result;
    6067                 :            : 
    6068                 :          0 :         if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
    6069                 :          0 :                 && !strcmp(res->tx, "tx")) {
    6070                 :          0 :                 if (!strcmp(res->delay, "delay"))
    6071                 :          0 :                         burst_tx_delay_time = res->time;
    6072                 :          0 :                 if (!strcmp(res->retry, "retry"))
    6073                 :          0 :                         burst_tx_retry_num = res->retry_num;
    6074                 :            :         }
    6075                 :            : 
    6076                 :          0 : }
    6077                 :            : 
    6078                 :            : static cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
    6079                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
    6080                 :            : static cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
    6081                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
    6082                 :            :                                  "burst");
    6083                 :            : static cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
    6084                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
    6085                 :            : static cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
    6086                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
    6087                 :            : static cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
    6088                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time,
    6089                 :            :                                  RTE_UINT32);
    6090                 :            : static cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
    6091                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
    6092                 :            : static cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
    6093                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num,
    6094                 :            :                                  RTE_UINT32);
    6095                 :            : 
    6096                 :            : static cmdline_parse_inst_t cmd_set_burst_tx_retry = {
    6097                 :            :         .f = cmd_set_burst_tx_retry_parsed,
    6098                 :            :         .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
    6099                 :            :         .tokens = {
    6100                 :            :                 (void *)&cmd_set_burst_tx_retry_set,
    6101                 :            :                 (void *)&cmd_set_burst_tx_retry_burst,
    6102                 :            :                 (void *)&cmd_set_burst_tx_retry_tx,
    6103                 :            :                 (void *)&cmd_set_burst_tx_retry_delay,
    6104                 :            :                 (void *)&cmd_set_burst_tx_retry_time,
    6105                 :            :                 (void *)&cmd_set_burst_tx_retry_retry,
    6106                 :            :                 (void *)&cmd_set_burst_tx_retry_retry_num,
    6107                 :            :                 NULL,
    6108                 :            :         },
    6109                 :            : };
    6110                 :            : 
    6111                 :            : /* *** SET PROMISC MODE *** */
    6112                 :            : struct cmd_set_promisc_mode_result {
    6113                 :            :         cmdline_fixed_string_t set;
    6114                 :            :         cmdline_fixed_string_t promisc;
    6115                 :            :         cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
    6116                 :            :         uint16_t port_num;               /* valid if "allports" argument == 0 */
    6117                 :            :         cmdline_fixed_string_t mode;
    6118                 :            : };
    6119                 :            : 
    6120                 :          0 : static void cmd_set_promisc_mode_parsed(void *parsed_result,
    6121                 :            :                                         __rte_unused struct cmdline *cl,
    6122                 :            :                                         void *allports)
    6123                 :            : {
    6124                 :            :         struct cmd_set_promisc_mode_result *res = parsed_result;
    6125                 :            :         int enable;
    6126                 :            :         portid_t i;
    6127                 :            : 
    6128                 :          0 :         if (!strcmp(res->mode, "on"))
    6129                 :            :                 enable = 1;
    6130                 :            :         else
    6131                 :            :                 enable = 0;
    6132                 :            : 
    6133                 :            :         /* all ports */
    6134                 :          0 :         if (allports) {
    6135                 :          0 :                 RTE_ETH_FOREACH_DEV(i)
    6136                 :          0 :                         eth_set_promisc_mode(i, enable);
    6137                 :            :         } else {
    6138                 :          0 :                 eth_set_promisc_mode(res->port_num, enable);
    6139                 :            :         }
    6140                 :          0 : }
    6141                 :            : 
    6142                 :            : static cmdline_parse_token_string_t cmd_setpromisc_set =
    6143                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
    6144                 :            : static cmdline_parse_token_string_t cmd_setpromisc_promisc =
    6145                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
    6146                 :            :                                  "promisc");
    6147                 :            : static cmdline_parse_token_string_t cmd_setpromisc_portall =
    6148                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
    6149                 :            :                                  "all");
    6150                 :            : static cmdline_parse_token_num_t cmd_setpromisc_portnum =
    6151                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
    6152                 :            :                               RTE_UINT16);
    6153                 :            : static cmdline_parse_token_string_t cmd_setpromisc_mode =
    6154                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
    6155                 :            :                                  "on#off");
    6156                 :            : 
    6157                 :            : static cmdline_parse_inst_t cmd_set_promisc_mode_all = {
    6158                 :            :         .f = cmd_set_promisc_mode_parsed,
    6159                 :            :         .data = (void *)1,
    6160                 :            :         .help_str = "set promisc all on|off: Set promisc mode for all ports",
    6161                 :            :         .tokens = {
    6162                 :            :                 (void *)&cmd_setpromisc_set,
    6163                 :            :                 (void *)&cmd_setpromisc_promisc,
    6164                 :            :                 (void *)&cmd_setpromisc_portall,
    6165                 :            :                 (void *)&cmd_setpromisc_mode,
    6166                 :            :                 NULL,
    6167                 :            :         },
    6168                 :            : };
    6169                 :            : 
    6170                 :            : static cmdline_parse_inst_t cmd_set_promisc_mode_one = {
    6171                 :            :         .f = cmd_set_promisc_mode_parsed,
    6172                 :            :         .data = (void *)0,
    6173                 :            :         .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
    6174                 :            :         .tokens = {
    6175                 :            :                 (void *)&cmd_setpromisc_set,
    6176                 :            :                 (void *)&cmd_setpromisc_promisc,
    6177                 :            :                 (void *)&cmd_setpromisc_portnum,
    6178                 :            :                 (void *)&cmd_setpromisc_mode,
    6179                 :            :                 NULL,
    6180                 :            :         },
    6181                 :            : };
    6182                 :            : 
    6183                 :            : /* *** SET ALLMULTI MODE *** */
    6184                 :            : struct cmd_set_allmulti_mode_result {
    6185                 :            :         cmdline_fixed_string_t set;
    6186                 :            :         cmdline_fixed_string_t allmulti;
    6187                 :            :         cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
    6188                 :            :         uint16_t port_num;               /* valid if "allports" argument == 0 */
    6189                 :            :         cmdline_fixed_string_t mode;
    6190                 :            : };
    6191                 :            : 
    6192                 :          0 : static void cmd_set_allmulti_mode_parsed(void *parsed_result,
    6193                 :            :                                         __rte_unused struct cmdline *cl,
    6194                 :            :                                         void *allports)
    6195                 :            : {
    6196                 :            :         struct cmd_set_allmulti_mode_result *res = parsed_result;
    6197                 :            :         int enable;
    6198                 :            :         portid_t i;
    6199                 :            : 
    6200                 :          0 :         if (!strcmp(res->mode, "on"))
    6201                 :            :                 enable = 1;
    6202                 :            :         else
    6203                 :            :                 enable = 0;
    6204                 :            : 
    6205                 :            :         /* all ports */
    6206                 :          0 :         if (allports) {
    6207                 :          0 :                 RTE_ETH_FOREACH_DEV(i) {
    6208                 :          0 :                         eth_set_allmulticast_mode(i, enable);
    6209                 :            :                 }
    6210                 :            :         }
    6211                 :            :         else {
    6212                 :          0 :                 eth_set_allmulticast_mode(res->port_num, enable);
    6213                 :            :         }
    6214                 :          0 : }
    6215                 :            : 
    6216                 :            : static cmdline_parse_token_string_t cmd_setallmulti_set =
    6217                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
    6218                 :            : static cmdline_parse_token_string_t cmd_setallmulti_allmulti =
    6219                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
    6220                 :            :                                  "allmulti");
    6221                 :            : static cmdline_parse_token_string_t cmd_setallmulti_portall =
    6222                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
    6223                 :            :                                  "all");
    6224                 :            : static cmdline_parse_token_num_t cmd_setallmulti_portnum =
    6225                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
    6226                 :            :                               RTE_UINT16);
    6227                 :            : static cmdline_parse_token_string_t cmd_setallmulti_mode =
    6228                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
    6229                 :            :                                  "on#off");
    6230                 :            : 
    6231                 :            : static cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
    6232                 :            :         .f = cmd_set_allmulti_mode_parsed,
    6233                 :            :         .data = (void *)1,
    6234                 :            :         .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
    6235                 :            :         .tokens = {
    6236                 :            :                 (void *)&cmd_setallmulti_set,
    6237                 :            :                 (void *)&cmd_setallmulti_allmulti,
    6238                 :            :                 (void *)&cmd_setallmulti_portall,
    6239                 :            :                 (void *)&cmd_setallmulti_mode,
    6240                 :            :                 NULL,
    6241                 :            :         },
    6242                 :            : };
    6243                 :            : 
    6244                 :            : static cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
    6245                 :            :         .f = cmd_set_allmulti_mode_parsed,
    6246                 :            :         .data = (void *)0,
    6247                 :            :         .help_str = "set allmulti <port_id> on|off: "
    6248                 :            :                 "Set allmulti mode on port_id",
    6249                 :            :         .tokens = {
    6250                 :            :                 (void *)&cmd_setallmulti_set,
    6251                 :            :                 (void *)&cmd_setallmulti_allmulti,
    6252                 :            :                 (void *)&cmd_setallmulti_portnum,
    6253                 :            :                 (void *)&cmd_setallmulti_mode,
    6254                 :            :                 NULL,
    6255                 :            :         },
    6256                 :            : };
    6257                 :            : 
    6258                 :            : /* *** GET CURRENT ETHERNET LINK FLOW CONTROL *** */
    6259                 :            : struct cmd_link_flow_ctrl_show {
    6260                 :            :         cmdline_fixed_string_t show;
    6261                 :            :         cmdline_fixed_string_t port;
    6262                 :            :         portid_t port_id;
    6263                 :            :         cmdline_fixed_string_t flow_ctrl;
    6264                 :            : };
    6265                 :            : 
    6266                 :            : static cmdline_parse_token_string_t cmd_lfc_show_show =
    6267                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
    6268                 :            :                                 show, "show");
    6269                 :            : static cmdline_parse_token_string_t cmd_lfc_show_port =
    6270                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
    6271                 :            :                                 port, "port");
    6272                 :            : static cmdline_parse_token_num_t cmd_lfc_show_portid =
    6273                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_show,
    6274                 :            :                                 port_id, RTE_UINT16);
    6275                 :            : static cmdline_parse_token_string_t cmd_lfc_show_flow_ctrl =
    6276                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
    6277                 :            :                                 flow_ctrl, "flow_ctrl");
    6278                 :            : 
    6279                 :            : static void
    6280                 :          0 : cmd_link_flow_ctrl_show_parsed(void *parsed_result,
    6281                 :            :                               __rte_unused struct cmdline *cl,
    6282                 :            :                               __rte_unused void *data)
    6283                 :            : {
    6284                 :            :         struct cmd_link_flow_ctrl_show *res = parsed_result;
    6285                 :            :         static const char *info_border = "*********************";
    6286                 :            :         struct rte_eth_fc_conf fc_conf;
    6287                 :            :         bool rx_fc_en = false;
    6288                 :            :         bool tx_fc_en = false;
    6289                 :            :         int ret;
    6290                 :            : 
    6291                 :          0 :         ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
    6292                 :          0 :         if (ret != 0) {
    6293                 :          0 :                 fprintf(stderr,
    6294                 :            :                         "Failed to get current flow ctrl information: err = %d\n",
    6295                 :            :                         ret);
    6296                 :          0 :                 return;
    6297                 :            :         }
    6298                 :            : 
    6299                 :          0 :         if (fc_conf.mode == RTE_ETH_FC_RX_PAUSE || fc_conf.mode == RTE_ETH_FC_FULL)
    6300                 :            :                 rx_fc_en = true;
    6301                 :          0 :         if (fc_conf.mode == RTE_ETH_FC_TX_PAUSE || fc_conf.mode == RTE_ETH_FC_FULL)
    6302                 :            :                 tx_fc_en = true;
    6303                 :            : 
    6304                 :          0 :         printf("\n%s Flow control infos for port %-2d %s\n",
    6305                 :          0 :                 info_border, res->port_id, info_border);
    6306                 :            :         printf("FC mode:\n");
    6307                 :          0 :         printf("   Rx pause: %s\n", rx_fc_en ? "on" : "off");
    6308                 :          0 :         printf("   Tx pause: %s\n", tx_fc_en ? "on" : "off");
    6309                 :          0 :         printf("Autoneg: %s\n", fc_conf.autoneg ? "on" : "off");
    6310                 :          0 :         printf("Pause time: 0x%x\n", fc_conf.pause_time);
    6311                 :          0 :         printf("High waterline: 0x%x\n", fc_conf.high_water);
    6312                 :          0 :         printf("Low waterline: 0x%x\n", fc_conf.low_water);
    6313                 :          0 :         printf("Send XON: %s\n", fc_conf.send_xon ? "on" : "off");
    6314                 :          0 :         printf("Forward MAC control frames: %s\n",
    6315                 :          0 :                 fc_conf.mac_ctrl_frame_fwd ? "on" : "off");
    6316                 :          0 :         printf("\n%s**************   End  ***********%s\n",
    6317                 :            :                 info_border, info_border);
    6318                 :            : }
    6319                 :            : 
    6320                 :            : static cmdline_parse_inst_t cmd_link_flow_control_show = {
    6321                 :            :         .f = cmd_link_flow_ctrl_show_parsed,
    6322                 :            :         .data = NULL,
    6323                 :            :         .help_str = "show port <port_id> flow_ctrl",
    6324                 :            :         .tokens = {
    6325                 :            :                 (void *)&cmd_lfc_show_show,
    6326                 :            :                 (void *)&cmd_lfc_show_port,
    6327                 :            :                 (void *)&cmd_lfc_show_portid,
    6328                 :            :                 (void *)&cmd_lfc_show_flow_ctrl,
    6329                 :            :                 NULL,
    6330                 :            :         },
    6331                 :            : };
    6332                 :            : 
    6333                 :            : /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
    6334                 :            : struct cmd_link_flow_ctrl_set_result {
    6335                 :            :         cmdline_fixed_string_t set;
    6336                 :            :         cmdline_fixed_string_t flow_ctrl;
    6337                 :            :         cmdline_fixed_string_t rx;
    6338                 :            :         cmdline_fixed_string_t rx_lfc_mode;
    6339                 :            :         cmdline_fixed_string_t tx;
    6340                 :            :         cmdline_fixed_string_t tx_lfc_mode;
    6341                 :            :         cmdline_fixed_string_t mac_ctrl_frame_fwd;
    6342                 :            :         cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
    6343                 :            :         cmdline_fixed_string_t autoneg_str;
    6344                 :            :         cmdline_fixed_string_t autoneg;
    6345                 :            :         cmdline_fixed_string_t hw_str;
    6346                 :            :         uint32_t high_water;
    6347                 :            :         cmdline_fixed_string_t lw_str;
    6348                 :            :         uint32_t low_water;
    6349                 :            :         cmdline_fixed_string_t pt_str;
    6350                 :            :         uint16_t pause_time;
    6351                 :            :         cmdline_fixed_string_t xon_str;
    6352                 :            :         uint16_t send_xon;
    6353                 :            :         portid_t port_id;
    6354                 :            : };
    6355                 :            : 
    6356                 :            : static cmdline_parse_token_string_t cmd_lfc_set_set =
    6357                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
    6358                 :            :                                 set, "set");
    6359                 :            : static cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
    6360                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
    6361                 :            :                                 flow_ctrl, "flow_ctrl");
    6362                 :            : static cmdline_parse_token_string_t cmd_lfc_set_rx =
    6363                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
    6364                 :            :                                 rx, "rx");
    6365                 :            : static cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
    6366                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
    6367                 :            :                                 rx_lfc_mode, "on#off");
    6368                 :            : static cmdline_parse_token_string_t cmd_lfc_set_tx =
    6369                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
    6370                 :            :                                 tx, "tx");
    6371                 :            : static cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
    6372                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
    6373                 :            :                                 tx_lfc_mode, "on#off");
    6374                 :            : static cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
    6375                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
    6376                 :            :                                 hw_str, "high_water");
    6377                 :            : static cmdline_parse_token_num_t cmd_lfc_set_high_water =
    6378                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
    6379                 :            :                                 high_water, RTE_UINT32);
    6380                 :            : static cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
    6381                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
    6382                 :            :                                 lw_str, "low_water");
    6383                 :            : static cmdline_parse_token_num_t cmd_lfc_set_low_water =
    6384                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
    6385                 :            :                                 low_water, RTE_UINT32);
    6386                 :            : static cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
    6387                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
    6388                 :            :                                 pt_str, "pause_time");
    6389                 :            : static cmdline_parse_token_num_t cmd_lfc_set_pause_time =
    6390                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
    6391                 :            :                                 pause_time, RTE_UINT16);
    6392                 :            : static cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
    6393                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
    6394                 :            :                                 xon_str, "send_xon");
    6395                 :            : static cmdline_parse_token_num_t cmd_lfc_set_send_xon =
    6396                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
    6397                 :            :                                 send_xon, RTE_UINT16);
    6398                 :            : static cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
    6399                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
    6400                 :            :                                 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
    6401                 :            : static cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
    6402                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
    6403                 :            :                                 mac_ctrl_frame_fwd_mode, "on#off");
    6404                 :            : static cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
    6405                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
    6406                 :            :                                 autoneg_str, "autoneg");
    6407                 :            : static cmdline_parse_token_string_t cmd_lfc_set_autoneg =
    6408                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
    6409                 :            :                                 autoneg, "on#off");
    6410                 :            : static cmdline_parse_token_num_t cmd_lfc_set_portid =
    6411                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
    6412                 :            :                                 port_id, RTE_UINT16);
    6413                 :            : 
    6414                 :            : /* forward declaration */
    6415                 :            : static void
    6416                 :            : cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
    6417                 :            :                               void *data);
    6418                 :            : 
    6419                 :            : static cmdline_parse_inst_t cmd_link_flow_control_set = {
    6420                 :            :         .f = cmd_link_flow_ctrl_set_parsed,
    6421                 :            :         .data = NULL,
    6422                 :            :         .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
    6423                 :            :                 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
    6424                 :            :                 "autoneg on|off <port_id>: Configure the Ethernet flow control",
    6425                 :            :         .tokens = {
    6426                 :            :                 (void *)&cmd_lfc_set_set,
    6427                 :            :                 (void *)&cmd_lfc_set_flow_ctrl,
    6428                 :            :                 (void *)&cmd_lfc_set_rx,
    6429                 :            :                 (void *)&cmd_lfc_set_rx_mode,
    6430                 :            :                 (void *)&cmd_lfc_set_tx,
    6431                 :            :                 (void *)&cmd_lfc_set_tx_mode,
    6432                 :            :                 (void *)&cmd_lfc_set_high_water,
    6433                 :            :                 (void *)&cmd_lfc_set_low_water,
    6434                 :            :                 (void *)&cmd_lfc_set_pause_time,
    6435                 :            :                 (void *)&cmd_lfc_set_send_xon,
    6436                 :            :                 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
    6437                 :            :                 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
    6438                 :            :                 (void *)&cmd_lfc_set_autoneg_str,
    6439                 :            :                 (void *)&cmd_lfc_set_autoneg,
    6440                 :            :                 (void *)&cmd_lfc_set_portid,
    6441                 :            :                 NULL,
    6442                 :            :         },
    6443                 :            : };
    6444                 :            : 
    6445                 :            : static cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
    6446                 :            :         .f = cmd_link_flow_ctrl_set_parsed,
    6447                 :            :         .data = (void *)&cmd_link_flow_control_set_rx,
    6448                 :            :         .help_str = "set flow_ctrl rx on|off <port_id>: "
    6449                 :            :                 "Change rx flow control parameter",
    6450                 :            :         .tokens = {
    6451                 :            :                 (void *)&cmd_lfc_set_set,
    6452                 :            :                 (void *)&cmd_lfc_set_flow_ctrl,
    6453                 :            :                 (void *)&cmd_lfc_set_rx,
    6454                 :            :                 (void *)&cmd_lfc_set_rx_mode,
    6455                 :            :                 (void *)&cmd_lfc_set_portid,
    6456                 :            :                 NULL,
    6457                 :            :         },
    6458                 :            : };
    6459                 :            : 
    6460                 :            : static cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
    6461                 :            :         .f = cmd_link_flow_ctrl_set_parsed,
    6462                 :            :         .data = (void *)&cmd_link_flow_control_set_tx,
    6463                 :            :         .help_str = "set flow_ctrl tx on|off <port_id>: "
    6464                 :            :                 "Change tx flow control parameter",
    6465                 :            :         .tokens = {
    6466                 :            :                 (void *)&cmd_lfc_set_set,
    6467                 :            :                 (void *)&cmd_lfc_set_flow_ctrl,
    6468                 :            :                 (void *)&cmd_lfc_set_tx,
    6469                 :            :                 (void *)&cmd_lfc_set_tx_mode,
    6470                 :            :                 (void *)&cmd_lfc_set_portid,
    6471                 :            :                 NULL,
    6472                 :            :         },
    6473                 :            : };
    6474                 :            : 
    6475                 :            : static cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
    6476                 :            :         .f = cmd_link_flow_ctrl_set_parsed,
    6477                 :            :         .data = (void *)&cmd_link_flow_control_set_hw,
    6478                 :            :         .help_str = "set flow_ctrl high_water <value> <port_id>: "
    6479                 :            :                 "Change high water flow control parameter",
    6480                 :            :         .tokens = {
    6481                 :            :                 (void *)&cmd_lfc_set_set,
    6482                 :            :                 (void *)&cmd_lfc_set_flow_ctrl,
    6483                 :            :                 (void *)&cmd_lfc_set_high_water_str,
    6484                 :            :                 (void *)&cmd_lfc_set_high_water,
    6485                 :            :                 (void *)&cmd_lfc_set_portid,
    6486                 :            :                 NULL,
    6487                 :            :         },
    6488                 :            : };
    6489                 :            : 
    6490                 :            : static cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
    6491                 :            :         .f = cmd_link_flow_ctrl_set_parsed,
    6492                 :            :         .data = (void *)&cmd_link_flow_control_set_lw,
    6493                 :            :         .help_str = "set flow_ctrl low_water <value> <port_id>: "
    6494                 :            :                 "Change low water flow control parameter",
    6495                 :            :         .tokens = {
    6496                 :            :                 (void *)&cmd_lfc_set_set,
    6497                 :            :                 (void *)&cmd_lfc_set_flow_ctrl,
    6498                 :            :                 (void *)&cmd_lfc_set_low_water_str,
    6499                 :            :                 (void *)&cmd_lfc_set_low_water,
    6500                 :            :                 (void *)&cmd_lfc_set_portid,
    6501                 :            :                 NULL,
    6502                 :            :         },
    6503                 :            : };
    6504                 :            : 
    6505                 :            : static cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
    6506                 :            :         .f = cmd_link_flow_ctrl_set_parsed,
    6507                 :            :         .data = (void *)&cmd_link_flow_control_set_pt,
    6508                 :            :         .help_str = "set flow_ctrl pause_time <value> <port_id>: "
    6509                 :            :                 "Change pause time flow control parameter",
    6510                 :            :         .tokens = {
    6511                 :            :                 (void *)&cmd_lfc_set_set,
    6512                 :            :                 (void *)&cmd_lfc_set_flow_ctrl,
    6513                 :            :                 (void *)&cmd_lfc_set_pause_time_str,
    6514                 :            :                 (void *)&cmd_lfc_set_pause_time,
    6515                 :            :                 (void *)&cmd_lfc_set_portid,
    6516                 :            :                 NULL,
    6517                 :            :         },
    6518                 :            : };
    6519                 :            : 
    6520                 :            : static cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
    6521                 :            :         .f = cmd_link_flow_ctrl_set_parsed,
    6522                 :            :         .data = (void *)&cmd_link_flow_control_set_xon,
    6523                 :            :         .help_str = "set flow_ctrl send_xon <value> <port_id>: "
    6524                 :            :                 "Change send_xon flow control parameter",
    6525                 :            :         .tokens = {
    6526                 :            :                 (void *)&cmd_lfc_set_set,
    6527                 :            :                 (void *)&cmd_lfc_set_flow_ctrl,
    6528                 :            :                 (void *)&cmd_lfc_set_send_xon_str,
    6529                 :            :                 (void *)&cmd_lfc_set_send_xon,
    6530                 :            :                 (void *)&cmd_lfc_set_portid,
    6531                 :            :                 NULL,
    6532                 :            :         },
    6533                 :            : };
    6534                 :            : 
    6535                 :            : static cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
    6536                 :            :         .f = cmd_link_flow_ctrl_set_parsed,
    6537                 :            :         .data = (void *)&cmd_link_flow_control_set_macfwd,
    6538                 :            :         .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
    6539                 :            :                 "Change mac ctrl fwd flow control parameter",
    6540                 :            :         .tokens = {
    6541                 :            :                 (void *)&cmd_lfc_set_set,
    6542                 :            :                 (void *)&cmd_lfc_set_flow_ctrl,
    6543                 :            :                 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
    6544                 :            :                 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
    6545                 :            :                 (void *)&cmd_lfc_set_portid,
    6546                 :            :                 NULL,
    6547                 :            :         },
    6548                 :            : };
    6549                 :            : 
    6550                 :            : static cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
    6551                 :            :         .f = cmd_link_flow_ctrl_set_parsed,
    6552                 :            :         .data = (void *)&cmd_link_flow_control_set_autoneg,
    6553                 :            :         .help_str = "set flow_ctrl autoneg on|off <port_id>: "
    6554                 :            :                 "Change autoneg flow control parameter",
    6555                 :            :         .tokens = {
    6556                 :            :                 (void *)&cmd_lfc_set_set,
    6557                 :            :                 (void *)&cmd_lfc_set_flow_ctrl,
    6558                 :            :                 (void *)&cmd_lfc_set_autoneg_str,
    6559                 :            :                 (void *)&cmd_lfc_set_autoneg,
    6560                 :            :                 (void *)&cmd_lfc_set_portid,
    6561                 :            :                 NULL,
    6562                 :            :         },
    6563                 :            : };
    6564                 :            : 
    6565                 :            : static void
    6566                 :          0 : cmd_link_flow_ctrl_set_parsed(void *parsed_result,
    6567                 :            :                               __rte_unused struct cmdline *cl,
    6568                 :            :                               void *data)
    6569                 :            : {
    6570                 :            :         struct cmd_link_flow_ctrl_set_result *res = parsed_result;
    6571                 :            :         cmdline_parse_inst_t *cmd = data;
    6572                 :            :         struct rte_eth_fc_conf fc_conf;
    6573                 :            :         int rx_fc_en = 0;
    6574                 :            :         int tx_fc_en = 0;
    6575                 :            :         int ret;
    6576                 :            : 
    6577                 :            :         /*
    6578                 :            :          * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
    6579                 :            :          * the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx side.
    6580                 :            :          * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
    6581                 :            :          * the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
    6582                 :            :          */
    6583                 :            :         static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
    6584                 :            :                         {RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE}, {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
    6585                 :            :         };
    6586                 :            : 
    6587                 :            :         /* Partial command line, retrieve current configuration */
    6588                 :          0 :         if (cmd) {
    6589                 :          0 :                 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
    6590                 :          0 :                 if (ret != 0) {
    6591                 :          0 :                         fprintf(stderr,
    6592                 :            :                                 "cannot get current flow ctrl parameters, return code = %d\n",
    6593                 :            :                                 ret);
    6594                 :          0 :                         return;
    6595                 :            :                 }
    6596                 :            : 
    6597                 :          0 :                 if ((fc_conf.mode == RTE_ETH_FC_RX_PAUSE) ||
    6598                 :            :                     (fc_conf.mode == RTE_ETH_FC_FULL))
    6599                 :            :                         rx_fc_en = 1;
    6600                 :          0 :                 if ((fc_conf.mode == RTE_ETH_FC_TX_PAUSE) ||
    6601                 :            :                     (fc_conf.mode == RTE_ETH_FC_FULL))
    6602                 :            :                         tx_fc_en = 1;
    6603                 :            :         }
    6604                 :            : 
    6605                 :          0 :         if (!cmd || cmd == &cmd_link_flow_control_set_rx)
    6606                 :          0 :                 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
    6607                 :            : 
    6608                 :          0 :         if (!cmd || cmd == &cmd_link_flow_control_set_tx)
    6609                 :          0 :                 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
    6610                 :            : 
    6611                 :          0 :         fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
    6612                 :            : 
    6613                 :          0 :         if (!cmd || cmd == &cmd_link_flow_control_set_hw)
    6614                 :          0 :                 fc_conf.high_water = res->high_water;
    6615                 :            : 
    6616                 :          0 :         if (!cmd || cmd == &cmd_link_flow_control_set_lw)
    6617                 :          0 :                 fc_conf.low_water = res->low_water;
    6618                 :            : 
    6619                 :          0 :         if (!cmd || cmd == &cmd_link_flow_control_set_pt)
    6620                 :          0 :                 fc_conf.pause_time = res->pause_time;
    6621                 :            : 
    6622                 :          0 :         if (!cmd || cmd == &cmd_link_flow_control_set_xon)
    6623                 :          0 :                 fc_conf.send_xon = res->send_xon;
    6624                 :            : 
    6625                 :          0 :         if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
    6626                 :          0 :                 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
    6627                 :          0 :                         fc_conf.mac_ctrl_frame_fwd = 1;
    6628                 :            :                 else
    6629                 :          0 :                         fc_conf.mac_ctrl_frame_fwd = 0;
    6630                 :            :         }
    6631                 :            : 
    6632                 :          0 :         if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
    6633                 :          0 :                 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
    6634                 :            : 
    6635                 :          0 :         ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
    6636                 :          0 :         if (ret != 0)
    6637                 :          0 :                 fprintf(stderr,
    6638                 :            :                         "bad flow control parameter, return code = %d\n",
    6639                 :            :                         ret);
    6640                 :            : }
    6641                 :            : 
    6642                 :            : /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
    6643                 :            : struct cmd_priority_flow_ctrl_set_result {
    6644                 :            :         cmdline_fixed_string_t set;
    6645                 :            :         cmdline_fixed_string_t pfc_ctrl;
    6646                 :            :         cmdline_fixed_string_t rx;
    6647                 :            :         cmdline_fixed_string_t rx_pfc_mode;
    6648                 :            :         cmdline_fixed_string_t tx;
    6649                 :            :         cmdline_fixed_string_t tx_pfc_mode;
    6650                 :            :         uint32_t high_water;
    6651                 :            :         uint32_t low_water;
    6652                 :            :         uint16_t pause_time;
    6653                 :            :         uint8_t  priority;
    6654                 :            :         portid_t port_id;
    6655                 :            : };
    6656                 :            : 
    6657                 :            : static void
    6658                 :          0 : cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
    6659                 :            :                        __rte_unused struct cmdline *cl,
    6660                 :            :                        __rte_unused void *data)
    6661                 :            : {
    6662                 :            :         struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
    6663                 :            :         struct rte_eth_pfc_conf pfc_conf;
    6664                 :            :         int rx_fc_enable, tx_fc_enable;
    6665                 :            :         int ret;
    6666                 :            : 
    6667                 :            :         /*
    6668                 :            :          * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
    6669                 :            :          * the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx side.
    6670                 :            :          * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
    6671                 :            :          * the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
    6672                 :            :          */
    6673                 :            :         static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
    6674                 :            :                 {RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE}, {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
    6675                 :            :         };
    6676                 :            : 
    6677                 :            :         memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
    6678                 :          0 :         rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
    6679                 :          0 :         tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
    6680                 :          0 :         pfc_conf.fc.mode       = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
    6681                 :          0 :         pfc_conf.fc.high_water = res->high_water;
    6682                 :          0 :         pfc_conf.fc.low_water  = res->low_water;
    6683                 :          0 :         pfc_conf.fc.pause_time = res->pause_time;
    6684                 :          0 :         pfc_conf.priority      = res->priority;
    6685                 :            : 
    6686                 :          0 :         ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
    6687                 :          0 :         if (ret != 0)
    6688                 :          0 :                 fprintf(stderr,
    6689                 :            :                         "bad priority flow control parameter, return code = %d\n",
    6690                 :            :                         ret);
    6691                 :          0 : }
    6692                 :            : 
    6693                 :            : static cmdline_parse_token_string_t cmd_pfc_set_set =
    6694                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
    6695                 :            :                                 set, "set");
    6696                 :            : static cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
    6697                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
    6698                 :            :                                 pfc_ctrl, "pfc_ctrl");
    6699                 :            : static cmdline_parse_token_string_t cmd_pfc_set_rx =
    6700                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
    6701                 :            :                                 rx, "rx");
    6702                 :            : static cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
    6703                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
    6704                 :            :                                 rx_pfc_mode, "on#off");
    6705                 :            : static cmdline_parse_token_string_t cmd_pfc_set_tx =
    6706                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
    6707                 :            :                                 tx, "tx");
    6708                 :            : static cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
    6709                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
    6710                 :            :                                 tx_pfc_mode, "on#off");
    6711                 :            : static cmdline_parse_token_num_t cmd_pfc_set_high_water =
    6712                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
    6713                 :            :                                 high_water, RTE_UINT32);
    6714                 :            : static cmdline_parse_token_num_t cmd_pfc_set_low_water =
    6715                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
    6716                 :            :                                 low_water, RTE_UINT32);
    6717                 :            : static cmdline_parse_token_num_t cmd_pfc_set_pause_time =
    6718                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
    6719                 :            :                                 pause_time, RTE_UINT16);
    6720                 :            : static cmdline_parse_token_num_t cmd_pfc_set_priority =
    6721                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
    6722                 :            :                                 priority, RTE_UINT8);
    6723                 :            : static cmdline_parse_token_num_t cmd_pfc_set_portid =
    6724                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
    6725                 :            :                                 port_id, RTE_UINT16);
    6726                 :            : 
    6727                 :            : static cmdline_parse_inst_t cmd_priority_flow_control_set = {
    6728                 :            :         .f = cmd_priority_flow_ctrl_set_parsed,
    6729                 :            :         .data = NULL,
    6730                 :            :         .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
    6731                 :            :                 "<pause_time> <priority> <port_id>: "
    6732                 :            :                 "Configure the Ethernet priority flow control",
    6733                 :            :         .tokens = {
    6734                 :            :                 (void *)&cmd_pfc_set_set,
    6735                 :            :                 (void *)&cmd_pfc_set_flow_ctrl,
    6736                 :            :                 (void *)&cmd_pfc_set_rx,
    6737                 :            :                 (void *)&cmd_pfc_set_rx_mode,
    6738                 :            :                 (void *)&cmd_pfc_set_tx,
    6739                 :            :                 (void *)&cmd_pfc_set_tx_mode,
    6740                 :            :                 (void *)&cmd_pfc_set_high_water,
    6741                 :            :                 (void *)&cmd_pfc_set_low_water,
    6742                 :            :                 (void *)&cmd_pfc_set_pause_time,
    6743                 :            :                 (void *)&cmd_pfc_set_priority,
    6744                 :            :                 (void *)&cmd_pfc_set_portid,
    6745                 :            :                 NULL,
    6746                 :            :         },
    6747                 :            : };
    6748                 :            : 
    6749                 :            : struct cmd_queue_priority_flow_ctrl_set_result {
    6750                 :            :         cmdline_fixed_string_t set;
    6751                 :            :         cmdline_fixed_string_t pfc_queue_ctrl;
    6752                 :            :         portid_t port_id;
    6753                 :            :         cmdline_fixed_string_t rx;
    6754                 :            :         cmdline_fixed_string_t rx_pfc_mode;
    6755                 :            :         uint16_t tx_qid;
    6756                 :            :         uint8_t  tx_tc;
    6757                 :            :         cmdline_fixed_string_t tx;
    6758                 :            :         cmdline_fixed_string_t tx_pfc_mode;
    6759                 :            :         uint16_t rx_qid;
    6760                 :            :         uint8_t  rx_tc;
    6761                 :            :         uint16_t pause_time;
    6762                 :            : };
    6763                 :            : 
    6764                 :            : static void
    6765                 :          0 : cmd_queue_priority_flow_ctrl_set_parsed(void *parsed_result,
    6766                 :            :                                         __rte_unused struct cmdline *cl,
    6767                 :            :                                         __rte_unused void *data)
    6768                 :            : {
    6769                 :            :         struct cmd_queue_priority_flow_ctrl_set_result *res = parsed_result;
    6770                 :            :         struct rte_eth_pfc_queue_conf pfc_queue_conf;
    6771                 :            :         int rx_fc_enable, tx_fc_enable;
    6772                 :            :         int ret;
    6773                 :            : 
    6774                 :            :         /*
    6775                 :            :          * Rx on/off, flow control is enabled/disabled on RX side. This can
    6776                 :            :          * indicate the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx
    6777                 :            :          * side. Tx on/off, flow control is enabled/disabled on TX side. This
    6778                 :            :          * can indicate the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at
    6779                 :            :          * the Tx side.
    6780                 :            :          */
    6781                 :            :         static enum rte_eth_fc_mode rx_tx_onoff_2_mode[2][2] = {
    6782                 :            :                 {RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE},
    6783                 :            :                 {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
    6784                 :            :         };
    6785                 :            : 
    6786                 :            :         memset(&pfc_queue_conf, 0, sizeof(struct rte_eth_pfc_queue_conf));
    6787                 :          0 :         rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on", 2)) ? 1 : 0;
    6788                 :          0 :         tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on", 2)) ? 1 : 0;
    6789                 :          0 :         pfc_queue_conf.mode = rx_tx_onoff_2_mode[rx_fc_enable][tx_fc_enable];
    6790                 :          0 :         pfc_queue_conf.rx_pause.tc  = res->tx_tc;
    6791                 :          0 :         pfc_queue_conf.rx_pause.tx_qid = res->tx_qid;
    6792                 :          0 :         pfc_queue_conf.tx_pause.tc  = res->rx_tc;
    6793                 :          0 :         pfc_queue_conf.tx_pause.rx_qid  = res->rx_qid;
    6794                 :          0 :         pfc_queue_conf.tx_pause.pause_time = res->pause_time;
    6795                 :            : 
    6796                 :          0 :         ret = rte_eth_dev_priority_flow_ctrl_queue_configure(res->port_id,
    6797                 :            :                                                              &pfc_queue_conf);
    6798                 :          0 :         if (ret != 0) {
    6799                 :          0 :                 fprintf(stderr,
    6800                 :            :                         "bad queue priority flow control parameter, rc = %d\n",
    6801                 :            :                         ret);
    6802                 :            :         }
    6803                 :          0 : }
    6804                 :            : 
    6805                 :            : static cmdline_parse_token_string_t cmd_q_pfc_set_set =
    6806                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
    6807                 :            :                                 set, "set");
    6808                 :            : static cmdline_parse_token_string_t cmd_q_pfc_set_flow_ctrl =
    6809                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
    6810                 :            :                                 pfc_queue_ctrl, "pfc_queue_ctrl");
    6811                 :            : static cmdline_parse_token_num_t cmd_q_pfc_set_portid =
    6812                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
    6813                 :            :                                 port_id, RTE_UINT16);
    6814                 :            : static cmdline_parse_token_string_t cmd_q_pfc_set_rx =
    6815                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
    6816                 :            :                                 rx, "rx");
    6817                 :            : static cmdline_parse_token_string_t cmd_q_pfc_set_rx_mode =
    6818                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
    6819                 :            :                                 rx_pfc_mode, "on#off");
    6820                 :            : static cmdline_parse_token_num_t cmd_q_pfc_set_tx_qid =
    6821                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
    6822                 :            :                                 tx_qid, RTE_UINT16);
    6823                 :            : static cmdline_parse_token_num_t cmd_q_pfc_set_tx_tc =
    6824                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
    6825                 :            :                                 tx_tc, RTE_UINT8);
    6826                 :            : static cmdline_parse_token_string_t cmd_q_pfc_set_tx =
    6827                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
    6828                 :            :                                 tx, "tx");
    6829                 :            : static cmdline_parse_token_string_t cmd_q_pfc_set_tx_mode =
    6830                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
    6831                 :            :                                 tx_pfc_mode, "on#off");
    6832                 :            : static cmdline_parse_token_num_t cmd_q_pfc_set_rx_qid =
    6833                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
    6834                 :            :                                 rx_qid, RTE_UINT16);
    6835                 :            : static cmdline_parse_token_num_t cmd_q_pfc_set_rx_tc =
    6836                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
    6837                 :            :                                 rx_tc, RTE_UINT8);
    6838                 :            : static cmdline_parse_token_num_t cmd_q_pfc_set_pause_time =
    6839                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
    6840                 :            :                                 pause_time, RTE_UINT16);
    6841                 :            : 
    6842                 :            : static cmdline_parse_inst_t cmd_queue_priority_flow_control_set = {
    6843                 :            :         .f = cmd_queue_priority_flow_ctrl_set_parsed,
    6844                 :            :         .data = NULL,
    6845                 :            :         .help_str = "set pfc_queue_ctrl <port_id> rx <on|off> <tx_qid> <tx_tc> "
    6846                 :            :                 "tx <on|off> <rx_qid> <rx_tc> <pause_time>: "
    6847                 :            :                 "Configure the Ethernet queue priority flow control",
    6848                 :            :         .tokens = {
    6849                 :            :                 (void *)&cmd_q_pfc_set_set,
    6850                 :            :                 (void *)&cmd_q_pfc_set_flow_ctrl,
    6851                 :            :                 (void *)&cmd_q_pfc_set_portid,
    6852                 :            :                 (void *)&cmd_q_pfc_set_rx,
    6853                 :            :                 (void *)&cmd_q_pfc_set_rx_mode,
    6854                 :            :                 (void *)&cmd_q_pfc_set_tx_qid,
    6855                 :            :                 (void *)&cmd_q_pfc_set_tx_tc,
    6856                 :            :                 (void *)&cmd_q_pfc_set_tx,
    6857                 :            :                 (void *)&cmd_q_pfc_set_tx_mode,
    6858                 :            :                 (void *)&cmd_q_pfc_set_rx_qid,
    6859                 :            :                 (void *)&cmd_q_pfc_set_rx_tc,
    6860                 :            :                 (void *)&cmd_q_pfc_set_pause_time,
    6861                 :            :                 NULL,
    6862                 :            :         },
    6863                 :            : };
    6864                 :            : 
    6865                 :            : /* *** RESET CONFIGURATION *** */
    6866                 :            : struct cmd_reset_result {
    6867                 :            :         cmdline_fixed_string_t reset;
    6868                 :            :         cmdline_fixed_string_t def;
    6869                 :            : };
    6870                 :            : 
    6871                 :          0 : static void cmd_reset_parsed(__rte_unused void *parsed_result,
    6872                 :            :                              struct cmdline *cl,
    6873                 :            :                              __rte_unused void *data)
    6874                 :            : {
    6875                 :          0 :         cmdline_printf(cl, "Reset to default forwarding configuration...\n");
    6876                 :          0 :         set_def_fwd_config();
    6877                 :          0 : }
    6878                 :            : 
    6879                 :            : static cmdline_parse_token_string_t cmd_reset_set =
    6880                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
    6881                 :            : static cmdline_parse_token_string_t cmd_reset_def =
    6882                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
    6883                 :            :                                  "default");
    6884                 :            : 
    6885                 :            : static cmdline_parse_inst_t cmd_reset = {
    6886                 :            :         .f = cmd_reset_parsed,
    6887                 :            :         .data = NULL,
    6888                 :            :         .help_str = "set default: Reset default forwarding configuration",
    6889                 :            :         .tokens = {
    6890                 :            :                 (void *)&cmd_reset_set,
    6891                 :            :                 (void *)&cmd_reset_def,
    6892                 :            :                 NULL,
    6893                 :            :         },
    6894                 :            : };
    6895                 :            : 
    6896                 :            : /* *** START FORWARDING *** */
    6897                 :            : struct cmd_start_result {
    6898                 :            :         cmdline_fixed_string_t start;
    6899                 :            : };
    6900                 :            : 
    6901                 :            : static cmdline_parse_token_string_t cmd_start_start =
    6902                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
    6903                 :            : 
    6904                 :          0 : static void cmd_start_parsed(__rte_unused void *parsed_result,
    6905                 :            :                              __rte_unused struct cmdline *cl,
    6906                 :            :                              __rte_unused void *data)
    6907                 :            : {
    6908                 :          0 :         start_packet_forwarding(0);
    6909                 :          0 : }
    6910                 :            : 
    6911                 :            : static cmdline_parse_inst_t cmd_start = {
    6912                 :            :         .f = cmd_start_parsed,
    6913                 :            :         .data = NULL,
    6914                 :            :         .help_str = "start: Start packet forwarding",
    6915                 :            :         .tokens = {
    6916                 :            :                 (void *)&cmd_start_start,
    6917                 :            :                 NULL,
    6918                 :            :         },
    6919                 :            : };
    6920                 :            : 
    6921                 :            : /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
    6922                 :            : struct cmd_start_tx_first_result {
    6923                 :            :         cmdline_fixed_string_t start;
    6924                 :            :         cmdline_fixed_string_t tx_first;
    6925                 :            : };
    6926                 :            : 
    6927                 :            : static void
    6928                 :          0 : cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
    6929                 :            :                           __rte_unused struct cmdline *cl,
    6930                 :            :                           __rte_unused void *data)
    6931                 :            : {
    6932                 :          0 :         start_packet_forwarding(1);
    6933                 :          0 : }
    6934                 :            : 
    6935                 :            : static cmdline_parse_token_string_t cmd_start_tx_first_start =
    6936                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
    6937                 :            :                                  "start");
    6938                 :            : static cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
    6939                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
    6940                 :            :                                  tx_first, "tx_first");
    6941                 :            : 
    6942                 :            : static cmdline_parse_inst_t cmd_start_tx_first = {
    6943                 :            :         .f = cmd_start_tx_first_parsed,
    6944                 :            :         .data = NULL,
    6945                 :            :         .help_str = "start tx_first: Start packet forwarding, "
    6946                 :            :                 "after sending 1 burst of packets",
    6947                 :            :         .tokens = {
    6948                 :            :                 (void *)&cmd_start_tx_first_start,
    6949                 :            :                 (void *)&cmd_start_tx_first_tx_first,
    6950                 :            :                 NULL,
    6951                 :            :         },
    6952                 :            : };
    6953                 :            : 
    6954                 :            : /* *** START FORWARDING WITH N TX BURST FIRST *** */
    6955                 :            : struct cmd_start_tx_first_n_result {
    6956                 :            :         cmdline_fixed_string_t start;
    6957                 :            :         cmdline_fixed_string_t tx_first;
    6958                 :            :         uint32_t tx_num;
    6959                 :            : };
    6960                 :            : 
    6961                 :            : static void
    6962                 :          0 : cmd_start_tx_first_n_parsed(void *parsed_result,
    6963                 :            :                           __rte_unused struct cmdline *cl,
    6964                 :            :                           __rte_unused void *data)
    6965                 :            : {
    6966                 :            :         struct cmd_start_tx_first_n_result *res = parsed_result;
    6967                 :            : 
    6968                 :          0 :         start_packet_forwarding(res->tx_num);
    6969                 :          0 : }
    6970                 :            : 
    6971                 :            : static cmdline_parse_token_string_t cmd_start_tx_first_n_start =
    6972                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
    6973                 :            :                         start, "start");
    6974                 :            : static cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
    6975                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
    6976                 :            :                         tx_first, "tx_first");
    6977                 :            : static cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
    6978                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
    6979                 :            :                         tx_num, RTE_UINT32);
    6980                 :            : 
    6981                 :            : static cmdline_parse_inst_t cmd_start_tx_first_n = {
    6982                 :            :         .f = cmd_start_tx_first_n_parsed,
    6983                 :            :         .data = NULL,
    6984                 :            :         .help_str = "start tx_first <num>: "
    6985                 :            :                 "packet forwarding, after sending <num> bursts of packets",
    6986                 :            :         .tokens = {
    6987                 :            :                 (void *)&cmd_start_tx_first_n_start,
    6988                 :            :                 (void *)&cmd_start_tx_first_n_tx_first,
    6989                 :            :                 (void *)&cmd_start_tx_first_n_tx_num,
    6990                 :            :                 NULL,
    6991                 :            :         },
    6992                 :            : };
    6993                 :            : 
    6994                 :            : /* *** SET LINK UP *** */
    6995                 :            : struct cmd_set_link_up_result {
    6996                 :            :         cmdline_fixed_string_t set;
    6997                 :            :         cmdline_fixed_string_t link_up;
    6998                 :            :         cmdline_fixed_string_t port;
    6999                 :            :         portid_t port_id;
    7000                 :            : };
    7001                 :            : 
    7002                 :            : static cmdline_parse_token_string_t cmd_set_link_up_set =
    7003                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
    7004                 :            : static cmdline_parse_token_string_t cmd_set_link_up_link_up =
    7005                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
    7006                 :            :                                 "link-up");
    7007                 :            : static cmdline_parse_token_string_t cmd_set_link_up_port =
    7008                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
    7009                 :            : static cmdline_parse_token_num_t cmd_set_link_up_port_id =
    7010                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id,
    7011                 :            :                                 RTE_UINT16);
    7012                 :            : 
    7013                 :          0 : static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
    7014                 :            :                              __rte_unused struct cmdline *cl,
    7015                 :            :                              __rte_unused void *data)
    7016                 :            : {
    7017                 :            :         struct cmd_set_link_up_result *res = parsed_result;
    7018                 :          0 :         dev_set_link_up(res->port_id);
    7019                 :          0 : }
    7020                 :            : 
    7021                 :            : static cmdline_parse_inst_t cmd_set_link_up = {
    7022                 :            :         .f = cmd_set_link_up_parsed,
    7023                 :            :         .data = NULL,
    7024                 :            :         .help_str = "set link-up port <port id>",
    7025                 :            :         .tokens = {
    7026                 :            :                 (void *)&cmd_set_link_up_set,
    7027                 :            :                 (void *)&cmd_set_link_up_link_up,
    7028                 :            :                 (void *)&cmd_set_link_up_port,
    7029                 :            :                 (void *)&cmd_set_link_up_port_id,
    7030                 :            :                 NULL,
    7031                 :            :         },
    7032                 :            : };
    7033                 :            : 
    7034                 :            : /* *** SET LINK DOWN *** */
    7035                 :            : struct cmd_set_link_down_result {
    7036                 :            :         cmdline_fixed_string_t set;
    7037                 :            :         cmdline_fixed_string_t link_down;
    7038                 :            :         cmdline_fixed_string_t port;
    7039                 :            :         portid_t port_id;
    7040                 :            : };
    7041                 :            : 
    7042                 :            : static cmdline_parse_token_string_t cmd_set_link_down_set =
    7043                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
    7044                 :            : static cmdline_parse_token_string_t cmd_set_link_down_link_down =
    7045                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
    7046                 :            :                                 "link-down");
    7047                 :            : static cmdline_parse_token_string_t cmd_set_link_down_port =
    7048                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
    7049                 :            : static cmdline_parse_token_num_t cmd_set_link_down_port_id =
    7050                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id,
    7051                 :            :                                 RTE_UINT16);
    7052                 :            : 
    7053                 :          0 : static void cmd_set_link_down_parsed(
    7054                 :            :                                 __rte_unused void *parsed_result,
    7055                 :            :                                 __rte_unused struct cmdline *cl,
    7056                 :            :                                 __rte_unused void *data)
    7057                 :            : {
    7058                 :            :         struct cmd_set_link_down_result *res = parsed_result;
    7059                 :          0 :         dev_set_link_down(res->port_id);
    7060                 :          0 : }
    7061                 :            : 
    7062                 :            : static cmdline_parse_inst_t cmd_set_link_down = {
    7063                 :            :         .f = cmd_set_link_down_parsed,
    7064                 :            :         .data = NULL,
    7065                 :            :         .help_str = "set link-down port <port id>",
    7066                 :            :         .tokens = {
    7067                 :            :                 (void *)&cmd_set_link_down_set,
    7068                 :            :                 (void *)&cmd_set_link_down_link_down,
    7069                 :            :                 (void *)&cmd_set_link_down_port,
    7070                 :            :                 (void *)&cmd_set_link_down_port_id,
    7071                 :            :                 NULL,
    7072                 :            :         },
    7073                 :            : };
    7074                 :            : 
    7075                 :            : /* *** SHOW CFG *** */
    7076                 :            : struct cmd_showcfg_result {
    7077                 :            :         cmdline_fixed_string_t show;
    7078                 :            :         cmdline_fixed_string_t cfg;
    7079                 :            :         cmdline_fixed_string_t what;
    7080                 :            : };
    7081                 :            : 
    7082                 :          0 : static void cmd_showcfg_parsed(void *parsed_result,
    7083                 :            :                                __rte_unused struct cmdline *cl,
    7084                 :            :                                __rte_unused void *data)
    7085                 :            : {
    7086                 :            :         struct cmd_showcfg_result *res = parsed_result;
    7087                 :          0 :         if (!strcmp(res->what, "rxtx"))
    7088                 :          0 :                 rxtx_config_display();
    7089                 :          0 :         else if (!strcmp(res->what, "cores"))
    7090                 :          0 :                 fwd_lcores_config_display();
    7091                 :          0 :         else if (!strcmp(res->what, "fwd"))
    7092                 :          0 :                 pkt_fwd_config_display(&cur_fwd_config);
    7093                 :          0 :         else if (!strcmp(res->what, "rxoffs"))
    7094                 :          0 :                 show_rx_pkt_offsets();
    7095                 :          0 :         else if (!strcmp(res->what, "rxpkts"))
    7096                 :          0 :                 show_rx_pkt_segments();
    7097                 :          0 :         else if (!strcmp(res->what, "rxhdrs"))
    7098                 :          0 :                 show_rx_pkt_hdrs();
    7099                 :          0 :         else if (!strcmp(res->what, "txpkts"))
    7100                 :          0 :                 show_tx_pkt_segments();
    7101                 :          0 :         else if (!strcmp(res->what, "txtimes"))
    7102                 :          0 :                 show_tx_pkt_times();
    7103                 :          0 : }
    7104                 :            : 
    7105                 :            : static cmdline_parse_token_string_t cmd_showcfg_show =
    7106                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
    7107                 :            : static cmdline_parse_token_string_t cmd_showcfg_port =
    7108                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
    7109                 :            : static cmdline_parse_token_string_t cmd_showcfg_what =
    7110                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
    7111                 :            :                                  "rxtx#cores#fwd#rxoffs#rxpkts#rxhdrs#txpkts#txtimes");
    7112                 :            : 
    7113                 :            : static cmdline_parse_inst_t cmd_showcfg = {
    7114                 :            :         .f = cmd_showcfg_parsed,
    7115                 :            :         .data = NULL,
    7116                 :            :         .help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|rxhdrs|txpkts|txtimes",
    7117                 :            :         .tokens = {
    7118                 :            :                 (void *)&cmd_showcfg_show,
    7119                 :            :                 (void *)&cmd_showcfg_port,
    7120                 :            :                 (void *)&cmd_showcfg_what,
    7121                 :            :                 NULL,
    7122                 :            :         },
    7123                 :            : };
    7124                 :            : 
    7125                 :            : /* *** SHOW ALL PORT INFO *** */
    7126                 :            : struct cmd_showportall_result {
    7127                 :            :         cmdline_fixed_string_t show;
    7128                 :            :         cmdline_fixed_string_t port;
    7129                 :            :         cmdline_fixed_string_t what;
    7130                 :            :         cmdline_fixed_string_t all;
    7131                 :            : };
    7132                 :            : 
    7133                 :          0 : static void cmd_showportall_parsed(void *parsed_result,
    7134                 :            :                                 __rte_unused struct cmdline *cl,
    7135                 :            :                                 __rte_unused void *data)
    7136                 :            : {
    7137                 :            :         portid_t i;
    7138                 :            : 
    7139                 :            :         struct cmd_showportall_result *res = parsed_result;
    7140                 :          0 :         if (!strcmp(res->show, "clear")) {
    7141                 :          0 :                 if (!strcmp(res->what, "stats"))
    7142                 :          0 :                         RTE_ETH_FOREACH_DEV(i)
    7143                 :          0 :                                 nic_stats_clear(i);
    7144                 :          0 :                 else if (!strcmp(res->what, "xstats"))
    7145                 :          0 :                         RTE_ETH_FOREACH_DEV(i)
    7146                 :          0 :                                 nic_xstats_clear(i);
    7147                 :          0 :         } else if (!strcmp(res->what, "info"))
    7148                 :          0 :                 RTE_ETH_FOREACH_DEV(i)
    7149                 :          0 :                         port_infos_display(i);
    7150                 :          0 :         else if (!strcmp(res->what, "summary")) {
    7151                 :          0 :                 port_summary_header_display();
    7152                 :          0 :                 RTE_ETH_FOREACH_DEV(i)
    7153                 :          0 :                         port_summary_display(i);
    7154                 :            :         }
    7155                 :          0 :         else if (!strcmp(res->what, "stats"))
    7156                 :          0 :                 RTE_ETH_FOREACH_DEV(i)
    7157                 :          0 :                         nic_stats_display(i);
    7158                 :          0 :         else if (!strcmp(res->what, "xstats"))
    7159                 :          0 :                 RTE_ETH_FOREACH_DEV(i)
    7160                 :          0 :                         nic_xstats_display(i);
    7161                 :            : #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
    7162                 :          0 :         else if (!strcmp(res->what, "fdir"))
    7163                 :          0 :                 RTE_ETH_FOREACH_DEV(i)
    7164                 :          0 :                         fdir_get_infos(i);
    7165                 :            : #endif
    7166                 :          0 :         else if (!strcmp(res->what, "dcb_tc"))
    7167                 :          0 :                 RTE_ETH_FOREACH_DEV(i)
    7168                 :          0 :                         port_dcb_info_display(i);
    7169                 :          0 : }
    7170                 :            : 
    7171                 :            : static cmdline_parse_token_string_t cmd_showportall_show =
    7172                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
    7173                 :            :                                  "show#clear");
    7174                 :            : static cmdline_parse_token_string_t cmd_showportall_port =
    7175                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
    7176                 :            : static cmdline_parse_token_string_t cmd_showportall_what =
    7177                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
    7178                 :            :                                  "info#summary#stats#xstats#fdir#dcb_tc");
    7179                 :            : static cmdline_parse_token_string_t cmd_showportall_all =
    7180                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
    7181                 :            : static cmdline_parse_inst_t cmd_showportall = {
    7182                 :            :         .f = cmd_showportall_parsed,
    7183                 :            :         .data = NULL,
    7184                 :            :         .help_str = "show|clear port "
    7185                 :            :                 "info|summary|stats|xstats|fdir|dcb_tc all",
    7186                 :            :         .tokens = {
    7187                 :            :                 (void *)&cmd_showportall_show,
    7188                 :            :                 (void *)&cmd_showportall_port,
    7189                 :            :                 (void *)&cmd_showportall_what,
    7190                 :            :                 (void *)&cmd_showportall_all,
    7191                 :            :                 NULL,
    7192                 :            :         },
    7193                 :            : };
    7194                 :            : 
    7195                 :            : /* *** SHOW PORT INFO *** */
    7196                 :            : struct cmd_showport_result {
    7197                 :            :         cmdline_fixed_string_t show;
    7198                 :            :         cmdline_fixed_string_t port;
    7199                 :            :         cmdline_fixed_string_t what;
    7200                 :            :         uint16_t portnum;
    7201                 :            : };
    7202                 :            : 
    7203                 :          0 : static void cmd_showport_parsed(void *parsed_result,
    7204                 :            :                                 __rte_unused struct cmdline *cl,
    7205                 :            :                                 __rte_unused void *data)
    7206                 :            : {
    7207                 :            :         struct cmd_showport_result *res = parsed_result;
    7208                 :          0 :         if (!strcmp(res->show, "clear")) {
    7209                 :          0 :                 if (!strcmp(res->what, "stats"))
    7210                 :          0 :                         nic_stats_clear(res->portnum);
    7211                 :          0 :                 else if (!strcmp(res->what, "xstats"))
    7212                 :          0 :                         nic_xstats_clear(res->portnum);
    7213                 :          0 :         } else if (!strcmp(res->what, "info"))
    7214                 :          0 :                 port_infos_display(res->portnum);
    7215                 :          0 :         else if (!strcmp(res->what, "summary")) {
    7216                 :          0 :                 port_summary_header_display();
    7217                 :          0 :                 port_summary_display(res->portnum);
    7218                 :            :         }
    7219                 :          0 :         else if (!strcmp(res->what, "stats"))
    7220                 :          0 :                 nic_stats_display(res->portnum);
    7221                 :          0 :         else if (!strcmp(res->what, "xstats"))
    7222                 :          0 :                 nic_xstats_display(res->portnum);
    7223                 :            : #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
    7224                 :          0 :         else if (!strcmp(res->what, "fdir"))
    7225                 :          0 :                  fdir_get_infos(res->portnum);
    7226                 :            : #endif
    7227                 :          0 :         else if (!strcmp(res->what, "dcb_tc"))
    7228                 :          0 :                 port_dcb_info_display(res->portnum);
    7229                 :          0 : }
    7230                 :            : 
    7231                 :            : static cmdline_parse_token_string_t cmd_showport_show =
    7232                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
    7233                 :            :                                  "show#clear");
    7234                 :            : static cmdline_parse_token_string_t cmd_showport_port =
    7235                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
    7236                 :            : static cmdline_parse_token_string_t cmd_showport_what =
    7237                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
    7238                 :            :                                  "info#summary#stats#xstats#fdir#dcb_tc");
    7239                 :            : static cmdline_parse_token_num_t cmd_showport_portnum =
    7240                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, RTE_UINT16);
    7241                 :            : 
    7242                 :            : static cmdline_parse_inst_t cmd_showport = {
    7243                 :            :         .f = cmd_showport_parsed,
    7244                 :            :         .data = NULL,
    7245                 :            :         .help_str = "show|clear port "
    7246                 :            :                 "info|summary|stats|xstats|fdir|dcb_tc "
    7247                 :            :                 "<port_id>",
    7248                 :            :         .tokens = {
    7249                 :            :                 (void *)&cmd_showport_show,
    7250                 :            :                 (void *)&cmd_showport_port,
    7251                 :            :                 (void *)&cmd_showport_what,
    7252                 :            :                 (void *)&cmd_showport_portnum,
    7253                 :            :                 NULL,
    7254                 :            :         },
    7255                 :            : };
    7256                 :            : 
    7257                 :            : /* *** show port representors information *** */
    7258                 :            : struct cmd_representor_info_result {
    7259                 :            :         cmdline_fixed_string_t cmd_show;
    7260                 :            :         cmdline_fixed_string_t cmd_port;
    7261                 :            :         cmdline_fixed_string_t cmd_info;
    7262                 :            :         cmdline_fixed_string_t cmd_keyword;
    7263                 :            :         portid_t cmd_pid;
    7264                 :            : };
    7265                 :            : 
    7266                 :            : static void
    7267                 :          0 : cmd_representor_info_parsed(void *parsed_result,
    7268                 :            :                 __rte_unused struct cmdline *cl,
    7269                 :            :                 __rte_unused void *data)
    7270                 :            : {
    7271                 :            :         struct cmd_representor_info_result *res = parsed_result;
    7272                 :            :         struct rte_eth_representor_info *info;
    7273                 :            :         struct rte_eth_representor_range *range;
    7274                 :            :         uint32_t range_diff;
    7275                 :            :         uint32_t i;
    7276                 :            :         int ret;
    7277                 :            :         int num;
    7278                 :            : 
    7279                 :          0 :         if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
    7280                 :          0 :                 fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
    7281                 :          0 :                 return;
    7282                 :            :         }
    7283                 :            : 
    7284                 :          0 :         ret = rte_eth_representor_info_get(res->cmd_pid, NULL);
    7285                 :          0 :         if (ret < 0) {
    7286                 :          0 :                 fprintf(stderr,
    7287                 :            :                         "Failed to get the number of representor info ranges for port %hu: %s\n",
    7288                 :          0 :                         res->cmd_pid, rte_strerror(-ret));
    7289                 :          0 :                 return;
    7290                 :            :         }
    7291                 :            :         num = ret;
    7292                 :            : 
    7293                 :          0 :         info = calloc(1, sizeof(*info) + num * sizeof(info->ranges[0]));
    7294                 :          0 :         if (info == NULL) {
    7295                 :          0 :                 fprintf(stderr,
    7296                 :            :                         "Failed to allocate memory for representor info for port %hu\n",
    7297                 :          0 :                         res->cmd_pid);
    7298                 :          0 :                 return;
    7299                 :            :         }
    7300                 :          0 :         info->nb_ranges_alloc = num;
    7301                 :            : 
    7302                 :          0 :         ret = rte_eth_representor_info_get(res->cmd_pid, info);
    7303                 :          0 :         if (ret < 0) {
    7304                 :          0 :                 fprintf(stderr,
    7305                 :            :                         "Failed to get the representor info for port %hu: %s\n",
    7306                 :          0 :                         res->cmd_pid, rte_strerror(-ret));
    7307                 :          0 :                 free(info);
    7308                 :          0 :                 return;
    7309                 :            :         }
    7310                 :            : 
    7311                 :          0 :         printf("Port controller: %hu\n", info->controller);
    7312                 :          0 :         printf("Port PF: %hu\n", info->pf);
    7313                 :            : 
    7314                 :          0 :         printf("Ranges: %u\n", info->nb_ranges);
    7315                 :          0 :         for (i = 0; i < info->nb_ranges; i++) {
    7316                 :            :                 range = &info->ranges[i];
    7317                 :          0 :                 range_diff = range->id_end - range->id_base;
    7318                 :            : 
    7319                 :          0 :                 printf("%u. ", i + 1);
    7320                 :          0 :                 printf("'%s' ", range->name);
    7321                 :          0 :                 if (range_diff > 0)
    7322                 :          0 :                         printf("[%u-%u]: ", range->id_base, range->id_end);
    7323                 :            :                 else
    7324                 :          0 :                         printf("[%u]: ", range->id_base);
    7325                 :            : 
    7326                 :          0 :                 printf("Controller %d, PF %d", range->controller, range->pf);
    7327                 :            : 
    7328                 :          0 :                 switch (range->type) {
    7329                 :            :                 case RTE_ETH_REPRESENTOR_NONE:
    7330                 :            :                         printf(", NONE\n");
    7331                 :            :                         break;
    7332                 :          0 :                 case RTE_ETH_REPRESENTOR_VF:
    7333                 :          0 :                         if (range_diff > 0)
    7334                 :          0 :                                 printf(", VF %d..%d\n", range->vf,
    7335                 :          0 :                                        range->vf + range_diff);
    7336                 :            :                         else
    7337                 :          0 :                                 printf(", VF %d\n", range->vf);
    7338                 :            :                         break;
    7339                 :          0 :                 case RTE_ETH_REPRESENTOR_SF:
    7340                 :          0 :                         printf(", SF %d\n", range->sf);
    7341                 :            :                         break;
    7342                 :          0 :                 case RTE_ETH_REPRESENTOR_PF:
    7343                 :          0 :                         if (range_diff > 0)
    7344                 :          0 :                                 printf("..%d\n", range->pf + range_diff);
    7345                 :            :                         else
    7346                 :            :                                 printf("\n");
    7347                 :            :                         break;
    7348                 :          0 :                 default:
    7349                 :            :                         printf(", UNKNOWN TYPE %d\n", range->type);
    7350                 :            :                         break;
    7351                 :            :                 }
    7352                 :            :         }
    7353                 :            : 
    7354                 :          0 :         free(info);
    7355                 :            : }
    7356                 :            : 
    7357                 :            : static cmdline_parse_token_string_t cmd_representor_info_show =
    7358                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
    7359                 :            :                         cmd_show, "show");
    7360                 :            : static cmdline_parse_token_string_t cmd_representor_info_port =
    7361                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
    7362                 :            :                         cmd_port, "port");
    7363                 :            : static cmdline_parse_token_string_t cmd_representor_info_info =
    7364                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
    7365                 :            :                         cmd_info, "info");
    7366                 :            : static cmdline_parse_token_num_t cmd_representor_info_pid =
    7367                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_representor_info_result,
    7368                 :            :                         cmd_pid, RTE_UINT16);
    7369                 :            : static cmdline_parse_token_string_t cmd_representor_info_keyword =
    7370                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
    7371                 :            :                         cmd_keyword, "representor");
    7372                 :            : 
    7373                 :            : static cmdline_parse_inst_t cmd_representor_info = {
    7374                 :            :         .f = cmd_representor_info_parsed,
    7375                 :            :         .data = NULL,
    7376                 :            :         .help_str = "show port info <port_id> representor",
    7377                 :            :         .tokens = {
    7378                 :            :                 (void *)&cmd_representor_info_show,
    7379                 :            :                 (void *)&cmd_representor_info_port,
    7380                 :            :                 (void *)&cmd_representor_info_info,
    7381                 :            :                 (void *)&cmd_representor_info_pid,
    7382                 :            :                 (void *)&cmd_representor_info_keyword,
    7383                 :            :                 NULL,
    7384                 :            :         },
    7385                 :            : };
    7386                 :            : 
    7387                 :            : 
    7388                 :            : /* *** SHOW DEVICE INFO *** */
    7389                 :            : struct cmd_showdevice_result {
    7390                 :            :         cmdline_fixed_string_t show;
    7391                 :            :         cmdline_fixed_string_t device;
    7392                 :            :         cmdline_fixed_string_t what;
    7393                 :            :         cmdline_fixed_string_t identifier;
    7394                 :            : };
    7395                 :            : 
    7396                 :          0 : static void cmd_showdevice_parsed(void *parsed_result,
    7397                 :            :                                 __rte_unused struct cmdline *cl,
    7398                 :            :                                 __rte_unused void *data)
    7399                 :            : {
    7400                 :            :         struct cmd_showdevice_result *res = parsed_result;
    7401                 :          0 :         if (!strcmp(res->what, "info")) {
    7402                 :          0 :                 if (!strcmp(res->identifier, "all"))
    7403                 :          0 :                         device_infos_display(NULL);
    7404                 :            :                 else
    7405                 :          0 :                         device_infos_display(res->identifier);
    7406                 :            :         }
    7407                 :          0 : }
    7408                 :            : 
    7409                 :            : static cmdline_parse_token_string_t cmd_showdevice_show =
    7410                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
    7411                 :            :                                  "show");
    7412                 :            : static cmdline_parse_token_string_t cmd_showdevice_device =
    7413                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
    7414                 :            : static cmdline_parse_token_string_t cmd_showdevice_what =
    7415                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
    7416                 :            :                                  "info");
    7417                 :            : static cmdline_parse_token_string_t cmd_showdevice_identifier =
    7418                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
    7419                 :            :                         identifier, NULL);
    7420                 :            : 
    7421                 :            : static cmdline_parse_inst_t cmd_showdevice = {
    7422                 :            :         .f = cmd_showdevice_parsed,
    7423                 :            :         .data = NULL,
    7424                 :            :         .help_str = "show device info <identifier>|all",
    7425                 :            :         .tokens = {
    7426                 :            :                 (void *)&cmd_showdevice_show,
    7427                 :            :                 (void *)&cmd_showdevice_device,
    7428                 :            :                 (void *)&cmd_showdevice_what,
    7429                 :            :                 (void *)&cmd_showdevice_identifier,
    7430                 :            :                 NULL,
    7431                 :            :         },
    7432                 :            : };
    7433                 :            : 
    7434                 :            : /* *** SHOW MODULE EEPROM/EEPROM port INFO *** */
    7435                 :            : struct cmd_showeeprom_result {
    7436                 :            :         cmdline_fixed_string_t show;
    7437                 :            :         cmdline_fixed_string_t port;
    7438                 :            :         uint16_t portnum;
    7439                 :            :         cmdline_fixed_string_t type;
    7440                 :            : };
    7441                 :            : 
    7442                 :          0 : static void cmd_showeeprom_parsed(void *parsed_result,
    7443                 :            :                 __rte_unused struct cmdline *cl,
    7444                 :            :                 __rte_unused void *data)
    7445                 :            : {
    7446                 :            :         struct cmd_showeeprom_result *res = parsed_result;
    7447                 :            : 
    7448                 :          0 :         if (!strcmp(res->type, "eeprom"))
    7449                 :          0 :                 port_eeprom_display(res->portnum);
    7450                 :          0 :         else if (!strcmp(res->type, "module_eeprom"))
    7451                 :          0 :                 port_module_eeprom_display(res->portnum);
    7452                 :            :         else
    7453                 :          0 :                 fprintf(stderr, "Unknown argument\n");
    7454                 :          0 : }
    7455                 :            : 
    7456                 :            : static cmdline_parse_token_string_t cmd_showeeprom_show =
    7457                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, show, "show");
    7458                 :            : static cmdline_parse_token_string_t cmd_showeeprom_port =
    7459                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, port, "port");
    7460                 :            : static cmdline_parse_token_num_t cmd_showeeprom_portnum =
    7461                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_result, portnum,
    7462                 :            :                         RTE_UINT16);
    7463                 :            : static cmdline_parse_token_string_t cmd_showeeprom_type =
    7464                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, type, "module_eeprom#eeprom");
    7465                 :            : 
    7466                 :            : static cmdline_parse_inst_t cmd_showeeprom = {
    7467                 :            :         .f = cmd_showeeprom_parsed,
    7468                 :            :         .data = NULL,
    7469                 :            :         .help_str = "show port <port_id> module_eeprom|eeprom",
    7470                 :            :         .tokens = {
    7471                 :            :                 (void *)&cmd_showeeprom_show,
    7472                 :            :                 (void *)&cmd_showeeprom_port,
    7473                 :            :                 (void *)&cmd_showeeprom_portnum,
    7474                 :            :                 (void *)&cmd_showeeprom_type,
    7475                 :            :                 NULL,
    7476                 :            :         },
    7477                 :            : };
    7478                 :            : 
    7479                 :            : /* *** SET PORT EEPROM *** */
    7480                 :            : struct cmd_seteeprom_result {
    7481                 :            :         cmdline_fixed_string_t set;
    7482                 :            :         cmdline_fixed_string_t port;
    7483                 :            :         uint16_t portnum;
    7484                 :            :         cmdline_fixed_string_t eeprom;
    7485                 :            :         cmdline_fixed_string_t confirm_str;
    7486                 :            :         cmdline_fixed_string_t magic_str;
    7487                 :            :         uint32_t magic;
    7488                 :            :         cmdline_fixed_string_t value;
    7489                 :            :         cmdline_multi_string_t token_str;
    7490                 :            : };
    7491                 :            : 
    7492                 :          0 : static void cmd_seteeprom_parsed(void *parsed_result,
    7493                 :            :                 __rte_unused struct cmdline *cl,
    7494                 :            :                 __rte_unused void *data)
    7495                 :            : {
    7496                 :            :         struct cmd_seteeprom_result *res = parsed_result;
    7497                 :            :         uint32_t offset = 0;
    7498                 :            :         uint32_t length;
    7499                 :            :         uint8_t *value;
    7500                 :            :         char *token_str;
    7501                 :            :         char *token;
    7502                 :            : 
    7503                 :          0 :         token_str = res->token_str;
    7504                 :          0 :         token = strtok_r(token_str, " \f\n\r\t\v", &token_str);
    7505                 :            : 
    7506                 :            :         /* Parse Hex string to Byte data */
    7507                 :          0 :         if (strlen(token) % 2 != 0) {
    7508                 :          0 :                 fprintf(stderr, "Bad Argument: %s\nHex string must be in multiples of 2 Bytes\n",
    7509                 :            :                         token);
    7510                 :          0 :                 return;
    7511                 :            :         }
    7512                 :            : 
    7513                 :          0 :         length = strlen(token) / 2;
    7514                 :          0 :         value = calloc(length, sizeof(uint8_t));
    7515                 :          0 :         for (int count = 0; count < (int)(length); count++) {
    7516                 :          0 :                 if (sscanf(token, "%2hhx", &value[count]) != 1) {
    7517                 :          0 :                         fprintf(stderr, "Bad Argument: %s\nValue must be a hex string\n",
    7518                 :          0 :                                 token - (count + 1));
    7519                 :          0 :                         goto out;
    7520                 :            :                 }
    7521                 :          0 :                 token += 2;
    7522                 :            :         }
    7523                 :            : 
    7524                 :            :         /* Second token: offset string */
    7525                 :          0 :         token = strtok_r(token_str, " \f\n\r\t\v", &token_str);
    7526                 :          0 :         if (token != NULL) {
    7527                 :          0 :                 if (strcmp(token, "offset") == 0) {
    7528                 :            :                         /* Third token: offset */
    7529                 :          0 :                         token = strtok_r(token_str, " \f\n\r\t\v", &token_str);
    7530                 :          0 :                         if (token == NULL) {
    7531                 :          0 :                                 fprintf(stderr, "No offset specified\n");
    7532                 :          0 :                                 goto out;
    7533                 :            :                         }
    7534                 :            : 
    7535                 :            :                         char *end;
    7536                 :          0 :                         offset = strtoul(token, &end, 10);
    7537                 :          0 :                         if (offset == 0 && strcmp(end, "") != 0) {
    7538                 :          0 :                                 fprintf(stderr, "Bad Argument: %s\n", token);
    7539                 :          0 :                                 goto out;
    7540                 :            :                         }
    7541                 :            :                 } else {
    7542                 :          0 :                         fprintf(stderr, "Bad Argument: %s\n", token);
    7543                 :          0 :                         goto out;
    7544                 :            :                 }
    7545                 :            :         }
    7546                 :            : 
    7547                 :          0 :         port_eeprom_set(res->portnum, res->magic, offset, length, value);
    7548                 :            : 
    7549                 :          0 : out:
    7550                 :          0 :         free(value);
    7551                 :            : }
    7552                 :            : 
    7553                 :            : static cmdline_parse_token_string_t cmd_seteeprom_set =
    7554                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, set, "set");
    7555                 :            : static cmdline_parse_token_string_t cmd_seteeprom_port =
    7556                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, port, "port");
    7557                 :            : static cmdline_parse_token_num_t cmd_seteeprom_portnum =
    7558                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_seteeprom_result, portnum, RTE_UINT16);
    7559                 :            : static cmdline_parse_token_string_t cmd_seteeprom_eeprom =
    7560                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, eeprom, "eeprom");
    7561                 :            : static cmdline_parse_token_string_t cmd_seteeprom_confirm_str =
    7562                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, confirm_str, "accept_risk");
    7563                 :            : static cmdline_parse_token_string_t cmd_seteeprom_magic_str =
    7564                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, magic_str, "magic");
    7565                 :            : static cmdline_parse_token_num_t cmd_seteeprom_magic =
    7566                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_seteeprom_result, magic, RTE_UINT32);
    7567                 :            : static cmdline_parse_token_string_t cmd_seteeprom_value =
    7568                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, value, "value");
    7569                 :            : static cmdline_parse_token_string_t cmd_seteeprom_token_str =
    7570                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, token_str, TOKEN_STRING_MULTI);
    7571                 :            : 
    7572                 :            : static cmdline_parse_inst_t cmd_seteeprom = {
    7573                 :            :         .f = cmd_seteeprom_parsed,
    7574                 :            :         .data = NULL,
    7575                 :            :         .help_str = "set port <port_id> eeprom <accept_risk> magic <magic_num> "
    7576                 :            :                 "value <value> offset <offset>: Set eeprom value for port_id.\n"
    7577                 :            :                 "Note:\n"
    7578                 :            :                 "This is a high-risk command and its misuse may result in "
    7579                 :            :                 "unexpected behaviour from the NIC.\n"
    7580                 :            :                 "By inserting \"accept_risk\" into the command, the user is "
    7581                 :            :                 "acknowledging and taking responsibility for this risk.",
    7582                 :            :         .tokens = {
    7583                 :            :                 (void *)&cmd_seteeprom_set,
    7584                 :            :                 (void *)&cmd_seteeprom_port,
    7585                 :            :                 (void *)&cmd_seteeprom_portnum,
    7586                 :            :                 (void *)&cmd_seteeprom_eeprom,
    7587                 :            :                 (void *)&cmd_seteeprom_confirm_str,
    7588                 :            :                 (void *)&cmd_seteeprom_magic_str,
    7589                 :            :                 (void *)&cmd_seteeprom_magic,
    7590                 :            :                 (void *)&cmd_seteeprom_value,
    7591                 :            :                 (void *)&cmd_seteeprom_token_str,
    7592                 :            :                 NULL,
    7593                 :            :         },
    7594                 :            : };
    7595                 :            : 
    7596                 :            : /* *** SHOW QUEUE INFO *** */
    7597                 :            : struct cmd_showqueue_result {
    7598                 :            :         cmdline_fixed_string_t show;
    7599                 :            :         cmdline_fixed_string_t type;
    7600                 :            :         cmdline_fixed_string_t what;
    7601                 :            :         uint16_t portnum;
    7602                 :            :         uint16_t queuenum;
    7603                 :            : };
    7604                 :            : 
    7605                 :            : static void
    7606                 :          0 : cmd_showqueue_parsed(void *parsed_result,
    7607                 :            :         __rte_unused struct cmdline *cl,
    7608                 :            :         __rte_unused void *data)
    7609                 :            : {
    7610                 :            :         struct cmd_showqueue_result *res = parsed_result;
    7611                 :            : 
    7612                 :          0 :         if (!strcmp(res->type, "rxq"))
    7613                 :          0 :                 rx_queue_infos_display(res->portnum, res->queuenum);
    7614                 :          0 :         else if (!strcmp(res->type, "txq"))
    7615                 :          0 :                 tx_queue_infos_display(res->portnum, res->queuenum);
    7616                 :          0 : }
    7617                 :            : 
    7618                 :            : static cmdline_parse_token_string_t cmd_showqueue_show =
    7619                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
    7620                 :            : static cmdline_parse_token_string_t cmd_showqueue_type =
    7621                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
    7622                 :            : static cmdline_parse_token_string_t cmd_showqueue_what =
    7623                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
    7624                 :            : static cmdline_parse_token_num_t cmd_showqueue_portnum =
    7625                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum,
    7626                 :            :                 RTE_UINT16);
    7627                 :            : static cmdline_parse_token_num_t cmd_showqueue_queuenum =
    7628                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum,
    7629                 :            :                 RTE_UINT16);
    7630                 :            : 
    7631                 :            : static cmdline_parse_inst_t cmd_showqueue = {
    7632                 :            :         .f = cmd_showqueue_parsed,
    7633                 :            :         .data = NULL,
    7634                 :            :         .help_str = "show rxq|txq info <port_id> <queue_id>",
    7635                 :            :         .tokens = {
    7636                 :            :                 (void *)&cmd_showqueue_show,
    7637                 :            :                 (void *)&cmd_showqueue_type,
    7638                 :            :                 (void *)&cmd_showqueue_what,
    7639                 :            :                 (void *)&cmd_showqueue_portnum,
    7640                 :            :                 (void *)&cmd_showqueue_queuenum,
    7641                 :            :                 NULL,
    7642                 :            :         },
    7643                 :            : };
    7644                 :            : 
    7645                 :            : /* show/clear fwd engine statistics */
    7646                 :            : struct fwd_result {
    7647                 :            :         cmdline_fixed_string_t action;
    7648                 :            :         cmdline_fixed_string_t fwd;
    7649                 :            :         cmdline_fixed_string_t stats;
    7650                 :            :         cmdline_fixed_string_t all;
    7651                 :            : };
    7652                 :            : 
    7653                 :            : static cmdline_parse_token_string_t cmd_fwd_action =
    7654                 :            :         TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
    7655                 :            : static cmdline_parse_token_string_t cmd_fwd_fwd =
    7656                 :            :         TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
    7657                 :            : static cmdline_parse_token_string_t cmd_fwd_stats =
    7658                 :            :         TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
    7659                 :            : static cmdline_parse_token_string_t cmd_fwd_all =
    7660                 :            :         TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
    7661                 :            : 
    7662                 :            : static void
    7663                 :          0 : cmd_showfwdall_parsed(void *parsed_result,
    7664                 :            :                       __rte_unused struct cmdline *cl,
    7665                 :            :                       __rte_unused void *data)
    7666                 :            : {
    7667                 :            :         struct fwd_result *res = parsed_result;
    7668                 :            : 
    7669                 :          0 :         if (!strcmp(res->action, "show"))
    7670                 :          0 :                 fwd_stats_display();
    7671                 :            :         else
    7672                 :          0 :                 fwd_stats_reset();
    7673                 :          0 : }
    7674                 :            : 
    7675                 :            : static cmdline_parse_inst_t cmd_showfwdall = {
    7676                 :            :         .f = cmd_showfwdall_parsed,
    7677                 :            :         .data = NULL,
    7678                 :            :         .help_str = "show|clear fwd stats all",
    7679                 :            :         .tokens = {
    7680                 :            :                 (void *)&cmd_fwd_action,
    7681                 :            :                 (void *)&cmd_fwd_fwd,
    7682                 :            :                 (void *)&cmd_fwd_stats,
    7683                 :            :                 (void *)&cmd_fwd_all,
    7684                 :            :                 NULL,
    7685                 :            :         },
    7686                 :            : };
    7687                 :            : 
    7688                 :            : /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
    7689                 :            : struct cmd_read_rxd_txd_result {
    7690                 :            :         cmdline_fixed_string_t read;
    7691                 :            :         cmdline_fixed_string_t rxd_txd;
    7692                 :            :         portid_t port_id;
    7693                 :            :         uint16_t queue_id;
    7694                 :            :         uint16_t desc_id;
    7695                 :            : };
    7696                 :            : 
    7697                 :            : static void
    7698                 :          0 : cmd_read_rxd_txd_parsed(void *parsed_result,
    7699                 :            :                         __rte_unused struct cmdline *cl,
    7700                 :            :                         __rte_unused void *data)
    7701                 :            : {
    7702                 :            :         struct cmd_read_rxd_txd_result *res = parsed_result;
    7703                 :            : 
    7704                 :          0 :         if (!strcmp(res->rxd_txd, "rxd"))
    7705                 :          0 :                 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
    7706                 :          0 :         else if (!strcmp(res->rxd_txd, "txd"))
    7707                 :          0 :                 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
    7708                 :          0 : }
    7709                 :            : 
    7710                 :            : static cmdline_parse_token_string_t cmd_read_rxd_txd_read =
    7711                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
    7712                 :            : static cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
    7713                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
    7714                 :            :                                  "rxd#txd");
    7715                 :            : static cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
    7716                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id,
    7717                 :            :                                  RTE_UINT16);
    7718                 :            : static cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
    7719                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id,
    7720                 :            :                                  RTE_UINT16);
    7721                 :            : static cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
    7722                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id,
    7723                 :            :                                  RTE_UINT16);
    7724                 :            : 
    7725                 :            : static cmdline_parse_inst_t cmd_read_rxd_txd = {
    7726                 :            :         .f = cmd_read_rxd_txd_parsed,
    7727                 :            :         .data = NULL,
    7728                 :            :         .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
    7729                 :            :         .tokens = {
    7730                 :            :                 (void *)&cmd_read_rxd_txd_read,
    7731                 :            :                 (void *)&cmd_read_rxd_txd_rxd_txd,
    7732                 :            :                 (void *)&cmd_read_rxd_txd_port_id,
    7733                 :            :                 (void *)&cmd_read_rxd_txd_queue_id,
    7734                 :            :                 (void *)&cmd_read_rxd_txd_desc_id,
    7735                 :            :                 NULL,
    7736                 :            :         },
    7737                 :            : };
    7738                 :            : 
    7739                 :            : /* *** QUIT *** */
    7740                 :            : struct cmd_quit_result {
    7741                 :            :         cmdline_fixed_string_t quit;
    7742                 :            : };
    7743                 :            : 
    7744                 :          0 : static void cmd_quit_parsed(__rte_unused void *parsed_result,
    7745                 :            :                             struct cmdline *cl,
    7746                 :            :                             __rte_unused void *data)
    7747                 :            : {
    7748                 :          0 :         cmdline_quit(cl);
    7749                 :          0 :         cl_quit = 1;
    7750                 :          0 : }
    7751                 :            : 
    7752                 :            : static cmdline_parse_token_string_t cmd_quit_quit =
    7753                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
    7754                 :            : 
    7755                 :            : static cmdline_parse_inst_t cmd_quit = {
    7756                 :            :         .f = cmd_quit_parsed,
    7757                 :            :         .data = NULL,
    7758                 :            :         .help_str = "quit: Exit application",
    7759                 :            :         .tokens = {
    7760                 :            :                 (void *)&cmd_quit_quit,
    7761                 :            :                 NULL,
    7762                 :            :         },
    7763                 :            : };
    7764                 :            : 
    7765                 :            : /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
    7766                 :            : struct cmd_mac_addr_result {
    7767                 :            :         cmdline_fixed_string_t mac_addr_cmd;
    7768                 :            :         cmdline_fixed_string_t what;
    7769                 :            :         uint16_t port_num;
    7770                 :            :         struct rte_ether_addr address;
    7771                 :            : };
    7772                 :            : 
    7773                 :          0 : static void cmd_mac_addr_parsed(void *parsed_result,
    7774                 :            :                 __rte_unused struct cmdline *cl,
    7775                 :            :                 __rte_unused void *data)
    7776                 :            : {
    7777                 :            :         struct cmd_mac_addr_result *res = parsed_result;
    7778                 :            :         int ret;
    7779                 :            : 
    7780                 :          0 :         if (strcmp(res->what, "add") == 0)
    7781                 :          0 :                 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
    7782                 :          0 :         else if (strcmp(res->what, "set") == 0)
    7783                 :          0 :                 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
    7784                 :            :                                                        &res->address);
    7785                 :            :         else
    7786                 :          0 :                 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
    7787                 :            : 
    7788                 :            :         /* check the return value and print it if is < 0 */
    7789                 :          0 :         if(ret < 0)
    7790                 :          0 :                 fprintf(stderr, "mac_addr_cmd error: (%s)\n", strerror(-ret));
    7791                 :            : 
    7792                 :          0 : }
    7793                 :            : 
    7794                 :            : static cmdline_parse_token_string_t cmd_mac_addr_cmd =
    7795                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
    7796                 :            :                                 "mac_addr");
    7797                 :            : static cmdline_parse_token_string_t cmd_mac_addr_what =
    7798                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
    7799                 :            :                                 "add#remove#set");
    7800                 :            : static cmdline_parse_token_num_t cmd_mac_addr_portnum =
    7801                 :            :                 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
    7802                 :            :                                         RTE_UINT16);
    7803                 :            : static cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
    7804                 :            :                 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
    7805                 :            : 
    7806                 :            : static cmdline_parse_inst_t cmd_mac_addr = {
    7807                 :            :         .f = cmd_mac_addr_parsed,
    7808                 :            :         .data = (void *)0,
    7809                 :            :         .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
    7810                 :            :                         "Add/Remove/Set MAC address on port_id",
    7811                 :            :         .tokens = {
    7812                 :            :                 (void *)&cmd_mac_addr_cmd,
    7813                 :            :                 (void *)&cmd_mac_addr_what,
    7814                 :            :                 (void *)&cmd_mac_addr_portnum,
    7815                 :            :                 (void *)&cmd_mac_addr_addr,
    7816                 :            :                 NULL,
    7817                 :            :         },
    7818                 :            : };
    7819                 :            : 
    7820                 :            : /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
    7821                 :            : struct cmd_eth_peer_result {
    7822                 :            :         cmdline_fixed_string_t set;
    7823                 :            :         cmdline_fixed_string_t eth_peer;
    7824                 :            :         portid_t port_id;
    7825                 :            :         cmdline_fixed_string_t peer_addr;
    7826                 :            : };
    7827                 :            : 
    7828                 :          0 : static void cmd_set_eth_peer_parsed(void *parsed_result,
    7829                 :            :                         __rte_unused struct cmdline *cl,
    7830                 :            :                         __rte_unused void *data)
    7831                 :            : {
    7832                 :            :                 struct cmd_eth_peer_result *res = parsed_result;
    7833                 :            : 
    7834                 :          0 :                 if (test_done == 0) {
    7835                 :          0 :                         fprintf(stderr, "Please stop forwarding first\n");
    7836                 :          0 :                         return;
    7837                 :            :                 }
    7838                 :          0 :                 if (!strcmp(res->eth_peer, "eth-peer")) {
    7839                 :          0 :                         set_fwd_eth_peer(res->port_id, res->peer_addr);
    7840                 :          0 :                         fwd_config_setup();
    7841                 :            :                 }
    7842                 :            : }
    7843                 :            : static cmdline_parse_token_string_t cmd_eth_peer_set =
    7844                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
    7845                 :            : static cmdline_parse_token_string_t cmd_eth_peer =
    7846                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
    7847                 :            : static cmdline_parse_token_num_t cmd_eth_peer_port_id =
    7848                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id,
    7849                 :            :                 RTE_UINT16);
    7850                 :            : static cmdline_parse_token_string_t cmd_eth_peer_addr =
    7851                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
    7852                 :            : 
    7853                 :            : static cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
    7854                 :            :         .f = cmd_set_eth_peer_parsed,
    7855                 :            :         .data = NULL,
    7856                 :            :         .help_str = "set eth-peer <port_id> <peer_mac>",
    7857                 :            :         .tokens = {
    7858                 :            :                 (void *)&cmd_eth_peer_set,
    7859                 :            :                 (void *)&cmd_eth_peer,
    7860                 :            :                 (void *)&cmd_eth_peer_port_id,
    7861                 :            :                 (void *)&cmd_eth_peer_addr,
    7862                 :            :                 NULL,
    7863                 :            :         },
    7864                 :            : };
    7865                 :            : 
    7866                 :            : /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
    7867                 :            : struct cmd_set_qmap_result {
    7868                 :            :         cmdline_fixed_string_t set;
    7869                 :            :         cmdline_fixed_string_t qmap;
    7870                 :            :         cmdline_fixed_string_t what;
    7871                 :            :         portid_t port_id;
    7872                 :            :         uint16_t queue_id;
    7873                 :            :         uint8_t map_value;
    7874                 :            : };
    7875                 :            : 
    7876                 :            : static void
    7877                 :          0 : cmd_set_qmap_parsed(void *parsed_result,
    7878                 :            :                        __rte_unused struct cmdline *cl,
    7879                 :            :                        __rte_unused void *data)
    7880                 :            : {
    7881                 :            :         struct cmd_set_qmap_result *res = parsed_result;
    7882                 :          0 :         int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
    7883                 :            : 
    7884                 :          0 :         set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
    7885                 :          0 : }
    7886                 :            : 
    7887                 :            : static cmdline_parse_token_string_t cmd_setqmap_set =
    7888                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
    7889                 :            :                                  set, "set");
    7890                 :            : static cmdline_parse_token_string_t cmd_setqmap_qmap =
    7891                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
    7892                 :            :                                  qmap, "stat_qmap");
    7893                 :            : static cmdline_parse_token_string_t cmd_setqmap_what =
    7894                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
    7895                 :            :                                  what, "tx#rx");
    7896                 :            : static cmdline_parse_token_num_t cmd_setqmap_portid =
    7897                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
    7898                 :            :                               port_id, RTE_UINT16);
    7899                 :            : static cmdline_parse_token_num_t cmd_setqmap_queueid =
    7900                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
    7901                 :            :                               queue_id, RTE_UINT16);
    7902                 :            : static cmdline_parse_token_num_t cmd_setqmap_mapvalue =
    7903                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
    7904                 :            :                               map_value, RTE_UINT8);
    7905                 :            : 
    7906                 :            : static cmdline_parse_inst_t cmd_set_qmap = {
    7907                 :            :         .f = cmd_set_qmap_parsed,
    7908                 :            :         .data = NULL,
    7909                 :            :         .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
    7910                 :            :                 "Set statistics mapping value on tx|rx queue_id of port_id",
    7911                 :            :         .tokens = {
    7912                 :            :                 (void *)&cmd_setqmap_set,
    7913                 :            :                 (void *)&cmd_setqmap_qmap,
    7914                 :            :                 (void *)&cmd_setqmap_what,
    7915                 :            :                 (void *)&cmd_setqmap_portid,
    7916                 :            :                 (void *)&cmd_setqmap_queueid,
    7917                 :            :                 (void *)&cmd_setqmap_mapvalue,
    7918                 :            :                 NULL,
    7919                 :            :         },
    7920                 :            : };
    7921                 :            : 
    7922                 :            : /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS  DISPLAY *** */
    7923                 :            : struct cmd_set_xstats_hide_zero_result {
    7924                 :            :         cmdline_fixed_string_t keyword;
    7925                 :            :         cmdline_fixed_string_t name;
    7926                 :            :         cmdline_fixed_string_t on_off;
    7927                 :            : };
    7928                 :            : 
    7929                 :            : static void
    7930                 :          0 : cmd_set_xstats_hide_zero_parsed(void *parsed_result,
    7931                 :            :                         __rte_unused struct cmdline *cl,
    7932                 :            :                         __rte_unused void *data)
    7933                 :            : {
    7934                 :            :         struct cmd_set_xstats_hide_zero_result *res;
    7935                 :            :         uint16_t on_off = 0;
    7936                 :            : 
    7937                 :            :         res = parsed_result;
    7938                 :          0 :         on_off = !strcmp(res->on_off, "on") ? 1 : 0;
    7939                 :          0 :         set_xstats_hide_zero(on_off);
    7940                 :          0 : }
    7941                 :            : 
    7942                 :            : static cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
    7943                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
    7944                 :            :                                  keyword, "set");
    7945                 :            : static cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
    7946                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
    7947                 :            :                                  name, "xstats-hide-zero");
    7948                 :            : static cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
    7949                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
    7950                 :            :                                  on_off, "on#off");
    7951                 :            : 
    7952                 :            : static cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
    7953                 :            :         .f = cmd_set_xstats_hide_zero_parsed,
    7954                 :            :         .data = NULL,
    7955                 :            :         .help_str = "set xstats-hide-zero on|off",
    7956                 :            :         .tokens = {
    7957                 :            :                 (void *)&cmd_set_xstats_hide_zero_keyword,
    7958                 :            :                 (void *)&cmd_set_xstats_hide_zero_name,
    7959                 :            :                 (void *)&cmd_set_xstats_hide_zero_on_off,
    7960                 :            :                 NULL,
    7961                 :            :         },
    7962                 :            : };
    7963                 :            : 
    7964                 :            : /* *** SET OPTION TO DISPLAY XSTAT STATE *** */
    7965                 :            : struct cmd_set_xstats_show_state_result {
    7966                 :            :         cmdline_fixed_string_t keyword;
    7967                 :            :         cmdline_fixed_string_t name;
    7968                 :            :         uint8_t on_off;
    7969                 :            : };
    7970                 :            : static void
    7971                 :          0 : cmd_set_xstats_show_state_parsed(void *parsed_result,
    7972                 :            :                         __rte_unused struct cmdline *cl,
    7973                 :            :                         __rte_unused void *data)
    7974                 :            : {
    7975                 :            :         struct cmd_set_xstats_show_state_result *res = parsed_result;
    7976                 :          0 :         set_xstats_show_state(res->on_off);
    7977                 :          0 : }
    7978                 :            : 
    7979                 :            : static cmdline_parse_token_string_t cmd_set_xstats_show_state_keyword =
    7980                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_show_state_result,
    7981                 :            :                                  keyword, "set");
    7982                 :            : static cmdline_parse_token_string_t cmd_set_xstats_show_state_name =
    7983                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_show_state_result,
    7984                 :            :                                  name, "xstats-show-state");
    7985                 :            : static cmdline_parse_token_bool_t cmd_set_xstats_show_state_on_off =
    7986                 :            :         TOKEN_BOOL_INITIALIZER(struct cmd_set_xstats_show_state_result,
    7987                 :            :                                  on_off);
    7988                 :            : 
    7989                 :            : static cmdline_parse_inst_t cmd_set_xstats_show_state = {
    7990                 :            :         .f = cmd_set_xstats_show_state_parsed,
    7991                 :            :         .data = NULL,
    7992                 :            :         .help_str = "set xstats-show-state on|off",
    7993                 :            :         .tokens = {
    7994                 :            :                 (void *)&cmd_set_xstats_show_state_keyword,
    7995                 :            :                 (void *)&cmd_set_xstats_show_state_name,
    7996                 :            :                 (void *)&cmd_set_xstats_show_state_on_off,
    7997                 :            :                 NULL,
    7998                 :            :         },
    7999                 :            : };
    8000                 :            : 
    8001                 :            : /* *** SET OPTION TO HIDE DISABLED XSTAT FOR XSTATS DISPLAY *** */
    8002                 :            : struct cmd_set_xstats_hide_disabled_result {
    8003                 :            :         cmdline_fixed_string_t keyword;
    8004                 :            :         cmdline_fixed_string_t name;
    8005                 :            :         uint8_t on_off;
    8006                 :            : };
    8007                 :            : 
    8008                 :            : static void
    8009                 :          0 : cmd_set_xstats_hide_disabled_parsed(void *parsed_result,
    8010                 :            :                         __rte_unused struct cmdline *cl,
    8011                 :            :                         __rte_unused void *data)
    8012                 :            : {
    8013                 :            :         struct cmd_set_xstats_hide_disabled_result *res = parsed_result;
    8014                 :          0 :         set_xstats_hide_disabled(res->on_off);
    8015                 :          0 : }
    8016                 :            : 
    8017                 :            : static cmdline_parse_token_string_t cmd_set_xstats_hide_disabled_keyword =
    8018                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_disabled_result,
    8019                 :            :                                  keyword, "set");
    8020                 :            : static cmdline_parse_token_string_t cmd_set_xstats_hide_disabled_name =
    8021                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_disabled_result,
    8022                 :            :                                  name, "xstats-hide-disabled");
    8023                 :            : static cmdline_parse_token_bool_t cmd_set_xstats_hide_disabled_on_off =
    8024                 :            :         TOKEN_BOOL_INITIALIZER(struct cmd_set_xstats_hide_disabled_result,
    8025                 :            :                                  on_off);
    8026                 :            : 
    8027                 :            : static cmdline_parse_inst_t cmd_set_xstats_hide_disabled = {
    8028                 :            :         .f = cmd_set_xstats_hide_disabled_parsed,
    8029                 :            :         .data = NULL,
    8030                 :            :         .help_str = "set xstats-hide-disabled on|off",
    8031                 :            :         .tokens = {
    8032                 :            :                 (void *)&cmd_set_xstats_hide_disabled_keyword,
    8033                 :            :                 (void *)&cmd_set_xstats_hide_disabled_name,
    8034                 :            :                 (void *)&cmd_set_xstats_hide_disabled_on_off,
    8035                 :            :                 NULL,
    8036                 :            :         },
    8037                 :            : };
    8038                 :            : 
    8039                 :            : /* *** enable/disable counter by name *** */
    8040                 :            : struct cmd_operate_set_counter_result {
    8041                 :            :         cmdline_fixed_string_t port;
    8042                 :            :         portid_t port_id;
    8043                 :            :         cmdline_fixed_string_t what;
    8044                 :            :         cmdline_multi_string_t counter_name;
    8045                 :            : };
    8046                 :            : 
    8047                 :            : static void
    8048                 :          0 : cmd_operate_set_counter_parsed(void *parsed_result,
    8049                 :            :                                 __rte_unused struct cmdline *cl,
    8050                 :            :                                 __rte_unused void *data)
    8051                 :            : {
    8052                 :            :         struct cmd_operate_set_counter_result *res = parsed_result;
    8053                 :          0 :         uint16_t on_off = strcmp(res->what, "enable") ? 0 : 1;
    8054                 :            : 
    8055                 :          0 :         if ((strcmp(res->port, "port") == 0))
    8056                 :          0 :                 nic_xstats_set_counter(res->port_id, res->counter_name, on_off);
    8057                 :          0 : }
    8058                 :            : 
    8059                 :            : static cmdline_parse_token_string_t cmd_operate_set_counter_port =
    8060                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_operate_set_counter_result,
    8061                 :            :                         port, "port");
    8062                 :            : static cmdline_parse_token_num_t cmd_operate_set_counter_port_id =
    8063                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_operate_set_counter_result,
    8064                 :            :                         port_id, RTE_UINT16);
    8065                 :            : static cmdline_parse_token_string_t cmd_operate_set_counter_what =
    8066                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_operate_set_counter_result,
    8067                 :            :                                  what, "enable#disable");
    8068                 :            : static cmdline_parse_token_string_t cmd_operate_set_counter_name =
    8069                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_operate_set_counter_result,
    8070                 :            :                         counter_name, TOKEN_STRING_MULTI);
    8071                 :            : 
    8072                 :            : static cmdline_parse_inst_t cmd_operate_set_counter = {
    8073                 :            :         .f = cmd_operate_set_counter_parsed,
    8074                 :            :         .data = NULL,
    8075                 :            :         .help_str = "port (port_id) enable|disable <counter_name>",
    8076                 :            :         .tokens = {
    8077                 :            :                 (void *)&cmd_operate_set_counter_port,
    8078                 :            :                 (void *)&cmd_operate_set_counter_port_id,
    8079                 :            :                 (void *)&cmd_operate_set_counter_what,
    8080                 :            :                 (void *)&cmd_operate_set_counter_name,
    8081                 :            :                 NULL,
    8082                 :            :         },
    8083                 :            : };
    8084                 :            : 
    8085                 :            : /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */
    8086                 :            : struct cmd_set_record_core_cycles_result {
    8087                 :            :         cmdline_fixed_string_t keyword;
    8088                 :            :         cmdline_fixed_string_t name;
    8089                 :            :         cmdline_fixed_string_t on_off;
    8090                 :            : };
    8091                 :            : 
    8092                 :            : static void
    8093                 :          0 : cmd_set_record_core_cycles_parsed(void *parsed_result,
    8094                 :            :                         __rte_unused struct cmdline *cl,
    8095                 :            :                         __rte_unused void *data)
    8096                 :            : {
    8097                 :            :         struct cmd_set_record_core_cycles_result *res;
    8098                 :            :         uint16_t on_off = 0;
    8099                 :            : 
    8100                 :            :         res = parsed_result;
    8101                 :          0 :         on_off = !strcmp(res->on_off, "on") ? 1 : 0;
    8102                 :          0 :         set_record_core_cycles(on_off);
    8103                 :          0 : }
    8104                 :            : 
    8105                 :            : static cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword =
    8106                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
    8107                 :            :                                  keyword, "set");
    8108                 :            : static cmdline_parse_token_string_t cmd_set_record_core_cycles_name =
    8109                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
    8110                 :            :                                  name, "record-core-cycles");
    8111                 :            : static cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off =
    8112                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
    8113                 :            :                                  on_off, "on#off");
    8114                 :            : 
    8115                 :            : static cmdline_parse_inst_t cmd_set_record_core_cycles = {
    8116                 :            :         .f = cmd_set_record_core_cycles_parsed,
    8117                 :            :         .data = NULL,
    8118                 :            :         .help_str = "set record-core-cycles on|off",
    8119                 :            :         .tokens = {
    8120                 :            :                 (void *)&cmd_set_record_core_cycles_keyword,
    8121                 :            :                 (void *)&cmd_set_record_core_cycles_name,
    8122                 :            :                 (void *)&cmd_set_record_core_cycles_on_off,
    8123                 :            :                 NULL,
    8124                 :            :         },
    8125                 :            : };
    8126                 :            : 
    8127                 :            : /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */
    8128                 :            : struct cmd_set_record_burst_stats_result {
    8129                 :            :         cmdline_fixed_string_t keyword;
    8130                 :            :         cmdline_fixed_string_t name;
    8131                 :            :         cmdline_fixed_string_t on_off;
    8132                 :            : };
    8133                 :            : 
    8134                 :            : static void
    8135                 :          0 : cmd_set_record_burst_stats_parsed(void *parsed_result,
    8136                 :            :                         __rte_unused struct cmdline *cl,
    8137                 :            :                         __rte_unused void *data)
    8138                 :            : {
    8139                 :            :         struct cmd_set_record_burst_stats_result *res;
    8140                 :            :         uint16_t on_off = 0;
    8141                 :            : 
    8142                 :            :         res = parsed_result;
    8143                 :          0 :         on_off = !strcmp(res->on_off, "on") ? 1 : 0;
    8144                 :          0 :         set_record_burst_stats(on_off);
    8145                 :          0 : }
    8146                 :            : 
    8147                 :            : static cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword =
    8148                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
    8149                 :            :                                  keyword, "set");
    8150                 :            : static cmdline_parse_token_string_t cmd_set_record_burst_stats_name =
    8151                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
    8152                 :            :                                  name, "record-burst-stats");
    8153                 :            : static cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off =
    8154                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
    8155                 :            :                                  on_off, "on#off");
    8156                 :            : 
    8157                 :            : static cmdline_parse_inst_t cmd_set_record_burst_stats = {
    8158                 :            :         .f = cmd_set_record_burst_stats_parsed,
    8159                 :            :         .data = NULL,
    8160                 :            :         .help_str = "set record-burst-stats on|off",
    8161                 :            :         .tokens = {
    8162                 :            :                 (void *)&cmd_set_record_burst_stats_keyword,
    8163                 :            :                 (void *)&cmd_set_record_burst_stats_name,
    8164                 :            :                 (void *)&cmd_set_record_burst_stats_on_off,
    8165                 :            :                 NULL,
    8166                 :            :         },
    8167                 :            : };
    8168                 :            : 
    8169                 :            : /* *** CONFIGURE UNICAST HASH TABLE *** */
    8170                 :            : struct cmd_set_uc_hash_table {
    8171                 :            :         cmdline_fixed_string_t set;
    8172                 :            :         cmdline_fixed_string_t port;
    8173                 :            :         portid_t port_id;
    8174                 :            :         cmdline_fixed_string_t what;
    8175                 :            :         struct rte_ether_addr address;
    8176                 :            :         cmdline_fixed_string_t mode;
    8177                 :            : };
    8178                 :            : 
    8179                 :            : static void
    8180                 :          0 : cmd_set_uc_hash_parsed(void *parsed_result,
    8181                 :            :                        __rte_unused struct cmdline *cl,
    8182                 :            :                        __rte_unused void *data)
    8183                 :            : {
    8184                 :            :         int ret=0;
    8185                 :            :         struct cmd_set_uc_hash_table *res = parsed_result;
    8186                 :            : 
    8187                 :          0 :         int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
    8188                 :            : 
    8189                 :          0 :         if (strcmp(res->what, "uta") == 0)
    8190                 :          0 :                 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
    8191                 :            :                                                 &res->address,(uint8_t)is_on);
    8192                 :          0 :         if (ret < 0)
    8193                 :          0 :                 fprintf(stderr,
    8194                 :            :                         "bad unicast hash table parameter, return code = %d\n",
    8195                 :            :                         ret);
    8196                 :            : 
    8197                 :          0 : }
    8198                 :            : 
    8199                 :            : static cmdline_parse_token_string_t cmd_set_uc_hash_set =
    8200                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
    8201                 :            :                                  set, "set");
    8202                 :            : static cmdline_parse_token_string_t cmd_set_uc_hash_port =
    8203                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
    8204                 :            :                                  port, "port");
    8205                 :            : static cmdline_parse_token_num_t cmd_set_uc_hash_portid =
    8206                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
    8207                 :            :                               port_id, RTE_UINT16);
    8208                 :            : static cmdline_parse_token_string_t cmd_set_uc_hash_what =
    8209                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
    8210                 :            :                                  what, "uta");
    8211                 :            : static cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
    8212                 :            :         TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
    8213                 :            :                                 address);
    8214                 :            : static cmdline_parse_token_string_t cmd_set_uc_hash_mode =
    8215                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
    8216                 :            :                                  mode, "on#off");
    8217                 :            : 
    8218                 :            : static cmdline_parse_inst_t cmd_set_uc_hash_filter = {
    8219                 :            :         .f = cmd_set_uc_hash_parsed,
    8220                 :            :         .data = NULL,
    8221                 :            :         .help_str = "set port <port_id> uta <mac_addr> on|off)",
    8222                 :            :         .tokens = {
    8223                 :            :                 (void *)&cmd_set_uc_hash_set,
    8224                 :            :                 (void *)&cmd_set_uc_hash_port,
    8225                 :            :                 (void *)&cmd_set_uc_hash_portid,
    8226                 :            :                 (void *)&cmd_set_uc_hash_what,
    8227                 :            :                 (void *)&cmd_set_uc_hash_mac,
    8228                 :            :                 (void *)&cmd_set_uc_hash_mode,
    8229                 :            :                 NULL,
    8230                 :            :         },
    8231                 :            : };
    8232                 :            : 
    8233                 :            : struct cmd_set_uc_all_hash_table {
    8234                 :            :         cmdline_fixed_string_t set;
    8235                 :            :         cmdline_fixed_string_t port;
    8236                 :            :         portid_t port_id;
    8237                 :            :         cmdline_fixed_string_t what;
    8238                 :            :         cmdline_fixed_string_t value;
    8239                 :            :         cmdline_fixed_string_t mode;
    8240                 :            : };
    8241                 :            : 
    8242                 :            : static void
    8243                 :          0 : cmd_set_uc_all_hash_parsed(void *parsed_result,
    8244                 :            :                        __rte_unused struct cmdline *cl,
    8245                 :            :                        __rte_unused void *data)
    8246                 :            : {
    8247                 :            :         int ret=0;
    8248                 :            :         struct cmd_set_uc_all_hash_table *res = parsed_result;
    8249                 :            : 
    8250                 :          0 :         int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
    8251                 :            : 
    8252                 :          0 :         if ((strcmp(res->what, "uta") == 0) &&
    8253                 :          0 :                 (strcmp(res->value, "all") == 0))
    8254                 :          0 :                 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
    8255                 :          0 :         if (ret < 0)
    8256                 :          0 :                 fprintf(stderr,
    8257                 :            :                         "bad unicast hash table parameter, return code = %d\n",
    8258                 :            :                         ret);
    8259                 :          0 : }
    8260                 :            : 
    8261                 :            : static cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
    8262                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
    8263                 :            :                                  set, "set");
    8264                 :            : static cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
    8265                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
    8266                 :            :                                  port, "port");
    8267                 :            : static cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
    8268                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
    8269                 :            :                               port_id, RTE_UINT16);
    8270                 :            : static cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
    8271                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
    8272                 :            :                                  what, "uta");
    8273                 :            : static cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
    8274                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
    8275                 :            :                                 value,"all");
    8276                 :            : static cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
    8277                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
    8278                 :            :                                  mode, "on#off");
    8279                 :            : 
    8280                 :            : static cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
    8281                 :            :         .f = cmd_set_uc_all_hash_parsed,
    8282                 :            :         .data = NULL,
    8283                 :            :         .help_str = "set port <port_id> uta all on|off",
    8284                 :            :         .tokens = {
    8285                 :            :                 (void *)&cmd_set_uc_all_hash_set,
    8286                 :            :                 (void *)&cmd_set_uc_all_hash_port,
    8287                 :            :                 (void *)&cmd_set_uc_all_hash_portid,
    8288                 :            :                 (void *)&cmd_set_uc_all_hash_what,
    8289                 :            :                 (void *)&cmd_set_uc_all_hash_value,
    8290                 :            :                 (void *)&cmd_set_uc_all_hash_mode,
    8291                 :            :                 NULL,
    8292                 :            :         },
    8293                 :            : };
    8294                 :            : 
    8295                 :            : /* *** CONFIGURE VF TRAFFIC CONTROL *** */
    8296                 :            : struct cmd_set_vf_traffic {
    8297                 :            :         cmdline_fixed_string_t set;
    8298                 :            :         cmdline_fixed_string_t port;
    8299                 :            :         portid_t port_id;
    8300                 :            :         cmdline_fixed_string_t vf;
    8301                 :            :         uint8_t vf_id;
    8302                 :            :         cmdline_fixed_string_t what;
    8303                 :            :         cmdline_fixed_string_t mode;
    8304                 :            : };
    8305                 :            : 
    8306                 :            : static void
    8307                 :          0 : cmd_set_vf_traffic_parsed(void *parsed_result,
    8308                 :            :                        __rte_unused struct cmdline *cl,
    8309                 :            :                        __rte_unused void *data)
    8310                 :            : {
    8311                 :            :         struct cmd_set_vf_traffic *res = parsed_result;
    8312                 :          0 :         int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
    8313                 :          0 :         int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
    8314                 :            : 
    8315                 :          0 :         set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
    8316                 :          0 : }
    8317                 :            : 
    8318                 :            : static cmdline_parse_token_string_t cmd_setvf_traffic_set =
    8319                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
    8320                 :            :                                  set, "set");
    8321                 :            : static cmdline_parse_token_string_t cmd_setvf_traffic_port =
    8322                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
    8323                 :            :                                  port, "port");
    8324                 :            : static cmdline_parse_token_num_t cmd_setvf_traffic_portid =
    8325                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
    8326                 :            :                               port_id, RTE_UINT16);
    8327                 :            : static cmdline_parse_token_string_t cmd_setvf_traffic_vf =
    8328                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
    8329                 :            :                                  vf, "vf");
    8330                 :            : static cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
    8331                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
    8332                 :            :                               vf_id, RTE_UINT8);
    8333                 :            : static cmdline_parse_token_string_t cmd_setvf_traffic_what =
    8334                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
    8335                 :            :                                  what, "tx#rx");
    8336                 :            : static cmdline_parse_token_string_t cmd_setvf_traffic_mode =
    8337                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
    8338                 :            :                                  mode, "on#off");
    8339                 :            : 
    8340                 :            : static cmdline_parse_inst_t cmd_set_vf_traffic = {
    8341                 :            :         .f = cmd_set_vf_traffic_parsed,
    8342                 :            :         .data = NULL,
    8343                 :            :         .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
    8344                 :            :         .tokens = {
    8345                 :            :                 (void *)&cmd_setvf_traffic_set,
    8346                 :            :                 (void *)&cmd_setvf_traffic_port,
    8347                 :            :                 (void *)&cmd_setvf_traffic_portid,
    8348                 :            :                 (void *)&cmd_setvf_traffic_vf,
    8349                 :            :                 (void *)&cmd_setvf_traffic_vfid,
    8350                 :            :                 (void *)&cmd_setvf_traffic_what,
    8351                 :            :                 (void *)&cmd_setvf_traffic_mode,
    8352                 :            :                 NULL,
    8353                 :            :         },
    8354                 :            : };
    8355                 :            : 
    8356                 :            : /* *** CONFIGURE VF RECEIVE MODE *** */
    8357                 :            : struct cmd_set_vf_rxmode {
    8358                 :            :         cmdline_fixed_string_t set;
    8359                 :            :         cmdline_fixed_string_t port;
    8360                 :            :         portid_t port_id;
    8361                 :            :         cmdline_fixed_string_t vf;
    8362                 :            :         uint8_t vf_id;
    8363                 :            :         cmdline_fixed_string_t what;
    8364                 :            :         cmdline_fixed_string_t mode;
    8365                 :            :         cmdline_fixed_string_t on;
    8366                 :            : };
    8367                 :            : 
    8368                 :            : static void
    8369                 :          0 : cmd_set_vf_rxmode_parsed(void *parsed_result,
    8370                 :            :                        __rte_unused struct cmdline *cl,
    8371                 :            :                        __rte_unused void *data)
    8372                 :            : {
    8373                 :            :         int ret = -ENOTSUP;
    8374                 :            :         uint16_t vf_rxmode = 0;
    8375                 :            :         struct cmd_set_vf_rxmode *res = parsed_result;
    8376                 :            : 
    8377                 :          0 :         int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
    8378                 :          0 :         if (!strcmp(res->what,"rxmode")) {
    8379                 :          0 :                 if (!strcmp(res->mode, "AUPE"))
    8380                 :            :                         vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_UNTAG;
    8381                 :          0 :                 else if (!strcmp(res->mode, "ROPE"))
    8382                 :            :                         vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_HASH_UC;
    8383                 :          0 :                 else if (!strcmp(res->mode, "BAM"))
    8384                 :            :                         vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_BROADCAST;
    8385                 :          0 :                 else if (!strncmp(res->mode, "MPE",3))
    8386                 :            :                         vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_MULTICAST;
    8387                 :            :         }
    8388                 :            : 
    8389                 :            :         RTE_SET_USED(is_on);
    8390                 :            :         RTE_SET_USED(vf_rxmode);
    8391                 :            : 
    8392                 :            : #ifdef RTE_NET_IXGBE
    8393                 :            :         if (ret == -ENOTSUP)
    8394                 :          0 :                 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
    8395                 :            :                                                   vf_rxmode, (uint8_t)is_on);
    8396                 :            : #endif
    8397                 :            : #ifdef RTE_NET_BNXT
    8398                 :          0 :         if (ret == -ENOTSUP)
    8399                 :          0 :                 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
    8400                 :            :                                                  vf_rxmode, (uint8_t)is_on);
    8401                 :            : #endif
    8402                 :          0 :         if (ret < 0)
    8403                 :          0 :                 fprintf(stderr,
    8404                 :            :                         "bad VF receive mode parameter, return code = %d\n",
    8405                 :            :                         ret);
    8406                 :          0 : }
    8407                 :            : 
    8408                 :            : static cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
    8409                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
    8410                 :            :                                  set, "set");
    8411                 :            : static cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
    8412                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
    8413                 :            :                                  port, "port");
    8414                 :            : static cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
    8415                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
    8416                 :            :                               port_id, RTE_UINT16);
    8417                 :            : static cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
    8418                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
    8419                 :            :                                  vf, "vf");
    8420                 :            : static cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
    8421                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
    8422                 :            :                               vf_id, RTE_UINT8);
    8423                 :            : static cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
    8424                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
    8425                 :            :                                  what, "rxmode");
    8426                 :            : static cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
    8427                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
    8428                 :            :                                  mode, "AUPE#ROPE#BAM#MPE");
    8429                 :            : static cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
    8430                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
    8431                 :            :                                  on, "on#off");
    8432                 :            : 
    8433                 :            : static cmdline_parse_inst_t cmd_set_vf_rxmode = {
    8434                 :            :         .f = cmd_set_vf_rxmode_parsed,
    8435                 :            :         .data = NULL,
    8436                 :            :         .help_str = "set port <port_id> vf <vf_id> rxmode "
    8437                 :            :                 "AUPE|ROPE|BAM|MPE on|off",
    8438                 :            :         .tokens = {
    8439                 :            :                 (void *)&cmd_set_vf_rxmode_set,
    8440                 :            :                 (void *)&cmd_set_vf_rxmode_port,
    8441                 :            :                 (void *)&cmd_set_vf_rxmode_portid,
    8442                 :            :                 (void *)&cmd_set_vf_rxmode_vf,
    8443                 :            :                 (void *)&cmd_set_vf_rxmode_vfid,
    8444                 :            :                 (void *)&cmd_set_vf_rxmode_what,
    8445                 :            :                 (void *)&cmd_set_vf_rxmode_mode,
    8446                 :            :                 (void *)&cmd_set_vf_rxmode_on,
    8447                 :            :                 NULL,
    8448                 :            :         },
    8449                 :            : };
    8450                 :            : 
    8451                 :            : /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
    8452                 :            : struct cmd_vf_mac_addr_result {
    8453                 :            :         cmdline_fixed_string_t mac_addr_cmd;
    8454                 :            :         cmdline_fixed_string_t what;
    8455                 :            :         cmdline_fixed_string_t port;
    8456                 :            :         uint16_t port_num;
    8457                 :            :         cmdline_fixed_string_t vf;
    8458                 :            :         uint8_t vf_num;
    8459                 :            :         struct rte_ether_addr address;
    8460                 :            : };
    8461                 :            : 
    8462                 :          0 : static void cmd_vf_mac_addr_parsed(void *parsed_result,
    8463                 :            :                 __rte_unused struct cmdline *cl,
    8464                 :            :                 __rte_unused void *data)
    8465                 :            : {
    8466                 :            :         struct cmd_vf_mac_addr_result *res = parsed_result;
    8467                 :            :         int ret = -ENOTSUP;
    8468                 :            : 
    8469                 :          0 :         if (strcmp(res->what, "add") != 0)
    8470                 :            :                 return;
    8471                 :            : 
    8472                 :            : #ifdef RTE_NET_I40E
    8473                 :            :         if (ret == -ENOTSUP)
    8474                 :          0 :                 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
    8475                 :            :                                                    &res->address);
    8476                 :            : #endif
    8477                 :            : #ifdef RTE_NET_BNXT
    8478                 :          0 :         if (ret == -ENOTSUP)
    8479                 :          0 :                 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
    8480                 :          0 :                                                 res->vf_num);
    8481                 :            : #endif
    8482                 :            : 
    8483                 :          0 :         if(ret < 0)
    8484                 :          0 :                 fprintf(stderr, "vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
    8485                 :            : 
    8486                 :            : }
    8487                 :            : 
    8488                 :            : static cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
    8489                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
    8490                 :            :                                 mac_addr_cmd,"mac_addr");
    8491                 :            : static cmdline_parse_token_string_t cmd_vf_mac_addr_what =
    8492                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
    8493                 :            :                                 what,"add");
    8494                 :            : static cmdline_parse_token_string_t cmd_vf_mac_addr_port =
    8495                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
    8496                 :            :                                 port,"port");
    8497                 :            : static cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
    8498                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
    8499                 :            :                                 port_num, RTE_UINT16);
    8500                 :            : static cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
    8501                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
    8502                 :            :                                 vf,"vf");
    8503                 :            : static cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
    8504                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
    8505                 :            :                                 vf_num, RTE_UINT8);
    8506                 :            : static cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
    8507                 :            :         TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
    8508                 :            :                                 address);
    8509                 :            : 
    8510                 :            : static cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
    8511                 :            :         .f = cmd_vf_mac_addr_parsed,
    8512                 :            :         .data = (void *)0,
    8513                 :            :         .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
    8514                 :            :                 "Add MAC address filtering for a VF on port_id",
    8515                 :            :         .tokens = {
    8516                 :            :                 (void *)&cmd_vf_mac_addr_cmd,
    8517                 :            :                 (void *)&cmd_vf_mac_addr_what,
    8518                 :            :                 (void *)&cmd_vf_mac_addr_port,
    8519                 :            :                 (void *)&cmd_vf_mac_addr_portnum,
    8520                 :            :                 (void *)&cmd_vf_mac_addr_vf,
    8521                 :            :                 (void *)&cmd_vf_mac_addr_vfnum,
    8522                 :            :                 (void *)&cmd_vf_mac_addr_addr,
    8523                 :            :                 NULL,
    8524                 :            :         },
    8525                 :            : };
    8526                 :            : 
    8527                 :            : /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
    8528                 :            : struct cmd_vf_rx_vlan_filter {
    8529                 :            :         cmdline_fixed_string_t rx_vlan;
    8530                 :            :         cmdline_fixed_string_t what;
    8531                 :            :         uint16_t vlan_id;
    8532                 :            :         cmdline_fixed_string_t port;
    8533                 :            :         portid_t port_id;
    8534                 :            :         cmdline_fixed_string_t vf;
    8535                 :            :         uint64_t vf_mask;
    8536                 :            : };
    8537                 :            : 
    8538                 :            : static void
    8539                 :          0 : cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
    8540                 :            :                           __rte_unused struct cmdline *cl,
    8541                 :            :                           __rte_unused void *data)
    8542                 :            : {
    8543                 :            :         struct cmd_vf_rx_vlan_filter *res = parsed_result;
    8544                 :            :         int ret = -ENOTSUP;
    8545                 :            : 
    8546                 :          0 :         __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
    8547                 :            : 
    8548                 :            : #ifdef RTE_NET_IXGBE
    8549                 :            :         if (ret == -ENOTSUP)
    8550                 :          0 :                 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
    8551                 :          0 :                                 res->vlan_id, res->vf_mask, is_add);
    8552                 :            : #endif
    8553                 :            : #ifdef RTE_NET_I40E
    8554                 :          0 :         if (ret == -ENOTSUP)
    8555                 :          0 :                 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
    8556                 :          0 :                                 res->vlan_id, res->vf_mask, is_add);
    8557                 :            : #endif
    8558                 :            : #ifdef RTE_NET_BNXT
    8559                 :          0 :         if (ret == -ENOTSUP)
    8560                 :          0 :                 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
    8561                 :          0 :                                 res->vlan_id, res->vf_mask, is_add);
    8562                 :            : #endif
    8563                 :            : 
    8564                 :          0 :         switch (ret) {
    8565                 :            :         case 0:
    8566                 :            :                 break;
    8567                 :          0 :         case -EINVAL:
    8568                 :          0 :                 fprintf(stderr, "invalid vlan_id %d or vf_mask %"PRIu64"\n",
    8569                 :          0 :                         res->vlan_id, res->vf_mask);
    8570                 :            :                 break;
    8571                 :          0 :         case -ENODEV:
    8572                 :          0 :                 fprintf(stderr, "invalid port_id %d\n", res->port_id);
    8573                 :            :                 break;
    8574                 :          0 :         case -ENOTSUP:
    8575                 :          0 :                 fprintf(stderr, "function not implemented or supported\n");
    8576                 :            :                 break;
    8577                 :          0 :         default:
    8578                 :          0 :                 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
    8579                 :            :         }
    8580                 :          0 : }
    8581                 :            : 
    8582                 :            : static cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
    8583                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
    8584                 :            :                                  rx_vlan, "rx_vlan");
    8585                 :            : static cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
    8586                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
    8587                 :            :                                  what, "add#rm");
    8588                 :            : static cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
    8589                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
    8590                 :            :                               vlan_id, RTE_UINT16);
    8591                 :            : static cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
    8592                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
    8593                 :            :                                  port, "port");
    8594                 :            : static cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
    8595                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
    8596                 :            :                               port_id, RTE_UINT16);
    8597                 :            : static cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
    8598                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
    8599                 :            :                                  vf, "vf");
    8600                 :            : static cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
    8601                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
    8602                 :            :                               vf_mask, RTE_UINT64);
    8603                 :            : 
    8604                 :            : static cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
    8605                 :            :         .f = cmd_vf_rx_vlan_filter_parsed,
    8606                 :            :         .data = NULL,
    8607                 :            :         .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
    8608                 :            :                 "(vf_mask = hexadecimal VF mask)",
    8609                 :            :         .tokens = {
    8610                 :            :                 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
    8611                 :            :                 (void *)&cmd_vf_rx_vlan_filter_what,
    8612                 :            :                 (void *)&cmd_vf_rx_vlan_filter_vlanid,
    8613                 :            :                 (void *)&cmd_vf_rx_vlan_filter_port,
    8614                 :            :                 (void *)&cmd_vf_rx_vlan_filter_portid,
    8615                 :            :                 (void *)&cmd_vf_rx_vlan_filter_vf,
    8616                 :            :                 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
    8617                 :            :                 NULL,
    8618                 :            :         },
    8619                 :            : };
    8620                 :            : 
    8621                 :            : /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
    8622                 :            : struct cmd_queue_rate_limit_result {
    8623                 :            :         cmdline_fixed_string_t set;
    8624                 :            :         cmdline_fixed_string_t port;
    8625                 :            :         uint16_t port_num;
    8626                 :            :         cmdline_fixed_string_t queue;
    8627                 :            :         uint8_t queue_num;
    8628                 :            :         cmdline_fixed_string_t rate;
    8629                 :            :         uint32_t rate_num;
    8630                 :            : };
    8631                 :            : 
    8632                 :          0 : static void cmd_queue_rate_limit_parsed(void *parsed_result,
    8633                 :            :                 __rte_unused struct cmdline *cl,
    8634                 :            :                 __rte_unused void *data)
    8635                 :            : {
    8636                 :            :         struct cmd_queue_rate_limit_result *res = parsed_result;
    8637                 :            :         int ret = 0;
    8638                 :            : 
    8639                 :          0 :         if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
    8640                 :          0 :                 && (strcmp(res->queue, "queue") == 0)
    8641                 :          0 :                 && (strcmp(res->rate, "rate") == 0))
    8642                 :          0 :                 ret = set_queue_rate_limit(res->port_num, res->queue_num,
    8643                 :            :                                         res->rate_num);
    8644                 :          0 :         if (ret < 0)
    8645                 :          0 :                 fprintf(stderr, "queue_rate_limit_cmd error: (%s)\n",
    8646                 :            :                         strerror(-ret));
    8647                 :            : 
    8648                 :          0 : }
    8649                 :            : 
    8650                 :            : static cmdline_parse_token_string_t cmd_queue_rate_limit_set =
    8651                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
    8652                 :            :                                 set, "set");
    8653                 :            : static cmdline_parse_token_string_t cmd_queue_rate_limit_port =
    8654                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
    8655                 :            :                                 port, "port");
    8656                 :            : static cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
    8657                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
    8658                 :            :                                 port_num, RTE_UINT16);
    8659                 :            : static cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
    8660                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
    8661                 :            :                                 queue, "queue");
    8662                 :            : static cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
    8663                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
    8664                 :            :                                 queue_num, RTE_UINT8);
    8665                 :            : static cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
    8666                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
    8667                 :            :                                 rate, "rate");
    8668                 :            : static cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
    8669                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
    8670                 :            :                                 rate_num, RTE_UINT32);
    8671                 :            : 
    8672                 :            : static cmdline_parse_inst_t cmd_queue_rate_limit = {
    8673                 :            :         .f = cmd_queue_rate_limit_parsed,
    8674                 :            :         .data = (void *)0,
    8675                 :            :         .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
    8676                 :            :                 "Set rate limit for a queue on port_id",
    8677                 :            :         .tokens = {
    8678                 :            :                 (void *)&cmd_queue_rate_limit_set,
    8679                 :            :                 (void *)&cmd_queue_rate_limit_port,
    8680                 :            :                 (void *)&cmd_queue_rate_limit_portnum,
    8681                 :            :                 (void *)&cmd_queue_rate_limit_queue,
    8682                 :            :                 (void *)&cmd_queue_rate_limit_queuenum,
    8683                 :            :                 (void *)&cmd_queue_rate_limit_rate,
    8684                 :            :                 (void *)&cmd_queue_rate_limit_ratenum,
    8685                 :            :                 NULL,
    8686                 :            :         },
    8687                 :            : };
    8688                 :            : 
    8689                 :            : /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
    8690                 :            : struct cmd_vf_rate_limit_result {
    8691                 :            :         cmdline_fixed_string_t set;
    8692                 :            :         cmdline_fixed_string_t port;
    8693                 :            :         uint16_t port_num;
    8694                 :            :         cmdline_fixed_string_t vf;
    8695                 :            :         uint8_t vf_num;
    8696                 :            :         cmdline_fixed_string_t rate;
    8697                 :            :         uint32_t rate_num;
    8698                 :            :         cmdline_fixed_string_t q_msk;
    8699                 :            :         uint64_t q_msk_val;
    8700                 :            : };
    8701                 :            : 
    8702                 :          0 : static void cmd_vf_rate_limit_parsed(void *parsed_result,
    8703                 :            :                 __rte_unused struct cmdline *cl,
    8704                 :            :                 __rte_unused void *data)
    8705                 :            : {
    8706                 :            :         struct cmd_vf_rate_limit_result *res = parsed_result;
    8707                 :            :         int ret = 0;
    8708                 :            : 
    8709                 :          0 :         if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
    8710                 :          0 :                 && (strcmp(res->vf, "vf") == 0)
    8711                 :          0 :                 && (strcmp(res->rate, "rate") == 0)
    8712                 :          0 :                 && (strcmp(res->q_msk, "queue_mask") == 0))
    8713                 :          0 :                 ret = set_vf_rate_limit(res->port_num, res->vf_num,
    8714                 :            :                                         res->rate_num, res->q_msk_val);
    8715                 :          0 :         if (ret < 0)
    8716                 :          0 :                 fprintf(stderr, "vf_rate_limit_cmd error: (%s)\n",
    8717                 :            :                         strerror(-ret));
    8718                 :            : 
    8719                 :          0 : }
    8720                 :            : 
    8721                 :            : static cmdline_parse_token_string_t cmd_vf_rate_limit_set =
    8722                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
    8723                 :            :                                 set, "set");
    8724                 :            : static cmdline_parse_token_string_t cmd_vf_rate_limit_port =
    8725                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
    8726                 :            :                                 port, "port");
    8727                 :            : static cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
    8728                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
    8729                 :            :                                 port_num, RTE_UINT16);
    8730                 :            : static cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
    8731                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
    8732                 :            :                                 vf, "vf");
    8733                 :            : static cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
    8734                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
    8735                 :            :                                 vf_num, RTE_UINT8);
    8736                 :            : static cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
    8737                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
    8738                 :            :                                 rate, "rate");
    8739                 :            : static cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
    8740                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
    8741                 :            :                                 rate_num, RTE_UINT32);
    8742                 :            : static cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
    8743                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
    8744                 :            :                                 q_msk, "queue_mask");
    8745                 :            : static cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
    8746                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
    8747                 :            :                                 q_msk_val, RTE_UINT64);
    8748                 :            : 
    8749                 :            : static cmdline_parse_inst_t cmd_vf_rate_limit = {
    8750                 :            :         .f = cmd_vf_rate_limit_parsed,
    8751                 :            :         .data = (void *)0,
    8752                 :            :         .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
    8753                 :            :                 "queue_mask <queue_mask_value>: "
    8754                 :            :                 "Set rate limit for queues of VF on port_id",
    8755                 :            :         .tokens = {
    8756                 :            :                 (void *)&cmd_vf_rate_limit_set,
    8757                 :            :                 (void *)&cmd_vf_rate_limit_port,
    8758                 :            :                 (void *)&cmd_vf_rate_limit_portnum,
    8759                 :            :                 (void *)&cmd_vf_rate_limit_vf,
    8760                 :            :                 (void *)&cmd_vf_rate_limit_vfnum,
    8761                 :            :                 (void *)&cmd_vf_rate_limit_rate,
    8762                 :            :                 (void *)&cmd_vf_rate_limit_ratenum,
    8763                 :            :                 (void *)&cmd_vf_rate_limit_q_msk,
    8764                 :            :                 (void *)&cmd_vf_rate_limit_q_msk_val,
    8765                 :            :                 NULL,
    8766                 :            :         },
    8767                 :            : };
    8768                 :            : 
    8769                 :            : /* *** CONFIGURE TUNNEL UDP PORT *** */
    8770                 :            : struct cmd_tunnel_udp_config {
    8771                 :            :         cmdline_fixed_string_t rx_vxlan_port;
    8772                 :            :         cmdline_fixed_string_t what;
    8773                 :            :         uint16_t udp_port;
    8774                 :            :         portid_t port_id;
    8775                 :            : };
    8776                 :            : 
    8777                 :            : static void
    8778                 :          0 : cmd_tunnel_udp_config_parsed(void *parsed_result,
    8779                 :            :                           __rte_unused struct cmdline *cl,
    8780                 :            :                           __rte_unused void *data)
    8781                 :            : {
    8782                 :            :         struct cmd_tunnel_udp_config *res = parsed_result;
    8783                 :            :         struct rte_eth_udp_tunnel tunnel_udp;
    8784                 :            :         int ret;
    8785                 :            : 
    8786                 :          0 :         tunnel_udp.udp_port = res->udp_port;
    8787                 :          0 :         tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN;
    8788                 :            : 
    8789                 :          0 :         if (!strcmp(res->what, "add"))
    8790                 :          0 :                 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
    8791                 :            :                                                       &tunnel_udp);
    8792                 :            :         else
    8793                 :          0 :                 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
    8794                 :            :                                                          &tunnel_udp);
    8795                 :            : 
    8796                 :          0 :         if (ret < 0)
    8797                 :          0 :                 fprintf(stderr, "udp tunneling add error: (%s)\n",
    8798                 :            :                         strerror(-ret));
    8799                 :          0 : }
    8800                 :            : 
    8801                 :            : static cmdline_parse_token_string_t cmd_tunnel_udp_config_rx_vxlan_port =
    8802                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
    8803                 :            :                                 rx_vxlan_port, "rx_vxlan_port");
    8804                 :            : static cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
    8805                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
    8806                 :            :                                 what, "add#rm");
    8807                 :            : static cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
    8808                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
    8809                 :            :                                 udp_port, RTE_UINT16);
    8810                 :            : static cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
    8811                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
    8812                 :            :                                 port_id, RTE_UINT16);
    8813                 :            : 
    8814                 :            : static cmdline_parse_inst_t cmd_tunnel_udp_config = {
    8815                 :            :         .f = cmd_tunnel_udp_config_parsed,
    8816                 :            :         .data = (void *)0,
    8817                 :            :         .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
    8818                 :            :                 "Add/Remove a tunneling UDP port filter",
    8819                 :            :         .tokens = {
    8820                 :            :                 (void *)&cmd_tunnel_udp_config_rx_vxlan_port,
    8821                 :            :                 (void *)&cmd_tunnel_udp_config_what,
    8822                 :            :                 (void *)&cmd_tunnel_udp_config_udp_port,
    8823                 :            :                 (void *)&cmd_tunnel_udp_config_port_id,
    8824                 :            :                 NULL,
    8825                 :            :         },
    8826                 :            : };
    8827                 :            : 
    8828                 :            : struct cmd_config_tunnel_udp_port {
    8829                 :            :         cmdline_fixed_string_t port;
    8830                 :            :         cmdline_fixed_string_t config;
    8831                 :            :         portid_t port_id;
    8832                 :            :         cmdline_fixed_string_t udp_tunnel_port;
    8833                 :            :         cmdline_fixed_string_t action;
    8834                 :            :         cmdline_fixed_string_t tunnel_type;
    8835                 :            :         uint16_t udp_port;
    8836                 :            : };
    8837                 :            : 
    8838                 :            : static void
    8839                 :          0 : cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
    8840                 :            :                                __rte_unused struct cmdline *cl,
    8841                 :            :                                __rte_unused void *data)
    8842                 :            : {
    8843                 :            :         struct cmd_config_tunnel_udp_port *res = parsed_result;
    8844                 :            :         struct rte_eth_udp_tunnel tunnel_udp;
    8845                 :            :         int ret = 0;
    8846                 :            : 
    8847                 :          0 :         if (port_id_is_invalid(res->port_id, ENABLED_WARN))
    8848                 :          0 :                 return;
    8849                 :            : 
    8850                 :          0 :         tunnel_udp.udp_port = res->udp_port;
    8851                 :            : 
    8852                 :          0 :         if (!strcmp(res->tunnel_type, "vxlan")) {
    8853                 :          0 :                 tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN;
    8854                 :          0 :         } else if (!strcmp(res->tunnel_type, "geneve")) {
    8855                 :          0 :                 tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_GENEVE;
    8856                 :          0 :         } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
    8857                 :          0 :                 tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN_GPE;
    8858                 :          0 :         } else if (!strcmp(res->tunnel_type, "ecpri")) {
    8859                 :          0 :                 tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_ECPRI;
    8860                 :            :         } else {
    8861                 :          0 :                 fprintf(stderr, "Invalid tunnel type\n");
    8862                 :          0 :                 return;
    8863                 :            :         }
    8864                 :            : 
    8865                 :          0 :         if (!strcmp(res->action, "add"))
    8866                 :          0 :                 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
    8867                 :            :                                                       &tunnel_udp);
    8868                 :            :         else
    8869                 :          0 :                 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
    8870                 :            :                                                          &tunnel_udp);
    8871                 :            : 
    8872                 :          0 :         if (ret < 0)
    8873                 :          0 :                 fprintf(stderr, "udp tunneling port add error: (%s)\n",
    8874                 :            :                         strerror(-ret));
    8875                 :            : }
    8876                 :            : 
    8877                 :            : static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
    8878                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
    8879                 :            :                                  "port");
    8880                 :            : static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
    8881                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
    8882                 :            :                                  "config");
    8883                 :            : static cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
    8884                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
    8885                 :            :                               RTE_UINT16);
    8886                 :            : static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
    8887                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
    8888                 :            :                                  udp_tunnel_port,
    8889                 :            :                                  "udp_tunnel_port");
    8890                 :            : static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
    8891                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
    8892                 :            :                                  "add#rm");
    8893                 :            : static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
    8894                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
    8895                 :            :                                  "vxlan#geneve#vxlan-gpe#ecpri");
    8896                 :            : static cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
    8897                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
    8898                 :            :                               RTE_UINT16);
    8899                 :            : 
    8900                 :            : static cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
    8901                 :            :         .f = cmd_cfg_tunnel_udp_port_parsed,
    8902                 :            :         .data = NULL,
    8903                 :            :         .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|"
    8904                 :            :                 "geneve|vxlan-gpe|ecpri <udp_port>",
    8905                 :            :         .tokens = {
    8906                 :            :                 (void *)&cmd_config_tunnel_udp_port_port,
    8907                 :            :                 (void *)&cmd_config_tunnel_udp_port_config,
    8908                 :            :                 (void *)&cmd_config_tunnel_udp_port_port_id,
    8909                 :            :                 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
    8910                 :            :                 (void *)&cmd_config_tunnel_udp_port_action,
    8911                 :            :                 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
    8912                 :            :                 (void *)&cmd_config_tunnel_udp_port_value,
    8913                 :            :                 NULL,
    8914                 :            :         },
    8915                 :            : };
    8916                 :            : 
    8917                 :            : /* ******************************************************************************** */
    8918                 :            : 
    8919                 :            : struct cmd_dump_result {
    8920                 :            :         cmdline_fixed_string_t dump;
    8921                 :            : };
    8922                 :            : 
    8923                 :            : static void
    8924                 :          0 : dump_struct_sizes(void)
    8925                 :            : {
    8926                 :            : #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
    8927                 :            :         DUMP_SIZE(struct rte_mbuf);
    8928                 :            :         DUMP_SIZE(struct rte_mempool);
    8929                 :            :         DUMP_SIZE(struct rte_ring);
    8930                 :            : #undef DUMP_SIZE
    8931                 :          0 : }
    8932                 :            : 
    8933                 :            : 
    8934                 :            : /* Dump the socket memory statistics on console */
    8935                 :            : static void
    8936                 :          0 : dump_socket_mem(FILE *f)
    8937                 :            : {
    8938                 :            :         struct rte_malloc_socket_stats socket_stats;
    8939                 :            :         unsigned int i;
    8940                 :            :         size_t total = 0;
    8941                 :            :         size_t alloc = 0;
    8942                 :            :         size_t free = 0;
    8943                 :            :         unsigned int n_alloc = 0;
    8944                 :            :         unsigned int n_free = 0;
    8945                 :            :         static size_t last_allocs;
    8946                 :            :         static size_t last_total;
    8947                 :            : 
    8948                 :            : 
    8949                 :          0 :         for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
    8950                 :          0 :                 if (rte_malloc_get_socket_stats(i, &socket_stats) ||
    8951                 :          0 :                     !socket_stats.heap_totalsz_bytes)
    8952                 :          0 :                         continue;
    8953                 :          0 :                 total += socket_stats.heap_totalsz_bytes;
    8954                 :          0 :                 alloc += socket_stats.heap_allocsz_bytes;
    8955                 :          0 :                 free += socket_stats.heap_freesz_bytes;
    8956                 :          0 :                 n_alloc += socket_stats.alloc_count;
    8957                 :          0 :                 n_free += socket_stats.free_count;
    8958                 :          0 :                 fprintf(f,
    8959                 :            :                         "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
    8960                 :            :                         i,
    8961                 :            :                         (double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
    8962                 :            :                         (double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
    8963                 :          0 :                         (double)socket_stats.heap_allocsz_bytes * 100 /
    8964                 :          0 :                         (double)socket_stats.heap_totalsz_bytes,
    8965                 :          0 :                         (double)socket_stats.heap_freesz_bytes / (1024 * 1024),
    8966                 :            :                         socket_stats.alloc_count,
    8967                 :            :                         socket_stats.free_count);
    8968                 :            :         }
    8969                 :          0 :         fprintf(f,
    8970                 :            :                 "Total   : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
    8971                 :          0 :                 (double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
    8972                 :          0 :                 total ? ((double)alloc * 100 / (double)total) : 0,
    8973                 :          0 :                 (double)free / (1024 * 1024),
    8974                 :            :                 n_alloc, n_free);
    8975                 :          0 :         if (last_allocs)
    8976                 :          0 :                 fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
    8977                 :          0 :                         ((double)total - (double)last_total) / (1024 * 1024),
    8978                 :          0 :                         (double)(alloc - (double)last_allocs) / 1024 / 1024);
    8979                 :          0 :         last_allocs = alloc;
    8980                 :          0 :         last_total = total;
    8981                 :          0 : }
    8982                 :            : 
    8983                 :          0 : static void cmd_dump_parsed(void *parsed_result,
    8984                 :            :                             __rte_unused struct cmdline *cl,
    8985                 :            :                             __rte_unused void *data)
    8986                 :            : {
    8987                 :            :         struct cmd_dump_result *res = parsed_result;
    8988                 :            : 
    8989                 :          0 :         if (!strcmp(res->dump, "dump_physmem"))
    8990                 :          0 :                 rte_dump_physmem_layout(stdout);
    8991                 :          0 :         else if (!strcmp(res->dump, "dump_socket_mem"))
    8992                 :          0 :                 dump_socket_mem(stdout);
    8993                 :          0 :         else if (!strcmp(res->dump, "dump_memzone"))
    8994                 :          0 :                 rte_memzone_dump(stdout);
    8995                 :          0 :         else if (!strcmp(res->dump, "dump_struct_sizes"))
    8996                 :          0 :                 dump_struct_sizes();
    8997                 :          0 :         else if (!strcmp(res->dump, "dump_ring"))
    8998                 :          0 :                 rte_ring_list_dump(stdout);
    8999                 :          0 :         else if (!strcmp(res->dump, "dump_mempool"))
    9000                 :          0 :                 rte_mempool_list_dump(stdout);
    9001                 :          0 :         else if (!strcmp(res->dump, "dump_devargs"))
    9002                 :          0 :                 rte_devargs_dump(stdout);
    9003                 :          0 :         else if (!strcmp(res->dump, "dump_lcores"))
    9004                 :          0 :                 rte_lcore_dump(stdout);
    9005                 :            : #ifndef RTE_EXEC_ENV_WINDOWS
    9006                 :          0 :         else if (!strcmp(res->dump, "dump_trace"))
    9007                 :          0 :                 rte_trace_save();
    9008                 :            : #endif
    9009                 :          0 :         else if (!strcmp(res->dump, "dump_log_types"))
    9010                 :          0 :                 rte_log_dump(stdout);
    9011                 :          0 : }
    9012                 :            : 
    9013                 :            : static cmdline_parse_token_string_t cmd_dump_dump =
    9014                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
    9015                 :            :                 "dump_physmem#"
    9016                 :            :                 "dump_memzone#"
    9017                 :            :                 "dump_socket_mem#"
    9018                 :            :                 "dump_struct_sizes#"
    9019                 :            :                 "dump_ring#"
    9020                 :            :                 "dump_mempool#"
    9021                 :            :                 "dump_devargs#"
    9022                 :            :                 "dump_lcores#"
    9023                 :            : #ifndef RTE_EXEC_ENV_WINDOWS
    9024                 :            :                 "dump_trace#"
    9025                 :            : #endif
    9026                 :            :                 "dump_log_types");
    9027                 :            : 
    9028                 :            : static cmdline_parse_inst_t cmd_dump = {
    9029                 :            :         .f = cmd_dump_parsed,  /* function to call */
    9030                 :            :         .data = NULL,      /* 2nd arg of func */
    9031                 :            :         .help_str = "Dump status",
    9032                 :            :         .tokens = {        /* token list, NULL terminated */
    9033                 :            :                 (void *)&cmd_dump_dump,
    9034                 :            :                 NULL,
    9035                 :            :         },
    9036                 :            : };
    9037                 :            : 
    9038                 :            : /* ******************************************************************************** */
    9039                 :            : 
    9040                 :            : struct cmd_dump_one_result {
    9041                 :            :         cmdline_fixed_string_t dump;
    9042                 :            :         cmdline_fixed_string_t name;
    9043                 :            : };
    9044                 :            : 
    9045                 :          0 : static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
    9046                 :            :                                 __rte_unused void *data)
    9047                 :            : {
    9048                 :            :         struct cmd_dump_one_result *res = parsed_result;
    9049                 :            : 
    9050                 :          0 :         if (!strcmp(res->dump, "dump_ring")) {
    9051                 :            :                 struct rte_ring *r;
    9052                 :          0 :                 r = rte_ring_lookup(res->name);
    9053                 :          0 :                 if (r == NULL) {
    9054                 :          0 :                         cmdline_printf(cl, "Cannot find ring\n");
    9055                 :          0 :                         return;
    9056                 :            :                 }
    9057                 :          0 :                 rte_ring_dump(stdout, r);
    9058                 :          0 :         } else if (!strcmp(res->dump, "dump_mempool")) {
    9059                 :            :                 struct rte_mempool *mp;
    9060                 :          0 :                 mp = rte_mempool_lookup(res->name);
    9061                 :          0 :                 if (mp == NULL) {
    9062                 :          0 :                         cmdline_printf(cl, "Cannot find mempool\n");
    9063                 :          0 :                         return;
    9064                 :            :                 }
    9065                 :          0 :                 rte_mempool_dump(stdout, mp);
    9066                 :            :         }
    9067                 :            : }
    9068                 :            : 
    9069                 :            : static cmdline_parse_token_string_t cmd_dump_one_dump =
    9070                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
    9071                 :            :                                  "dump_ring#dump_mempool");
    9072                 :            : 
    9073                 :            : static cmdline_parse_token_string_t cmd_dump_one_name =
    9074                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
    9075                 :            : 
    9076                 :            : static cmdline_parse_inst_t cmd_dump_one = {
    9077                 :            :         .f = cmd_dump_one_parsed,  /* function to call */
    9078                 :            :         .data = NULL,      /* 2nd arg of func */
    9079                 :            :         .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
    9080                 :            :         .tokens = {        /* token list, NULL terminated */
    9081                 :            :                 (void *)&cmd_dump_one_dump,
    9082                 :            :                 (void *)&cmd_dump_one_name,
    9083                 :            :                 NULL,
    9084                 :            :         },
    9085                 :            : };
    9086                 :            : 
    9087                 :            : /* *** Filters Control *** */
    9088                 :            : 
    9089                 :            : #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
    9090                 :            : do { \
    9091                 :            :         if ((ip_addr).family == AF_INET) \
    9092                 :            :                 (ip) = (ip_addr).addr.ipv4.s_addr; \
    9093                 :            :         else { \
    9094                 :            :                 fprintf(stderr, "invalid parameter.\n"); \
    9095                 :            :                 return; \
    9096                 :            :         } \
    9097                 :            : } while (0)
    9098                 :            : 
    9099                 :            : #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
    9100                 :            : do { \
    9101                 :            :         if ((ip_addr).family == AF_INET6) \
    9102                 :            :                 ip = ip_addr.addr.ipv6; \
    9103                 :            :         else { \
    9104                 :            :                 fprintf(stderr, "invalid parameter.\n"); \
    9105                 :            :                 return; \
    9106                 :            :         } \
    9107                 :            : } while (0)
    9108                 :            : 
    9109                 :            : /* Generic flow interface command. */
    9110                 :            : extern cmdline_parse_inst_t cmd_flow;
    9111                 :            : 
    9112                 :            : /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
    9113                 :            : struct cmd_mcast_addr_result {
    9114                 :            :         cmdline_fixed_string_t mcast_addr_cmd;
    9115                 :            :         cmdline_fixed_string_t what;
    9116                 :            :         uint16_t port_num;
    9117                 :            :         struct rte_ether_addr mc_addr;
    9118                 :            : };
    9119                 :            : 
    9120                 :          0 : static void cmd_mcast_addr_parsed(void *parsed_result,
    9121                 :            :                 __rte_unused struct cmdline *cl,
    9122                 :            :                 __rte_unused void *data)
    9123                 :            : {
    9124                 :            :         struct cmd_mcast_addr_result *res = parsed_result;
    9125                 :            : 
    9126                 :          0 :         if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
    9127                 :          0 :                 fprintf(stderr,
    9128                 :            :                         "Invalid multicast addr " RTE_ETHER_ADDR_PRT_FMT "\n",
    9129                 :          0 :                         RTE_ETHER_ADDR_BYTES(&res->mc_addr));
    9130                 :          0 :                 return;
    9131                 :            :         }
    9132                 :          0 :         if (strcmp(res->what, "add") == 0)
    9133                 :          0 :                 mcast_addr_add(res->port_num, &res->mc_addr);
    9134                 :            :         else
    9135                 :          0 :                 mcast_addr_remove(res->port_num, &res->mc_addr);
    9136                 :            : }
    9137                 :            : 
    9138                 :            : static cmdline_parse_token_string_t cmd_mcast_addr_cmd =
    9139                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
    9140                 :            :                                  mcast_addr_cmd, "mcast_addr");
    9141                 :            : static cmdline_parse_token_string_t cmd_mcast_addr_what =
    9142                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
    9143                 :            :                                  "add#remove");
    9144                 :            : static cmdline_parse_token_num_t cmd_mcast_addr_portnum =
    9145                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num,
    9146                 :            :                                  RTE_UINT16);
    9147                 :            : static cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
    9148                 :            :         TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
    9149                 :            : 
    9150                 :            : static cmdline_parse_inst_t cmd_mcast_addr = {
    9151                 :            :         .f = cmd_mcast_addr_parsed,
    9152                 :            :         .data = (void *)0,
    9153                 :            :         .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
    9154                 :            :                 "Add/Remove multicast MAC address on port_id",
    9155                 :            :         .tokens = {
    9156                 :            :                 (void *)&cmd_mcast_addr_cmd,
    9157                 :            :                 (void *)&cmd_mcast_addr_what,
    9158                 :            :                 (void *)&cmd_mcast_addr_portnum,
    9159                 :            :                 (void *)&cmd_mcast_addr_addr,
    9160                 :            :                 NULL,
    9161                 :            :         },
    9162                 :            : };
    9163                 :            : 
    9164                 :            : /* *** FLUSH MULTICAST MAC ADDRESS ON PORT *** */
    9165                 :            : struct cmd_mcast_addr_flush_result {
    9166                 :            :         cmdline_fixed_string_t mcast_addr_cmd;
    9167                 :            :         cmdline_fixed_string_t what;
    9168                 :            :         uint16_t port_num;
    9169                 :            : };
    9170                 :            : 
    9171                 :          0 : static void cmd_mcast_addr_flush_parsed(void *parsed_result,
    9172                 :            :                 __rte_unused struct cmdline *cl,
    9173                 :            :                 __rte_unused void *data)
    9174                 :            : {
    9175                 :            :         struct cmd_mcast_addr_flush_result *res = parsed_result;
    9176                 :            : 
    9177                 :          0 :         mcast_addr_flush(res->port_num);
    9178                 :          0 : }
    9179                 :            : 
    9180                 :            : static cmdline_parse_token_string_t cmd_mcast_addr_flush_cmd =
    9181                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
    9182                 :            :                                  mcast_addr_cmd, "mcast_addr");
    9183                 :            : static cmdline_parse_token_string_t cmd_mcast_addr_flush_what =
    9184                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
    9185                 :            :                                  "flush");
    9186                 :            : static cmdline_parse_token_num_t cmd_mcast_addr_flush_portnum =
    9187                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num,
    9188                 :            :                                  RTE_UINT16);
    9189                 :            : 
    9190                 :            : static cmdline_parse_inst_t cmd_mcast_addr_flush = {
    9191                 :            :         .f = cmd_mcast_addr_flush_parsed,
    9192                 :            :         .data = (void *)0,
    9193                 :            :         .help_str = "mcast_addr flush <port_id> : "
    9194                 :            :                 "flush all multicast MAC addresses on port_id",
    9195                 :            :         .tokens = {
    9196                 :            :                 (void *)&cmd_mcast_addr_flush_cmd,
    9197                 :            :                 (void *)&cmd_mcast_addr_flush_what,
    9198                 :            :                 (void *)&cmd_mcast_addr_flush_portnum,
    9199                 :            :                 NULL,
    9200                 :            :         },
    9201                 :            : };
    9202                 :            : 
    9203                 :            : /* vf vlan anti spoof configuration */
    9204                 :            : 
    9205                 :            : /* Common result structure for vf vlan anti spoof */
    9206                 :            : struct cmd_vf_vlan_anti_spoof_result {
    9207                 :            :         cmdline_fixed_string_t set;
    9208                 :            :         cmdline_fixed_string_t vf;
    9209                 :            :         cmdline_fixed_string_t vlan;
    9210                 :            :         cmdline_fixed_string_t antispoof;
    9211                 :            :         portid_t port_id;
    9212                 :            :         uint32_t vf_id;
    9213                 :            :         cmdline_fixed_string_t on_off;
    9214                 :            : };
    9215                 :            : 
    9216                 :            : /* Common CLI fields for vf vlan anti spoof enable disable */
    9217                 :            : static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
    9218                 :            :         TOKEN_STRING_INITIALIZER
    9219                 :            :                 (struct cmd_vf_vlan_anti_spoof_result,
    9220                 :            :                  set, "set");
    9221                 :            : static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
    9222                 :            :         TOKEN_STRING_INITIALIZER
    9223                 :            :                 (struct cmd_vf_vlan_anti_spoof_result,
    9224                 :            :                  vf, "vf");
    9225                 :            : static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
    9226                 :            :         TOKEN_STRING_INITIALIZER
    9227                 :            :                 (struct cmd_vf_vlan_anti_spoof_result,
    9228                 :            :                  vlan, "vlan");
    9229                 :            : static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
    9230                 :            :         TOKEN_STRING_INITIALIZER
    9231                 :            :                 (struct cmd_vf_vlan_anti_spoof_result,
    9232                 :            :                  antispoof, "antispoof");
    9233                 :            : static cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
    9234                 :            :         TOKEN_NUM_INITIALIZER
    9235                 :            :                 (struct cmd_vf_vlan_anti_spoof_result,
    9236                 :            :                  port_id, RTE_UINT16);
    9237                 :            : static cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
    9238                 :            :         TOKEN_NUM_INITIALIZER
    9239                 :            :                 (struct cmd_vf_vlan_anti_spoof_result,
    9240                 :            :                  vf_id, RTE_UINT32);
    9241                 :            : static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
    9242                 :            :         TOKEN_STRING_INITIALIZER
    9243                 :            :                 (struct cmd_vf_vlan_anti_spoof_result,
    9244                 :            :                  on_off, "on#off");
    9245                 :            : 
    9246                 :            : static void
    9247                 :          0 : cmd_set_vf_vlan_anti_spoof_parsed(
    9248                 :            :         void *parsed_result,
    9249                 :            :         __rte_unused struct cmdline *cl,
    9250                 :            :         __rte_unused void *data)
    9251                 :            : {
    9252                 :            :         struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
    9253                 :            :         int ret = -ENOTSUP;
    9254                 :            : 
    9255                 :          0 :         __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
    9256                 :            : 
    9257                 :          0 :         if (port_id_is_invalid(res->port_id, ENABLED_WARN))
    9258                 :            :                 return;
    9259                 :            : 
    9260                 :            : #ifdef RTE_NET_IXGBE
    9261                 :            :         if (ret == -ENOTSUP)
    9262                 :          0 :                 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
    9263                 :          0 :                                 res->vf_id, is_on);
    9264                 :            : #endif
    9265                 :            : #ifdef RTE_NET_I40E
    9266                 :          0 :         if (ret == -ENOTSUP)
    9267                 :          0 :                 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
    9268                 :          0 :                                 res->vf_id, is_on);
    9269                 :            : #endif
    9270                 :            : #ifdef RTE_NET_BNXT
    9271                 :          0 :         if (ret == -ENOTSUP)
    9272                 :          0 :                 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
    9273                 :          0 :                                 res->vf_id, is_on);
    9274                 :            : #endif
    9275                 :            : 
    9276                 :          0 :         switch (ret) {
    9277                 :            :         case 0:
    9278                 :            :                 break;
    9279                 :          0 :         case -EINVAL:
    9280                 :          0 :                 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
    9281                 :            :                 break;
    9282                 :          0 :         case -ENODEV:
    9283                 :          0 :                 fprintf(stderr, "invalid port_id %d\n", res->port_id);
    9284                 :            :                 break;
    9285                 :          0 :         case -ENOTSUP:
    9286                 :          0 :                 fprintf(stderr, "function not implemented\n");
    9287                 :            :                 break;
    9288                 :          0 :         default:
    9289                 :          0 :                 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
    9290                 :            :         }
    9291                 :            : }
    9292                 :            : 
    9293                 :            : static cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
    9294                 :            :         .f = cmd_set_vf_vlan_anti_spoof_parsed,
    9295                 :            :         .data = NULL,
    9296                 :            :         .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
    9297                 :            :         .tokens = {
    9298                 :            :                 (void *)&cmd_vf_vlan_anti_spoof_set,
    9299                 :            :                 (void *)&cmd_vf_vlan_anti_spoof_vf,
    9300                 :            :                 (void *)&cmd_vf_vlan_anti_spoof_vlan,
    9301                 :            :                 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
    9302                 :            :                 (void *)&cmd_vf_vlan_anti_spoof_port_id,
    9303                 :            :                 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
    9304                 :            :                 (void *)&cmd_vf_vlan_anti_spoof_on_off,
    9305                 :            :                 NULL,
    9306                 :            :         },
    9307                 :            : };
    9308                 :            : 
    9309                 :            : /* vf mac anti spoof configuration */
    9310                 :            : 
    9311                 :            : /* Common result structure for vf mac anti spoof */
    9312                 :            : struct cmd_vf_mac_anti_spoof_result {
    9313                 :            :         cmdline_fixed_string_t set;
    9314                 :            :         cmdline_fixed_string_t vf;
    9315                 :            :         cmdline_fixed_string_t mac;
    9316                 :            :         cmdline_fixed_string_t antispoof;
    9317                 :            :         portid_t port_id;
    9318                 :            :         uint32_t vf_id;
    9319                 :            :         cmdline_fixed_string_t on_off;
    9320                 :            : };
    9321                 :            : 
    9322                 :            : /* Common CLI fields for vf mac anti spoof enable disable */
    9323                 :            : static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
    9324                 :            :         TOKEN_STRING_INITIALIZER
    9325                 :            :                 (struct cmd_vf_mac_anti_spoof_result,
    9326                 :            :                  set, "set");
    9327                 :            : static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
    9328                 :            :         TOKEN_STRING_INITIALIZER
    9329                 :            :                 (struct cmd_vf_mac_anti_spoof_result,
    9330                 :            :                  vf, "vf");
    9331                 :            : static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
    9332                 :            :         TOKEN_STRING_INITIALIZER
    9333                 :            :                 (struct cmd_vf_mac_anti_spoof_result,
    9334                 :            :                  mac, "mac");
    9335                 :            : static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
    9336                 :            :         TOKEN_STRING_INITIALIZER
    9337                 :            :                 (struct cmd_vf_mac_anti_spoof_result,
    9338                 :            :                  antispoof, "antispoof");
    9339                 :            : static cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
    9340                 :            :         TOKEN_NUM_INITIALIZER
    9341                 :            :                 (struct cmd_vf_mac_anti_spoof_result,
    9342                 :            :                  port_id, RTE_UINT16);
    9343                 :            : static cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
    9344                 :            :         TOKEN_NUM_INITIALIZER
    9345                 :            :                 (struct cmd_vf_mac_anti_spoof_result,
    9346                 :            :                  vf_id, RTE_UINT32);
    9347                 :            : static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
    9348                 :            :         TOKEN_STRING_INITIALIZER
    9349                 :            :                 (struct cmd_vf_mac_anti_spoof_result,
    9350                 :            :                  on_off, "on#off");
    9351                 :            : 
    9352                 :            : static void
    9353                 :          0 : cmd_set_vf_mac_anti_spoof_parsed(
    9354                 :            :         void *parsed_result,
    9355                 :            :         __rte_unused struct cmdline *cl,
    9356                 :            :         __rte_unused void *data)
    9357                 :            : {
    9358                 :            :         struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
    9359                 :            :         int ret = -ENOTSUP;
    9360                 :            : 
    9361                 :          0 :         __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
    9362                 :            : 
    9363                 :          0 :         if (port_id_is_invalid(res->port_id, ENABLED_WARN))
    9364                 :            :                 return;
    9365                 :            : 
    9366                 :            : #ifdef RTE_NET_IXGBE
    9367                 :            :         if (ret == -ENOTSUP)
    9368                 :          0 :                 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
    9369                 :          0 :                         res->vf_id, is_on);
    9370                 :            : #endif
    9371                 :            : #ifdef RTE_NET_I40E
    9372                 :          0 :         if (ret == -ENOTSUP)
    9373                 :          0 :                 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
    9374                 :          0 :                         res->vf_id, is_on);
    9375                 :            : #endif
    9376                 :            : #ifdef RTE_NET_BNXT
    9377                 :          0 :         if (ret == -ENOTSUP)
    9378                 :          0 :                 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
    9379                 :          0 :                         res->vf_id, is_on);
    9380                 :            : #endif
    9381                 :            : 
    9382                 :          0 :         switch (ret) {
    9383                 :            :         case 0:
    9384                 :            :                 break;
    9385                 :          0 :         case -EINVAL:
    9386                 :          0 :                 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
    9387                 :            :                         res->vf_id, is_on);
    9388                 :            :                 break;
    9389                 :          0 :         case -ENODEV:
    9390                 :          0 :                 fprintf(stderr, "invalid port_id %d\n", res->port_id);
    9391                 :            :                 break;
    9392                 :          0 :         case -ENOTSUP:
    9393                 :          0 :                 fprintf(stderr, "function not implemented\n");
    9394                 :            :                 break;
    9395                 :          0 :         default:
    9396                 :          0 :                 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
    9397                 :            :         }
    9398                 :            : }
    9399                 :            : 
    9400                 :            : static cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
    9401                 :            :         .f = cmd_set_vf_mac_anti_spoof_parsed,
    9402                 :            :         .data = NULL,
    9403                 :            :         .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
    9404                 :            :         .tokens = {
    9405                 :            :                 (void *)&cmd_vf_mac_anti_spoof_set,
    9406                 :            :                 (void *)&cmd_vf_mac_anti_spoof_vf,
    9407                 :            :                 (void *)&cmd_vf_mac_anti_spoof_mac,
    9408                 :            :                 (void *)&cmd_vf_mac_anti_spoof_antispoof,
    9409                 :            :                 (void *)&cmd_vf_mac_anti_spoof_port_id,
    9410                 :            :                 (void *)&cmd_vf_mac_anti_spoof_vf_id,
    9411                 :            :                 (void *)&cmd_vf_mac_anti_spoof_on_off,
    9412                 :            :                 NULL,
    9413                 :            :         },
    9414                 :            : };
    9415                 :            : 
    9416                 :            : /* vf vlan strip queue configuration */
    9417                 :            : 
    9418                 :            : /* Common result structure for vf mac anti spoof */
    9419                 :            : struct cmd_vf_vlan_stripq_result {
    9420                 :            :         cmdline_fixed_string_t set;
    9421                 :            :         cmdline_fixed_string_t vf;
    9422                 :            :         cmdline_fixed_string_t vlan;
    9423                 :            :         cmdline_fixed_string_t stripq;
    9424                 :            :         portid_t port_id;
    9425                 :            :         uint16_t vf_id;
    9426                 :            :         cmdline_fixed_string_t on_off;
    9427                 :            : };
    9428                 :            : 
    9429                 :            : /* Common CLI fields for vf vlan strip enable disable */
    9430                 :            : static cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
    9431                 :            :         TOKEN_STRING_INITIALIZER
    9432                 :            :                 (struct cmd_vf_vlan_stripq_result,
    9433                 :            :                  set, "set");
    9434                 :            : static cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
    9435                 :            :         TOKEN_STRING_INITIALIZER
    9436                 :            :                 (struct cmd_vf_vlan_stripq_result,
    9437                 :            :                  vf, "vf");
    9438                 :            : static cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
    9439                 :            :         TOKEN_STRING_INITIALIZER
    9440                 :            :                 (struct cmd_vf_vlan_stripq_result,
    9441                 :            :                  vlan, "vlan");
    9442                 :            : static cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
    9443                 :            :         TOKEN_STRING_INITIALIZER
    9444                 :            :                 (struct cmd_vf_vlan_stripq_result,
    9445                 :            :                  stripq, "stripq");
    9446                 :            : static cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
    9447                 :            :         TOKEN_NUM_INITIALIZER
    9448                 :            :                 (struct cmd_vf_vlan_stripq_result,
    9449                 :            :                  port_id, RTE_UINT16);
    9450                 :            : static cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
    9451                 :            :         TOKEN_NUM_INITIALIZER
    9452                 :            :                 (struct cmd_vf_vlan_stripq_result,
    9453                 :            :                  vf_id, RTE_UINT16);
    9454                 :            : static cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
    9455                 :            :         TOKEN_STRING_INITIALIZER
    9456                 :            :                 (struct cmd_vf_vlan_stripq_result,
    9457                 :            :                  on_off, "on#off");
    9458                 :            : 
    9459                 :            : static void
    9460                 :          0 : cmd_set_vf_vlan_stripq_parsed(
    9461                 :            :         void *parsed_result,
    9462                 :            :         __rte_unused struct cmdline *cl,
    9463                 :            :         __rte_unused void *data)
    9464                 :            : {
    9465                 :            :         struct cmd_vf_vlan_stripq_result *res = parsed_result;
    9466                 :            :         int ret = -ENOTSUP;
    9467                 :            : 
    9468                 :          0 :         __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
    9469                 :            : 
    9470                 :          0 :         if (port_id_is_invalid(res->port_id, ENABLED_WARN))
    9471                 :            :                 return;
    9472                 :            : 
    9473                 :            : #ifdef RTE_NET_IXGBE
    9474                 :            :         if (ret == -ENOTSUP)
    9475                 :          0 :                 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
    9476                 :          0 :                         res->vf_id, is_on);
    9477                 :            : #endif
    9478                 :            : #ifdef RTE_NET_I40E
    9479                 :          0 :         if (ret == -ENOTSUP)
    9480                 :          0 :                 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
    9481                 :          0 :                         res->vf_id, is_on);
    9482                 :            : #endif
    9483                 :            : #ifdef RTE_NET_BNXT
    9484                 :          0 :         if (ret == -ENOTSUP)
    9485                 :          0 :                 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
    9486                 :          0 :                         res->vf_id, is_on);
    9487                 :            : #endif
    9488                 :            : 
    9489                 :          0 :         switch (ret) {
    9490                 :            :         case 0:
    9491                 :            :                 break;
    9492                 :          0 :         case -EINVAL:
    9493                 :          0 :                 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
    9494                 :          0 :                         res->vf_id, is_on);
    9495                 :            :                 break;
    9496                 :          0 :         case -ENODEV:
    9497                 :          0 :                 fprintf(stderr, "invalid port_id %d\n", res->port_id);
    9498                 :            :                 break;
    9499                 :          0 :         case -ENOTSUP:
    9500                 :          0 :                 fprintf(stderr, "function not implemented\n");
    9501                 :            :                 break;
    9502                 :          0 :         default:
    9503                 :          0 :                 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
    9504                 :            :         }
    9505                 :            : }
    9506                 :            : 
    9507                 :            : static cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
    9508                 :            :         .f = cmd_set_vf_vlan_stripq_parsed,
    9509                 :            :         .data = NULL,
    9510                 :            :         .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
    9511                 :            :         .tokens = {
    9512                 :            :                 (void *)&cmd_vf_vlan_stripq_set,
    9513                 :            :                 (void *)&cmd_vf_vlan_stripq_vf,
    9514                 :            :                 (void *)&cmd_vf_vlan_stripq_vlan,
    9515                 :            :                 (void *)&cmd_vf_vlan_stripq_stripq,
    9516                 :            :                 (void *)&cmd_vf_vlan_stripq_port_id,
    9517                 :            :                 (void *)&cmd_vf_vlan_stripq_vf_id,
    9518                 :            :                 (void *)&cmd_vf_vlan_stripq_on_off,
    9519                 :            :                 NULL,
    9520                 :            :         },
    9521                 :            : };
    9522                 :            : 
    9523                 :            : /* vf vlan insert configuration */
    9524                 :            : 
    9525                 :            : /* Common result structure for vf vlan insert */
    9526                 :            : struct cmd_vf_vlan_insert_result {
    9527                 :            :         cmdline_fixed_string_t set;
    9528                 :            :         cmdline_fixed_string_t vf;
    9529                 :            :         cmdline_fixed_string_t vlan;
    9530                 :            :         cmdline_fixed_string_t insert;
    9531                 :            :         portid_t port_id;
    9532                 :            :         uint16_t vf_id;
    9533                 :            :         uint16_t vlan_id;
    9534                 :            : };
    9535                 :            : 
    9536                 :            : /* Common CLI fields for vf vlan insert enable disable */
    9537                 :            : static cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
    9538                 :            :         TOKEN_STRING_INITIALIZER
    9539                 :            :                 (struct cmd_vf_vlan_insert_result,
    9540                 :            :                  set, "set");
    9541                 :            : static cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
    9542                 :            :         TOKEN_STRING_INITIALIZER
    9543                 :            :                 (struct cmd_vf_vlan_insert_result,
    9544                 :            :                  vf, "vf");
    9545                 :            : static cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
    9546                 :            :         TOKEN_STRING_INITIALIZER
    9547                 :            :                 (struct cmd_vf_vlan_insert_result,
    9548                 :            :                  vlan, "vlan");
    9549                 :            : static cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
    9550                 :            :         TOKEN_STRING_INITIALIZER
    9551                 :            :                 (struct cmd_vf_vlan_insert_result,
    9552                 :            :                  insert, "insert");
    9553                 :            : static cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
    9554                 :            :         TOKEN_NUM_INITIALIZER
    9555                 :            :                 (struct cmd_vf_vlan_insert_result,
    9556                 :            :                  port_id, RTE_UINT16);
    9557                 :            : static cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
    9558                 :            :         TOKEN_NUM_INITIALIZER
    9559                 :            :                 (struct cmd_vf_vlan_insert_result,
    9560                 :            :                  vf_id, RTE_UINT16);
    9561                 :            : static cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
    9562                 :            :         TOKEN_NUM_INITIALIZER
    9563                 :            :                 (struct cmd_vf_vlan_insert_result,
    9564                 :            :                  vlan_id, RTE_UINT16);
    9565                 :            : 
    9566                 :            : static void
    9567                 :          0 : cmd_set_vf_vlan_insert_parsed(
    9568                 :            :         void *parsed_result,
    9569                 :            :         __rte_unused struct cmdline *cl,
    9570                 :            :         __rte_unused void *data)
    9571                 :            : {
    9572                 :            :         struct cmd_vf_vlan_insert_result *res = parsed_result;
    9573                 :            :         int ret = -ENOTSUP;
    9574                 :            : 
    9575                 :          0 :         if (port_id_is_invalid(res->port_id, ENABLED_WARN))
    9576                 :            :                 return;
    9577                 :            : 
    9578                 :            : #ifdef RTE_NET_IXGBE
    9579                 :            :         if (ret == -ENOTSUP)
    9580                 :          0 :                 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
    9581                 :          0 :                         res->vlan_id);
    9582                 :            : #endif
    9583                 :            : #ifdef RTE_NET_I40E
    9584                 :          0 :         if (ret == -ENOTSUP)
    9585                 :          0 :                 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
    9586                 :          0 :                         res->vlan_id);
    9587                 :            : #endif
    9588                 :            : #ifdef RTE_NET_BNXT
    9589                 :          0 :         if (ret == -ENOTSUP)
    9590                 :          0 :                 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
    9591                 :          0 :                         res->vlan_id);
    9592                 :            : #endif
    9593                 :            : 
    9594                 :          0 :         switch (ret) {
    9595                 :            :         case 0:
    9596                 :            :                 break;
    9597                 :          0 :         case -EINVAL:
    9598                 :          0 :                 fprintf(stderr, "invalid vf_id %d or vlan_id %d\n",
    9599                 :          0 :                         res->vf_id, res->vlan_id);
    9600                 :            :                 break;
    9601                 :          0 :         case -ENODEV:
    9602                 :          0 :                 fprintf(stderr, "invalid port_id %d\n", res->port_id);
    9603                 :            :                 break;
    9604                 :          0 :         case -ENOTSUP:
    9605                 :          0 :                 fprintf(stderr, "function not implemented\n");
    9606                 :            :                 break;
    9607                 :          0 :         default:
    9608                 :          0 :                 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
    9609                 :            :         }
    9610                 :            : }
    9611                 :            : 
    9612                 :            : static cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
    9613                 :            :         .f = cmd_set_vf_vlan_insert_parsed,
    9614                 :            :         .data = NULL,
    9615                 :            :         .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
    9616                 :            :         .tokens = {
    9617                 :            :                 (void *)&cmd_vf_vlan_insert_set,
    9618                 :            :                 (void *)&cmd_vf_vlan_insert_vf,
    9619                 :            :                 (void *)&cmd_vf_vlan_insert_vlan,
    9620                 :            :                 (void *)&cmd_vf_vlan_insert_insert,
    9621                 :            :                 (void *)&cmd_vf_vlan_insert_port_id,
    9622                 :            :                 (void *)&cmd_vf_vlan_insert_vf_id,
    9623                 :            :                 (void *)&cmd_vf_vlan_insert_vlan_id,
    9624                 :            :                 NULL,
    9625                 :            :         },
    9626                 :            : };
    9627                 :            : 
    9628                 :            : /* tx loopback configuration */
    9629                 :            : 
    9630                 :            : /* Common result structure for tx loopback */
    9631                 :            : struct cmd_tx_loopback_result {
    9632                 :            :         cmdline_fixed_string_t set;
    9633                 :            :         cmdline_fixed_string_t tx;
    9634                 :            :         cmdline_fixed_string_t loopback;
    9635                 :            :         portid_t port_id;
    9636                 :            :         cmdline_fixed_string_t on_off;
    9637                 :            : };
    9638                 :            : 
    9639                 :            : /* Common CLI fields for tx loopback enable disable */
    9640                 :            : static cmdline_parse_token_string_t cmd_tx_loopback_set =
    9641                 :            :         TOKEN_STRING_INITIALIZER
    9642                 :            :                 (struct cmd_tx_loopback_result,
    9643                 :            :                  set, "set");
    9644                 :            : static cmdline_parse_token_string_t cmd_tx_loopback_tx =
    9645                 :            :         TOKEN_STRING_INITIALIZER
    9646                 :            :                 (struct cmd_tx_loopback_result,
    9647                 :            :                  tx, "tx");
    9648                 :            : static cmdline_parse_token_string_t cmd_tx_loopback_loopback =
    9649                 :            :         TOKEN_STRING_INITIALIZER
    9650                 :            :                 (struct cmd_tx_loopback_result,
    9651                 :            :                  loopback, "loopback");
    9652                 :            : static cmdline_parse_token_num_t cmd_tx_loopback_port_id =
    9653                 :            :         TOKEN_NUM_INITIALIZER
    9654                 :            :                 (struct cmd_tx_loopback_result,
    9655                 :            :                  port_id, RTE_UINT16);
    9656                 :            : static cmdline_parse_token_string_t cmd_tx_loopback_on_off =
    9657                 :            :         TOKEN_STRING_INITIALIZER
    9658                 :            :                 (struct cmd_tx_loopback_result,
    9659                 :            :                  on_off, "on#off");
    9660                 :            : 
    9661                 :            : static void
    9662                 :          0 : cmd_set_tx_loopback_parsed(
    9663                 :            :         void *parsed_result,
    9664                 :            :         __rte_unused struct cmdline *cl,
    9665                 :            :         __rte_unused void *data)
    9666                 :            : {
    9667                 :            :         struct cmd_tx_loopback_result *res = parsed_result;
    9668                 :            :         int ret = -ENOTSUP;
    9669                 :            : 
    9670                 :          0 :         __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
    9671                 :            : 
    9672                 :          0 :         if (port_id_is_invalid(res->port_id, ENABLED_WARN))
    9673                 :            :                 return;
    9674                 :            : 
    9675                 :            : #ifdef RTE_NET_IXGBE
    9676                 :            :         if (ret == -ENOTSUP)
    9677                 :          0 :                 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
    9678                 :            : #endif
    9679                 :            : #ifdef RTE_NET_I40E
    9680                 :          0 :         if (ret == -ENOTSUP)
    9681                 :          0 :                 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
    9682                 :            : #endif
    9683                 :            : #ifdef RTE_NET_BNXT
    9684                 :          0 :         if (ret == -ENOTSUP)
    9685                 :          0 :                 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
    9686                 :            : #endif
    9687                 :            : #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
    9688                 :          0 :         if (ret == -ENOTSUP)
    9689                 :          0 :                 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
    9690                 :            : #endif
    9691                 :            : 
    9692                 :          0 :         switch (ret) {
    9693                 :            :         case 0:
    9694                 :            :                 break;
    9695                 :          0 :         case -EINVAL:
    9696                 :          0 :                 fprintf(stderr, "invalid is_on %d\n", is_on);
    9697                 :            :                 break;
    9698                 :          0 :         case -ENODEV:
    9699                 :          0 :                 fprintf(stderr, "invalid port_id %d\n", res->port_id);
    9700                 :            :                 break;
    9701                 :          0 :         case -ENOTSUP:
    9702                 :          0 :                 fprintf(stderr, "function not implemented\n");
    9703                 :            :                 break;
    9704                 :          0 :         default:
    9705                 :          0 :                 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
    9706                 :            :         }
    9707                 :            : }
    9708                 :            : 
    9709                 :            : static cmdline_parse_inst_t cmd_set_tx_loopback = {
    9710                 :            :         .f = cmd_set_tx_loopback_parsed,
    9711                 :            :         .data = NULL,
    9712                 :            :         .help_str = "set tx loopback <port_id> on|off",
    9713                 :            :         .tokens = {
    9714                 :            :                 (void *)&cmd_tx_loopback_set,
    9715                 :            :                 (void *)&cmd_tx_loopback_tx,
    9716                 :            :                 (void *)&cmd_tx_loopback_loopback,
    9717                 :            :                 (void *)&cmd_tx_loopback_port_id,
    9718                 :            :                 (void *)&cmd_tx_loopback_on_off,
    9719                 :            :                 NULL,
    9720                 :            :         },
    9721                 :            : };
    9722                 :            : 
    9723                 :            : /* all queues drop enable configuration */
    9724                 :            : 
    9725                 :            : /* Common result structure for all queues drop enable */
    9726                 :            : struct cmd_all_queues_drop_en_result {
    9727                 :            :         cmdline_fixed_string_t set;
    9728                 :            :         cmdline_fixed_string_t all;
    9729                 :            :         cmdline_fixed_string_t queues;
    9730                 :            :         cmdline_fixed_string_t drop;
    9731                 :            :         portid_t port_id;
    9732                 :            :         cmdline_fixed_string_t on_off;
    9733                 :            : };
    9734                 :            : 
    9735                 :            : /* Common CLI fields for tx loopback enable disable */
    9736                 :            : static cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
    9737                 :            :         TOKEN_STRING_INITIALIZER
    9738                 :            :                 (struct cmd_all_queues_drop_en_result,
    9739                 :            :                  set, "set");
    9740                 :            : static cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
    9741                 :            :         TOKEN_STRING_INITIALIZER
    9742                 :            :                 (struct cmd_all_queues_drop_en_result,
    9743                 :            :                  all, "all");
    9744                 :            : static cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
    9745                 :            :         TOKEN_STRING_INITIALIZER
    9746                 :            :                 (struct cmd_all_queues_drop_en_result,
    9747                 :            :                  queues, "queues");
    9748                 :            : static cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
    9749                 :            :         TOKEN_STRING_INITIALIZER
    9750                 :            :                 (struct cmd_all_queues_drop_en_result,
    9751                 :            :                  drop, "drop");
    9752                 :            : static cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
    9753                 :            :         TOKEN_NUM_INITIALIZER
    9754                 :            :                 (struct cmd_all_queues_drop_en_result,
    9755                 :            :                  port_id, RTE_UINT16);
    9756                 :            : static cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
    9757                 :            :         TOKEN_STRING_INITIALIZER
    9758                 :            :                 (struct cmd_all_queues_drop_en_result,
    9759                 :            :                  on_off, "on#off");
    9760                 :            : 
    9761                 :            : static void
    9762                 :          0 : cmd_set_all_queues_drop_en_parsed(
    9763                 :            :         void *parsed_result,
    9764                 :            :         __rte_unused struct cmdline *cl,
    9765                 :            :         __rte_unused void *data)
    9766                 :            : {
    9767                 :            :         struct cmd_all_queues_drop_en_result *res = parsed_result;
    9768                 :            :         int ret = -ENOTSUP;
    9769                 :          0 :         int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
    9770                 :            : 
    9771                 :          0 :         if (port_id_is_invalid(res->port_id, ENABLED_WARN))
    9772                 :            :                 return;
    9773                 :            : 
    9774                 :            : #ifdef RTE_NET_IXGBE
    9775                 :            :         if (ret == -ENOTSUP)
    9776                 :          0 :                 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
    9777                 :            : #endif
    9778                 :            : #ifdef RTE_NET_BNXT
    9779                 :          0 :         if (ret == -ENOTSUP)
    9780                 :          0 :                 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
    9781                 :            : #endif
    9782                 :          0 :         switch (ret) {
    9783                 :            :         case 0:
    9784                 :            :                 break;
    9785                 :          0 :         case -EINVAL:
    9786                 :          0 :                 fprintf(stderr, "invalid is_on %d\n", is_on);
    9787                 :            :                 break;
    9788                 :          0 :         case -ENODEV:
    9789                 :          0 :                 fprintf(stderr, "invalid port_id %d\n", res->port_id);
    9790                 :            :                 break;
    9791                 :          0 :         case -ENOTSUP:
    9792                 :          0 :                 fprintf(stderr, "function not implemented\n");
    9793                 :            :                 break;
    9794                 :          0 :         default:
    9795                 :          0 :                 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
    9796                 :            :         }
    9797                 :            : }
    9798                 :            : 
    9799                 :            : static cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
    9800                 :            :         .f = cmd_set_all_queues_drop_en_parsed,
    9801                 :            :         .data = NULL,
    9802                 :            :         .help_str = "set all queues drop <port_id> on|off",
    9803                 :            :         .tokens = {
    9804                 :            :                 (void *)&cmd_all_queues_drop_en_set,
    9805                 :            :                 (void *)&cmd_all_queues_drop_en_all,
    9806                 :            :                 (void *)&cmd_all_queues_drop_en_queues,
    9807                 :            :                 (void *)&cmd_all_queues_drop_en_drop,
    9808                 :            :                 (void *)&cmd_all_queues_drop_en_port_id,
    9809                 :            :                 (void *)&cmd_all_queues_drop_en_on_off,
    9810                 :            :                 NULL,
    9811                 :            :         },
    9812                 :            : };
    9813                 :            : 
    9814                 :            : /* vf mac address configuration */
    9815                 :            : 
    9816                 :            : /* Common result structure for vf mac address */
    9817                 :            : struct cmd_set_vf_mac_addr_result {
    9818                 :            :         cmdline_fixed_string_t set;
    9819                 :            :         cmdline_fixed_string_t vf;
    9820                 :            :         cmdline_fixed_string_t mac;
    9821                 :            :         cmdline_fixed_string_t addr;
    9822                 :            :         portid_t port_id;
    9823                 :            :         uint16_t vf_id;
    9824                 :            :         struct rte_ether_addr mac_addr;
    9825                 :            : 
    9826                 :            : };
    9827                 :            : 
    9828                 :            : /* Common CLI fields for vf split drop enable disable */
    9829                 :            : static cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
    9830                 :            :         TOKEN_STRING_INITIALIZER
    9831                 :            :                 (struct cmd_set_vf_mac_addr_result,
    9832                 :            :                  set, "set");
    9833                 :            : static cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
    9834                 :            :         TOKEN_STRING_INITIALIZER
    9835                 :            :                 (struct cmd_set_vf_mac_addr_result,
    9836                 :            :                  vf, "vf");
    9837                 :            : static cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
    9838                 :            :         TOKEN_STRING_INITIALIZER
    9839                 :            :                 (struct cmd_set_vf_mac_addr_result,
    9840                 :            :                  mac, "mac");
    9841                 :            : static cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
    9842                 :            :         TOKEN_STRING_INITIALIZER
    9843                 :            :                 (struct cmd_set_vf_mac_addr_result,
    9844                 :            :                  addr, "addr");
    9845                 :            : static cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
    9846                 :            :         TOKEN_NUM_INITIALIZER
    9847                 :            :                 (struct cmd_set_vf_mac_addr_result,
    9848                 :            :                  port_id, RTE_UINT16);
    9849                 :            : static cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
    9850                 :            :         TOKEN_NUM_INITIALIZER
    9851                 :            :                 (struct cmd_set_vf_mac_addr_result,
    9852                 :            :                  vf_id, RTE_UINT16);
    9853                 :            : static cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
    9854                 :            :         TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
    9855                 :            :                  mac_addr);
    9856                 :            : 
    9857                 :            : static void
    9858                 :          0 : cmd_set_vf_mac_addr_parsed(
    9859                 :            :         void *parsed_result,
    9860                 :            :         __rte_unused struct cmdline *cl,
    9861                 :            :         __rte_unused void *data)
    9862                 :            : {
    9863                 :            :         struct cmd_set_vf_mac_addr_result *res = parsed_result;
    9864                 :            :         int ret = -ENOTSUP;
    9865                 :            : 
    9866                 :          0 :         if (port_id_is_invalid(res->port_id, ENABLED_WARN))
    9867                 :            :                 return;
    9868                 :            : 
    9869                 :            : #ifdef RTE_NET_IXGBE
    9870                 :            :         if (ret == -ENOTSUP)
    9871                 :          0 :                 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
    9872                 :            :                                 &res->mac_addr);
    9873                 :            : #endif
    9874                 :            : #ifdef RTE_NET_I40E
    9875                 :          0 :         if (ret == -ENOTSUP)
    9876                 :          0 :                 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
    9877                 :            :                                 &res->mac_addr);
    9878                 :            : #endif
    9879                 :            : #ifdef RTE_NET_BNXT
    9880                 :          0 :         if (ret == -ENOTSUP)
    9881                 :          0 :                 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
    9882                 :            :                                 &res->mac_addr);
    9883                 :            : #endif
    9884                 :            : 
    9885                 :          0 :         switch (ret) {
    9886                 :            :         case 0:
    9887                 :            :                 break;
    9888                 :          0 :         case -EINVAL:
    9889                 :          0 :                 fprintf(stderr, "invalid vf_id %d or mac_addr\n", res->vf_id);
    9890                 :            :                 break;
    9891                 :          0 :         case -ENODEV:
    9892                 :          0 :                 fprintf(stderr, "invalid port_id %d\n", res->port_id);
    9893                 :            :                 break;
    9894                 :          0 :         case -ENOTSUP:
    9895                 :          0 :                 fprintf(stderr, "function not implemented\n");
    9896                 :            :                 break;
    9897                 :          0 :         default:
    9898                 :          0 :                 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
    9899                 :            :         }
    9900                 :            : }
    9901                 :            : 
    9902                 :            : static cmdline_parse_inst_t cmd_set_vf_mac_addr = {
    9903                 :            :         .f = cmd_set_vf_mac_addr_parsed,
    9904                 :            :         .data = NULL,
    9905                 :            :         .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
    9906                 :            :         .tokens = {
    9907                 :            :                 (void *)&cmd_set_vf_mac_addr_set,
    9908                 :            :                 (void *)&cmd_set_vf_mac_addr_vf,
    9909                 :            :                 (void *)&cmd_set_vf_mac_addr_mac,
    9910                 :            :                 (void *)&cmd_set_vf_mac_addr_addr,
    9911                 :            :                 (void *)&cmd_set_vf_mac_addr_port_id,
    9912                 :            :                 (void *)&cmd_set_vf_mac_addr_vf_id,
    9913                 :            :                 (void *)&cmd_set_vf_mac_addr_mac_addr,
    9914                 :            :                 NULL,
    9915                 :            :         },
    9916                 :            : };
    9917                 :            : 
    9918                 :            : /** Set VXLAN encapsulation details */
    9919                 :            : struct cmd_set_vxlan_result {
    9920                 :            :         cmdline_fixed_string_t set;
    9921                 :            :         cmdline_fixed_string_t vxlan;
    9922                 :            :         cmdline_fixed_string_t pos_token;
    9923                 :            :         cmdline_fixed_string_t ip_version;
    9924                 :            :         uint32_t vlan_present:1;
    9925                 :            :         uint32_t vni;
    9926                 :            :         uint16_t udp_src;
    9927                 :            :         uint16_t udp_dst;
    9928                 :            :         cmdline_ipaddr_t ip_src;
    9929                 :            :         cmdline_ipaddr_t ip_dst;
    9930                 :            :         uint16_t tci;
    9931                 :            :         uint8_t tos;
    9932                 :            :         uint8_t ttl;
    9933                 :            :         struct rte_ether_addr eth_src;
    9934                 :            :         struct rte_ether_addr eth_dst;
    9935                 :            : };
    9936                 :            : 
    9937                 :            : static cmdline_parse_token_string_t cmd_set_vxlan_set =
    9938                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
    9939                 :            : static cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
    9940                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
    9941                 :            : static cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
    9942                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
    9943                 :            :                                  "vxlan-tos-ttl");
    9944                 :            : static cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
    9945                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
    9946                 :            :                                  "vxlan-with-vlan");
    9947                 :            : static cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
    9948                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
    9949                 :            :                                  "ip-version");
    9950                 :            : static cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
    9951                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
    9952                 :            :                                  "ipv4#ipv6");
    9953                 :            : static cmdline_parse_token_string_t cmd_set_vxlan_vni =
    9954                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
    9955                 :            :                                  "vni");
    9956                 :            : static cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
    9957                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, RTE_UINT32);
    9958                 :            : static cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
    9959                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
    9960                 :            :                                  "udp-src");
    9961                 :            : static cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
    9962                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, RTE_UINT16);
    9963                 :            : static cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
    9964                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
    9965                 :            :                                  "udp-dst");
    9966                 :            : static cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
    9967                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, RTE_UINT16);
    9968                 :            : static cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
    9969                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
    9970                 :            :                                  "ip-tos");
    9971                 :            : static cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
    9972                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, RTE_UINT8);
    9973                 :            : static cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
    9974                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
    9975                 :            :                                  "ip-ttl");
    9976                 :            : static cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
    9977                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, RTE_UINT8);
    9978                 :            : static cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
    9979                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
    9980                 :            :                                  "ip-src");
    9981                 :            : static cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
    9982                 :            :         TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
    9983                 :            : static cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
    9984                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
    9985                 :            :                                  "ip-dst");
    9986                 :            : static cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
    9987                 :            :         TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
    9988                 :            : static cmdline_parse_token_string_t cmd_set_vxlan_vlan =
    9989                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
    9990                 :            :                                  "vlan-tci");
    9991                 :            : static cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
    9992                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, RTE_UINT16);
    9993                 :            : static cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
    9994                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
    9995                 :            :                                  "eth-src");
    9996                 :            : static cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
    9997                 :            :         TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
    9998                 :            : static cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
    9999                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
   10000                 :            :                                  "eth-dst");
   10001                 :            : static cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
   10002                 :            :         TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
   10003                 :            : 
   10004                 :          0 : static void cmd_set_vxlan_parsed(void *parsed_result,
   10005                 :            :         __rte_unused struct cmdline *cl,
   10006                 :            :         __rte_unused void *data)
   10007                 :            : {
   10008                 :            :         struct cmd_set_vxlan_result *res = parsed_result;
   10009                 :            :         union {
   10010                 :            :                 uint32_t vxlan_id;
   10011                 :            :                 uint8_t vni[4];
   10012                 :          0 :         } id = {
   10013                 :          0 :                 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
   10014                 :            :         };
   10015                 :            : 
   10016                 :          0 :         vxlan_encap_conf.select_tos_ttl = 0;
   10017                 :          0 :         if (strcmp(res->vxlan, "vxlan") == 0)
   10018                 :          0 :                 vxlan_encap_conf.select_vlan = 0;
   10019                 :          0 :         else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
   10020                 :          0 :                 vxlan_encap_conf.select_vlan = 1;
   10021                 :          0 :         else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
   10022                 :          0 :                 vxlan_encap_conf.select_vlan = 0;
   10023                 :          0 :                 vxlan_encap_conf.select_tos_ttl = 1;
   10024                 :            :         }
   10025                 :          0 :         if (strcmp(res->ip_version, "ipv4") == 0)
   10026                 :          0 :                 vxlan_encap_conf.select_ipv4 = 1;
   10027                 :          0 :         else if (strcmp(res->ip_version, "ipv6") == 0)
   10028                 :          0 :                 vxlan_encap_conf.select_ipv4 = 0;
   10029                 :            :         else
   10030                 :          0 :                 return;
   10031                 :            :         rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
   10032                 :          0 :         vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
   10033                 :          0 :         vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
   10034                 :          0 :         vxlan_encap_conf.ip_tos = res->tos;
   10035                 :          0 :         vxlan_encap_conf.ip_ttl = res->ttl;
   10036                 :          0 :         if (vxlan_encap_conf.select_ipv4) {
   10037                 :          0 :                 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
   10038                 :          0 :                 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
   10039                 :            :         } else {
   10040                 :          0 :                 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
   10041                 :          0 :                 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
   10042                 :            :         }
   10043                 :          0 :         if (vxlan_encap_conf.select_vlan)
   10044                 :          0 :                 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
   10045                 :          0 :         rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
   10046                 :            :                    RTE_ETHER_ADDR_LEN);
   10047                 :            :         rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
   10048                 :            :                    RTE_ETHER_ADDR_LEN);
   10049                 :            : }
   10050                 :            : 
   10051                 :            : static cmdline_parse_inst_t cmd_set_vxlan = {
   10052                 :            :         .f = cmd_set_vxlan_parsed,
   10053                 :            :         .data = NULL,
   10054                 :            :         .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
   10055                 :            :                 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
   10056                 :            :                 " eth-src <eth-src> eth-dst <eth-dst>",
   10057                 :            :         .tokens = {
   10058                 :            :                 (void *)&cmd_set_vxlan_set,
   10059                 :            :                 (void *)&cmd_set_vxlan_vxlan,
   10060                 :            :                 (void *)&cmd_set_vxlan_ip_version,
   10061                 :            :                 (void *)&cmd_set_vxlan_ip_version_value,
   10062                 :            :                 (void *)&cmd_set_vxlan_vni,
   10063                 :            :                 (void *)&cmd_set_vxlan_vni_value,
   10064                 :            :                 (void *)&cmd_set_vxlan_udp_src,
   10065                 :            :                 (void *)&cmd_set_vxlan_udp_src_value,
   10066                 :            :                 (void *)&cmd_set_vxlan_udp_dst,
   10067                 :            :                 (void *)&cmd_set_vxlan_udp_dst_value,
   10068                 :            :                 (void *)&cmd_set_vxlan_ip_src,
   10069                 :            :                 (void *)&cmd_set_vxlan_ip_src_value,
   10070                 :            :                 (void *)&cmd_set_vxlan_ip_dst,
   10071                 :            :                 (void *)&cmd_set_vxlan_ip_dst_value,
   10072                 :            :                 (void *)&cmd_set_vxlan_eth_src,
   10073                 :            :                 (void *)&cmd_set_vxlan_eth_src_value,
   10074                 :            :                 (void *)&cmd_set_vxlan_eth_dst,
   10075                 :            :                 (void *)&cmd_set_vxlan_eth_dst_value,
   10076                 :            :                 NULL,
   10077                 :            :         },
   10078                 :            : };
   10079                 :            : 
   10080                 :            : static cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
   10081                 :            :         .f = cmd_set_vxlan_parsed,
   10082                 :            :         .data = NULL,
   10083                 :            :         .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
   10084                 :            :                 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
   10085                 :            :                 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
   10086                 :            :                 " eth-dst <eth-dst>",
   10087                 :            :         .tokens = {
   10088                 :            :                 (void *)&cmd_set_vxlan_set,
   10089                 :            :                 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
   10090                 :            :                 (void *)&cmd_set_vxlan_ip_version,
   10091                 :            :                 (void *)&cmd_set_vxlan_ip_version_value,
   10092                 :            :                 (void *)&cmd_set_vxlan_vni,
   10093                 :            :                 (void *)&cmd_set_vxlan_vni_value,
   10094                 :            :                 (void *)&cmd_set_vxlan_udp_src,
   10095                 :            :                 (void *)&cmd_set_vxlan_udp_src_value,
   10096                 :            :                 (void *)&cmd_set_vxlan_udp_dst,
   10097                 :            :                 (void *)&cmd_set_vxlan_udp_dst_value,
   10098                 :            :                 (void *)&cmd_set_vxlan_ip_tos,
   10099                 :            :                 (void *)&cmd_set_vxlan_ip_tos_value,
   10100                 :            :                 (void *)&cmd_set_vxlan_ip_ttl,
   10101                 :            :                 (void *)&cmd_set_vxlan_ip_ttl_value,
   10102                 :            :                 (void *)&cmd_set_vxlan_ip_src,
   10103                 :            :                 (void *)&cmd_set_vxlan_ip_src_value,
   10104                 :            :                 (void *)&cmd_set_vxlan_ip_dst,
   10105                 :            :                 (void *)&cmd_set_vxlan_ip_dst_value,
   10106                 :            :                 (void *)&cmd_set_vxlan_eth_src,
   10107                 :            :                 (void *)&cmd_set_vxlan_eth_src_value,
   10108                 :            :                 (void *)&cmd_set_vxlan_eth_dst,
   10109                 :            :                 (void *)&cmd_set_vxlan_eth_dst_value,
   10110                 :            :                 NULL,
   10111                 :            :         },
   10112                 :            : };
   10113                 :            : 
   10114                 :            : static cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
   10115                 :            :         .f = cmd_set_vxlan_parsed,
   10116                 :            :         .data = NULL,
   10117                 :            :         .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
   10118                 :            :                 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
   10119                 :            :                 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
   10120                 :            :                 " <eth-dst>",
   10121                 :            :         .tokens = {
   10122                 :            :                 (void *)&cmd_set_vxlan_set,
   10123                 :            :                 (void *)&cmd_set_vxlan_vxlan_with_vlan,
   10124                 :            :                 (void *)&cmd_set_vxlan_ip_version,
   10125                 :            :                 (void *)&cmd_set_vxlan_ip_version_value,
   10126                 :            :                 (void *)&cmd_set_vxlan_vni,
   10127                 :            :                 (void *)&cmd_set_vxlan_vni_value,
   10128                 :            :                 (void *)&cmd_set_vxlan_udp_src,
   10129                 :            :                 (void *)&cmd_set_vxlan_udp_src_value,
   10130                 :            :                 (void *)&cmd_set_vxlan_udp_dst,
   10131                 :            :                 (void *)&cmd_set_vxlan_udp_dst_value,
   10132                 :            :                 (void *)&cmd_set_vxlan_ip_src,
   10133                 :            :                 (void *)&cmd_set_vxlan_ip_src_value,
   10134                 :            :                 (void *)&cmd_set_vxlan_ip_dst,
   10135                 :            :                 (void *)&cmd_set_vxlan_ip_dst_value,
   10136                 :            :                 (void *)&cmd_set_vxlan_vlan,
   10137                 :            :                 (void *)&cmd_set_vxlan_vlan_value,
   10138                 :            :                 (void *)&cmd_set_vxlan_eth_src,
   10139                 :            :                 (void *)&cmd_set_vxlan_eth_src_value,
   10140                 :            :                 (void *)&cmd_set_vxlan_eth_dst,
   10141                 :            :                 (void *)&cmd_set_vxlan_eth_dst_value,
   10142                 :            :                 NULL,
   10143                 :            :         },
   10144                 :            : };
   10145                 :            : 
   10146                 :            : /** Set NVGRE encapsulation details */
   10147                 :            : struct cmd_set_nvgre_result {
   10148                 :            :         cmdline_fixed_string_t set;
   10149                 :            :         cmdline_fixed_string_t nvgre;
   10150                 :            :         cmdline_fixed_string_t pos_token;
   10151                 :            :         cmdline_fixed_string_t ip_version;
   10152                 :            :         uint32_t tni;
   10153                 :            :         cmdline_ipaddr_t ip_src;
   10154                 :            :         cmdline_ipaddr_t ip_dst;
   10155                 :            :         uint16_t tci;
   10156                 :            :         struct rte_ether_addr eth_src;
   10157                 :            :         struct rte_ether_addr eth_dst;
   10158                 :            : };
   10159                 :            : 
   10160                 :            : static cmdline_parse_token_string_t cmd_set_nvgre_set =
   10161                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
   10162                 :            : static cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
   10163                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
   10164                 :            : static cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
   10165                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
   10166                 :            :                                  "nvgre-with-vlan");
   10167                 :            : static cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
   10168                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
   10169                 :            :                                  "ip-version");
   10170                 :            : static cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
   10171                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
   10172                 :            :                                  "ipv4#ipv6");
   10173                 :            : static cmdline_parse_token_string_t cmd_set_nvgre_tni =
   10174                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
   10175                 :            :                                  "tni");
   10176                 :            : static cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
   10177                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, RTE_UINT32);
   10178                 :            : static cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
   10179                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
   10180                 :            :                                  "ip-src");
   10181                 :            : static cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
   10182                 :            :         TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
   10183                 :            : static cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
   10184                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
   10185                 :            :                                  "ip-dst");
   10186                 :            : static cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
   10187                 :            :         TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
   10188                 :            : static cmdline_parse_token_string_t cmd_set_nvgre_vlan =
   10189                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
   10190                 :            :                                  "vlan-tci");
   10191                 :            : static cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
   10192                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, RTE_UINT16);
   10193                 :            : static cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
   10194                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
   10195                 :            :                                  "eth-src");
   10196                 :            : static cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
   10197                 :            :         TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
   10198                 :            : static cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
   10199                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
   10200                 :            :                                  "eth-dst");
   10201                 :            : static cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
   10202                 :            :         TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
   10203                 :            : 
   10204                 :          0 : static void cmd_set_nvgre_parsed(void *parsed_result,
   10205                 :            :         __rte_unused struct cmdline *cl,
   10206                 :            :         __rte_unused void *data)
   10207                 :            : {
   10208                 :            :         struct cmd_set_nvgre_result *res = parsed_result;
   10209                 :            :         union {
   10210                 :            :                 uint32_t nvgre_tni;
   10211                 :            :                 uint8_t tni[4];
   10212                 :          0 :         } id = {
   10213                 :          0 :                 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
   10214                 :            :         };
   10215                 :            : 
   10216                 :          0 :         if (strcmp(res->nvgre, "nvgre") == 0)
   10217                 :          0 :                 nvgre_encap_conf.select_vlan = 0;
   10218                 :          0 :         else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
   10219                 :          0 :                 nvgre_encap_conf.select_vlan = 1;
   10220                 :          0 :         if (strcmp(res->ip_version, "ipv4") == 0)
   10221                 :          0 :                 nvgre_encap_conf.select_ipv4 = 1;
   10222                 :          0 :         else if (strcmp(res->ip_version, "ipv6") == 0)
   10223                 :          0 :                 nvgre_encap_conf.select_ipv4 = 0;
   10224                 :            :         else
   10225                 :          0 :                 return;
   10226                 :            :         rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
   10227                 :          0 :         if (nvgre_encap_conf.select_ipv4) {
   10228                 :          0 :                 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
   10229                 :          0 :                 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
   10230                 :            :         } else {
   10231                 :          0 :                 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
   10232                 :          0 :                 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
   10233                 :            :         }
   10234                 :          0 :         if (nvgre_encap_conf.select_vlan)
   10235                 :          0 :                 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
   10236                 :            :         rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
   10237                 :            :                    RTE_ETHER_ADDR_LEN);
   10238                 :          0 :         rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
   10239                 :            :                    RTE_ETHER_ADDR_LEN);
   10240                 :            : }
   10241                 :            : 
   10242                 :            : static cmdline_parse_inst_t cmd_set_nvgre = {
   10243                 :            :         .f = cmd_set_nvgre_parsed,
   10244                 :            :         .data = NULL,
   10245                 :            :         .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
   10246                 :            :                 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
   10247                 :            :                 " eth-dst <eth-dst>",
   10248                 :            :         .tokens = {
   10249                 :            :                 (void *)&cmd_set_nvgre_set,
   10250                 :            :                 (void *)&cmd_set_nvgre_nvgre,
   10251                 :            :                 (void *)&cmd_set_nvgre_ip_version,
   10252                 :            :                 (void *)&cmd_set_nvgre_ip_version_value,
   10253                 :            :                 (void *)&cmd_set_nvgre_tni,
   10254                 :            :                 (void *)&cmd_set_nvgre_tni_value,
   10255                 :            :                 (void *)&cmd_set_nvgre_ip_src,
   10256                 :            :                 (void *)&cmd_set_nvgre_ip_src_value,
   10257                 :            :                 (void *)&cmd_set_nvgre_ip_dst,
   10258                 :            :                 (void *)&cmd_set_nvgre_ip_dst_value,
   10259                 :            :                 (void *)&cmd_set_nvgre_eth_src,
   10260                 :            :                 (void *)&cmd_set_nvgre_eth_src_value,
   10261                 :            :                 (void *)&cmd_set_nvgre_eth_dst,
   10262                 :            :                 (void *)&cmd_set_nvgre_eth_dst_value,
   10263                 :            :                 NULL,
   10264                 :            :         },
   10265                 :            : };
   10266                 :            : 
   10267                 :            : static cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
   10268                 :            :         .f = cmd_set_nvgre_parsed,
   10269                 :            :         .data = NULL,
   10270                 :            :         .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
   10271                 :            :                 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
   10272                 :            :                 " eth-src <eth-src> eth-dst <eth-dst>",
   10273                 :            :         .tokens = {
   10274                 :            :                 (void *)&cmd_set_nvgre_set,
   10275                 :            :                 (void *)&cmd_set_nvgre_nvgre_with_vlan,
   10276                 :            :                 (void *)&cmd_set_nvgre_ip_version,
   10277                 :            :                 (void *)&cmd_set_nvgre_ip_version_value,
   10278                 :            :                 (void *)&cmd_set_nvgre_tni,
   10279                 :            :                 (void *)&cmd_set_nvgre_tni_value,
   10280                 :            :                 (void *)&cmd_set_nvgre_ip_src,
   10281                 :            :                 (void *)&cmd_set_nvgre_ip_src_value,
   10282                 :            :                 (void *)&cmd_set_nvgre_ip_dst,
   10283                 :            :                 (void *)&cmd_set_nvgre_ip_dst_value,
   10284                 :            :                 (void *)&cmd_set_nvgre_vlan,
   10285                 :            :                 (void *)&cmd_set_nvgre_vlan_value,
   10286                 :            :                 (void *)&cmd_set_nvgre_eth_src,
   10287                 :            :                 (void *)&cmd_set_nvgre_eth_src_value,
   10288                 :            :                 (void *)&cmd_set_nvgre_eth_dst,
   10289                 :            :                 (void *)&cmd_set_nvgre_eth_dst_value,
   10290                 :            :                 NULL,
   10291                 :            :         },
   10292                 :            : };
   10293                 :            : 
   10294                 :            : /** Set L2 encapsulation details */
   10295                 :            : struct cmd_set_l2_encap_result {
   10296                 :            :         cmdline_fixed_string_t set;
   10297                 :            :         cmdline_fixed_string_t l2_encap;
   10298                 :            :         cmdline_fixed_string_t pos_token;
   10299                 :            :         cmdline_fixed_string_t ip_version;
   10300                 :            :         uint32_t vlan_present:1;
   10301                 :            :         uint16_t tci;
   10302                 :            :         struct rte_ether_addr eth_src;
   10303                 :            :         struct rte_ether_addr eth_dst;
   10304                 :            : };
   10305                 :            : 
   10306                 :            : static cmdline_parse_token_string_t cmd_set_l2_encap_set =
   10307                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
   10308                 :            : static cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
   10309                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
   10310                 :            : static cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
   10311                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
   10312                 :            :                                  "l2_encap-with-vlan");
   10313                 :            : static cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
   10314                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
   10315                 :            :                                  "ip-version");
   10316                 :            : static cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
   10317                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
   10318                 :            :                                  "ipv4#ipv6");
   10319                 :            : static cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
   10320                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
   10321                 :            :                                  "vlan-tci");
   10322                 :            : static cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
   10323                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, RTE_UINT16);
   10324                 :            : static cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
   10325                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
   10326                 :            :                                  "eth-src");
   10327                 :            : static cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
   10328                 :            :         TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
   10329                 :            : static cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
   10330                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
   10331                 :            :                                  "eth-dst");
   10332                 :            : static cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
   10333                 :            :         TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
   10334                 :            : 
   10335                 :          0 : static void cmd_set_l2_encap_parsed(void *parsed_result,
   10336                 :            :         __rte_unused struct cmdline *cl,
   10337                 :            :         __rte_unused void *data)
   10338                 :            : {
   10339                 :            :         struct cmd_set_l2_encap_result *res = parsed_result;
   10340                 :            : 
   10341                 :          0 :         if (strcmp(res->l2_encap, "l2_encap") == 0)
   10342                 :          0 :                 l2_encap_conf.select_vlan = 0;
   10343                 :          0 :         else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
   10344                 :          0 :                 l2_encap_conf.select_vlan = 1;
   10345                 :          0 :         if (strcmp(res->ip_version, "ipv4") == 0)
   10346                 :          0 :                 l2_encap_conf.select_ipv4 = 1;
   10347                 :          0 :         else if (strcmp(res->ip_version, "ipv6") == 0)
   10348                 :          0 :                 l2_encap_conf.select_ipv4 = 0;
   10349                 :            :         else
   10350                 :            :                 return;
   10351                 :          0 :         if (l2_encap_conf.select_vlan)
   10352                 :          0 :                 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
   10353                 :          0 :         rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
   10354                 :            :                    RTE_ETHER_ADDR_LEN);
   10355                 :            :         rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
   10356                 :            :                    RTE_ETHER_ADDR_LEN);
   10357                 :            : }
   10358                 :            : 
   10359                 :            : static cmdline_parse_inst_t cmd_set_l2_encap = {
   10360                 :            :         .f = cmd_set_l2_encap_parsed,
   10361                 :            :         .data = NULL,
   10362                 :            :         .help_str = "set l2_encap ip-version ipv4|ipv6"
   10363                 :            :                 " eth-src <eth-src> eth-dst <eth-dst>",
   10364                 :            :         .tokens = {
   10365                 :            :                 (void *)&cmd_set_l2_encap_set,
   10366                 :            :                 (void *)&cmd_set_l2_encap_l2_encap,
   10367                 :            :                 (void *)&cmd_set_l2_encap_ip_version,
   10368                 :            :                 (void *)&cmd_set_l2_encap_ip_version_value,
   10369                 :            :                 (void *)&cmd_set_l2_encap_eth_src,
   10370                 :            :                 (void *)&cmd_set_l2_encap_eth_src_value,
   10371                 :            :                 (void *)&cmd_set_l2_encap_eth_dst,
   10372                 :            :                 (void *)&cmd_set_l2_encap_eth_dst_value,
   10373                 :            :                 NULL,
   10374                 :            :         },
   10375                 :            : };
   10376                 :            : 
   10377                 :            : static cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
   10378                 :            :         .f = cmd_set_l2_encap_parsed,
   10379                 :            :         .data = NULL,
   10380                 :            :         .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
   10381                 :            :                 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
   10382                 :            :         .tokens = {
   10383                 :            :                 (void *)&cmd_set_l2_encap_set,
   10384                 :            :                 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
   10385                 :            :                 (void *)&cmd_set_l2_encap_ip_version,
   10386                 :            :                 (void *)&cmd_set_l2_encap_ip_version_value,
   10387                 :            :                 (void *)&cmd_set_l2_encap_vlan,
   10388                 :            :                 (void *)&cmd_set_l2_encap_vlan_value,
   10389                 :            :                 (void *)&cmd_set_l2_encap_eth_src,
   10390                 :            :                 (void *)&cmd_set_l2_encap_eth_src_value,
   10391                 :            :                 (void *)&cmd_set_l2_encap_eth_dst,
   10392                 :            :                 (void *)&cmd_set_l2_encap_eth_dst_value,
   10393                 :            :                 NULL,
   10394                 :            :         },
   10395                 :            : };
   10396                 :            : 
   10397                 :            : /** Set L2 decapsulation details */
   10398                 :            : struct cmd_set_l2_decap_result {
   10399                 :            :         cmdline_fixed_string_t set;
   10400                 :            :         cmdline_fixed_string_t l2_decap;
   10401                 :            :         cmdline_fixed_string_t pos_token;
   10402                 :            :         uint32_t vlan_present:1;
   10403                 :            : };
   10404                 :            : 
   10405                 :            : static cmdline_parse_token_string_t cmd_set_l2_decap_set =
   10406                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
   10407                 :            : static cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
   10408                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
   10409                 :            :                                  "l2_decap");
   10410                 :            : static cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
   10411                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
   10412                 :            :                                  "l2_decap-with-vlan");
   10413                 :            : 
   10414                 :          0 : static void cmd_set_l2_decap_parsed(void *parsed_result,
   10415                 :            :         __rte_unused struct cmdline *cl,
   10416                 :            :         __rte_unused void *data)
   10417                 :            : {
   10418                 :            :         struct cmd_set_l2_decap_result *res = parsed_result;
   10419                 :            : 
   10420                 :          0 :         if (strcmp(res->l2_decap, "l2_decap") == 0)
   10421                 :          0 :                 l2_decap_conf.select_vlan = 0;
   10422                 :          0 :         else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
   10423                 :          0 :                 l2_decap_conf.select_vlan = 1;
   10424                 :          0 : }
   10425                 :            : 
   10426                 :            : static cmdline_parse_inst_t cmd_set_l2_decap = {
   10427                 :            :         .f = cmd_set_l2_decap_parsed,
   10428                 :            :         .data = NULL,
   10429                 :            :         .help_str = "set l2_decap",
   10430                 :            :         .tokens = {
   10431                 :            :                 (void *)&cmd_set_l2_decap_set,
   10432                 :            :                 (void *)&cmd_set_l2_decap_l2_decap,
   10433                 :            :                 NULL,
   10434                 :            :         },
   10435                 :            : };
   10436                 :            : 
   10437                 :            : static cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
   10438                 :            :         .f = cmd_set_l2_decap_parsed,
   10439                 :            :         .data = NULL,
   10440                 :            :         .help_str = "set l2_decap-with-vlan",
   10441                 :            :         .tokens = {
   10442                 :            :                 (void *)&cmd_set_l2_decap_set,
   10443                 :            :                 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
   10444                 :            :                 NULL,
   10445                 :            :         },
   10446                 :            : };
   10447                 :            : 
   10448                 :            : /** Set MPLSoGRE encapsulation details */
   10449                 :            : struct cmd_set_mplsogre_encap_result {
   10450                 :            :         cmdline_fixed_string_t set;
   10451                 :            :         cmdline_fixed_string_t mplsogre;
   10452                 :            :         cmdline_fixed_string_t pos_token;
   10453                 :            :         cmdline_fixed_string_t ip_version;
   10454                 :            :         uint32_t vlan_present:1;
   10455                 :            :         uint32_t label;
   10456                 :            :         cmdline_ipaddr_t ip_src;
   10457                 :            :         cmdline_ipaddr_t ip_dst;
   10458                 :            :         uint16_t tci;
   10459                 :            :         struct rte_ether_addr eth_src;
   10460                 :            :         struct rte_ether_addr eth_dst;
   10461                 :            : };
   10462                 :            : 
   10463                 :            : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
   10464                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
   10465                 :            :                                  "set");
   10466                 :            : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
   10467                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
   10468                 :            :                                  "mplsogre_encap");
   10469                 :            : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
   10470                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
   10471                 :            :                                  mplsogre, "mplsogre_encap-with-vlan");
   10472                 :            : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
   10473                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
   10474                 :            :                                  pos_token, "ip-version");
   10475                 :            : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
   10476                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
   10477                 :            :                                  ip_version, "ipv4#ipv6");
   10478                 :            : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
   10479                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
   10480                 :            :                                  pos_token, "label");
   10481                 :            : static cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
   10482                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
   10483                 :            :                               RTE_UINT32);
   10484                 :            : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
   10485                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
   10486                 :            :                                  pos_token, "ip-src");
   10487                 :            : static cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
   10488                 :            :         TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
   10489                 :            : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
   10490                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
   10491                 :            :                                  pos_token, "ip-dst");
   10492                 :            : static cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
   10493                 :            :         TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
   10494                 :            : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
   10495                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
   10496                 :            :                                  pos_token, "vlan-tci");
   10497                 :            : static cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
   10498                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
   10499                 :            :                               RTE_UINT16);
   10500                 :            : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
   10501                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
   10502                 :            :                                  pos_token, "eth-src");
   10503                 :            : static cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
   10504                 :            :         TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
   10505                 :            :                                     eth_src);
   10506                 :            : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
   10507                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
   10508                 :            :                                  pos_token, "eth-dst");
   10509                 :            : static cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
   10510                 :            :         TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
   10511                 :            :                                     eth_dst);
   10512                 :            : 
   10513                 :          0 : static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
   10514                 :            :         __rte_unused struct cmdline *cl,
   10515                 :            :         __rte_unused void *data)
   10516                 :            : {
   10517                 :            :         struct cmd_set_mplsogre_encap_result *res = parsed_result;
   10518                 :            :         union {
   10519                 :            :                 uint32_t mplsogre_label;
   10520                 :            :                 uint8_t label[4];
   10521                 :          0 :         } id = {
   10522                 :          0 :                 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
   10523                 :            :         };
   10524                 :            : 
   10525                 :          0 :         if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
   10526                 :          0 :                 mplsogre_encap_conf.select_vlan = 0;
   10527                 :          0 :         else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
   10528                 :          0 :                 mplsogre_encap_conf.select_vlan = 1;
   10529                 :          0 :         if (strcmp(res->ip_version, "ipv4") == 0)
   10530                 :          0 :                 mplsogre_encap_conf.select_ipv4 = 1;
   10531                 :          0 :         else if (strcmp(res->ip_version, "ipv6") == 0)
   10532                 :          0 :                 mplsogre_encap_conf.select_ipv4 = 0;
   10533                 :            :         else
   10534                 :          0 :                 return;
   10535                 :            :         rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
   10536                 :          0 :         if (mplsogre_encap_conf.select_ipv4) {
   10537                 :          0 :                 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
   10538                 :          0 :                 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
   10539                 :            :         } else {
   10540                 :          0 :                 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
   10541                 :          0 :                 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
   10542                 :            :         }
   10543                 :          0 :         if (mplsogre_encap_conf.select_vlan)
   10544                 :          0 :                 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
   10545                 :            :         rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
   10546                 :            :                    RTE_ETHER_ADDR_LEN);
   10547                 :          0 :         rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
   10548                 :            :                    RTE_ETHER_ADDR_LEN);
   10549                 :            : }
   10550                 :            : 
   10551                 :            : static cmdline_parse_inst_t cmd_set_mplsogre_encap = {
   10552                 :            :         .f = cmd_set_mplsogre_encap_parsed,
   10553                 :            :         .data = NULL,
   10554                 :            :         .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
   10555                 :            :                 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
   10556                 :            :                 " eth-dst <eth-dst>",
   10557                 :            :         .tokens = {
   10558                 :            :                 (void *)&cmd_set_mplsogre_encap_set,
   10559                 :            :                 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
   10560                 :            :                 (void *)&cmd_set_mplsogre_encap_ip_version,
   10561                 :            :                 (void *)&cmd_set_mplsogre_encap_ip_version_value,
   10562                 :            :                 (void *)&cmd_set_mplsogre_encap_label,
   10563                 :            :                 (void *)&cmd_set_mplsogre_encap_label_value,
   10564                 :            :                 (void *)&cmd_set_mplsogre_encap_ip_src,
   10565                 :            :                 (void *)&cmd_set_mplsogre_encap_ip_src_value,
   10566                 :            :                 (void *)&cmd_set_mplsogre_encap_ip_dst,
   10567                 :            :                 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
   10568                 :            :                 (void *)&cmd_set_mplsogre_encap_eth_src,
   10569                 :            :                 (void *)&cmd_set_mplsogre_encap_eth_src_value,
   10570                 :            :                 (void *)&cmd_set_mplsogre_encap_eth_dst,
   10571                 :            :                 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
   10572                 :            :                 NULL,
   10573                 :            :         },
   10574                 :            : };
   10575                 :            : 
   10576                 :            : static cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
   10577                 :            :         .f = cmd_set_mplsogre_encap_parsed,
   10578                 :            :         .data = NULL,
   10579                 :            :         .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
   10580                 :            :                 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
   10581                 :            :                 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
   10582                 :            :         .tokens = {
   10583                 :            :                 (void *)&cmd_set_mplsogre_encap_set,
   10584                 :            :                 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
   10585                 :            :                 (void *)&cmd_set_mplsogre_encap_ip_version,
   10586                 :            :                 (void *)&cmd_set_mplsogre_encap_ip_version_value,
   10587                 :            :                 (void *)&cmd_set_mplsogre_encap_label,
   10588                 :            :                 (void *)&cmd_set_mplsogre_encap_label_value,
   10589                 :            :                 (void *)&cmd_set_mplsogre_encap_ip_src,
   10590                 :            :                 (void *)&cmd_set_mplsogre_encap_ip_src_value,
   10591                 :            :                 (void *)&cmd_set_mplsogre_encap_ip_dst,
   10592                 :            :                 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
   10593                 :            :                 (void *)&cmd_set_mplsogre_encap_vlan,
   10594                 :            :                 (void *)&cmd_set_mplsogre_encap_vlan_value,
   10595                 :            :                 (void *)&cmd_set_mplsogre_encap_eth_src,
   10596                 :            :                 (void *)&cmd_set_mplsogre_encap_eth_src_value,
   10597                 :            :                 (void *)&cmd_set_mplsogre_encap_eth_dst,
   10598                 :            :                 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
   10599                 :            :                 NULL,
   10600                 :            :         },
   10601                 :            : };
   10602                 :            : 
   10603                 :            : /** Set MPLSoGRE decapsulation details */
   10604                 :            : struct cmd_set_mplsogre_decap_result {
   10605                 :            :         cmdline_fixed_string_t set;
   10606                 :            :         cmdline_fixed_string_t mplsogre;
   10607                 :            :         cmdline_fixed_string_t pos_token;
   10608                 :            :         cmdline_fixed_string_t ip_version;
   10609                 :            :         uint32_t vlan_present:1;
   10610                 :            : };
   10611                 :            : 
   10612                 :            : static cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
   10613                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
   10614                 :            :                                  "set");
   10615                 :            : static cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
   10616                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
   10617                 :            :                                  "mplsogre_decap");
   10618                 :            : static cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
   10619                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
   10620                 :            :                                  mplsogre, "mplsogre_decap-with-vlan");
   10621                 :            : static cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
   10622                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
   10623                 :            :                                  pos_token, "ip-version");
   10624                 :            : static cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
   10625                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
   10626                 :            :                                  ip_version, "ipv4#ipv6");
   10627                 :            : 
   10628                 :          0 : static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
   10629                 :            :         __rte_unused struct cmdline *cl,
   10630                 :            :         __rte_unused void *data)
   10631                 :            : {
   10632                 :            :         struct cmd_set_mplsogre_decap_result *res = parsed_result;
   10633                 :            : 
   10634                 :          0 :         if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
   10635                 :          0 :                 mplsogre_decap_conf.select_vlan = 0;
   10636                 :          0 :         else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
   10637                 :          0 :                 mplsogre_decap_conf.select_vlan = 1;
   10638                 :          0 :         if (strcmp(res->ip_version, "ipv4") == 0)
   10639                 :          0 :                 mplsogre_decap_conf.select_ipv4 = 1;
   10640                 :          0 :         else if (strcmp(res->ip_version, "ipv6") == 0)
   10641                 :          0 :                 mplsogre_decap_conf.select_ipv4 = 0;
   10642                 :          0 : }
   10643                 :            : 
   10644                 :            : static cmdline_parse_inst_t cmd_set_mplsogre_decap = {
   10645                 :            :         .f = cmd_set_mplsogre_decap_parsed,
   10646                 :            :         .data = NULL,
   10647                 :            :         .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
   10648                 :            :         .tokens = {
   10649                 :            :                 (void *)&cmd_set_mplsogre_decap_set,
   10650                 :            :                 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
   10651                 :            :                 (void *)&cmd_set_mplsogre_decap_ip_version,
   10652                 :            :                 (void *)&cmd_set_mplsogre_decap_ip_version_value,
   10653                 :            :                 NULL,
   10654                 :            :         },
   10655                 :            : };
   10656                 :            : 
   10657                 :            : static cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
   10658                 :            :         .f = cmd_set_mplsogre_decap_parsed,
   10659                 :            :         .data = NULL,
   10660                 :            :         .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
   10661                 :            :         .tokens = {
   10662                 :            :                 (void *)&cmd_set_mplsogre_decap_set,
   10663                 :            :                 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
   10664                 :            :                 (void *)&cmd_set_mplsogre_decap_ip_version,
   10665                 :            :                 (void *)&cmd_set_mplsogre_decap_ip_version_value,
   10666                 :            :                 NULL,
   10667                 :            :         },
   10668                 :            : };
   10669                 :            : 
   10670                 :            : /** Set MPLSoUDP encapsulation details */
   10671                 :            : struct cmd_set_mplsoudp_encap_result {
   10672                 :            :         cmdline_fixed_string_t set;
   10673                 :            :         cmdline_fixed_string_t mplsoudp;
   10674                 :            :         cmdline_fixed_string_t pos_token;
   10675                 :            :         cmdline_fixed_string_t ip_version;
   10676                 :            :         uint32_t vlan_present:1;
   10677                 :            :         uint32_t label;
   10678                 :            :         uint16_t udp_src;
   10679                 :            :         uint16_t udp_dst;
   10680                 :            :         cmdline_ipaddr_t ip_src;
   10681                 :            :         cmdline_ipaddr_t ip_dst;
   10682                 :            :         uint16_t tci;
   10683                 :            :         struct rte_ether_addr eth_src;
   10684                 :            :         struct rte_ether_addr eth_dst;
   10685                 :            : };
   10686                 :            : 
   10687                 :            : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
   10688                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
   10689                 :            :                                  "set");
   10690                 :            : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
   10691                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
   10692                 :            :                                  "mplsoudp_encap");
   10693                 :            : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
   10694                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
   10695                 :            :                                  mplsoudp, "mplsoudp_encap-with-vlan");
   10696                 :            : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
   10697                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
   10698                 :            :                                  pos_token, "ip-version");
   10699                 :            : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
   10700                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
   10701                 :            :                                  ip_version, "ipv4#ipv6");
   10702                 :            : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
   10703                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
   10704                 :            :                                  pos_token, "label");
   10705                 :            : static cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
   10706                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
   10707                 :            :                               RTE_UINT32);
   10708                 :            : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
   10709                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
   10710                 :            :                                  pos_token, "udp-src");
   10711                 :            : static cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
   10712                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
   10713                 :            :                               RTE_UINT16);
   10714                 :            : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
   10715                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
   10716                 :            :                                  pos_token, "udp-dst");
   10717                 :            : static cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
   10718                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
   10719                 :            :                               RTE_UINT16);
   10720                 :            : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
   10721                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
   10722                 :            :                                  pos_token, "ip-src");
   10723                 :            : static cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
   10724                 :            :         TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
   10725                 :            : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
   10726                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
   10727                 :            :                                  pos_token, "ip-dst");
   10728                 :            : static cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
   10729                 :            :         TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
   10730                 :            : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
   10731                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
   10732                 :            :                                  pos_token, "vlan-tci");
   10733                 :            : static cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
   10734                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
   10735                 :            :                               RTE_UINT16);
   10736                 :            : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
   10737                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
   10738                 :            :                                  pos_token, "eth-src");
   10739                 :            : static cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
   10740                 :            :         TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
   10741                 :            :                                     eth_src);
   10742                 :            : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
   10743                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
   10744                 :            :                                  pos_token, "eth-dst");
   10745                 :            : static cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
   10746                 :            :         TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
   10747                 :            :                                     eth_dst);
   10748                 :            : 
   10749                 :          0 : static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
   10750                 :            :         __rte_unused struct cmdline *cl,
   10751                 :            :         __rte_unused void *data)
   10752                 :            : {
   10753                 :            :         struct cmd_set_mplsoudp_encap_result *res = parsed_result;
   10754                 :            :         union {
   10755                 :            :                 uint32_t mplsoudp_label;
   10756                 :            :                 uint8_t label[4];
   10757                 :          0 :         } id = {
   10758                 :          0 :                 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
   10759                 :            :         };
   10760                 :            : 
   10761                 :          0 :         if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
   10762                 :          0 :                 mplsoudp_encap_conf.select_vlan = 0;
   10763                 :          0 :         else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
   10764                 :          0 :                 mplsoudp_encap_conf.select_vlan = 1;
   10765                 :          0 :         if (strcmp(res->ip_version, "ipv4") == 0)
   10766                 :          0 :                 mplsoudp_encap_conf.select_ipv4 = 1;
   10767                 :          0 :         else if (strcmp(res->ip_version, "ipv6") == 0)
   10768                 :          0 :                 mplsoudp_encap_conf.select_ipv4 = 0;
   10769                 :            :         else
   10770                 :          0 :                 return;
   10771                 :            :         rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
   10772                 :          0 :         mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
   10773                 :          0 :         mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
   10774                 :          0 :         if (mplsoudp_encap_conf.select_ipv4) {
   10775                 :          0 :                 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
   10776                 :          0 :                 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
   10777                 :            :         } else {
   10778                 :          0 :                 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
   10779                 :          0 :                 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
   10780                 :            :         }
   10781                 :          0 :         if (mplsoudp_encap_conf.select_vlan)
   10782                 :          0 :                 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
   10783                 :            :         rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
   10784                 :            :                    RTE_ETHER_ADDR_LEN);
   10785                 :          0 :         rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
   10786                 :            :                    RTE_ETHER_ADDR_LEN);
   10787                 :            : }
   10788                 :            : 
   10789                 :            : static cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
   10790                 :            :         .f = cmd_set_mplsoudp_encap_parsed,
   10791                 :            :         .data = NULL,
   10792                 :            :         .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
   10793                 :            :                 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
   10794                 :            :                 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
   10795                 :            :         .tokens = {
   10796                 :            :                 (void *)&cmd_set_mplsoudp_encap_set,
   10797                 :            :                 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
   10798                 :            :                 (void *)&cmd_set_mplsoudp_encap_ip_version,
   10799                 :            :                 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
   10800                 :            :                 (void *)&cmd_set_mplsoudp_encap_label,
   10801                 :            :                 (void *)&cmd_set_mplsoudp_encap_label_value,
   10802                 :            :                 (void *)&cmd_set_mplsoudp_encap_udp_src,
   10803                 :            :                 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
   10804                 :            :                 (void *)&cmd_set_mplsoudp_encap_udp_dst,
   10805                 :            :                 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
   10806                 :            :                 (void *)&cmd_set_mplsoudp_encap_ip_src,
   10807                 :            :                 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
   10808                 :            :                 (void *)&cmd_set_mplsoudp_encap_ip_dst,
   10809                 :            :                 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
   10810                 :            :                 (void *)&cmd_set_mplsoudp_encap_eth_src,
   10811                 :            :                 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
   10812                 :            :                 (void *)&cmd_set_mplsoudp_encap_eth_dst,
   10813                 :            :                 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
   10814                 :            :                 NULL,
   10815                 :            :         },
   10816                 :            : };
   10817                 :            : 
   10818                 :            : static cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
   10819                 :            :         .f = cmd_set_mplsoudp_encap_parsed,
   10820                 :            :         .data = NULL,
   10821                 :            :         .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
   10822                 :            :                 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
   10823                 :            :                 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
   10824                 :            :                 " eth-src <eth-src> eth-dst <eth-dst>",
   10825                 :            :         .tokens = {
   10826                 :            :                 (void *)&cmd_set_mplsoudp_encap_set,
   10827                 :            :                 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
   10828                 :            :                 (void *)&cmd_set_mplsoudp_encap_ip_version,
   10829                 :            :                 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
   10830                 :            :                 (void *)&cmd_set_mplsoudp_encap_label,
   10831                 :            :                 (void *)&cmd_set_mplsoudp_encap_label_value,
   10832                 :            :                 (void *)&cmd_set_mplsoudp_encap_udp_src,
   10833                 :            :                 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
   10834                 :            :                 (void *)&cmd_set_mplsoudp_encap_udp_dst,
   10835                 :            :                 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
   10836                 :            :                 (void *)&cmd_set_mplsoudp_encap_ip_src,
   10837                 :            :                 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
   10838                 :            :                 (void *)&cmd_set_mplsoudp_encap_ip_dst,
   10839                 :            :                 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
   10840                 :            :                 (void *)&cmd_set_mplsoudp_encap_vlan,
   10841                 :            :                 (void *)&cmd_set_mplsoudp_encap_vlan_value,
   10842                 :            :                 (void *)&cmd_set_mplsoudp_encap_eth_src,
   10843                 :            :                 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
   10844                 :            :                 (void *)&cmd_set_mplsoudp_encap_eth_dst,
   10845                 :            :                 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
   10846                 :            :                 NULL,
   10847                 :            :         },
   10848                 :            : };
   10849                 :            : 
   10850                 :            : /** Set MPLSoUDP decapsulation details */
   10851                 :            : struct cmd_set_mplsoudp_decap_result {
   10852                 :            :         cmdline_fixed_string_t set;
   10853                 :            :         cmdline_fixed_string_t mplsoudp;
   10854                 :            :         cmdline_fixed_string_t pos_token;
   10855                 :            :         cmdline_fixed_string_t ip_version;
   10856                 :            :         uint32_t vlan_present:1;
   10857                 :            : };
   10858                 :            : 
   10859                 :            : static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
   10860                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
   10861                 :            :                                  "set");
   10862                 :            : static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
   10863                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
   10864                 :            :                                  "mplsoudp_decap");
   10865                 :            : static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
   10866                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
   10867                 :            :                                  mplsoudp, "mplsoudp_decap-with-vlan");
   10868                 :            : static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
   10869                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
   10870                 :            :                                  pos_token, "ip-version");
   10871                 :            : static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
   10872                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
   10873                 :            :                                  ip_version, "ipv4#ipv6");
   10874                 :            : 
   10875                 :          0 : static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
   10876                 :            :         __rte_unused struct cmdline *cl,
   10877                 :            :         __rte_unused void *data)
   10878                 :            : {
   10879                 :            :         struct cmd_set_mplsoudp_decap_result *res = parsed_result;
   10880                 :            : 
   10881                 :          0 :         if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
   10882                 :          0 :                 mplsoudp_decap_conf.select_vlan = 0;
   10883                 :          0 :         else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
   10884                 :          0 :                 mplsoudp_decap_conf.select_vlan = 1;
   10885                 :          0 :         if (strcmp(res->ip_version, "ipv4") == 0)
   10886                 :          0 :                 mplsoudp_decap_conf.select_ipv4 = 1;
   10887                 :          0 :         else if (strcmp(res->ip_version, "ipv6") == 0)
   10888                 :          0 :                 mplsoudp_decap_conf.select_ipv4 = 0;
   10889                 :          0 : }
   10890                 :            : 
   10891                 :            : static cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
   10892                 :            :         .f = cmd_set_mplsoudp_decap_parsed,
   10893                 :            :         .data = NULL,
   10894                 :            :         .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
   10895                 :            :         .tokens = {
   10896                 :            :                 (void *)&cmd_set_mplsoudp_decap_set,
   10897                 :            :                 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
   10898                 :            :                 (void *)&cmd_set_mplsoudp_decap_ip_version,
   10899                 :            :                 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
   10900                 :            :                 NULL,
   10901                 :            :         },
   10902                 :            : };
   10903                 :            : 
   10904                 :            : static cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
   10905                 :            :         .f = cmd_set_mplsoudp_decap_parsed,
   10906                 :            :         .data = NULL,
   10907                 :            :         .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
   10908                 :            :         .tokens = {
   10909                 :            :                 (void *)&cmd_set_mplsoudp_decap_set,
   10910                 :            :                 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
   10911                 :            :                 (void *)&cmd_set_mplsoudp_decap_ip_version,
   10912                 :            :                 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
   10913                 :            :                 NULL,
   10914                 :            :         },
   10915                 :            : };
   10916                 :            : 
   10917                 :            : /** Set connection tracking object common details */
   10918                 :            : struct cmd_set_conntrack_common_result {
   10919                 :            :         cmdline_fixed_string_t set;
   10920                 :            :         cmdline_fixed_string_t conntrack;
   10921                 :            :         cmdline_fixed_string_t common;
   10922                 :            :         cmdline_fixed_string_t peer;
   10923                 :            :         cmdline_fixed_string_t is_orig;
   10924                 :            :         cmdline_fixed_string_t enable;
   10925                 :            :         cmdline_fixed_string_t live;
   10926                 :            :         cmdline_fixed_string_t sack;
   10927                 :            :         cmdline_fixed_string_t cack;
   10928                 :            :         cmdline_fixed_string_t last_dir;
   10929                 :            :         cmdline_fixed_string_t liberal;
   10930                 :            :         cmdline_fixed_string_t state;
   10931                 :            :         cmdline_fixed_string_t max_ack_win;
   10932                 :            :         cmdline_fixed_string_t retrans;
   10933                 :            :         cmdline_fixed_string_t last_win;
   10934                 :            :         cmdline_fixed_string_t last_seq;
   10935                 :            :         cmdline_fixed_string_t last_ack;
   10936                 :            :         cmdline_fixed_string_t last_end;
   10937                 :            :         cmdline_fixed_string_t last_index;
   10938                 :            :         uint8_t stat;
   10939                 :            :         uint8_t factor;
   10940                 :            :         uint16_t peer_port;
   10941                 :            :         uint32_t is_original;
   10942                 :            :         uint32_t en;
   10943                 :            :         uint32_t is_live;
   10944                 :            :         uint32_t s_ack;
   10945                 :            :         uint32_t c_ack;
   10946                 :            :         uint32_t ld;
   10947                 :            :         uint32_t lb;
   10948                 :            :         uint8_t re_num;
   10949                 :            :         uint8_t li;
   10950                 :            :         uint16_t lw;
   10951                 :            :         uint32_t ls;
   10952                 :            :         uint32_t la;
   10953                 :            :         uint32_t le;
   10954                 :            : };
   10955                 :            : 
   10956                 :            : static cmdline_parse_token_string_t cmd_set_conntrack_set =
   10957                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
   10958                 :            :                                  set, "set");
   10959                 :            : static cmdline_parse_token_string_t cmd_set_conntrack_conntrack =
   10960                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
   10961                 :            :                                  conntrack, "conntrack");
   10962                 :            : static cmdline_parse_token_string_t cmd_set_conntrack_common_com =
   10963                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
   10964                 :            :                                  common, "com");
   10965                 :            : static cmdline_parse_token_string_t cmd_set_conntrack_common_peer =
   10966                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
   10967                 :            :                                  peer, "peer");
   10968                 :            : static cmdline_parse_token_num_t cmd_set_conntrack_common_peer_value =
   10969                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
   10970                 :            :                               peer_port, RTE_UINT16);
   10971                 :            : static cmdline_parse_token_string_t cmd_set_conntrack_common_is_orig =
   10972                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
   10973                 :            :                                  is_orig, "is_orig");
   10974                 :            : static cmdline_parse_token_num_t cmd_set_conntrack_common_is_orig_value =
   10975                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
   10976                 :            :                               is_original, RTE_UINT32);
   10977                 :            : static cmdline_parse_token_string_t cmd_set_conntrack_common_enable =
   10978                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
   10979                 :            :                                  enable, "enable");
   10980                 :            : static cmdline_parse_token_num_t cmd_set_conntrack_common_enable_value =
   10981                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
   10982                 :            :                               en, RTE_UINT32);
   10983                 :            : static cmdline_parse_token_string_t cmd_set_conntrack_common_live =
   10984                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
   10985                 :            :                                  live, "live");
   10986                 :            : static cmdline_parse_token_num_t cmd_set_conntrack_common_live_value =
   10987                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
   10988                 :            :                               is_live, RTE_UINT32);
   10989                 :            : static cmdline_parse_token_string_t cmd_set_conntrack_common_sack =
   10990                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
   10991                 :            :                                  sack, "sack");
   10992                 :            : static cmdline_parse_token_num_t cmd_set_conntrack_common_sack_value =
   10993                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
   10994                 :            :                               s_ack, RTE_UINT32);
   10995                 :            : static cmdline_parse_token_string_t cmd_set_conntrack_common_cack =
   10996                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
   10997                 :            :                                  cack, "cack");
   10998                 :            : static cmdline_parse_token_num_t cmd_set_conntrack_common_cack_value =
   10999                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
   11000                 :            :                               c_ack, RTE_UINT32);
   11001                 :            : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_dir =
   11002                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
   11003                 :            :                                  last_dir, "last_dir");
   11004                 :            : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_dir_value =
   11005                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
   11006                 :            :                               ld, RTE_UINT32);
   11007                 :            : static cmdline_parse_token_string_t cmd_set_conntrack_common_liberal =
   11008                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
   11009                 :            :                                  liberal, "liberal");
   11010                 :            : static cmdline_parse_token_num_t cmd_set_conntrack_common_liberal_value =
   11011                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
   11012                 :            :                               lb, RTE_UINT32);
   11013                 :            : static cmdline_parse_token_string_t cmd_set_conntrack_common_state =
   11014                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
   11015                 :            :                                  state, "state");
   11016                 :            : static cmdline_parse_token_num_t cmd_set_conntrack_common_state_value =
   11017                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
   11018                 :            :                               stat, RTE_UINT8);
   11019                 :            : static cmdline_parse_token_string_t cmd_set_conntrack_common_max_ackwin =
   11020                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
   11021                 :            :                                  max_ack_win, "max_ack_win");
   11022                 :            : static cmdline_parse_token_num_t cmd_set_conntrack_common_max_ackwin_value =
   11023                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
   11024                 :            :                               factor, RTE_UINT8);
   11025                 :            : static cmdline_parse_token_string_t cmd_set_conntrack_common_retrans =
   11026                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
   11027                 :            :                                  retrans, "r_lim");
   11028                 :            : static cmdline_parse_token_num_t cmd_set_conntrack_common_retrans_value =
   11029                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
   11030                 :            :                               re_num, RTE_UINT8);
   11031                 :            : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_win =
   11032                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
   11033                 :            :                                  last_win, "last_win");
   11034                 :            : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_win_value =
   11035                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
   11036                 :            :                               lw, RTE_UINT16);
   11037                 :            : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_seq =
   11038                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
   11039                 :            :                                  last_seq, "last_seq");
   11040                 :            : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_seq_value =
   11041                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
   11042                 :            :                               ls, RTE_UINT32);
   11043                 :            : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_ack =
   11044                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
   11045                 :            :                                  last_ack, "last_ack");
   11046                 :            : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_ack_value =
   11047                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
   11048                 :            :                               la, RTE_UINT32);
   11049                 :            : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_end =
   11050                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
   11051                 :            :                                  last_end, "last_end");
   11052                 :            : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_end_value =
   11053                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
   11054                 :            :                               le, RTE_UINT32);
   11055                 :            : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_index =
   11056                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
   11057                 :            :                                  last_index, "last_index");
   11058                 :            : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_index_value =
   11059                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
   11060                 :            :                               li, RTE_UINT8);
   11061                 :            : 
   11062                 :          0 : static void cmd_set_conntrack_common_parsed(void *parsed_result,
   11063                 :            :         __rte_unused struct cmdline *cl,
   11064                 :            :         __rte_unused void *data)
   11065                 :            : {
   11066                 :            :         struct cmd_set_conntrack_common_result *res = parsed_result;
   11067                 :            : 
   11068                 :            :         /* No need to swap to big endian. */
   11069                 :          0 :         conntrack_context.peer_port = res->peer_port;
   11070                 :          0 :         conntrack_context.is_original_dir = res->is_original;
   11071                 :          0 :         conntrack_context.enable = res->en;
   11072                 :          0 :         conntrack_context.live_connection = res->is_live;
   11073                 :          0 :         conntrack_context.selective_ack = res->s_ack;
   11074                 :          0 :         conntrack_context.challenge_ack_passed = res->c_ack;
   11075                 :          0 :         conntrack_context.last_direction = res->ld;
   11076                 :          0 :         conntrack_context.liberal_mode = res->lb;
   11077                 :          0 :         conntrack_context.state = (enum rte_flow_conntrack_state)res->stat;
   11078                 :          0 :         conntrack_context.max_ack_window = res->factor;
   11079                 :          0 :         conntrack_context.retransmission_limit = res->re_num;
   11080                 :          0 :         conntrack_context.last_window = res->lw;
   11081                 :          0 :         conntrack_context.last_index =
   11082                 :          0 :                 (enum rte_flow_conntrack_tcp_last_index)res->li;
   11083                 :          0 :         conntrack_context.last_seq = res->ls;
   11084                 :          0 :         conntrack_context.last_ack = res->la;
   11085                 :          0 :         conntrack_context.last_end = res->le;
   11086                 :          0 : }
   11087                 :            : 
   11088                 :            : static cmdline_parse_inst_t cmd_set_conntrack_common = {
   11089                 :            :         .f = cmd_set_conntrack_common_parsed,
   11090                 :            :         .data = NULL,
   11091                 :            :         .help_str = "set conntrack com peer <port_id> is_orig <dir> enable <en>"
   11092                 :            :                 " live <ack_seen> sack <en> cack <passed> last_dir <dir>"
   11093                 :            :                 " liberal <en> state <s> max_ack_win <factor> r_lim <num>"
   11094                 :            :                 " last_win <win> last_seq <seq> last_ack <ack> last_end <end>"
   11095                 :            :                 " last_index <flag>",
   11096                 :            :         .tokens = {
   11097                 :            :                 (void *)&cmd_set_conntrack_set,
   11098                 :            :                 (void *)&cmd_set_conntrack_conntrack,
   11099                 :            :                 (void *)&cmd_set_conntrack_common_com,
   11100                 :            :                 (void *)&cmd_set_conntrack_common_peer,
   11101                 :            :                 (void *)&cmd_set_conntrack_common_peer_value,
   11102                 :            :                 (void *)&cmd_set_conntrack_common_is_orig,
   11103                 :            :                 (void *)&cmd_set_conntrack_common_is_orig_value,
   11104                 :            :                 (void *)&cmd_set_conntrack_common_enable,
   11105                 :            :                 (void *)&cmd_set_conntrack_common_enable_value,
   11106                 :            :                 (void *)&cmd_set_conntrack_common_live,
   11107                 :            :                 (void *)&cmd_set_conntrack_common_live_value,
   11108                 :            :                 (void *)&cmd_set_conntrack_common_sack,
   11109                 :            :                 (void *)&cmd_set_conntrack_common_sack_value,
   11110                 :            :                 (void *)&cmd_set_conntrack_common_cack,
   11111                 :            :                 (void *)&cmd_set_conntrack_common_cack_value,
   11112                 :            :                 (void *)&cmd_set_conntrack_common_last_dir,
   11113                 :            :                 (void *)&cmd_set_conntrack_common_last_dir_value,
   11114                 :            :                 (void *)&cmd_set_conntrack_common_liberal,
   11115                 :            :                 (void *)&cmd_set_conntrack_common_liberal_value,
   11116                 :            :                 (void *)&cmd_set_conntrack_common_state,
   11117                 :            :                 (void *)&cmd_set_conntrack_common_state_value,
   11118                 :            :                 (void *)&cmd_set_conntrack_common_max_ackwin,
   11119                 :            :                 (void *)&cmd_set_conntrack_common_max_ackwin_value,
   11120                 :            :                 (void *)&cmd_set_conntrack_common_retrans,
   11121                 :            :                 (void *)&cmd_set_conntrack_common_retrans_value,
   11122                 :            :                 (void *)&cmd_set_conntrack_common_last_win,
   11123                 :            :                 (void *)&cmd_set_conntrack_common_last_win_value,
   11124                 :            :                 (void *)&cmd_set_conntrack_common_last_seq,
   11125                 :            :                 (void *)&cmd_set_conntrack_common_last_seq_value,
   11126                 :            :                 (void *)&cmd_set_conntrack_common_last_ack,
   11127                 :            :                 (void *)&cmd_set_conntrack_common_last_ack_value,
   11128                 :            :                 (void *)&cmd_set_conntrack_common_last_end,
   11129                 :            :                 (void *)&cmd_set_conntrack_common_last_end_value,
   11130                 :            :                 (void *)&cmd_set_conntrack_common_last_index,
   11131                 :            :                 (void *)&cmd_set_conntrack_common_last_index_value,
   11132                 :            :                 NULL,
   11133                 :            :         },
   11134                 :            : };
   11135                 :            : 
   11136                 :            : /** Set connection tracking object both directions' details */
   11137                 :            : struct cmd_set_conntrack_dir_result {
   11138                 :            :         cmdline_fixed_string_t set;
   11139                 :            :         cmdline_fixed_string_t conntrack;
   11140                 :            :         cmdline_fixed_string_t dir;
   11141                 :            :         cmdline_fixed_string_t scale;
   11142                 :            :         cmdline_fixed_string_t fin;
   11143                 :            :         cmdline_fixed_string_t ack_seen;
   11144                 :            :         cmdline_fixed_string_t unack;
   11145                 :            :         cmdline_fixed_string_t sent_end;
   11146                 :            :         cmdline_fixed_string_t reply_end;
   11147                 :            :         cmdline_fixed_string_t max_win;
   11148                 :            :         cmdline_fixed_string_t max_ack;
   11149                 :            :         uint32_t factor;
   11150                 :            :         uint32_t f;
   11151                 :            :         uint32_t as;
   11152                 :            :         uint32_t un;
   11153                 :            :         uint32_t se;
   11154                 :            :         uint32_t re;
   11155                 :            :         uint32_t mw;
   11156                 :            :         uint32_t ma;
   11157                 :            : };
   11158                 :            : 
   11159                 :            : static cmdline_parse_token_string_t cmd_set_conntrack_dir_dir =
   11160                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
   11161                 :            :                                  dir, "orig#rply");
   11162                 :            : static cmdline_parse_token_string_t cmd_set_conntrack_dir_scale =
   11163                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
   11164                 :            :                                  scale, "scale");
   11165                 :            : static cmdline_parse_token_num_t cmd_set_conntrack_dir_scale_value =
   11166                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
   11167                 :            :                               factor, RTE_UINT32);
   11168                 :            : static cmdline_parse_token_string_t cmd_set_conntrack_dir_fin =
   11169                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
   11170                 :            :                                  fin, "fin");
   11171                 :            : static cmdline_parse_token_num_t cmd_set_conntrack_dir_fin_value =
   11172                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
   11173                 :            :                               f, RTE_UINT32);
   11174                 :            : static cmdline_parse_token_string_t cmd_set_conntrack_dir_ack =
   11175                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
   11176                 :            :                                  ack_seen, "acked");
   11177                 :            : static cmdline_parse_token_num_t cmd_set_conntrack_dir_ack_value =
   11178                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
   11179                 :            :                               as, RTE_UINT32);
   11180                 :            : static cmdline_parse_token_string_t cmd_set_conntrack_dir_unack_data =
   11181                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
   11182                 :            :                                  unack, "unack_data");
   11183                 :            : static cmdline_parse_token_num_t cmd_set_conntrack_dir_unack_data_value =
   11184                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
   11185                 :            :                               un, RTE_UINT32);
   11186                 :            : static cmdline_parse_token_string_t cmd_set_conntrack_dir_sent_end =
   11187                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
   11188                 :            :                                  sent_end, "sent_end");
   11189                 :            : static cmdline_parse_token_num_t cmd_set_conntrack_dir_sent_end_value =
   11190                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
   11191                 :            :                               se, RTE_UINT32);
   11192                 :            : static cmdline_parse_token_string_t cmd_set_conntrack_dir_reply_end =
   11193                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
   11194                 :            :                                  reply_end, "reply_end");
   11195                 :            : static cmdline_parse_token_num_t cmd_set_conntrack_dir_reply_end_value =
   11196                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
   11197                 :            :                               re, RTE_UINT32);
   11198                 :            : static cmdline_parse_token_string_t cmd_set_conntrack_dir_max_win =
   11199                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
   11200                 :            :                                  max_win, "max_win");
   11201                 :            : static cmdline_parse_token_num_t cmd_set_conntrack_dir_max_win_value =
   11202                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
   11203                 :            :                               mw, RTE_UINT32);
   11204                 :            : static cmdline_parse_token_string_t cmd_set_conntrack_dir_max_ack =
   11205                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
   11206                 :            :                                  max_ack, "max_ack");
   11207                 :            : static cmdline_parse_token_num_t cmd_set_conntrack_dir_max_ack_value =
   11208                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
   11209                 :            :                               ma, RTE_UINT32);
   11210                 :            : 
   11211                 :          0 : static void cmd_set_conntrack_dir_parsed(void *parsed_result,
   11212                 :            :         __rte_unused struct cmdline *cl,
   11213                 :            :         __rte_unused void *data)
   11214                 :            : {
   11215                 :            :         struct cmd_set_conntrack_dir_result *res = parsed_result;
   11216                 :            :         struct rte_flow_tcp_dir_param *dir = NULL;
   11217                 :            : 
   11218                 :          0 :         if (strcmp(res->dir, "orig") == 0)
   11219                 :            :                 dir = &conntrack_context.original_dir;
   11220                 :          0 :         else if (strcmp(res->dir, "rply") == 0)
   11221                 :            :                 dir = &conntrack_context.reply_dir;
   11222                 :            :         else
   11223                 :            :                 return;
   11224                 :          0 :         dir->scale = res->factor;
   11225                 :          0 :         dir->close_initiated = res->f;
   11226                 :          0 :         dir->last_ack_seen = res->as;
   11227                 :          0 :         dir->data_unacked = res->un;
   11228                 :          0 :         dir->sent_end = res->se;
   11229                 :          0 :         dir->reply_end = res->re;
   11230                 :          0 :         dir->max_ack = res->ma;
   11231                 :          0 :         dir->max_win = res->mw;
   11232                 :            : }
   11233                 :            : 
   11234                 :            : static cmdline_parse_inst_t cmd_set_conntrack_dir = {
   11235                 :            :         .f = cmd_set_conntrack_dir_parsed,
   11236                 :            :         .data = NULL,
   11237                 :            :         .help_str = "set conntrack orig|rply scale <factor> fin <sent>"
   11238                 :            :                     " acked <seen> unack_data <unack> sent_end <sent>"
   11239                 :            :                     " reply_end <reply> max_win <win> max_ack <ack>",
   11240                 :            :         .tokens = {
   11241                 :            :                 (void *)&cmd_set_conntrack_set,
   11242                 :            :                 (void *)&cmd_set_conntrack_conntrack,
   11243                 :            :                 (void *)&cmd_set_conntrack_dir_dir,
   11244                 :            :                 (void *)&cmd_set_conntrack_dir_scale,
   11245                 :            :                 (void *)&cmd_set_conntrack_dir_scale_value,
   11246                 :            :                 (void *)&cmd_set_conntrack_dir_fin,
   11247                 :            :                 (void *)&cmd_set_conntrack_dir_fin_value,
   11248                 :            :                 (void *)&cmd_set_conntrack_dir_ack,
   11249                 :            :                 (void *)&cmd_set_conntrack_dir_ack_value,
   11250                 :            :                 (void *)&cmd_set_conntrack_dir_unack_data,
   11251                 :            :                 (void *)&cmd_set_conntrack_dir_unack_data_value,
   11252                 :            :                 (void *)&cmd_set_conntrack_dir_sent_end,
   11253                 :            :                 (void *)&cmd_set_conntrack_dir_sent_end_value,
   11254                 :            :                 (void *)&cmd_set_conntrack_dir_reply_end,
   11255                 :            :                 (void *)&cmd_set_conntrack_dir_reply_end_value,
   11256                 :            :                 (void *)&cmd_set_conntrack_dir_max_win,
   11257                 :            :                 (void *)&cmd_set_conntrack_dir_max_win_value,
   11258                 :            :                 (void *)&cmd_set_conntrack_dir_max_ack,
   11259                 :            :                 (void *)&cmd_set_conntrack_dir_max_ack_value,
   11260                 :            :                 NULL,
   11261                 :            :         },
   11262                 :            : };
   11263                 :            : 
   11264                 :            : /* show vf stats */
   11265                 :            : 
   11266                 :            : /* Common result structure for show vf stats */
   11267                 :            : struct cmd_show_vf_stats_result {
   11268                 :            :         cmdline_fixed_string_t show;
   11269                 :            :         cmdline_fixed_string_t vf;
   11270                 :            :         cmdline_fixed_string_t stats;
   11271                 :            :         portid_t port_id;
   11272                 :            :         uint16_t vf_id;
   11273                 :            : };
   11274                 :            : 
   11275                 :            : /* Common CLI fields show vf stats*/
   11276                 :            : static cmdline_parse_token_string_t cmd_show_vf_stats_show =
   11277                 :            :         TOKEN_STRING_INITIALIZER
   11278                 :            :                 (struct cmd_show_vf_stats_result,
   11279                 :            :                  show, "show");
   11280                 :            : static cmdline_parse_token_string_t cmd_show_vf_stats_vf =
   11281                 :            :         TOKEN_STRING_INITIALIZER
   11282                 :            :                 (struct cmd_show_vf_stats_result,
   11283                 :            :                  vf, "vf");
   11284                 :            : static cmdline_parse_token_string_t cmd_show_vf_stats_stats =
   11285                 :            :         TOKEN_STRING_INITIALIZER
   11286                 :            :                 (struct cmd_show_vf_stats_result,
   11287                 :            :                  stats, "stats");
   11288                 :            : static cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
   11289                 :            :         TOKEN_NUM_INITIALIZER
   11290                 :            :                 (struct cmd_show_vf_stats_result,
   11291                 :            :                  port_id, RTE_UINT16);
   11292                 :            : static cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
   11293                 :            :         TOKEN_NUM_INITIALIZER
   11294                 :            :                 (struct cmd_show_vf_stats_result,
   11295                 :            :                  vf_id, RTE_UINT16);
   11296                 :            : 
   11297                 :            : static void
   11298                 :          0 : cmd_show_vf_stats_parsed(
   11299                 :            :         void *parsed_result,
   11300                 :            :         __rte_unused struct cmdline *cl,
   11301                 :            :         __rte_unused void *data)
   11302                 :            : {
   11303                 :            :         struct cmd_show_vf_stats_result *res = parsed_result;
   11304                 :            :         struct rte_eth_stats stats;
   11305                 :            :         int ret = -ENOTSUP;
   11306                 :            :         static const char *nic_stats_border = "########################";
   11307                 :            : 
   11308                 :          0 :         if (port_id_is_invalid(res->port_id, ENABLED_WARN))
   11309                 :          0 :                 return;
   11310                 :            : 
   11311                 :            :         memset(&stats, 0, sizeof(stats));
   11312                 :            : 
   11313                 :            : #ifdef RTE_NET_I40E
   11314                 :            :         if (ret == -ENOTSUP)
   11315                 :          0 :                 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
   11316                 :          0 :                                                 res->vf_id,
   11317                 :            :                                                 &stats);
   11318                 :            : #endif
   11319                 :            : #ifdef RTE_NET_BNXT
   11320                 :          0 :         if (ret == -ENOTSUP)
   11321                 :          0 :                 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
   11322                 :          0 :                                                 res->vf_id,
   11323                 :            :                                                 &stats);
   11324                 :            : #endif
   11325                 :            : 
   11326                 :          0 :         switch (ret) {
   11327                 :            :         case 0:
   11328                 :            :                 break;
   11329                 :          0 :         case -EINVAL:
   11330                 :          0 :                 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
   11331                 :            :                 break;
   11332                 :          0 :         case -ENODEV:
   11333                 :          0 :                 fprintf(stderr, "invalid port_id %d\n", res->port_id);
   11334                 :            :                 break;
   11335                 :          0 :         case -ENOTSUP:
   11336                 :          0 :                 fprintf(stderr, "function not implemented\n");
   11337                 :            :                 break;
   11338                 :          0 :         default:
   11339                 :          0 :                 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
   11340                 :            :         }
   11341                 :            : 
   11342                 :          0 :         printf("\n  %s NIC statistics for port %-2d vf %-2d %s\n",
   11343                 :          0 :                 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
   11344                 :            : 
   11345                 :          0 :         printf("  RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes:  "
   11346                 :            :                "%-"PRIu64"\n",
   11347                 :            :                stats.ipackets, stats.imissed, stats.ibytes);
   11348                 :          0 :         printf("  RX-errors: %-"PRIu64"\n", stats.ierrors);
   11349                 :          0 :         printf("  RX-nombuf:  %-10"PRIu64"\n",
   11350                 :            :                stats.rx_nombuf);
   11351                 :          0 :         printf("  TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes:  "
   11352                 :            :                "%-"PRIu64"\n",
   11353                 :            :                stats.opackets, stats.oerrors, stats.obytes);
   11354                 :            : 
   11355                 :          0 :         printf("  %s############################%s\n",
   11356                 :            :                                nic_stats_border, nic_stats_border);
   11357                 :            : }
   11358                 :            : 
   11359                 :            : static cmdline_parse_inst_t cmd_show_vf_stats = {
   11360                 :            :         .f = cmd_show_vf_stats_parsed,
   11361                 :            :         .data = NULL,
   11362                 :            :         .help_str = "show vf stats <port_id> <vf_id>",
   11363                 :            :         .tokens = {
   11364                 :            :                 (void *)&cmd_show_vf_stats_show,
   11365                 :            :                 (void *)&cmd_show_vf_stats_vf,
   11366                 :            :                 (void *)&cmd_show_vf_stats_stats,
   11367                 :            :                 (void *)&cmd_show_vf_stats_port_id,
   11368                 :            :                 (void *)&cmd_show_vf_stats_vf_id,
   11369                 :            :                 NULL,
   11370                 :            :         },
   11371                 :            : };
   11372                 :            : 
   11373                 :            : /* clear vf stats */
   11374                 :            : 
   11375                 :            : /* Common result structure for clear vf stats */
   11376                 :            : struct cmd_clear_vf_stats_result {
   11377                 :            :         cmdline_fixed_string_t clear;
   11378                 :            :         cmdline_fixed_string_t vf;
   11379                 :            :         cmdline_fixed_string_t stats;
   11380                 :            :         portid_t port_id;
   11381                 :            :         uint16_t vf_id;
   11382                 :            : };
   11383                 :            : 
   11384                 :            : /* Common CLI fields clear vf stats*/
   11385                 :            : static cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
   11386                 :            :         TOKEN_STRING_INITIALIZER
   11387                 :            :                 (struct cmd_clear_vf_stats_result,
   11388                 :            :                  clear, "clear");
   11389                 :            : static cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
   11390                 :            :         TOKEN_STRING_INITIALIZER
   11391                 :            :                 (struct cmd_clear_vf_stats_result,
   11392                 :            :                  vf, "vf");
   11393                 :            : static cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
   11394                 :            :         TOKEN_STRING_INITIALIZER
   11395                 :            :                 (struct cmd_clear_vf_stats_result,
   11396                 :            :                  stats, "stats");
   11397                 :            : static cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
   11398                 :            :         TOKEN_NUM_INITIALIZER
   11399                 :            :                 (struct cmd_clear_vf_stats_result,
   11400                 :            :                  port_id, RTE_UINT16);
   11401                 :            : static cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
   11402                 :            :         TOKEN_NUM_INITIALIZER
   11403                 :            :                 (struct cmd_clear_vf_stats_result,
   11404                 :            :                  vf_id, RTE_UINT16);
   11405                 :            : 
   11406                 :            : static void
   11407                 :          0 : cmd_clear_vf_stats_parsed(
   11408                 :            :         void *parsed_result,
   11409                 :            :         __rte_unused struct cmdline *cl,
   11410                 :            :         __rte_unused void *data)
   11411                 :            : {
   11412                 :            :         struct cmd_clear_vf_stats_result *res = parsed_result;
   11413                 :            :         int ret = -ENOTSUP;
   11414                 :            : 
   11415                 :          0 :         if (port_id_is_invalid(res->port_id, ENABLED_WARN))
   11416                 :            :                 return;
   11417                 :            : 
   11418                 :            : #ifdef RTE_NET_I40E
   11419                 :            :         if (ret == -ENOTSUP)
   11420                 :          0 :                 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
   11421                 :          0 :                                                   res->vf_id);
   11422                 :            : #endif
   11423                 :            : #ifdef RTE_NET_BNXT
   11424                 :          0 :         if (ret == -ENOTSUP)
   11425                 :          0 :                 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
   11426                 :          0 :                                                   res->vf_id);
   11427                 :            : #endif
   11428                 :            : 
   11429                 :          0 :         switch (ret) {
   11430                 :            :         case 0:
   11431                 :            :                 break;
   11432                 :          0 :         case -EINVAL:
   11433                 :          0 :                 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
   11434                 :            :                 break;
   11435                 :          0 :         case -ENODEV:
   11436                 :          0 :                 fprintf(stderr, "invalid port_id %d\n", res->port_id);
   11437                 :            :                 break;
   11438                 :          0 :         case -ENOTSUP:
   11439                 :          0 :                 fprintf(stderr, "function not implemented\n");
   11440                 :            :                 break;
   11441                 :          0 :         default:
   11442                 :          0 :                 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
   11443                 :            :         }
   11444                 :            : }
   11445                 :            : 
   11446                 :            : static cmdline_parse_inst_t cmd_clear_vf_stats = {
   11447                 :            :         .f = cmd_clear_vf_stats_parsed,
   11448                 :            :         .data = NULL,
   11449                 :            :         .help_str = "clear vf stats <port_id> <vf_id>",
   11450                 :            :         .tokens = {
   11451                 :            :                 (void *)&cmd_clear_vf_stats_clear,
   11452                 :            :                 (void *)&cmd_clear_vf_stats_vf,
   11453                 :            :                 (void *)&cmd_clear_vf_stats_stats,
   11454                 :            :                 (void *)&cmd_clear_vf_stats_port_id,
   11455                 :            :                 (void *)&cmd_clear_vf_stats_vf_id,
   11456                 :            :                 NULL,
   11457                 :            :         },
   11458                 :            : };
   11459                 :            : 
   11460                 :            : /* Common result structure for file commands */
   11461                 :            : struct cmd_cmdfile_result {
   11462                 :            :         cmdline_fixed_string_t load;
   11463                 :            :         cmdline_fixed_string_t filename;
   11464                 :            : };
   11465                 :            : 
   11466                 :            : /* Common CLI fields for file commands */
   11467                 :            : static cmdline_parse_token_string_t cmd_load_cmdfile =
   11468                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
   11469                 :            : static cmdline_parse_token_string_t cmd_load_cmdfile_filename =
   11470                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
   11471                 :            : 
   11472                 :            : static void
   11473                 :          0 : cmd_load_from_file_parsed(
   11474                 :            :         void *parsed_result,
   11475                 :            :         __rte_unused struct cmdline *cl,
   11476                 :            :         __rte_unused void *data)
   11477                 :            : {
   11478                 :            :         struct cmd_cmdfile_result *res = parsed_result;
   11479                 :            : 
   11480                 :          0 :         cmdline_read_from_file(res->filename);
   11481                 :          0 : }
   11482                 :            : 
   11483                 :            : static cmdline_parse_inst_t cmd_load_from_file = {
   11484                 :            :         .f = cmd_load_from_file_parsed,
   11485                 :            :         .data = NULL,
   11486                 :            :         .help_str = "load <filename>",
   11487                 :            :         .tokens = {
   11488                 :            :                 (void *)&cmd_load_cmdfile,
   11489                 :            :                 (void *)&cmd_load_cmdfile_filename,
   11490                 :            :                 NULL,
   11491                 :            :         },
   11492                 :            : };
   11493                 :            : 
   11494                 :            : /* Get Rx offloads capabilities */
   11495                 :            : struct cmd_rx_offload_get_capa_result {
   11496                 :            :         cmdline_fixed_string_t show;
   11497                 :            :         cmdline_fixed_string_t port;
   11498                 :            :         portid_t port_id;
   11499                 :            :         cmdline_fixed_string_t rx_offload;
   11500                 :            :         cmdline_fixed_string_t capabilities;
   11501                 :            : };
   11502                 :            : 
   11503                 :            : static cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
   11504                 :            :         TOKEN_STRING_INITIALIZER
   11505                 :            :                 (struct cmd_rx_offload_get_capa_result,
   11506                 :            :                  show, "show");
   11507                 :            : static cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
   11508                 :            :         TOKEN_STRING_INITIALIZER
   11509                 :            :                 (struct cmd_rx_offload_get_capa_result,
   11510                 :            :                  port, "port");
   11511                 :            : static cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
   11512                 :            :         TOKEN_NUM_INITIALIZER
   11513                 :            :                 (struct cmd_rx_offload_get_capa_result,
   11514                 :            :                  port_id, RTE_UINT16);
   11515                 :            : static cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
   11516                 :            :         TOKEN_STRING_INITIALIZER
   11517                 :            :                 (struct cmd_rx_offload_get_capa_result,
   11518                 :            :                  rx_offload, "rx_offload");
   11519                 :            : static cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
   11520                 :            :         TOKEN_STRING_INITIALIZER
   11521                 :            :                 (struct cmd_rx_offload_get_capa_result,
   11522                 :            :                  capabilities, "capabilities");
   11523                 :            : 
   11524                 :            : static void
   11525                 :          0 : print_rx_offloads(uint64_t offloads)
   11526                 :            : {
   11527                 :            :         uint64_t single_offload;
   11528                 :            :         int begin;
   11529                 :            :         int end;
   11530                 :            :         int bit;
   11531                 :            : 
   11532                 :          0 :         if (offloads == 0)
   11533                 :            :                 return;
   11534                 :            : 
   11535                 :            :         begin = rte_ctz64(offloads);
   11536                 :          0 :         end = sizeof(offloads) * CHAR_BIT - rte_clz64(offloads);
   11537                 :            : 
   11538                 :          0 :         single_offload = 1ULL << begin;
   11539                 :          0 :         for (bit = begin; bit < end; bit++) {
   11540                 :          0 :                 if (offloads & single_offload)
   11541                 :          0 :                         printf(" %s",
   11542                 :            :                                rte_eth_dev_rx_offload_name(single_offload));
   11543                 :          0 :                 single_offload <<= 1;
   11544                 :            :         }
   11545                 :            : }
   11546                 :            : 
   11547                 :            : static void
   11548                 :          0 : cmd_rx_offload_get_capa_parsed(
   11549                 :            :         void *parsed_result,
   11550                 :            :         __rte_unused struct cmdline *cl,
   11551                 :            :         __rte_unused void *data)
   11552                 :            : {
   11553                 :            :         struct cmd_rx_offload_get_capa_result *res = parsed_result;
   11554                 :            :         struct rte_eth_dev_info dev_info;
   11555                 :          0 :         portid_t port_id = res->port_id;
   11556                 :            :         uint64_t queue_offloads;
   11557                 :            :         uint64_t port_offloads;
   11558                 :            :         int ret;
   11559                 :            : 
   11560                 :          0 :         ret = eth_dev_info_get_print_err(port_id, &dev_info);
   11561                 :          0 :         if (ret != 0)
   11562                 :          0 :                 return;
   11563                 :            : 
   11564                 :          0 :         queue_offloads = dev_info.rx_queue_offload_capa;
   11565                 :          0 :         port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
   11566                 :            : 
   11567                 :            :         printf("Rx Offloading Capabilities of port %d :\n", port_id);
   11568                 :            :         printf("  Per Queue :");
   11569                 :          0 :         print_rx_offloads(queue_offloads);
   11570                 :            : 
   11571                 :            :         printf("\n");
   11572                 :            :         printf("  Per Port  :");
   11573                 :          0 :         print_rx_offloads(port_offloads);
   11574                 :            :         printf("\n\n");
   11575                 :            : }
   11576                 :            : 
   11577                 :            : static cmdline_parse_inst_t cmd_rx_offload_get_capa = {
   11578                 :            :         .f = cmd_rx_offload_get_capa_parsed,
   11579                 :            :         .data = NULL,
   11580                 :            :         .help_str = "show port <port_id> rx_offload capabilities",
   11581                 :            :         .tokens = {
   11582                 :            :                 (void *)&cmd_rx_offload_get_capa_show,
   11583                 :            :                 (void *)&cmd_rx_offload_get_capa_port,
   11584                 :            :                 (void *)&cmd_rx_offload_get_capa_port_id,
   11585                 :            :                 (void *)&cmd_rx_offload_get_capa_rx_offload,
   11586                 :            :                 (void *)&cmd_rx_offload_get_capa_capabilities,
   11587                 :            :                 NULL,
   11588                 :            :         }
   11589                 :            : };
   11590                 :            : 
   11591                 :            : /* Get Rx offloads configuration */
   11592                 :            : struct cmd_rx_offload_get_configuration_result {
   11593                 :            :         cmdline_fixed_string_t show;
   11594                 :            :         cmdline_fixed_string_t port;
   11595                 :            :         portid_t port_id;
   11596                 :            :         cmdline_fixed_string_t rx_offload;
   11597                 :            :         cmdline_fixed_string_t configuration;
   11598                 :            : };
   11599                 :            : 
   11600                 :            : static cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
   11601                 :            :         TOKEN_STRING_INITIALIZER
   11602                 :            :                 (struct cmd_rx_offload_get_configuration_result,
   11603                 :            :                  show, "show");
   11604                 :            : static cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
   11605                 :            :         TOKEN_STRING_INITIALIZER
   11606                 :            :                 (struct cmd_rx_offload_get_configuration_result,
   11607                 :            :                  port, "port");
   11608                 :            : static cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
   11609                 :            :         TOKEN_NUM_INITIALIZER
   11610                 :            :                 (struct cmd_rx_offload_get_configuration_result,
   11611                 :            :                  port_id, RTE_UINT16);
   11612                 :            : static cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
   11613                 :            :         TOKEN_STRING_INITIALIZER
   11614                 :            :                 (struct cmd_rx_offload_get_configuration_result,
   11615                 :            :                  rx_offload, "rx_offload");
   11616                 :            : static cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
   11617                 :            :         TOKEN_STRING_INITIALIZER
   11618                 :            :                 (struct cmd_rx_offload_get_configuration_result,
   11619                 :            :                  configuration, "configuration");
   11620                 :            : 
   11621                 :            : static void
   11622                 :          0 : cmd_rx_offload_get_configuration_parsed(
   11623                 :            :         void *parsed_result,
   11624                 :            :         __rte_unused struct cmdline *cl,
   11625                 :            :         __rte_unused void *data)
   11626                 :            : {
   11627                 :            :         struct cmd_rx_offload_get_configuration_result *res = parsed_result;
   11628                 :            :         struct rte_eth_dev_info dev_info;
   11629                 :          0 :         portid_t port_id = res->port_id;
   11630                 :          0 :         struct rte_port *port = &ports[port_id];
   11631                 :            :         struct rte_eth_conf dev_conf;
   11632                 :            :         uint64_t port_offloads;
   11633                 :            :         uint64_t queue_offloads;
   11634                 :            :         uint16_t nb_rx_queues;
   11635                 :            :         int q;
   11636                 :            :         int ret;
   11637                 :            : 
   11638                 :          0 :         printf("Rx Offloading Configuration of port %d :\n", port_id);
   11639                 :            : 
   11640                 :          0 :         ret = eth_dev_conf_get_print_err(port_id, &dev_conf);
   11641                 :          0 :         if (ret != 0)
   11642                 :          0 :                 return;
   11643                 :            : 
   11644                 :          0 :         port_offloads = dev_conf.rxmode.offloads;
   11645                 :            :         printf("  Port :");
   11646                 :          0 :         print_rx_offloads(port_offloads);
   11647                 :            :         printf("\n");
   11648                 :            : 
   11649                 :          0 :         ret = eth_dev_info_get_print_err(port_id, &dev_info);
   11650                 :          0 :         if (ret != 0)
   11651                 :            :                 return;
   11652                 :            : 
   11653                 :          0 :         nb_rx_queues = dev_info.nb_rx_queues;
   11654                 :          0 :         for (q = 0; q < nb_rx_queues; q++) {
   11655                 :          0 :                 queue_offloads = port->rxq[q].conf.offloads;
   11656                 :            :                 printf("  Queue[%2d] :", q);
   11657                 :          0 :                 print_rx_offloads(queue_offloads);
   11658                 :            :                 printf("\n");
   11659                 :            :         }
   11660                 :            :         printf("\n");
   11661                 :            : }
   11662                 :            : 
   11663                 :            : static cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
   11664                 :            :         .f = cmd_rx_offload_get_configuration_parsed,
   11665                 :            :         .data = NULL,
   11666                 :            :         .help_str = "show port <port_id> rx_offload configuration",
   11667                 :            :         .tokens = {
   11668                 :            :                 (void *)&cmd_rx_offload_get_configuration_show,
   11669                 :            :                 (void *)&cmd_rx_offload_get_configuration_port,
   11670                 :            :                 (void *)&cmd_rx_offload_get_configuration_port_id,
   11671                 :            :                 (void *)&cmd_rx_offload_get_configuration_rx_offload,
   11672                 :            :                 (void *)&cmd_rx_offload_get_configuration_configuration,
   11673                 :            :                 NULL,
   11674                 :            :         }
   11675                 :            : };
   11676                 :            : 
   11677                 :            : /* Enable/Disable a per port offloading */
   11678                 :            : struct cmd_config_per_port_rx_offload_result {
   11679                 :            :         cmdline_fixed_string_t port;
   11680                 :            :         cmdline_fixed_string_t config;
   11681                 :            :         portid_t port_id;
   11682                 :            :         cmdline_fixed_string_t rx_offload;
   11683                 :            :         cmdline_fixed_string_t offload;
   11684                 :            :         cmdline_fixed_string_t on_off;
   11685                 :            : };
   11686                 :            : 
   11687                 :            : static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
   11688                 :            :         TOKEN_STRING_INITIALIZER
   11689                 :            :                 (struct cmd_config_per_port_rx_offload_result,
   11690                 :            :                  port, "port");
   11691                 :            : static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
   11692                 :            :         TOKEN_STRING_INITIALIZER
   11693                 :            :                 (struct cmd_config_per_port_rx_offload_result,
   11694                 :            :                  config, "config");
   11695                 :            : static cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
   11696                 :            :         TOKEN_NUM_INITIALIZER
   11697                 :            :                 (struct cmd_config_per_port_rx_offload_result,
   11698                 :            :                  port_id, RTE_UINT16);
   11699                 :            : static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
   11700                 :            :         TOKEN_STRING_INITIALIZER
   11701                 :            :                 (struct cmd_config_per_port_rx_offload_result,
   11702                 :            :                  rx_offload, "rx_offload");
   11703                 :            : static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
   11704                 :            :         TOKEN_STRING_INITIALIZER
   11705                 :            :                 (struct cmd_config_per_port_rx_offload_result,
   11706                 :            :                  offload, "all#vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
   11707                 :            :                            "qinq_strip#outer_ipv4_cksum#macsec_strip#"
   11708                 :            :                            "vlan_filter#vlan_extend#"
   11709                 :            :                            "scatter#buffer_split#timestamp#security#"
   11710                 :            :                            "keep_crc#rss_hash");
   11711                 :            : static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
   11712                 :            :         TOKEN_STRING_INITIALIZER
   11713                 :            :                 (struct cmd_config_per_port_rx_offload_result,
   11714                 :            :                  on_off, "on#off");
   11715                 :            : 
   11716                 :            : static uint64_t
   11717                 :          0 : search_rx_offload(const char *name)
   11718                 :            : {
   11719                 :            :         uint64_t single_offload;
   11720                 :            :         const char *single_name;
   11721                 :            :         int found = 0;
   11722                 :            :         unsigned int bit;
   11723                 :            : 
   11724                 :            :         single_offload = 1;
   11725                 :          0 :         for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
   11726                 :          0 :                 single_name = rte_eth_dev_rx_offload_name(single_offload);
   11727                 :          0 :                 if (!strcasecmp(single_name, name)) {
   11728                 :            :                         found = 1;
   11729                 :            :                         break;
   11730                 :            :                 }
   11731                 :          0 :                 single_offload <<= 1;
   11732                 :            :         }
   11733                 :            : 
   11734                 :          0 :         if (found)
   11735                 :          0 :                 return single_offload;
   11736                 :            : 
   11737                 :            :         return 0;
   11738                 :            : }
   11739                 :            : 
   11740                 :            : static void
   11741                 :          0 : config_port_rx_offload(portid_t port_id, char *name, bool on)
   11742                 :            : {
   11743                 :            :         struct rte_eth_dev_info dev_info;
   11744                 :          0 :         struct rte_port *port = &ports[port_id];
   11745                 :            :         uint16_t nb_rx_queues;
   11746                 :            :         uint64_t offload;
   11747                 :            :         int q;
   11748                 :            :         int ret;
   11749                 :            : 
   11750                 :          0 :         if (port->port_status != RTE_PORT_STOPPED) {
   11751                 :          0 :                 fprintf(stderr,
   11752                 :            :                         "Error: Can't config offload when Port %d is not stopped\n",
   11753                 :            :                         port_id);
   11754                 :          0 :                 return;
   11755                 :            :         }
   11756                 :            : 
   11757                 :          0 :         ret = eth_dev_info_get_print_err(port_id, &dev_info);
   11758                 :          0 :         if (ret != 0)
   11759                 :            :                 return;
   11760                 :            : 
   11761                 :          0 :         if (!strcmp(name, "all")) {
   11762                 :          0 :                 offload = dev_info.rx_offload_capa;
   11763                 :            :         } else {
   11764                 :          0 :                 offload = search_rx_offload(name);
   11765                 :          0 :                 if (offload == 0) {
   11766                 :          0 :                         fprintf(stderr, "Unknown offload name: %s\n", name);
   11767                 :          0 :                         return;
   11768                 :            :                 }
   11769                 :          0 :                 if ((offload & dev_info.rx_offload_capa) == 0) {
   11770                 :          0 :                         fprintf(stderr, "Error: port %u doesn't support offload: %s.\n",
   11771                 :            :                                 port_id, name);
   11772                 :          0 :                         return;
   11773                 :            :                 }
   11774                 :            :         }
   11775                 :            : 
   11776                 :          0 :         nb_rx_queues = dev_info.nb_rx_queues;
   11777                 :          0 :         if (on) {
   11778                 :          0 :                 port->dev_conf.rxmode.offloads |= offload;
   11779                 :          0 :                 for (q = 0; q < nb_rx_queues; q++)
   11780                 :          0 :                         port->rxq[q].conf.offloads |= offload;
   11781                 :            :         } else {
   11782                 :          0 :                 port->dev_conf.rxmode.offloads &= ~offload;
   11783                 :          0 :                 for (q = 0; q < nb_rx_queues; q++)
   11784                 :          0 :                         port->rxq[q].conf.offloads &= ~offload;
   11785                 :            :         }
   11786                 :            : 
   11787                 :          0 :         cmd_reconfig_device_queue(port_id, 1, 1);
   11788                 :            : }
   11789                 :            : 
   11790                 :            : static void
   11791                 :          0 : cmd_config_per_port_rx_offload_parsed(void *parsed_result,
   11792                 :            :                                 __rte_unused struct cmdline *cl,
   11793                 :            :                                 __rte_unused void *data)
   11794                 :            : {
   11795                 :            :         struct cmd_config_per_port_rx_offload_result *res = parsed_result;
   11796                 :            :         bool on;
   11797                 :            : 
   11798                 :          0 :         on = strcmp(res->on_off, "on") == 0;
   11799                 :          0 :         config_port_rx_offload(res->port_id, res->offload, on);
   11800                 :          0 : }
   11801                 :            : 
   11802                 :            : static cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
   11803                 :            :         .f = cmd_config_per_port_rx_offload_parsed,
   11804                 :            :         .data = NULL,
   11805                 :            :         .help_str = "port config <port_id> rx_offload all|vlan_strip|ipv4_cksum|"
   11806                 :            :                     "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
   11807                 :            :                     "macsec_strip|vlan_filter|vlan_extend|"
   11808                 :            :                     "scatter|buffer_split|timestamp|security|"
   11809                 :            :                     "keep_crc|rss_hash on|off",
   11810                 :            :         .tokens = {
   11811                 :            :                 (void *)&cmd_config_per_port_rx_offload_result_port,
   11812                 :            :                 (void *)&cmd_config_per_port_rx_offload_result_config,
   11813                 :            :                 (void *)&cmd_config_per_port_rx_offload_result_port_id,
   11814                 :            :                 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
   11815                 :            :                 (void *)&cmd_config_per_port_rx_offload_result_offload,
   11816                 :            :                 (void *)&cmd_config_per_port_rx_offload_result_on_off,
   11817                 :            :                 NULL,
   11818                 :            :         }
   11819                 :            : };
   11820                 :            : 
   11821                 :            : /* Enable/Disable all port Rx offloading */
   11822                 :            : struct cmd_config_all_port_rx_offload_result {
   11823                 :            :         cmdline_fixed_string_t port;
   11824                 :            :         cmdline_fixed_string_t config;
   11825                 :            :         cmdline_fixed_string_t port_all;
   11826                 :            :         cmdline_fixed_string_t rx_offload;
   11827                 :            :         cmdline_fixed_string_t offload;
   11828                 :            :         cmdline_fixed_string_t on_off;
   11829                 :            : };
   11830                 :            : 
   11831                 :            : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_port =
   11832                 :            :         TOKEN_STRING_INITIALIZER
   11833                 :            :                 (struct cmd_config_all_port_rx_offload_result,
   11834                 :            :                  port, "port");
   11835                 :            : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_config =
   11836                 :            :         TOKEN_STRING_INITIALIZER
   11837                 :            :                 (struct cmd_config_all_port_rx_offload_result,
   11838                 :            :                  config, "config");
   11839                 :            : 
   11840                 :            : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_port_all =
   11841                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_all_port_rx_offload_result,
   11842                 :            :                                  port_all, "all");
   11843                 :            : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_rx_offload =
   11844                 :            :         TOKEN_STRING_INITIALIZER
   11845                 :            :                 (struct cmd_config_all_port_rx_offload_result,
   11846                 :            :                  rx_offload, "rx_offload");
   11847                 :            : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_offload =
   11848                 :            :         TOKEN_STRING_INITIALIZER
   11849                 :            :                 (struct cmd_config_all_port_rx_offload_result,
   11850                 :            :                  offload, "all#vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
   11851                 :            :                            "qinq_strip#outer_ipv4_cksum#macsec_strip#"
   11852                 :            :                            "vlan_filter#vlan_extend#"
   11853                 :            :                            "scatter#buffer_split#timestamp#security#"
   11854                 :            :                            "keep_crc#rss_hash");
   11855                 :            : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_on_off =
   11856                 :            :         TOKEN_STRING_INITIALIZER
   11857                 :            :                 (struct cmd_config_all_port_rx_offload_result,
   11858                 :            :                  on_off, "on#off");
   11859                 :            : 
   11860                 :            : static void
   11861                 :          0 : cmd_config_all_port_rx_offload_parsed(void *parsed_result,
   11862                 :            :                                 __rte_unused struct cmdline *cl,
   11863                 :            :                                 __rte_unused void *data)
   11864                 :            : {
   11865                 :            :         struct cmd_config_all_port_rx_offload_result *res = parsed_result;
   11866                 :            :         bool on_off;
   11867                 :            :         portid_t i;
   11868                 :            : 
   11869                 :          0 :         on_off = strcmp(res->on_off, "on") == 0;
   11870                 :          0 :         RTE_ETH_FOREACH_DEV(i)
   11871                 :          0 :                 config_port_rx_offload(i, res->offload, on_off);
   11872                 :            : 
   11873                 :          0 : }
   11874                 :            : 
   11875                 :            : static cmdline_parse_inst_t cmd_config_all_port_rx_offload = {
   11876                 :            :         .f = cmd_config_all_port_rx_offload_parsed,
   11877                 :            :         .data = NULL,
   11878                 :            :         .help_str = "port config all rx_offload all|vlan_strip|ipv4_cksum|"
   11879                 :            :                     "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
   11880                 :            :                     "macsec_strip|vlan_filter|vlan_extend|"
   11881                 :            :                     "scatter|buffer_split|timestamp|security|"
   11882                 :            :                     "keep_crc|rss_hash on|off",
   11883                 :            :         .tokens = {
   11884                 :            :                 (void *)&cmd_config_all_port_rx_offload_result_port,
   11885                 :            :                 (void *)&cmd_config_all_port_rx_offload_result_config,
   11886                 :            :                 (void *)&cmd_config_all_port_rx_offload_result_port_all,
   11887                 :            :                 (void *)&cmd_config_all_port_rx_offload_result_rx_offload,
   11888                 :            :                 (void *)&cmd_config_all_port_rx_offload_result_offload,
   11889                 :            :                 (void *)&cmd_config_all_port_rx_offload_result_on_off,
   11890                 :            :                 NULL,
   11891                 :            :         }
   11892                 :            : };
   11893                 :            : 
   11894                 :            : /* Enable/Disable a per queue offloading */
   11895                 :            : struct cmd_config_per_queue_rx_offload_result {
   11896                 :            :         cmdline_fixed_string_t port;
   11897                 :            :         portid_t port_id;
   11898                 :            :         cmdline_fixed_string_t rxq;
   11899                 :            :         uint16_t queue_id;
   11900                 :            :         cmdline_fixed_string_t rx_offload;
   11901                 :            :         cmdline_fixed_string_t offload;
   11902                 :            :         cmdline_fixed_string_t on_off;
   11903                 :            : };
   11904                 :            : 
   11905                 :            : static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
   11906                 :            :         TOKEN_STRING_INITIALIZER
   11907                 :            :                 (struct cmd_config_per_queue_rx_offload_result,
   11908                 :            :                  port, "port");
   11909                 :            : static cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
   11910                 :            :         TOKEN_NUM_INITIALIZER
   11911                 :            :                 (struct cmd_config_per_queue_rx_offload_result,
   11912                 :            :                  port_id, RTE_UINT16);
   11913                 :            : static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
   11914                 :            :         TOKEN_STRING_INITIALIZER
   11915                 :            :                 (struct cmd_config_per_queue_rx_offload_result,
   11916                 :            :                  rxq, "rxq");
   11917                 :            : static cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
   11918                 :            :         TOKEN_NUM_INITIALIZER
   11919                 :            :                 (struct cmd_config_per_queue_rx_offload_result,
   11920                 :            :                  queue_id, RTE_UINT16);
   11921                 :            : static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
   11922                 :            :         TOKEN_STRING_INITIALIZER
   11923                 :            :                 (struct cmd_config_per_queue_rx_offload_result,
   11924                 :            :                  rx_offload, "rx_offload");
   11925                 :            : static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
   11926                 :            :         TOKEN_STRING_INITIALIZER
   11927                 :            :                 (struct cmd_config_per_queue_rx_offload_result,
   11928                 :            :                  offload, "all#vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
   11929                 :            :                            "qinq_strip#outer_ipv4_cksum#macsec_strip#"
   11930                 :            :                            "vlan_filter#vlan_extend#"
   11931                 :            :                            "scatter#buffer_split#timestamp#security#keep_crc");
   11932                 :            : static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
   11933                 :            :         TOKEN_STRING_INITIALIZER
   11934                 :            :                 (struct cmd_config_per_queue_rx_offload_result,
   11935                 :            :                  on_off, "on#off");
   11936                 :            : 
   11937                 :            : static void
   11938                 :          0 : cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
   11939                 :            :                                 __rte_unused struct cmdline *cl,
   11940                 :            :                                 __rte_unused void *data)
   11941                 :            : {
   11942                 :            :         struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
   11943                 :            :         struct rte_eth_dev_info dev_info;
   11944                 :          0 :         portid_t port_id = res->port_id;
   11945                 :          0 :         uint16_t queue_id = res->queue_id;
   11946                 :          0 :         struct rte_port *port = &ports[port_id];
   11947                 :            :         uint64_t offload;
   11948                 :            :         int ret;
   11949                 :            : 
   11950                 :          0 :         if (port->port_status != RTE_PORT_STOPPED) {
   11951                 :          0 :                 fprintf(stderr,
   11952                 :            :                         "Error: Can't config offload when Port %d is not stopped\n",
   11953                 :            :                         port_id);
   11954                 :          0 :                 return;
   11955                 :            :         }
   11956                 :            : 
   11957                 :          0 :         ret = eth_dev_info_get_print_err(port_id, &dev_info);
   11958                 :          0 :         if (ret != 0)
   11959                 :            :                 return;
   11960                 :            : 
   11961                 :          0 :         if (queue_id >= dev_info.nb_rx_queues) {
   11962                 :          0 :                 fprintf(stderr,
   11963                 :            :                         "Error: input queue_id should be 0 ... %d\n",
   11964                 :          0 :                         dev_info.nb_rx_queues - 1);
   11965                 :          0 :                 return;
   11966                 :            :         }
   11967                 :            : 
   11968                 :          0 :         if (!strcmp(res->offload, "all")) {
   11969                 :          0 :                 offload = dev_info.rx_queue_offload_capa;
   11970                 :            :         } else {
   11971                 :          0 :                 offload = search_rx_offload(res->offload);
   11972                 :          0 :                 if (offload == 0) {
   11973                 :          0 :                         fprintf(stderr, "Unknown offload name: %s\n", res->offload);
   11974                 :          0 :                         return;
   11975                 :            :                 }
   11976                 :          0 :                 if ((offload & dev_info.rx_queue_offload_capa) == 0) {
   11977                 :          0 :                         fprintf(stderr, "Error: port %u doesn't support per queue offload: %s.\n",
   11978                 :            :                                 port_id, res->offload);
   11979                 :          0 :                         return;
   11980                 :            :                 }
   11981                 :            :         }
   11982                 :            : 
   11983                 :          0 :         if (!strcmp(res->on_off, "on"))
   11984                 :          0 :                 port->rxq[queue_id].conf.offloads |= offload;
   11985                 :            :         else
   11986                 :          0 :                 port->rxq[queue_id].conf.offloads &= ~offload;
   11987                 :            : 
   11988                 :          0 :         cmd_reconfig_device_queue(port_id, 1, 1);
   11989                 :            : }
   11990                 :            : 
   11991                 :            : static cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
   11992                 :            :         .f = cmd_config_per_queue_rx_offload_parsed,
   11993                 :            :         .data = NULL,
   11994                 :            :         .help_str = "port <port_id> rxq <queue_id> rx_offload "
   11995                 :            :                     "all|vlan_strip|ipv4_cksum|"
   11996                 :            :                     "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
   11997                 :            :                     "macsec_strip|vlan_filter|vlan_extend|"
   11998                 :            :                     "scatter|buffer_split|timestamp|security|"
   11999                 :            :                     "keep_crc on|off",
   12000                 :            :         .tokens = {
   12001                 :            :                 (void *)&cmd_config_per_queue_rx_offload_result_port,
   12002                 :            :                 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
   12003                 :            :                 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
   12004                 :            :                 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
   12005                 :            :                 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
   12006                 :            :                 (void *)&cmd_config_per_queue_rx_offload_result_offload,
   12007                 :            :                 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
   12008                 :            :                 NULL,
   12009                 :            :         }
   12010                 :            : };
   12011                 :            : 
   12012                 :            : /* Get Tx offloads capabilities */
   12013                 :            : struct cmd_tx_offload_get_capa_result {
   12014                 :            :         cmdline_fixed_string_t show;
   12015                 :            :         cmdline_fixed_string_t port;
   12016                 :            :         portid_t port_id;
   12017                 :            :         cmdline_fixed_string_t tx_offload;
   12018                 :            :         cmdline_fixed_string_t capabilities;
   12019                 :            : };
   12020                 :            : 
   12021                 :            : static cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
   12022                 :            :         TOKEN_STRING_INITIALIZER
   12023                 :            :                 (struct cmd_tx_offload_get_capa_result,
   12024                 :            :                  show, "show");
   12025                 :            : static cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
   12026                 :            :         TOKEN_STRING_INITIALIZER
   12027                 :            :                 (struct cmd_tx_offload_get_capa_result,
   12028                 :            :                  port, "port");
   12029                 :            : static cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
   12030                 :            :         TOKEN_NUM_INITIALIZER
   12031                 :            :                 (struct cmd_tx_offload_get_capa_result,
   12032                 :            :                  port_id, RTE_UINT16);
   12033                 :            : static cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
   12034                 :            :         TOKEN_STRING_INITIALIZER
   12035                 :            :                 (struct cmd_tx_offload_get_capa_result,
   12036                 :            :                  tx_offload, "tx_offload");
   12037                 :            : static cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
   12038                 :            :         TOKEN_STRING_INITIALIZER
   12039                 :            :                 (struct cmd_tx_offload_get_capa_result,
   12040                 :            :                  capabilities, "capabilities");
   12041                 :            : 
   12042                 :            : static void
   12043                 :          0 : print_tx_offloads(uint64_t offloads)
   12044                 :            : {
   12045                 :            :         uint64_t single_offload;
   12046                 :            :         int begin;
   12047                 :            :         int end;
   12048                 :            :         int bit;
   12049                 :            : 
   12050                 :          0 :         if (offloads == 0)
   12051                 :            :                 return;
   12052                 :            : 
   12053                 :            :         begin = rte_ctz64(offloads);
   12054                 :          0 :         end = sizeof(offloads) * CHAR_BIT - rte_clz64(offloads);
   12055                 :            : 
   12056                 :          0 :         single_offload = 1ULL << begin;
   12057                 :          0 :         for (bit = begin; bit < end; bit++) {
   12058                 :          0 :                 if (offloads & single_offload)
   12059                 :          0 :                         printf(" %s",
   12060                 :            :                                rte_eth_dev_tx_offload_name(single_offload));
   12061                 :          0 :                 single_offload <<= 1;
   12062                 :            :         }
   12063                 :            : }
   12064                 :            : 
   12065                 :            : static void
   12066                 :          0 : cmd_tx_offload_get_capa_parsed(
   12067                 :            :         void *parsed_result,
   12068                 :            :         __rte_unused struct cmdline *cl,
   12069                 :            :         __rte_unused void *data)
   12070                 :            : {
   12071                 :            :         struct cmd_tx_offload_get_capa_result *res = parsed_result;
   12072                 :            :         struct rte_eth_dev_info dev_info;
   12073                 :          0 :         portid_t port_id = res->port_id;
   12074                 :            :         uint64_t queue_offloads;
   12075                 :            :         uint64_t port_offloads;
   12076                 :            :         int ret;
   12077                 :            : 
   12078                 :          0 :         ret = eth_dev_info_get_print_err(port_id, &dev_info);
   12079                 :          0 :         if (ret != 0)
   12080                 :          0 :                 return;
   12081                 :            : 
   12082                 :          0 :         queue_offloads = dev_info.tx_queue_offload_capa;
   12083                 :          0 :         port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
   12084                 :            : 
   12085                 :            :         printf("Tx Offloading Capabilities of port %d :\n", port_id);
   12086                 :            :         printf("  Per Queue :");
   12087                 :          0 :         print_tx_offloads(queue_offloads);
   12088                 :            : 
   12089                 :            :         printf("\n");
   12090                 :            :         printf("  Per Port  :");
   12091                 :          0 :         print_tx_offloads(port_offloads);
   12092                 :            :         printf("\n\n");
   12093                 :            : }
   12094                 :            : 
   12095                 :            : static cmdline_parse_inst_t cmd_tx_offload_get_capa = {
   12096                 :            :         .f = cmd_tx_offload_get_capa_parsed,
   12097                 :            :         .data = NULL,
   12098                 :            :         .help_str = "show port <port_id> tx_offload capabilities",
   12099                 :            :         .tokens = {
   12100                 :            :                 (void *)&cmd_tx_offload_get_capa_show,
   12101                 :            :                 (void *)&cmd_tx_offload_get_capa_port,
   12102                 :            :                 (void *)&cmd_tx_offload_get_capa_port_id,
   12103                 :            :                 (void *)&cmd_tx_offload_get_capa_tx_offload,
   12104                 :            :                 (void *)&cmd_tx_offload_get_capa_capabilities,
   12105                 :            :                 NULL,
   12106                 :            :         }
   12107                 :            : };
   12108                 :            : 
   12109                 :            : /* Get Tx offloads configuration */
   12110                 :            : struct cmd_tx_offload_get_configuration_result {
   12111                 :            :         cmdline_fixed_string_t show;
   12112                 :            :         cmdline_fixed_string_t port;
   12113                 :            :         portid_t port_id;
   12114                 :            :         cmdline_fixed_string_t tx_offload;
   12115                 :            :         cmdline_fixed_string_t configuration;
   12116                 :            : };
   12117                 :            : 
   12118                 :            : static cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
   12119                 :            :         TOKEN_STRING_INITIALIZER
   12120                 :            :                 (struct cmd_tx_offload_get_configuration_result,
   12121                 :            :                  show, "show");
   12122                 :            : static cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
   12123                 :            :         TOKEN_STRING_INITIALIZER
   12124                 :            :                 (struct cmd_tx_offload_get_configuration_result,
   12125                 :            :                  port, "port");
   12126                 :            : static cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
   12127                 :            :         TOKEN_NUM_INITIALIZER
   12128                 :            :                 (struct cmd_tx_offload_get_configuration_result,
   12129                 :            :                  port_id, RTE_UINT16);
   12130                 :            : static cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
   12131                 :            :         TOKEN_STRING_INITIALIZER
   12132                 :            :                 (struct cmd_tx_offload_get_configuration_result,
   12133                 :            :                  tx_offload, "tx_offload");
   12134                 :            : static cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
   12135                 :            :         TOKEN_STRING_INITIALIZER
   12136                 :            :                 (struct cmd_tx_offload_get_configuration_result,
   12137                 :            :                  configuration, "configuration");
   12138                 :            : 
   12139                 :            : static void
   12140                 :          0 : cmd_tx_offload_get_configuration_parsed(
   12141                 :            :         void *parsed_result,
   12142                 :            :         __rte_unused struct cmdline *cl,
   12143                 :            :         __rte_unused void *data)
   12144                 :            : {
   12145                 :            :         struct cmd_tx_offload_get_configuration_result *res = parsed_result;
   12146                 :            :         struct rte_eth_dev_info dev_info;
   12147                 :          0 :         portid_t port_id = res->port_id;
   12148                 :          0 :         struct rte_port *port = &ports[port_id];
   12149                 :            :         struct rte_eth_conf dev_conf;
   12150                 :            :         uint64_t port_offloads;
   12151                 :            :         uint64_t queue_offloads;
   12152                 :            :         uint16_t nb_tx_queues;
   12153                 :            :         int q;
   12154                 :            :         int ret;
   12155                 :            : 
   12156                 :          0 :         printf("Tx Offloading Configuration of port %d :\n", port_id);
   12157                 :            : 
   12158                 :          0 :         ret = eth_dev_conf_get_print_err(port_id, &dev_conf);
   12159                 :          0 :         if (ret != 0)
   12160                 :          0 :                 return;
   12161                 :            : 
   12162                 :          0 :         port_offloads = dev_conf.txmode.offloads;
   12163                 :            :         printf("  Port :");
   12164                 :          0 :         print_tx_offloads(port_offloads);
   12165                 :            :         printf("\n");
   12166                 :            : 
   12167                 :          0 :         ret = eth_dev_info_get_print_err(port_id, &dev_info);
   12168                 :          0 :         if (ret != 0)
   12169                 :            :                 return;
   12170                 :            : 
   12171                 :          0 :         nb_tx_queues = dev_info.nb_tx_queues;
   12172                 :          0 :         for (q = 0; q < nb_tx_queues; q++) {
   12173                 :          0 :                 queue_offloads = port->txq[q].conf.offloads;
   12174                 :            :                 printf("  Queue[%2d] :", q);
   12175                 :          0 :                 print_tx_offloads(queue_offloads);
   12176                 :            :                 printf("\n");
   12177                 :            :         }
   12178                 :            :         printf("\n");
   12179                 :            : }
   12180                 :            : 
   12181                 :            : static cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
   12182                 :            :         .f = cmd_tx_offload_get_configuration_parsed,
   12183                 :            :         .data = NULL,
   12184                 :            :         .help_str = "show port <port_id> tx_offload configuration",
   12185                 :            :         .tokens = {
   12186                 :            :                 (void *)&cmd_tx_offload_get_configuration_show,
   12187                 :            :                 (void *)&cmd_tx_offload_get_configuration_port,
   12188                 :            :                 (void *)&cmd_tx_offload_get_configuration_port_id,
   12189                 :            :                 (void *)&cmd_tx_offload_get_configuration_tx_offload,
   12190                 :            :                 (void *)&cmd_tx_offload_get_configuration_configuration,
   12191                 :            :                 NULL,
   12192                 :            :         }
   12193                 :            : };
   12194                 :            : 
   12195                 :            : /* Enable/Disable a per port offloading */
   12196                 :            : struct cmd_config_per_port_tx_offload_result {
   12197                 :            :         cmdline_fixed_string_t port;
   12198                 :            :         cmdline_fixed_string_t config;
   12199                 :            :         portid_t port_id;
   12200                 :            :         cmdline_fixed_string_t tx_offload;
   12201                 :            :         cmdline_fixed_string_t offload;
   12202                 :            :         cmdline_fixed_string_t on_off;
   12203                 :            : };
   12204                 :            : 
   12205                 :            : static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
   12206                 :            :         TOKEN_STRING_INITIALIZER
   12207                 :            :                 (struct cmd_config_per_port_tx_offload_result,
   12208                 :            :                  port, "port");
   12209                 :            : static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
   12210                 :            :         TOKEN_STRING_INITIALIZER
   12211                 :            :                 (struct cmd_config_per_port_tx_offload_result,
   12212                 :            :                  config, "config");
   12213                 :            : static cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
   12214                 :            :         TOKEN_NUM_INITIALIZER
   12215                 :            :                 (struct cmd_config_per_port_tx_offload_result,
   12216                 :            :                  port_id, RTE_UINT16);
   12217                 :            : static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
   12218                 :            :         TOKEN_STRING_INITIALIZER
   12219                 :            :                 (struct cmd_config_per_port_tx_offload_result,
   12220                 :            :                  tx_offload, "tx_offload");
   12221                 :            : static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
   12222                 :            :         TOKEN_STRING_INITIALIZER
   12223                 :            :                 (struct cmd_config_per_port_tx_offload_result,
   12224                 :            :                  offload, "all#vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
   12225                 :            :                           "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
   12226                 :            :                           "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
   12227                 :            :                           "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
   12228                 :            :                           "mt_lockfree#multi_segs#mbuf_fast_free#security#"
   12229                 :            :                           "send_on_timestamp");
   12230                 :            : static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
   12231                 :            :         TOKEN_STRING_INITIALIZER
   12232                 :            :                 (struct cmd_config_per_port_tx_offload_result,
   12233                 :            :                  on_off, "on#off");
   12234                 :            : 
   12235                 :            : static uint64_t
   12236                 :          0 : search_tx_offload(const char *name)
   12237                 :            : {
   12238                 :            :         uint64_t single_offload;
   12239                 :            :         const char *single_name;
   12240                 :            :         int found = 0;
   12241                 :            :         unsigned int bit;
   12242                 :            : 
   12243                 :            :         single_offload = 1;
   12244                 :          0 :         for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
   12245                 :          0 :                 single_name = rte_eth_dev_tx_offload_name(single_offload);
   12246                 :          0 :                 if (single_name == NULL)
   12247                 :            :                         break;
   12248                 :          0 :                 if (!strcasecmp(single_name, name)) {
   12249                 :            :                         found = 1;
   12250                 :            :                         break;
   12251                 :          0 :                 } else if (!strcasecmp(single_name, "UNKNOWN"))
   12252                 :            :                         break;
   12253                 :          0 :                 single_offload <<= 1;
   12254                 :            :         }
   12255                 :            : 
   12256                 :          0 :         if (found)
   12257                 :          0 :                 return single_offload;
   12258                 :            : 
   12259                 :            :         return 0;
   12260                 :            : }
   12261                 :            : 
   12262                 :            : static void
   12263                 :          0 : config_port_tx_offload(portid_t port_id, char *name, bool on)
   12264                 :            : {
   12265                 :            :         struct rte_eth_dev_info dev_info;
   12266                 :          0 :         struct rte_port *port = &ports[port_id];
   12267                 :            :         uint16_t nb_tx_queues;
   12268                 :            :         uint64_t offload;
   12269                 :            :         int q;
   12270                 :            :         int ret;
   12271                 :            : 
   12272                 :          0 :         if (port->port_status != RTE_PORT_STOPPED) {
   12273                 :          0 :                 fprintf(stderr,
   12274                 :            :                         "Error: Can't config offload when Port %d is not stopped\n",
   12275                 :            :                         port_id);
   12276                 :          0 :                 return;
   12277                 :            :         }
   12278                 :            : 
   12279                 :          0 :         ret = eth_dev_info_get_print_err(port_id, &dev_info);
   12280                 :          0 :         if (ret != 0)
   12281                 :            :                 return;
   12282                 :            : 
   12283                 :          0 :         if (!strcmp(name, "all")) {
   12284                 :          0 :                 offload = dev_info.tx_offload_capa;
   12285                 :            :         } else {
   12286                 :          0 :                 offload = search_tx_offload(name);
   12287                 :          0 :                 if (offload == 0) {
   12288                 :          0 :                         fprintf(stderr, "Unknown offload name: %s\n", name);
   12289                 :          0 :                         return;
   12290                 :            :                 }
   12291                 :          0 :                 if ((offload & dev_info.tx_offload_capa) == 0) {
   12292                 :          0 :                         fprintf(stderr, "Error: port %u doesn't support offload: %s.\n",
   12293                 :            :                                 port_id, name);
   12294                 :          0 :                         return;
   12295                 :            :                 }
   12296                 :            :         }
   12297                 :            : 
   12298                 :          0 :         nb_tx_queues = dev_info.nb_tx_queues;
   12299                 :          0 :         if (on) {
   12300                 :          0 :                 port->dev_conf.txmode.offloads |= offload;
   12301                 :          0 :                 for (q = 0; q < nb_tx_queues; q++)
   12302                 :          0 :                         port->txq[q].conf.offloads |= offload;
   12303                 :            :         } else {
   12304                 :          0 :                 port->dev_conf.txmode.offloads &= ~offload;
   12305                 :          0 :                 for (q = 0; q < nb_tx_queues; q++)
   12306                 :          0 :                         port->txq[q].conf.offloads &= ~offload;
   12307                 :            :         }
   12308                 :            : 
   12309                 :          0 :         cmd_reconfig_device_queue(port_id, 1, 1);
   12310                 :            : }
   12311                 :            : 
   12312                 :            : static void
   12313                 :          0 : cmd_config_per_port_tx_offload_parsed(void *parsed_result,
   12314                 :            :                                 __rte_unused struct cmdline *cl,
   12315                 :            :                                 __rte_unused void *data)
   12316                 :            : {
   12317                 :            :         struct cmd_config_per_port_tx_offload_result *res = parsed_result;
   12318                 :            :         bool on;
   12319                 :            : 
   12320                 :          0 :         on = strcmp(res->on_off, "on") == 0;
   12321                 :          0 :         config_port_tx_offload(res->port_id, res->offload, on);
   12322                 :          0 : }
   12323                 :            : 
   12324                 :            : static cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
   12325                 :            :         .f = cmd_config_per_port_tx_offload_parsed,
   12326                 :            :         .data = NULL,
   12327                 :            :         .help_str = "port config <port_id> tx_offload "
   12328                 :            :                     "all|vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
   12329                 :            :                     "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
   12330                 :            :                     "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
   12331                 :            :                     "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
   12332                 :            :                     "mt_lockfree|multi_segs|mbuf_fast_free|security|"
   12333                 :            :                     "send_on_timestamp on|off",
   12334                 :            :         .tokens = {
   12335                 :            :                 (void *)&cmd_config_per_port_tx_offload_result_port,
   12336                 :            :                 (void *)&cmd_config_per_port_tx_offload_result_config,
   12337                 :            :                 (void *)&cmd_config_per_port_tx_offload_result_port_id,
   12338                 :            :                 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
   12339                 :            :                 (void *)&cmd_config_per_port_tx_offload_result_offload,
   12340                 :            :                 (void *)&cmd_config_per_port_tx_offload_result_on_off,
   12341                 :            :                 NULL,
   12342                 :            :         }
   12343                 :            : };
   12344                 :            : 
   12345                 :            : /* Enable/Disable all port Tx offloading */
   12346                 :            : struct cmd_config_all_port_tx_offload_result {
   12347                 :            :         cmdline_fixed_string_t port;
   12348                 :            :         cmdline_fixed_string_t config;
   12349                 :            :         cmdline_fixed_string_t port_all;
   12350                 :            :         cmdline_fixed_string_t tx_offload;
   12351                 :            :         cmdline_fixed_string_t offload;
   12352                 :            :         cmdline_fixed_string_t on_off;
   12353                 :            : };
   12354                 :            : 
   12355                 :            : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_port =
   12356                 :            :         TOKEN_STRING_INITIALIZER
   12357                 :            :                 (struct cmd_config_all_port_tx_offload_result,
   12358                 :            :                  port, "port");
   12359                 :            : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_config =
   12360                 :            :         TOKEN_STRING_INITIALIZER
   12361                 :            :                 (struct cmd_config_all_port_tx_offload_result,
   12362                 :            :                  config, "config");
   12363                 :            : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_port_all =
   12364                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_all_port_tx_offload_result,
   12365                 :            :                                  port_all, "all");
   12366                 :            : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_tx_offload =
   12367                 :            :         TOKEN_STRING_INITIALIZER
   12368                 :            :                 (struct cmd_config_all_port_tx_offload_result,
   12369                 :            :                  tx_offload, "tx_offload");
   12370                 :            : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_offload =
   12371                 :            :         TOKEN_STRING_INITIALIZER
   12372                 :            :                 (struct cmd_config_all_port_tx_offload_result,
   12373                 :            :                  offload, "all#vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
   12374                 :            :                           "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
   12375                 :            :                           "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
   12376                 :            :                           "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
   12377                 :            :                           "mt_lockfree#multi_segs#mbuf_fast_free#security#"
   12378                 :            :                           "send_on_timestamp");
   12379                 :            : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_on_off =
   12380                 :            :         TOKEN_STRING_INITIALIZER
   12381                 :            :                 (struct cmd_config_all_port_tx_offload_result,
   12382                 :            :                  on_off, "on#off");
   12383                 :            : 
   12384                 :            : static void
   12385                 :          0 : cmd_config_all_port_tx_offload_parsed(void *parsed_result,
   12386                 :            :                                 __rte_unused struct cmdline *cl,
   12387                 :            :                                 __rte_unused void *data)
   12388                 :            : {
   12389                 :            :         struct cmd_config_all_port_tx_offload_result *res = parsed_result;
   12390                 :            :         portid_t i;
   12391                 :            :         bool on_off;
   12392                 :            : 
   12393                 :          0 :         on_off = strcmp(res->on_off, "on") == 0;
   12394                 :          0 :         RTE_ETH_FOREACH_DEV(i)
   12395                 :          0 :                 config_port_tx_offload(i, res->offload, on_off);
   12396                 :          0 : }
   12397                 :            : 
   12398                 :            : static cmdline_parse_inst_t cmd_config_all_port_tx_offload = {
   12399                 :            :         .f = cmd_config_all_port_tx_offload_parsed,
   12400                 :            :         .data = NULL,
   12401                 :            :         .help_str = "port config all tx_offload "
   12402                 :            :                     "all|vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
   12403                 :            :                     "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
   12404                 :            :                     "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
   12405                 :            :                     "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
   12406                 :            :                     "mt_lockfree|multi_segs|mbuf_fast_free|security|"
   12407                 :            :                     "send_on_timestamp on|off",
   12408                 :            :         .tokens = {
   12409                 :            :                 (void *)&cmd_config_all_port_tx_offload_result_port,
   12410                 :            :                 (void *)&cmd_config_all_port_tx_offload_result_config,
   12411                 :            :                 (void *)&cmd_config_all_port_tx_offload_result_port_all,
   12412                 :            :                 (void *)&cmd_config_all_port_tx_offload_result_tx_offload,
   12413                 :            :                 (void *)&cmd_config_all_port_tx_offload_result_offload,
   12414                 :            :                 (void *)&cmd_config_all_port_tx_offload_result_on_off,
   12415                 :            :                 NULL,
   12416                 :            :         }
   12417                 :            : };
   12418                 :            : 
   12419                 :            : /* Enable/Disable a per queue offloading */
   12420                 :            : struct cmd_config_per_queue_tx_offload_result {
   12421                 :            :         cmdline_fixed_string_t port;
   12422                 :            :         portid_t port_id;
   12423                 :            :         cmdline_fixed_string_t txq;
   12424                 :            :         uint16_t queue_id;
   12425                 :            :         cmdline_fixed_string_t tx_offload;
   12426                 :            :         cmdline_fixed_string_t offload;
   12427                 :            :         cmdline_fixed_string_t on_off;
   12428                 :            : };
   12429                 :            : 
   12430                 :            : static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
   12431                 :            :         TOKEN_STRING_INITIALIZER
   12432                 :            :                 (struct cmd_config_per_queue_tx_offload_result,
   12433                 :            :                  port, "port");
   12434                 :            : static cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
   12435                 :            :         TOKEN_NUM_INITIALIZER
   12436                 :            :                 (struct cmd_config_per_queue_tx_offload_result,
   12437                 :            :                  port_id, RTE_UINT16);
   12438                 :            : static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
   12439                 :            :         TOKEN_STRING_INITIALIZER
   12440                 :            :                 (struct cmd_config_per_queue_tx_offload_result,
   12441                 :            :                  txq, "txq");
   12442                 :            : static cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
   12443                 :            :         TOKEN_NUM_INITIALIZER
   12444                 :            :                 (struct cmd_config_per_queue_tx_offload_result,
   12445                 :            :                  queue_id, RTE_UINT16);
   12446                 :            : static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
   12447                 :            :         TOKEN_STRING_INITIALIZER
   12448                 :            :                 (struct cmd_config_per_queue_tx_offload_result,
   12449                 :            :                  tx_offload, "tx_offload");
   12450                 :            : static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
   12451                 :            :         TOKEN_STRING_INITIALIZER
   12452                 :            :                 (struct cmd_config_per_queue_tx_offload_result,
   12453                 :            :                  offload, "all#vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
   12454                 :            :                           "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
   12455                 :            :                           "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
   12456                 :            :                           "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
   12457                 :            :                           "mt_lockfree#multi_segs#mbuf_fast_free#security");
   12458                 :            : static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
   12459                 :            :         TOKEN_STRING_INITIALIZER
   12460                 :            :                 (struct cmd_config_per_queue_tx_offload_result,
   12461                 :            :                  on_off, "on#off");
   12462                 :            : 
   12463                 :            : static void
   12464                 :          0 : cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
   12465                 :            :                                 __rte_unused struct cmdline *cl,
   12466                 :            :                                 __rte_unused void *data)
   12467                 :            : {
   12468                 :            :         struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
   12469                 :            :         struct rte_eth_dev_info dev_info;
   12470                 :          0 :         portid_t port_id = res->port_id;
   12471                 :          0 :         uint16_t queue_id = res->queue_id;
   12472                 :          0 :         struct rte_port *port = &ports[port_id];
   12473                 :            :         uint64_t offload;
   12474                 :            :         int ret;
   12475                 :            : 
   12476                 :          0 :         if (port->port_status != RTE_PORT_STOPPED) {
   12477                 :          0 :                 fprintf(stderr,
   12478                 :            :                         "Error: Can't config offload when Port %d is not stopped\n",
   12479                 :            :                         port_id);
   12480                 :          0 :                 return;
   12481                 :            :         }
   12482                 :            : 
   12483                 :          0 :         ret = eth_dev_info_get_print_err(port_id, &dev_info);
   12484                 :          0 :         if (ret != 0)
   12485                 :            :                 return;
   12486                 :            : 
   12487                 :          0 :         if (queue_id >= dev_info.nb_tx_queues) {
   12488                 :          0 :                 fprintf(stderr,
   12489                 :            :                         "Error: input queue_id should be 0 ... %d\n",
   12490                 :          0 :                         dev_info.nb_tx_queues - 1);
   12491                 :          0 :                 return;
   12492                 :            :         }
   12493                 :            : 
   12494                 :          0 :         if (!strcmp(res->offload, "all")) {
   12495                 :          0 :                 offload = dev_info.tx_queue_offload_capa;
   12496                 :            :         } else {
   12497                 :          0 :                 offload = search_tx_offload(res->offload);
   12498                 :          0 :                 if (offload == 0) {
   12499                 :          0 :                         fprintf(stderr, "Unknown offload name: %s\n", res->offload);
   12500                 :          0 :                         return;
   12501                 :            :                 }
   12502                 :          0 :                 if ((offload & dev_info.tx_queue_offload_capa) == 0) {
   12503                 :          0 :                         fprintf(stderr, "Error: port %u doesn't support per queue offload: %s.\n",
   12504                 :            :                                 port_id, res->offload);
   12505                 :          0 :                         return;
   12506                 :            :                 }
   12507                 :            :         }
   12508                 :            : 
   12509                 :          0 :         if (!strcmp(res->on_off, "on"))
   12510                 :          0 :                 port->txq[queue_id].conf.offloads |= offload;
   12511                 :            :         else
   12512                 :          0 :                 port->txq[queue_id].conf.offloads &= ~offload;
   12513                 :            : 
   12514                 :          0 :         cmd_reconfig_device_queue(port_id, 1, 1);
   12515                 :            : }
   12516                 :            : 
   12517                 :            : static cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
   12518                 :            :         .f = cmd_config_per_queue_tx_offload_parsed,
   12519                 :            :         .data = NULL,
   12520                 :            :         .help_str = "port <port_id> txq <queue_id> tx_offload "
   12521                 :            :                     "all|vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
   12522                 :            :                     "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
   12523                 :            :                     "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
   12524                 :            :                     "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
   12525                 :            :                     "mt_lockfree|multi_segs|mbuf_fast_free|security "
   12526                 :            :                     "on|off",
   12527                 :            :         .tokens = {
   12528                 :            :                 (void *)&cmd_config_per_queue_tx_offload_result_port,
   12529                 :            :                 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
   12530                 :            :                 (void *)&cmd_config_per_queue_tx_offload_result_txq,
   12531                 :            :                 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
   12532                 :            :                 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
   12533                 :            :                 (void *)&cmd_config_per_queue_tx_offload_result_offload,
   12534                 :            :                 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
   12535                 :            :                 NULL,
   12536                 :            :         }
   12537                 :            : };
   12538                 :            : 
   12539                 :            : /* *** configure tx_metadata for specific port *** */
   12540                 :            : struct cmd_config_tx_metadata_specific_result {
   12541                 :            :         cmdline_fixed_string_t port;
   12542                 :            :         cmdline_fixed_string_t keyword;
   12543                 :            :         uint16_t port_id;
   12544                 :            :         cmdline_fixed_string_t item;
   12545                 :            :         uint32_t value;
   12546                 :            : };
   12547                 :            : 
   12548                 :            : static void
   12549                 :          0 : cmd_config_tx_metadata_specific_parsed(void *parsed_result,
   12550                 :            :                                 __rte_unused struct cmdline *cl,
   12551                 :            :                                 __rte_unused void *data)
   12552                 :            : {
   12553                 :            :         struct cmd_config_tx_metadata_specific_result *res = parsed_result;
   12554                 :            : 
   12555                 :          0 :         if (port_id_is_invalid(res->port_id, ENABLED_WARN))
   12556                 :            :                 return;
   12557                 :          0 :         ports[res->port_id].tx_metadata = res->value;
   12558                 :            :         /* Add/remove callback to insert valid metadata in every Tx packet. */
   12559                 :          0 :         if (ports[res->port_id].tx_metadata)
   12560                 :          0 :                 add_tx_md_callback(res->port_id);
   12561                 :            :         else
   12562                 :          0 :                 remove_tx_md_callback(res->port_id);
   12563                 :          0 :         rte_flow_dynf_metadata_register();
   12564                 :            : }
   12565                 :            : 
   12566                 :            : static cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
   12567                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
   12568                 :            :                         port, "port");
   12569                 :            : static cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
   12570                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
   12571                 :            :                         keyword, "config");
   12572                 :            : static cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
   12573                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
   12574                 :            :                         port_id, RTE_UINT16);
   12575                 :            : static cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
   12576                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
   12577                 :            :                         item, "tx_metadata");
   12578                 :            : static cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
   12579                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
   12580                 :            :                         value, RTE_UINT32);
   12581                 :            : 
   12582                 :            : static cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
   12583                 :            :         .f = cmd_config_tx_metadata_specific_parsed,
   12584                 :            :         .data = NULL,
   12585                 :            :         .help_str = "port config <port_id> tx_metadata <value>",
   12586                 :            :         .tokens = {
   12587                 :            :                 (void *)&cmd_config_tx_metadata_specific_port,
   12588                 :            :                 (void *)&cmd_config_tx_metadata_specific_keyword,
   12589                 :            :                 (void *)&cmd_config_tx_metadata_specific_id,
   12590                 :            :                 (void *)&cmd_config_tx_metadata_specific_item,
   12591                 :            :                 (void *)&cmd_config_tx_metadata_specific_value,
   12592                 :            :                 NULL,
   12593                 :            :         },
   12594                 :            : };
   12595                 :            : 
   12596                 :            : /* *** set dynf *** */
   12597                 :            : struct cmd_config_tx_dynf_specific_result {
   12598                 :            :         cmdline_fixed_string_t port;
   12599                 :            :         cmdline_fixed_string_t keyword;
   12600                 :            :         uint16_t port_id;
   12601                 :            :         cmdline_fixed_string_t item;
   12602                 :            :         cmdline_fixed_string_t name;
   12603                 :            :         cmdline_fixed_string_t value;
   12604                 :            : };
   12605                 :            : 
   12606                 :            : static void
   12607                 :          0 : cmd_config_dynf_specific_parsed(void *parsed_result,
   12608                 :            :                                 __rte_unused struct cmdline *cl,
   12609                 :            :                                 __rte_unused void *data)
   12610                 :            : {
   12611                 :            :         struct cmd_config_tx_dynf_specific_result *res = parsed_result;
   12612                 :            :         struct rte_mbuf_dynflag desc_flag;
   12613                 :            :         int flag;
   12614                 :            :         uint64_t old_port_flags;
   12615                 :            : 
   12616                 :          0 :         if (port_id_is_invalid(res->port_id, ENABLED_WARN))
   12617                 :          0 :                 return;
   12618                 :          0 :         flag = rte_mbuf_dynflag_lookup(res->name, NULL);
   12619                 :          0 :         if (flag <= 0) {
   12620                 :          0 :                 if (strlcpy(desc_flag.name, res->name,
   12621                 :            :                             RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
   12622                 :          0 :                         fprintf(stderr, "Flag name too long\n");
   12623                 :          0 :                         return;
   12624                 :            :                 }
   12625                 :          0 :                 desc_flag.flags = 0;
   12626                 :          0 :                 flag = rte_mbuf_dynflag_register(&desc_flag);
   12627                 :          0 :                 if (flag < 0) {
   12628                 :          0 :                         fprintf(stderr, "Can't register flag\n");
   12629                 :          0 :                         return;
   12630                 :            :                 }
   12631                 :          0 :                 strcpy(dynf_names[flag], desc_flag.name);
   12632                 :            :         }
   12633                 :          0 :         old_port_flags = ports[res->port_id].mbuf_dynf;
   12634                 :          0 :         if (!strcmp(res->value, "set")) {
   12635                 :          0 :                 ports[res->port_id].mbuf_dynf |= 1UL << flag;
   12636                 :          0 :                 if (old_port_flags == 0)
   12637                 :          0 :                         add_tx_dynf_callback(res->port_id);
   12638                 :            :         } else {
   12639                 :          0 :                 ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
   12640                 :          0 :                 if (ports[res->port_id].mbuf_dynf == 0)
   12641                 :          0 :                         remove_tx_dynf_callback(res->port_id);
   12642                 :            :         }
   12643                 :            : }
   12644                 :            : 
   12645                 :            : static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
   12646                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
   12647                 :            :                         keyword, "port");
   12648                 :            : static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
   12649                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
   12650                 :            :                         keyword, "config");
   12651                 :            : static cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
   12652                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
   12653                 :            :                         port_id, RTE_UINT16);
   12654                 :            : static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
   12655                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
   12656                 :            :                         item, "dynf");
   12657                 :            : static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
   12658                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
   12659                 :            :                         name, NULL);
   12660                 :            : static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
   12661                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
   12662                 :            :                         value, "set#clear");
   12663                 :            : 
   12664                 :            : static cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
   12665                 :            :         .f = cmd_config_dynf_specific_parsed,
   12666                 :            :         .data = NULL,
   12667                 :            :         .help_str = "port config <port id> dynf <name> set|clear",
   12668                 :            :         .tokens = {
   12669                 :            :                 (void *)&cmd_config_tx_dynf_specific_port,
   12670                 :            :                 (void *)&cmd_config_tx_dynf_specific_keyword,
   12671                 :            :                 (void *)&cmd_config_tx_dynf_specific_port_id,
   12672                 :            :                 (void *)&cmd_config_tx_dynf_specific_item,
   12673                 :            :                 (void *)&cmd_config_tx_dynf_specific_name,
   12674                 :            :                 (void *)&cmd_config_tx_dynf_specific_value,
   12675                 :            :                 NULL,
   12676                 :            :         },
   12677                 :            : };
   12678                 :            : 
   12679                 :            : /* *** display tx_metadata per port configuration *** */
   12680                 :            : struct cmd_show_tx_metadata_result {
   12681                 :            :         cmdline_fixed_string_t cmd_show;
   12682                 :            :         cmdline_fixed_string_t cmd_port;
   12683                 :            :         cmdline_fixed_string_t cmd_keyword;
   12684                 :            :         portid_t cmd_pid;
   12685                 :            : };
   12686                 :            : 
   12687                 :            : static void
   12688                 :          0 : cmd_show_tx_metadata_parsed(void *parsed_result,
   12689                 :            :                 __rte_unused struct cmdline *cl,
   12690                 :            :                 __rte_unused void *data)
   12691                 :            : {
   12692                 :            :         struct cmd_show_tx_metadata_result *res = parsed_result;
   12693                 :            : 
   12694                 :          0 :         if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
   12695                 :          0 :                 fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
   12696                 :          0 :                 return;
   12697                 :            :         }
   12698                 :          0 :         if (!strcmp(res->cmd_keyword, "tx_metadata")) {
   12699                 :          0 :                 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
   12700                 :          0 :                        ports[res->cmd_pid].tx_metadata);
   12701                 :            :         }
   12702                 :            : }
   12703                 :            : 
   12704                 :            : static cmdline_parse_token_string_t cmd_show_tx_metadata_show =
   12705                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
   12706                 :            :                         cmd_show, "show");
   12707                 :            : static cmdline_parse_token_string_t cmd_show_tx_metadata_port =
   12708                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
   12709                 :            :                         cmd_port, "port");
   12710                 :            : static cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
   12711                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
   12712                 :            :                         cmd_pid, RTE_UINT16);
   12713                 :            : static cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
   12714                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
   12715                 :            :                         cmd_keyword, "tx_metadata");
   12716                 :            : 
   12717                 :            : static cmdline_parse_inst_t cmd_show_tx_metadata = {
   12718                 :            :         .f = cmd_show_tx_metadata_parsed,
   12719                 :            :         .data = NULL,
   12720                 :            :         .help_str = "show port <port_id> tx_metadata",
   12721                 :            :         .tokens = {
   12722                 :            :                 (void *)&cmd_show_tx_metadata_show,
   12723                 :            :                 (void *)&cmd_show_tx_metadata_port,
   12724                 :            :                 (void *)&cmd_show_tx_metadata_pid,
   12725                 :            :                 (void *)&cmd_show_tx_metadata_keyword,
   12726                 :            :                 NULL,
   12727                 :            :         },
   12728                 :            : };
   12729                 :            : 
   12730                 :            : /* *** show fec capability per port configuration *** */
   12731                 :            : struct cmd_show_fec_capability_result {
   12732                 :            :         cmdline_fixed_string_t cmd_show;
   12733                 :            :         cmdline_fixed_string_t cmd_port;
   12734                 :            :         cmdline_fixed_string_t cmd_fec;
   12735                 :            :         cmdline_fixed_string_t cmd_keyword;
   12736                 :            :         portid_t cmd_pid;
   12737                 :            : };
   12738                 :            : 
   12739                 :            : static void
   12740                 :          0 : cmd_show_fec_capability_parsed(void *parsed_result,
   12741                 :            :                 __rte_unused struct cmdline *cl,
   12742                 :            :                 __rte_unused void *data)
   12743                 :            : {
   12744                 :            :         struct cmd_show_fec_capability_result *res = parsed_result;
   12745                 :            :         struct rte_eth_fec_capa *speed_fec_capa;
   12746                 :            :         unsigned int num;
   12747                 :            :         int ret;
   12748                 :            : 
   12749                 :          0 :         if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
   12750                 :          0 :                 fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
   12751                 :          0 :                 return;
   12752                 :            :         }
   12753                 :            : 
   12754                 :          0 :         ret = rte_eth_fec_get_capability(res->cmd_pid, NULL, 0);
   12755                 :          0 :         if (ret == -ENOTSUP) {
   12756                 :          0 :                 fprintf(stderr, "Function not implemented\n");
   12757                 :          0 :                 return;
   12758                 :          0 :         } else if (ret < 0) {
   12759                 :          0 :                 fprintf(stderr, "Get FEC capability failed: %d\n", ret);
   12760                 :          0 :                 return;
   12761                 :            :         }
   12762                 :            : 
   12763                 :          0 :         num = (unsigned int)ret;
   12764                 :          0 :         speed_fec_capa = calloc(num, sizeof(*speed_fec_capa));
   12765                 :          0 :         if (speed_fec_capa == NULL) {
   12766                 :          0 :                 fprintf(stderr, "Failed to alloc FEC capability buffer\n");
   12767                 :          0 :                 return;
   12768                 :            :         }
   12769                 :            : 
   12770                 :          0 :         ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num);
   12771                 :          0 :         if (ret < 0) {
   12772                 :          0 :                 fprintf(stderr, "Error getting FEC capability: %d\n", ret);
   12773                 :          0 :                 goto out;
   12774                 :            :         }
   12775                 :            : 
   12776                 :          0 :         show_fec_capability(num, speed_fec_capa);
   12777                 :          0 : out:
   12778                 :          0 :         free(speed_fec_capa);
   12779                 :            : }
   12780                 :            : 
   12781                 :            : static cmdline_parse_token_string_t cmd_show_fec_capability_show =
   12782                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
   12783                 :            :                         cmd_show, "show");
   12784                 :            : static cmdline_parse_token_string_t cmd_show_fec_capability_port =
   12785                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
   12786                 :            :                         cmd_port, "port");
   12787                 :            : static cmdline_parse_token_num_t cmd_show_fec_capability_pid =
   12788                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
   12789                 :            :                         cmd_pid, RTE_UINT16);
   12790                 :            : static cmdline_parse_token_string_t cmd_show_fec_capability_fec =
   12791                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
   12792                 :            :                         cmd_fec, "fec");
   12793                 :            : static cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
   12794                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
   12795                 :            :                         cmd_keyword, "capabilities");
   12796                 :            : 
   12797                 :            : static cmdline_parse_inst_t cmd_show_capability = {
   12798                 :            :         .f = cmd_show_fec_capability_parsed,
   12799                 :            :         .data = NULL,
   12800                 :            :         .help_str = "show port <port_id> fec capabilities",
   12801                 :            :         .tokens = {
   12802                 :            :                 (void *)&cmd_show_fec_capability_show,
   12803                 :            :                 (void *)&cmd_show_fec_capability_port,
   12804                 :            :                 (void *)&cmd_show_fec_capability_pid,
   12805                 :            :                 (void *)&cmd_show_fec_capability_fec,
   12806                 :            :                 (void *)&cmd_show_fec_capability_keyword,
   12807                 :            :                 NULL,
   12808                 :            :         },
   12809                 :            : };
   12810                 :            : 
   12811                 :            : /* *** show fec mode per port configuration *** */
   12812                 :            : struct cmd_show_fec_metadata_result {
   12813                 :            :         cmdline_fixed_string_t cmd_show;
   12814                 :            :         cmdline_fixed_string_t cmd_port;
   12815                 :            :         cmdline_fixed_string_t cmd_keyword;
   12816                 :            :         portid_t cmd_pid;
   12817                 :            : };
   12818                 :            : 
   12819                 :            : static void
   12820                 :          0 : cmd_show_fec_mode_parsed(void *parsed_result,
   12821                 :            :                 __rte_unused struct cmdline *cl,
   12822                 :            :                 __rte_unused void *data)
   12823                 :            : {
   12824                 :            : #define FEC_NAME_SIZE 16
   12825                 :            :         struct cmd_show_fec_metadata_result *res = parsed_result;
   12826                 :            :         uint32_t mode;
   12827                 :            :         char buf[FEC_NAME_SIZE];
   12828                 :            :         int ret;
   12829                 :            : 
   12830                 :          0 :         if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
   12831                 :          0 :                 fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
   12832                 :          0 :                 return;
   12833                 :            :         }
   12834                 :          0 :         ret = rte_eth_fec_get(res->cmd_pid, &mode);
   12835                 :          0 :         if (ret == -ENOTSUP) {
   12836                 :          0 :                 fprintf(stderr, "Function not implemented\n");
   12837                 :          0 :                 return;
   12838                 :          0 :         } else if (ret < 0) {
   12839                 :          0 :                 fprintf(stderr, "Get FEC mode failed\n");
   12840                 :          0 :                 return;
   12841                 :            :         }
   12842                 :            : 
   12843                 :          0 :         switch (mode) {
   12844                 :            :         case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC):
   12845                 :            :                 strlcpy(buf, "off", sizeof(buf));
   12846                 :            :                 break;
   12847                 :            :         case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO):
   12848                 :            :                 strlcpy(buf, "auto", sizeof(buf));
   12849                 :            :                 break;
   12850                 :            :         case RTE_ETH_FEC_MODE_CAPA_MASK(BASER):
   12851                 :            :                 strlcpy(buf, "baser", sizeof(buf));
   12852                 :            :                 break;
   12853                 :            :         case RTE_ETH_FEC_MODE_CAPA_MASK(RS):
   12854                 :            :                 strlcpy(buf, "rs", sizeof(buf));
   12855                 :            :                 break;
   12856                 :            :         case RTE_ETH_FEC_MODE_CAPA_MASK(LLRS):
   12857                 :            :                 strlcpy(buf, "llrs", sizeof(buf));
   12858                 :            :                 break;
   12859                 :            :         default:
   12860                 :            :                 return;
   12861                 :            :         }
   12862                 :            : 
   12863                 :            :         printf("%s\n", buf);
   12864                 :            : }
   12865                 :            : 
   12866                 :            : static cmdline_parse_token_string_t cmd_show_fec_mode_show =
   12867                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
   12868                 :            :                         cmd_show, "show");
   12869                 :            : static cmdline_parse_token_string_t cmd_show_fec_mode_port =
   12870                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
   12871                 :            :                         cmd_port, "port");
   12872                 :            : static cmdline_parse_token_num_t cmd_show_fec_mode_pid =
   12873                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
   12874                 :            :                         cmd_pid, RTE_UINT16);
   12875                 :            : static cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
   12876                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
   12877                 :            :                         cmd_keyword, "fec_mode");
   12878                 :            : 
   12879                 :            : static cmdline_parse_inst_t cmd_show_fec_mode = {
   12880                 :            :         .f = cmd_show_fec_mode_parsed,
   12881                 :            :         .data = NULL,
   12882                 :            :         .help_str = "show port <port_id> fec_mode",
   12883                 :            :         .tokens = {
   12884                 :            :                 (void *)&cmd_show_fec_mode_show,
   12885                 :            :                 (void *)&cmd_show_fec_mode_port,
   12886                 :            :                 (void *)&cmd_show_fec_mode_pid,
   12887                 :            :                 (void *)&cmd_show_fec_mode_keyword,
   12888                 :            :                 NULL,
   12889                 :            :         },
   12890                 :            : };
   12891                 :            : 
   12892                 :            : /* *** set fec mode per port configuration *** */
   12893                 :            : struct cmd_set_port_fec_mode {
   12894                 :            :         cmdline_fixed_string_t set;
   12895                 :            :         cmdline_fixed_string_t port;
   12896                 :            :         portid_t port_id;
   12897                 :            :         cmdline_fixed_string_t fec_mode;
   12898                 :            :         cmdline_fixed_string_t fec_value;
   12899                 :            : };
   12900                 :            : 
   12901                 :            : /* Common CLI fields for set fec mode */
   12902                 :            : static cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
   12903                 :            :         TOKEN_STRING_INITIALIZER
   12904                 :            :                 (struct cmd_set_port_fec_mode,
   12905                 :            :                  set, "set");
   12906                 :            : static cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
   12907                 :            :         TOKEN_STRING_INITIALIZER
   12908                 :            :                 (struct cmd_set_port_fec_mode,
   12909                 :            :                  port, "port");
   12910                 :            : static cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
   12911                 :            :         TOKEN_NUM_INITIALIZER
   12912                 :            :                 (struct cmd_set_port_fec_mode,
   12913                 :            :                  port_id, RTE_UINT16);
   12914                 :            : static cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
   12915                 :            :         TOKEN_STRING_INITIALIZER
   12916                 :            :                 (struct cmd_set_port_fec_mode,
   12917                 :            :                  fec_mode, "fec_mode");
   12918                 :            : static cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
   12919                 :            :         TOKEN_STRING_INITIALIZER
   12920                 :            :                 (struct cmd_set_port_fec_mode,
   12921                 :            :                  fec_value, NULL);
   12922                 :            : 
   12923                 :            : static void
   12924                 :          0 : cmd_set_port_fec_mode_parsed(
   12925                 :            :         void *parsed_result,
   12926                 :            :         __rte_unused struct cmdline *cl,
   12927                 :            :         __rte_unused void *data)
   12928                 :            : {
   12929                 :            :         struct cmd_set_port_fec_mode *res = parsed_result;
   12930                 :          0 :         uint16_t port_id = res->port_id;
   12931                 :            :         uint32_t fec_capa;
   12932                 :            :         int ret;
   12933                 :            : 
   12934                 :          0 :         ret = parse_fec_mode(res->fec_value, &fec_capa);
   12935                 :          0 :         if (ret < 0) {
   12936                 :          0 :                 fprintf(stderr, "Unknown fec mode: %s for port %d\n",
   12937                 :            :                                 res->fec_value,      port_id);
   12938                 :          0 :                 return;
   12939                 :            :         }
   12940                 :            : 
   12941                 :          0 :         ret = rte_eth_fec_set(port_id, fec_capa);
   12942                 :          0 :         if (ret == -ENOTSUP) {
   12943                 :          0 :                 fprintf(stderr, "Function not implemented\n");
   12944                 :          0 :                 return;
   12945                 :          0 :         } else if (ret < 0) {
   12946                 :          0 :                 fprintf(stderr, "Set FEC mode failed\n");
   12947                 :          0 :                 return;
   12948                 :            :         }
   12949                 :            : }
   12950                 :            : 
   12951                 :            : static cmdline_parse_inst_t cmd_set_fec_mode = {
   12952                 :            :         .f = cmd_set_port_fec_mode_parsed,
   12953                 :            :         .data = NULL,
   12954                 :            :         .help_str = "set port <port_id> fec_mode auto|off|rs|baser|llrs",
   12955                 :            :         .tokens = {
   12956                 :            :                 (void *)&cmd_set_port_fec_mode_set,
   12957                 :            :                 (void *)&cmd_set_port_fec_mode_port,
   12958                 :            :                 (void *)&cmd_set_port_fec_mode_port_id,
   12959                 :            :                 (void *)&cmd_set_port_fec_mode_str,
   12960                 :            :                 (void *)&cmd_set_port_fec_mode_value,
   12961                 :            :                 NULL,
   12962                 :            :         },
   12963                 :            : };
   12964                 :            : 
   12965                 :            : /* *** set available descriptors threshold for an RxQ of a port *** */
   12966                 :            : struct cmd_set_rxq_avail_thresh_result {
   12967                 :            :         cmdline_fixed_string_t set;
   12968                 :            :         cmdline_fixed_string_t port;
   12969                 :            :         uint16_t port_num;
   12970                 :            :         cmdline_fixed_string_t rxq;
   12971                 :            :         uint16_t rxq_num;
   12972                 :            :         cmdline_fixed_string_t avail_thresh;
   12973                 :            :         uint8_t avail_thresh_num;
   12974                 :            : };
   12975                 :            : 
   12976                 :          0 : static void cmd_set_rxq_avail_thresh_parsed(void *parsed_result,
   12977                 :            :                 __rte_unused struct cmdline *cl,
   12978                 :            :                 __rte_unused void *data)
   12979                 :            : {
   12980                 :            :         struct cmd_set_rxq_avail_thresh_result *res = parsed_result;
   12981                 :            :         int ret = 0;
   12982                 :            : 
   12983                 :          0 :         if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
   12984                 :          0 :             && (strcmp(res->rxq, "rxq") == 0)
   12985                 :          0 :             && (strcmp(res->avail_thresh, "avail_thresh") == 0))
   12986                 :          0 :                 ret = set_rxq_avail_thresh(res->port_num, res->rxq_num,
   12987                 :          0 :                                   res->avail_thresh_num);
   12988                 :          0 :         if (ret < 0)
   12989                 :          0 :                 printf("rxq_avail_thresh_cmd error: (%s)\n", strerror(-ret));
   12990                 :            : 
   12991                 :          0 : }
   12992                 :            : 
   12993                 :            : static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_set =
   12994                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
   12995                 :            :                                 set, "set");
   12996                 :            : static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_port =
   12997                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
   12998                 :            :                                 port, "port");
   12999                 :            : static cmdline_parse_token_num_t cmd_set_rxq_avail_thresh_portnum =
   13000                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
   13001                 :            :                                 port_num, RTE_UINT16);
   13002                 :            : static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_rxq =
   13003                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
   13004                 :            :                                 rxq, "rxq");
   13005                 :            : static cmdline_parse_token_num_t cmd_set_rxq_avail_thresh_rxqnum =
   13006                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
   13007                 :            :                                 rxq_num, RTE_UINT16);
   13008                 :            : static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_avail_thresh =
   13009                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
   13010                 :            :                                 avail_thresh, "avail_thresh");
   13011                 :            : static cmdline_parse_token_num_t cmd_set_rxq_avail_thresh_avail_threshnum =
   13012                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
   13013                 :            :                                 avail_thresh_num, RTE_UINT8);
   13014                 :            : 
   13015                 :            : static cmdline_parse_inst_t cmd_set_rxq_avail_thresh = {
   13016                 :            :         .f = cmd_set_rxq_avail_thresh_parsed,
   13017                 :            :         .data = (void *)0,
   13018                 :            :         .help_str =
   13019                 :            :                 "set port <port_id> rxq <queue_id> avail_thresh <0..99>: "
   13020                 :            :                 "Set available descriptors threshold for Rx queue",
   13021                 :            :         .tokens = {
   13022                 :            :                 (void *)&cmd_set_rxq_avail_thresh_set,
   13023                 :            :                 (void *)&cmd_set_rxq_avail_thresh_port,
   13024                 :            :                 (void *)&cmd_set_rxq_avail_thresh_portnum,
   13025                 :            :                 (void *)&cmd_set_rxq_avail_thresh_rxq,
   13026                 :            :                 (void *)&cmd_set_rxq_avail_thresh_rxqnum,
   13027                 :            :                 (void *)&cmd_set_rxq_avail_thresh_avail_thresh,
   13028                 :            :                 (void *)&cmd_set_rxq_avail_thresh_avail_threshnum,
   13029                 :            :                 NULL,
   13030                 :            :         },
   13031                 :            : };
   13032                 :            : 
   13033                 :            : /* show port supported ptypes */
   13034                 :            : 
   13035                 :            : /* Common result structure for show port ptypes */
   13036                 :            : struct cmd_show_port_supported_ptypes_result {
   13037                 :            :         cmdline_fixed_string_t show;
   13038                 :            :         cmdline_fixed_string_t port;
   13039                 :            :         portid_t port_id;
   13040                 :            :         cmdline_fixed_string_t ptypes;
   13041                 :            : };
   13042                 :            : 
   13043                 :            : /* Common CLI fields for show port ptypes */
   13044                 :            : static cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
   13045                 :            :         TOKEN_STRING_INITIALIZER
   13046                 :            :                 (struct cmd_show_port_supported_ptypes_result,
   13047                 :            :                  show, "show");
   13048                 :            : static cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
   13049                 :            :         TOKEN_STRING_INITIALIZER
   13050                 :            :                 (struct cmd_show_port_supported_ptypes_result,
   13051                 :            :                  port, "port");
   13052                 :            : static cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
   13053                 :            :         TOKEN_NUM_INITIALIZER
   13054                 :            :                 (struct cmd_show_port_supported_ptypes_result,
   13055                 :            :                  port_id, RTE_UINT16);
   13056                 :            : static cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
   13057                 :            :         TOKEN_STRING_INITIALIZER
   13058                 :            :                 (struct cmd_show_port_supported_ptypes_result,
   13059                 :            :                  ptypes, "ptypes");
   13060                 :            : 
   13061                 :            : static void
   13062                 :          0 : cmd_show_port_supported_ptypes_parsed(
   13063                 :            :         void *parsed_result,
   13064                 :            :         __rte_unused struct cmdline *cl,
   13065                 :            :         __rte_unused void *data)
   13066                 :            : {
   13067                 :            : #define RSVD_PTYPE_MASK       0xf0000000
   13068                 :            : #define MAX_PTYPES_PER_LAYER  16
   13069                 :            : #define LTYPE_NAMESIZE        32
   13070                 :            : #define PTYPE_NAMESIZE        256
   13071                 :            :         struct cmd_show_port_supported_ptypes_result *res = parsed_result;
   13072                 :            :         char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
   13073                 :            :         uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
   13074                 :            :         uint32_t ptypes[MAX_PTYPES_PER_LAYER];
   13075                 :          0 :         uint16_t port_id = res->port_id;
   13076                 :            :         int ret, i;
   13077                 :            : 
   13078                 :          0 :         ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
   13079                 :          0 :         if (ret < 0)
   13080                 :          0 :                 return;
   13081                 :            : 
   13082                 :          0 :         while (ptype_mask != RSVD_PTYPE_MASK) {
   13083                 :            : 
   13084                 :          0 :                 switch (ptype_mask) {
   13085                 :            :                 case RTE_PTYPE_L2_MASK:
   13086                 :            :                         strlcpy(ltype, "L2", sizeof(ltype));
   13087                 :            :                         break;
   13088                 :            :                 case RTE_PTYPE_L3_MASK:
   13089                 :            :                         strlcpy(ltype, "L3", sizeof(ltype));
   13090                 :            :                         break;
   13091                 :            :                 case RTE_PTYPE_L4_MASK:
   13092                 :            :                         strlcpy(ltype, "L4", sizeof(ltype));
   13093                 :            :                         break;
   13094                 :            :                 case RTE_PTYPE_TUNNEL_MASK:
   13095                 :            :                         strlcpy(ltype, "Tunnel", sizeof(ltype));
   13096                 :            :                         break;
   13097                 :            :                 case RTE_PTYPE_INNER_L2_MASK:
   13098                 :            :                         strlcpy(ltype, "Inner L2", sizeof(ltype));
   13099                 :            :                         break;
   13100                 :            :                 case RTE_PTYPE_INNER_L3_MASK:
   13101                 :            :                         strlcpy(ltype, "Inner L3", sizeof(ltype));
   13102                 :            :                         break;
   13103                 :            :                 case RTE_PTYPE_INNER_L4_MASK:
   13104                 :            :                         strlcpy(ltype, "Inner L4", sizeof(ltype));
   13105                 :            :                         break;
   13106                 :            :                 default:
   13107                 :            :                         return;
   13108                 :            :                 }
   13109                 :            : 
   13110                 :          0 :                 ret = rte_eth_dev_get_supported_ptypes(res->port_id,
   13111                 :            :                                                        ptype_mask, ptypes,
   13112                 :            :                                                        MAX_PTYPES_PER_LAYER);
   13113                 :            : 
   13114                 :          0 :                 if (ret > 0)
   13115                 :            :                         printf("Supported %s ptypes:\n", ltype);
   13116                 :            :                 else
   13117                 :            :                         printf("%s ptypes unsupported\n", ltype);
   13118                 :            : 
   13119                 :          0 :                 for (i = 0; i < ret; ++i) {
   13120                 :          0 :                         rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
   13121                 :            :                         printf("%s\n", buf);
   13122                 :            :                 }
   13123                 :            : 
   13124                 :          0 :                 ptype_mask <<= 4;
   13125                 :            :         }
   13126                 :            : }
   13127                 :            : 
   13128                 :            : static cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
   13129                 :            :         .f = cmd_show_port_supported_ptypes_parsed,
   13130                 :            :         .data = NULL,
   13131                 :            :         .help_str = "show port <port_id> ptypes",
   13132                 :            :         .tokens = {
   13133                 :            :                 (void *)&cmd_show_port_supported_ptypes_show,
   13134                 :            :                 (void *)&cmd_show_port_supported_ptypes_port,
   13135                 :            :                 (void *)&cmd_show_port_supported_ptypes_port_id,
   13136                 :            :                 (void *)&cmd_show_port_supported_ptypes_ptypes,
   13137                 :            :                 NULL,
   13138                 :            :         },
   13139                 :            : };
   13140                 :            : 
   13141                 :            : /* *** display rx/tx descriptor status *** */
   13142                 :            : struct cmd_show_rx_tx_desc_status_result {
   13143                 :            :         cmdline_fixed_string_t cmd_show;
   13144                 :            :         cmdline_fixed_string_t cmd_port;
   13145                 :            :         cmdline_fixed_string_t cmd_keyword;
   13146                 :            :         cmdline_fixed_string_t cmd_desc;
   13147                 :            :         cmdline_fixed_string_t cmd_status;
   13148                 :            :         portid_t cmd_pid;
   13149                 :            :         portid_t cmd_qid;
   13150                 :            :         portid_t cmd_did;
   13151                 :            : };
   13152                 :            : 
   13153                 :            : static void
   13154                 :          0 : cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
   13155                 :            :                 __rte_unused struct cmdline *cl,
   13156                 :            :                 __rte_unused void *data)
   13157                 :            : {
   13158                 :            :         struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
   13159                 :            :         int rc;
   13160                 :            : 
   13161                 :          0 :         if (!strcmp(res->cmd_keyword, "rxq")) {
   13162                 :          0 :                 if (rte_eth_rx_queue_is_valid(res->cmd_pid, res->cmd_qid) != 0) {
   13163                 :          0 :                         fprintf(stderr,
   13164                 :            :                                 "Invalid input: port id = %d, queue id = %d\n",
   13165                 :          0 :                                 res->cmd_pid, res->cmd_qid);
   13166                 :          0 :                         return;
   13167                 :            :                 }
   13168                 :          0 :                 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
   13169                 :          0 :                                              res->cmd_did);
   13170                 :          0 :                 if (rc < 0) {
   13171                 :          0 :                         fprintf(stderr,
   13172                 :            :                                 "Invalid input: queue id = %d, desc id = %d\n",
   13173                 :          0 :                                 res->cmd_qid, res->cmd_did);
   13174                 :          0 :                         return;
   13175                 :            :                 }
   13176                 :          0 :                 if (rc == RTE_ETH_RX_DESC_AVAIL)
   13177                 :            :                         printf("Desc status = AVAILABLE\n");
   13178                 :          0 :                 else if (rc == RTE_ETH_RX_DESC_DONE)
   13179                 :            :                         printf("Desc status = DONE\n");
   13180                 :            :                 else
   13181                 :            :                         printf("Desc status = UNAVAILABLE\n");
   13182                 :          0 :         } else if (!strcmp(res->cmd_keyword, "txq")) {
   13183                 :          0 :                 if (rte_eth_tx_queue_is_valid(res->cmd_pid, res->cmd_qid) != 0) {
   13184                 :          0 :                         fprintf(stderr,
   13185                 :            :                                 "Invalid input: port id = %d, queue id = %d\n",
   13186                 :          0 :                                 res->cmd_pid, res->cmd_qid);
   13187                 :          0 :                         return;
   13188                 :            :                 }
   13189                 :          0 :                 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
   13190                 :          0 :                                              res->cmd_did);
   13191                 :          0 :                 if (rc < 0) {
   13192                 :          0 :                         fprintf(stderr,
   13193                 :            :                                 "Invalid input: queue id = %d, desc id = %d\n",
   13194                 :          0 :                                 res->cmd_qid, res->cmd_did);
   13195                 :          0 :                         return;
   13196                 :            :                 }
   13197                 :          0 :                 if (rc == RTE_ETH_TX_DESC_FULL)
   13198                 :            :                         printf("Desc status = FULL\n");
   13199                 :          0 :                 else if (rc == RTE_ETH_TX_DESC_DONE)
   13200                 :            :                         printf("Desc status = DONE\n");
   13201                 :            :                 else
   13202                 :            :                         printf("Desc status = UNAVAILABLE\n");
   13203                 :            :         }
   13204                 :            : }
   13205                 :            : 
   13206                 :            : static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
   13207                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
   13208                 :            :                         cmd_show, "show");
   13209                 :            : static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
   13210                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
   13211                 :            :                         cmd_port, "port");
   13212                 :            : static cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
   13213                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
   13214                 :            :                         cmd_pid, RTE_UINT16);
   13215                 :            : static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
   13216                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
   13217                 :            :                         cmd_keyword, "rxq#txq");
   13218                 :            : static cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
   13219                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
   13220                 :            :                         cmd_qid, RTE_UINT16);
   13221                 :            : static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
   13222                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
   13223                 :            :                         cmd_desc, "desc");
   13224                 :            : static cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
   13225                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
   13226                 :            :                         cmd_did, RTE_UINT16);
   13227                 :            : static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
   13228                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
   13229                 :            :                         cmd_status, "status");
   13230                 :            : static cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
   13231                 :            :         .f = cmd_show_rx_tx_desc_status_parsed,
   13232                 :            :         .data = NULL,
   13233                 :            :         .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
   13234                 :            :                 "status",
   13235                 :            :         .tokens = {
   13236                 :            :                 (void *)&cmd_show_rx_tx_desc_status_show,
   13237                 :            :                 (void *)&cmd_show_rx_tx_desc_status_port,
   13238                 :            :                 (void *)&cmd_show_rx_tx_desc_status_pid,
   13239                 :            :                 (void *)&cmd_show_rx_tx_desc_status_keyword,
   13240                 :            :                 (void *)&cmd_show_rx_tx_desc_status_qid,
   13241                 :            :                 (void *)&cmd_show_rx_tx_desc_status_desc,
   13242                 :            :                 (void *)&cmd_show_rx_tx_desc_status_did,
   13243                 :            :                 (void *)&cmd_show_rx_tx_desc_status_status,
   13244                 :            :                 NULL,
   13245                 :            :         },
   13246                 :            : };
   13247                 :            : 
   13248                 :            : /* *** display rx/tx queue descriptor used count *** */
   13249                 :            : struct cmd_show_rx_tx_queue_desc_used_count_result {
   13250                 :            :         cmdline_fixed_string_t cmd_show;
   13251                 :            :         cmdline_fixed_string_t cmd_port;
   13252                 :            :         cmdline_fixed_string_t cmd_dir;
   13253                 :            :         cmdline_fixed_string_t cmd_desc;
   13254                 :            :         cmdline_fixed_string_t cmd_used;
   13255                 :            :         cmdline_fixed_string_t cmd_count;
   13256                 :            :         portid_t cmd_pid;
   13257                 :            :         portid_t cmd_qid;
   13258                 :            : };
   13259                 :            : 
   13260                 :            : static void
   13261                 :          0 : cmd_show_rx_tx_queue_desc_used_count_parsed(void *parsed_result, __rte_unused struct cmdline *cl,
   13262                 :            :                                             __rte_unused void *data)
   13263                 :            : {
   13264                 :            :         struct cmd_show_rx_tx_queue_desc_used_count_result *res = parsed_result;
   13265                 :            :         int rc;
   13266                 :            : 
   13267                 :          0 :         if (!strcmp(res->cmd_dir, "rxq")) {
   13268                 :          0 :                 if (rte_eth_rx_queue_is_valid(res->cmd_pid, res->cmd_qid) != 0) {
   13269                 :          0 :                         fprintf(stderr, "Invalid input: port id = %d, queue id = %d\n",
   13270                 :          0 :                                 res->cmd_pid, res->cmd_qid);
   13271                 :          0 :                         return;
   13272                 :            :                 }
   13273                 :            : 
   13274                 :          0 :                 rc = rte_eth_rx_queue_count(res->cmd_pid, res->cmd_qid);
   13275                 :          0 :                 if (rc < 0) {
   13276                 :          0 :                         fprintf(stderr, "Rx queue count get failed rc=%d queue_id=%d\n", rc,
   13277                 :          0 :                                 res->cmd_qid);
   13278                 :          0 :                         return;
   13279                 :            :                 }
   13280                 :          0 :                 printf("RxQ %d used desc count = %d\n", res->cmd_qid, rc);
   13281                 :          0 :         } else if (!strcmp(res->cmd_dir, "txq")) {
   13282                 :          0 :                 if (rte_eth_tx_queue_is_valid(res->cmd_pid, res->cmd_qid) != 0) {
   13283                 :          0 :                         fprintf(stderr, "Invalid input: port id = %d, queue id = %d\n",
   13284                 :          0 :                                 res->cmd_pid, res->cmd_qid);
   13285                 :          0 :                         return;
   13286                 :            :                 }
   13287                 :            : 
   13288                 :          0 :                 rc = rte_eth_tx_queue_count(res->cmd_pid, res->cmd_qid);
   13289                 :          0 :                 if (rc < 0) {
   13290                 :          0 :                         fprintf(stderr, "Tx queue count get failed rc=%d queue_id=%d\n", rc,
   13291                 :          0 :                                 res->cmd_qid);
   13292                 :          0 :                         return;
   13293                 :            :                 }
   13294                 :          0 :                 printf("TxQ %d used desc count = %d\n", res->cmd_qid, rc);
   13295                 :            :         }
   13296                 :            : }
   13297                 :            : 
   13298                 :            : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_show =
   13299                 :            :         TOKEN_STRING_INITIALIZER
   13300                 :            :                 (struct cmd_show_rx_tx_queue_desc_used_count_result,
   13301                 :            :                  cmd_show, "show");
   13302                 :            : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_port =
   13303                 :            :         TOKEN_STRING_INITIALIZER
   13304                 :            :                 (struct cmd_show_rx_tx_queue_desc_used_count_result,
   13305                 :            :                  cmd_port, "port");
   13306                 :            : static cmdline_parse_token_num_t cmd_show_rx_tx_queue_desc_used_count_pid =
   13307                 :            :         TOKEN_NUM_INITIALIZER
   13308                 :            :                 (struct cmd_show_rx_tx_queue_desc_used_count_result,
   13309                 :            :                  cmd_pid, RTE_UINT16);
   13310                 :            : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_dir =
   13311                 :            :         TOKEN_STRING_INITIALIZER
   13312                 :            :                 (struct cmd_show_rx_tx_queue_desc_used_count_result,
   13313                 :            :                  cmd_dir, "rxq#txq");
   13314                 :            : static cmdline_parse_token_num_t cmd_show_rx_tx_queue_desc_used_count_qid =
   13315                 :            :         TOKEN_NUM_INITIALIZER
   13316                 :            :                 (struct cmd_show_rx_tx_queue_desc_used_count_result,
   13317                 :            :                  cmd_qid, RTE_UINT16);
   13318                 :            : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_desc =
   13319                 :            :         TOKEN_STRING_INITIALIZER
   13320                 :            :                 (struct cmd_show_rx_tx_queue_desc_used_count_result,
   13321                 :            :                  cmd_desc, "desc");
   13322                 :            : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_used =
   13323                 :            :         TOKEN_STRING_INITIALIZER
   13324                 :            :                 (struct cmd_show_rx_tx_queue_desc_used_count_result,
   13325                 :            :                  cmd_count, "used");
   13326                 :            : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_count =
   13327                 :            :         TOKEN_STRING_INITIALIZER
   13328                 :            :                 (struct cmd_show_rx_tx_queue_desc_used_count_result,
   13329                 :            :                  cmd_count, "count");
   13330                 :            : static cmdline_parse_inst_t cmd_show_rx_tx_queue_desc_used_count = {
   13331                 :            :         .f = cmd_show_rx_tx_queue_desc_used_count_parsed,
   13332                 :            :         .data = NULL,
   13333                 :            :         .help_str = "show port <port_id> rxq|txq <queue_id> desc used count",
   13334                 :            :         .tokens = {
   13335                 :            :                 (void *)&cmd_show_rx_tx_queue_desc_used_count_show,
   13336                 :            :                 (void *)&cmd_show_rx_tx_queue_desc_used_count_port,
   13337                 :            :                 (void *)&cmd_show_rx_tx_queue_desc_used_count_pid,
   13338                 :            :                 (void *)&cmd_show_rx_tx_queue_desc_used_count_dir,
   13339                 :            :                 (void *)&cmd_show_rx_tx_queue_desc_used_count_qid,
   13340                 :            :                 (void *)&cmd_show_rx_tx_queue_desc_used_count_desc,
   13341                 :            :                 (void *)&cmd_show_rx_tx_queue_desc_used_count_used,
   13342                 :            :                 (void *)&cmd_show_rx_tx_queue_desc_used_count_count,
   13343                 :            :                 NULL,
   13344                 :            :         },
   13345                 :            : };
   13346                 :            : 
   13347                 :            : /* Common result structure for set port ptypes */
   13348                 :            : struct cmd_set_port_ptypes_result {
   13349                 :            :         cmdline_fixed_string_t set;
   13350                 :            :         cmdline_fixed_string_t port;
   13351                 :            :         portid_t port_id;
   13352                 :            :         cmdline_fixed_string_t ptype_mask;
   13353                 :            :         uint32_t mask;
   13354                 :            : };
   13355                 :            : 
   13356                 :            : /* Common CLI fields for set port ptypes */
   13357                 :            : static cmdline_parse_token_string_t cmd_set_port_ptypes_set =
   13358                 :            :         TOKEN_STRING_INITIALIZER
   13359                 :            :                 (struct cmd_set_port_ptypes_result,
   13360                 :            :                  set, "set");
   13361                 :            : static cmdline_parse_token_string_t cmd_set_port_ptypes_port =
   13362                 :            :         TOKEN_STRING_INITIALIZER
   13363                 :            :                 (struct cmd_set_port_ptypes_result,
   13364                 :            :                  port, "port");
   13365                 :            : static cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
   13366                 :            :         TOKEN_NUM_INITIALIZER
   13367                 :            :                 (struct cmd_set_port_ptypes_result,
   13368                 :            :                  port_id, RTE_UINT16);
   13369                 :            : static cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
   13370                 :            :         TOKEN_STRING_INITIALIZER
   13371                 :            :                 (struct cmd_set_port_ptypes_result,
   13372                 :            :                  ptype_mask, "ptype_mask");
   13373                 :            : static cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
   13374                 :            :         TOKEN_NUM_INITIALIZER
   13375                 :            :                 (struct cmd_set_port_ptypes_result,
   13376                 :            :                  mask, RTE_UINT32);
   13377                 :            : 
   13378                 :            : static void
   13379                 :          0 : cmd_set_port_ptypes_parsed(
   13380                 :            :         void *parsed_result,
   13381                 :            :         __rte_unused struct cmdline *cl,
   13382                 :            :         __rte_unused void *data)
   13383                 :            : {
   13384                 :            :         struct cmd_set_port_ptypes_result *res = parsed_result;
   13385                 :            : #define PTYPE_NAMESIZE        256
   13386                 :            :         char ptype_name[PTYPE_NAMESIZE];
   13387                 :          0 :         uint16_t port_id = res->port_id;
   13388                 :          0 :         uint32_t ptype_mask = res->mask;
   13389                 :            :         int ret, i;
   13390                 :            : 
   13391                 :          0 :         ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
   13392                 :            :                                                NULL, 0);
   13393                 :          0 :         if (ret <= 0) {
   13394                 :          0 :                 fprintf(stderr, "Port %d doesn't support any ptypes.\n",
   13395                 :            :                         port_id);
   13396                 :          0 :                 return;
   13397                 :            :         }
   13398                 :            : 
   13399                 :          0 :         uint32_t *ptypes = alloca(sizeof(uint32_t) * ret);
   13400                 :            : 
   13401                 :          0 :         ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
   13402                 :          0 :         if (ret < 0) {
   13403                 :          0 :                 fprintf(stderr, "Unable to set requested ptypes for Port %d\n",
   13404                 :            :                         port_id);
   13405                 :          0 :                 return;
   13406                 :            :         }
   13407                 :            : 
   13408                 :            :         printf("Successfully set following ptypes for Port %d\n", port_id);
   13409                 :          0 :         for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
   13410                 :          0 :                 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
   13411                 :            :                 printf("%s\n", ptype_name);
   13412                 :            :         }
   13413                 :            : 
   13414                 :          0 :         clear_ptypes = false;
   13415                 :            : }
   13416                 :            : 
   13417                 :            : static cmdline_parse_inst_t cmd_set_port_ptypes = {
   13418                 :            :         .f = cmd_set_port_ptypes_parsed,
   13419                 :            :         .data = NULL,
   13420                 :            :         .help_str = "set port <port_id> ptype_mask <mask>",
   13421                 :            :         .tokens = {
   13422                 :            :                 (void *)&cmd_set_port_ptypes_set,
   13423                 :            :                 (void *)&cmd_set_port_ptypes_port,
   13424                 :            :                 (void *)&cmd_set_port_ptypes_port_id,
   13425                 :            :                 (void *)&cmd_set_port_ptypes_mask_str,
   13426                 :            :                 (void *)&cmd_set_port_ptypes_mask_u32,
   13427                 :            :                 NULL,
   13428                 :            :         },
   13429                 :            : };
   13430                 :            : 
   13431                 :            : /* *** display mac addresses added to a port *** */
   13432                 :            : struct cmd_showport_macs_result {
   13433                 :            :         cmdline_fixed_string_t cmd_show;
   13434                 :            :         cmdline_fixed_string_t cmd_port;
   13435                 :            :         cmdline_fixed_string_t cmd_keyword;
   13436                 :            :         portid_t cmd_pid;
   13437                 :            : };
   13438                 :            : 
   13439                 :            : static void
   13440                 :          0 : cmd_showport_macs_parsed(void *parsed_result,
   13441                 :            :                 __rte_unused struct cmdline *cl,
   13442                 :            :                 __rte_unused void *data)
   13443                 :            : {
   13444                 :            :         struct cmd_showport_macs_result *res = parsed_result;
   13445                 :            : 
   13446                 :          0 :         if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
   13447                 :            :                 return;
   13448                 :            : 
   13449                 :          0 :         if (!strcmp(res->cmd_keyword, "macs"))
   13450                 :          0 :                 show_macs(res->cmd_pid);
   13451                 :          0 :         else if (!strcmp(res->cmd_keyword, "mcast_macs"))
   13452                 :          0 :                 show_mcast_macs(res->cmd_pid);
   13453                 :            : }
   13454                 :            : 
   13455                 :            : static cmdline_parse_token_string_t cmd_showport_macs_show =
   13456                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
   13457                 :            :                         cmd_show, "show");
   13458                 :            : static cmdline_parse_token_string_t cmd_showport_macs_port =
   13459                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
   13460                 :            :                         cmd_port, "port");
   13461                 :            : static cmdline_parse_token_num_t cmd_showport_macs_pid =
   13462                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
   13463                 :            :                         cmd_pid, RTE_UINT16);
   13464                 :            : static cmdline_parse_token_string_t cmd_showport_macs_keyword =
   13465                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
   13466                 :            :                         cmd_keyword, "macs#mcast_macs");
   13467                 :            : 
   13468                 :            : static cmdline_parse_inst_t cmd_showport_macs = {
   13469                 :            :         .f = cmd_showport_macs_parsed,
   13470                 :            :         .data = NULL,
   13471                 :            :         .help_str = "show port <port_id> macs|mcast_macs",
   13472                 :            :         .tokens = {
   13473                 :            :                 (void *)&cmd_showport_macs_show,
   13474                 :            :                 (void *)&cmd_showport_macs_port,
   13475                 :            :                 (void *)&cmd_showport_macs_pid,
   13476                 :            :                 (void *)&cmd_showport_macs_keyword,
   13477                 :            :                 NULL,
   13478                 :            :         },
   13479                 :            : };
   13480                 :            : 
   13481                 :            : /* *** show flow transfer proxy port ID for the given port *** */
   13482                 :            : struct cmd_show_port_flow_transfer_proxy_result {
   13483                 :            :         cmdline_fixed_string_t show;
   13484                 :            :         cmdline_fixed_string_t port;
   13485                 :            :         portid_t port_id;
   13486                 :            :         cmdline_fixed_string_t flow;
   13487                 :            :         cmdline_fixed_string_t transfer;
   13488                 :            :         cmdline_fixed_string_t proxy;
   13489                 :            : };
   13490                 :            : 
   13491                 :            : static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_show =
   13492                 :            :         TOKEN_STRING_INITIALIZER
   13493                 :            :                 (struct cmd_show_port_flow_transfer_proxy_result,
   13494                 :            :                  show, "show");
   13495                 :            : static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_port =
   13496                 :            :         TOKEN_STRING_INITIALIZER
   13497                 :            :                 (struct cmd_show_port_flow_transfer_proxy_result,
   13498                 :            :                  port, "port");
   13499                 :            : static cmdline_parse_token_num_t cmd_show_port_flow_transfer_proxy_port_id =
   13500                 :            :         TOKEN_NUM_INITIALIZER
   13501                 :            :                 (struct cmd_show_port_flow_transfer_proxy_result,
   13502                 :            :                  port_id, RTE_UINT16);
   13503                 :            : static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_flow =
   13504                 :            :         TOKEN_STRING_INITIALIZER
   13505                 :            :                 (struct cmd_show_port_flow_transfer_proxy_result,
   13506                 :            :                  flow, "flow");
   13507                 :            : static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_transfer =
   13508                 :            :         TOKEN_STRING_INITIALIZER
   13509                 :            :                 (struct cmd_show_port_flow_transfer_proxy_result,
   13510                 :            :                  transfer, "transfer");
   13511                 :            : static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_proxy =
   13512                 :            :         TOKEN_STRING_INITIALIZER
   13513                 :            :                 (struct cmd_show_port_flow_transfer_proxy_result,
   13514                 :            :                  proxy, "proxy");
   13515                 :            : 
   13516                 :            : static void
   13517                 :          0 : cmd_show_port_flow_transfer_proxy_parsed(void *parsed_result,
   13518                 :            :                                          __rte_unused struct cmdline *cl,
   13519                 :            :                                          __rte_unused void *data)
   13520                 :            : {
   13521                 :            :         struct cmd_show_port_flow_transfer_proxy_result *res = parsed_result;
   13522                 :            :         portid_t proxy_port_id;
   13523                 :            :         int ret;
   13524                 :            : 
   13525                 :            :         printf("\n");
   13526                 :            : 
   13527                 :          0 :         ret = rte_flow_pick_transfer_proxy(res->port_id, &proxy_port_id, NULL);
   13528                 :          0 :         if (ret != 0) {
   13529                 :          0 :                 fprintf(stderr, "Failed to pick transfer proxy: %s\n",
   13530                 :            :                         rte_strerror(-ret));
   13531                 :          0 :                 return;
   13532                 :            :         }
   13533                 :            : 
   13534                 :          0 :         printf("Transfer proxy port ID: %u\n\n", proxy_port_id);
   13535                 :            : }
   13536                 :            : 
   13537                 :            : static cmdline_parse_inst_t cmd_show_port_flow_transfer_proxy = {
   13538                 :            :         .f = cmd_show_port_flow_transfer_proxy_parsed,
   13539                 :            :         .data = NULL,
   13540                 :            :         .help_str = "show port <port_id> flow transfer proxy",
   13541                 :            :         .tokens = {
   13542                 :            :                 (void *)&cmd_show_port_flow_transfer_proxy_show,
   13543                 :            :                 (void *)&cmd_show_port_flow_transfer_proxy_port,
   13544                 :            :                 (void *)&cmd_show_port_flow_transfer_proxy_port_id,
   13545                 :            :                 (void *)&cmd_show_port_flow_transfer_proxy_flow,
   13546                 :            :                 (void *)&cmd_show_port_flow_transfer_proxy_transfer,
   13547                 :            :                 (void *)&cmd_show_port_flow_transfer_proxy_proxy,
   13548                 :            :                 NULL,
   13549                 :            :         }
   13550                 :            : };
   13551                 :            : 
   13552                 :            : /* *** configure port txq affinity value *** */
   13553                 :            : struct cmd_config_tx_affinity_map {
   13554                 :            :         cmdline_fixed_string_t port;
   13555                 :            :         cmdline_fixed_string_t config;
   13556                 :            :         portid_t portid;
   13557                 :            :         cmdline_fixed_string_t txq;
   13558                 :            :         uint16_t qid;
   13559                 :            :         cmdline_fixed_string_t affinity;
   13560                 :            :         uint8_t value;
   13561                 :            : };
   13562                 :            : 
   13563                 :            : static void
   13564                 :          0 : cmd_config_tx_affinity_map_parsed(void *parsed_result,
   13565                 :            :                                   __rte_unused struct cmdline *cl,
   13566                 :            :                                   __rte_unused void *data)
   13567                 :            : {
   13568                 :            :         struct cmd_config_tx_affinity_map *res = parsed_result;
   13569                 :            :         int ret;
   13570                 :            : 
   13571                 :          0 :         if (port_id_is_invalid(res->portid, ENABLED_WARN))
   13572                 :            :                 return;
   13573                 :            : 
   13574                 :          0 :         if (res->portid == (portid_t)RTE_PORT_ALL) {
   13575                 :            :                 printf("Invalid port id\n");
   13576                 :          0 :                 return;
   13577                 :            :         }
   13578                 :            : 
   13579                 :          0 :         if (strcmp(res->txq, "txq")) {
   13580                 :            :                 printf("Unknown parameter\n");
   13581                 :          0 :                 return;
   13582                 :            :         }
   13583                 :          0 :         if (tx_queue_id_is_invalid(res->qid))
   13584                 :            :                 return;
   13585                 :            : 
   13586                 :          0 :         ret = rte_eth_dev_count_aggr_ports(res->portid);
   13587                 :          0 :         if (ret < 0) {
   13588                 :          0 :                 printf("Failed to count the aggregated ports: (%s)\n",
   13589                 :            :                         strerror(-ret));
   13590                 :          0 :                 return;
   13591                 :            :         }
   13592                 :            : 
   13593                 :          0 :         ret = rte_eth_dev_map_aggr_tx_affinity(res->portid, res->qid, res->value);
   13594                 :          0 :         if (ret != 0) {
   13595                 :          0 :                 printf("Failed to map tx queue with an aggregated port: %s\n",
   13596                 :            :                         rte_strerror(-ret));
   13597                 :          0 :                 return;
   13598                 :            :         }
   13599                 :            : }
   13600                 :            : 
   13601                 :            : cmdline_parse_token_string_t cmd_config_tx_affinity_map_port =
   13602                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_tx_affinity_map,
   13603                 :            :                                  port, "port");
   13604                 :            : cmdline_parse_token_string_t cmd_config_tx_affinity_map_config =
   13605                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_tx_affinity_map,
   13606                 :            :                                  config, "config");
   13607                 :            : cmdline_parse_token_num_t cmd_config_tx_affinity_map_portid =
   13608                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_config_tx_affinity_map,
   13609                 :            :                                  portid, RTE_UINT16);
   13610                 :            : cmdline_parse_token_string_t cmd_config_tx_affinity_map_txq =
   13611                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_tx_affinity_map,
   13612                 :            :                                  txq, "txq");
   13613                 :            : cmdline_parse_token_num_t cmd_config_tx_affinity_map_qid =
   13614                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_config_tx_affinity_map,
   13615                 :            :                               qid, RTE_UINT16);
   13616                 :            : cmdline_parse_token_string_t cmd_config_tx_affinity_map_affinity =
   13617                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_config_tx_affinity_map,
   13618                 :            :                                  affinity, "affinity");
   13619                 :            : cmdline_parse_token_num_t cmd_config_tx_affinity_map_value =
   13620                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_config_tx_affinity_map,
   13621                 :            :                               value, RTE_UINT8);
   13622                 :            : 
   13623                 :            : static cmdline_parse_inst_t cmd_config_tx_affinity_map = {
   13624                 :            :         .f = cmd_config_tx_affinity_map_parsed,
   13625                 :            :         .data = (void *)0,
   13626                 :            :         .help_str = "port config <port_id> txq <queue_id> affinity <value>",
   13627                 :            :         .tokens = {
   13628                 :            :                 (void *)&cmd_config_tx_affinity_map_port,
   13629                 :            :                 (void *)&cmd_config_tx_affinity_map_config,
   13630                 :            :                 (void *)&cmd_config_tx_affinity_map_portid,
   13631                 :            :                 (void *)&cmd_config_tx_affinity_map_txq,
   13632                 :            :                 (void *)&cmd_config_tx_affinity_map_qid,
   13633                 :            :                 (void *)&cmd_config_tx_affinity_map_affinity,
   13634                 :            :                 (void *)&cmd_config_tx_affinity_map_value,
   13635                 :            :                 NULL,
   13636                 :            :         },
   13637                 :            : };
   13638                 :            : 
   13639                 :            : /* *** SET THE LED FOR CERTAIN PORT TO ON/OFF *** */
   13640                 :            : struct cmd_dev_led_result {
   13641                 :            :         cmdline_fixed_string_t set;
   13642                 :            :         cmdline_fixed_string_t port;
   13643                 :            :         portid_t port_id;
   13644                 :            :         cmdline_fixed_string_t led;
   13645                 :            :         cmdline_fixed_string_t state;
   13646                 :            : };
   13647                 :            : 
   13648                 :            : static void
   13649                 :          0 : cmd_set_dev_led_parsed(void *parsed_result,
   13650                 :            :                 __rte_unused struct cmdline *cl,
   13651                 :            :                 __rte_unused void *data)
   13652                 :            : {
   13653                 :            :         struct cmd_dev_led_result *res = parsed_result;
   13654                 :            : 
   13655                 :          0 :         if (strcmp(res->state, "on") == 0)
   13656                 :          0 :                 set_dev_led(res->port_id, true);
   13657                 :            :         else
   13658                 :          0 :                 set_dev_led(res->port_id, false);
   13659                 :          0 : }
   13660                 :            : 
   13661                 :            : static cmdline_parse_token_string_t cmd_dev_led_set =
   13662                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_dev_led_result, set, "set");
   13663                 :            : static cmdline_parse_token_string_t cmd_dev_led_port =
   13664                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_dev_led_result, port, "port");
   13665                 :            : static cmdline_parse_token_num_t cmd_dev_led_port_id =
   13666                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_dev_led_result, port_id, RTE_UINT16);
   13667                 :            : static cmdline_parse_token_string_t cmd_dev_led =
   13668                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_dev_led_result, led, "led");
   13669                 :            : static cmdline_parse_token_string_t cmd_dev_state =
   13670                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_dev_led_result, state, "on#off");
   13671                 :            : 
   13672                 :            : static cmdline_parse_inst_t cmd_set_dev_led = {
   13673                 :            :         .f = cmd_set_dev_led_parsed,
   13674                 :            :         .data = NULL,
   13675                 :            :         .help_str = "set port <port_id> led <on/off>",
   13676                 :            :         .tokens = {
   13677                 :            :                 (void *)&cmd_dev_led_set,
   13678                 :            :                 (void *)&cmd_dev_led_port,
   13679                 :            :                 (void *)&cmd_dev_led_port_id,
   13680                 :            :                 (void *)&cmd_dev_led,
   13681                 :            :                 (void *)&cmd_dev_state,
   13682                 :            :                 NULL,
   13683                 :            :         },
   13684                 :            : };
   13685                 :            : 
   13686                 :            : /* ******************************************************************************** */
   13687                 :            : 
   13688                 :            : /* list of instructions */
   13689                 :            : static cmdline_parse_ctx_t builtin_ctx[] = {
   13690                 :            :         &cmd_help_brief,
   13691                 :            :         &cmd_help_long,
   13692                 :            :         &cmd_quit,
   13693                 :            :         &cmd_load_from_file,
   13694                 :            :         &cmd_showport,
   13695                 :            :         &cmd_showqueue,
   13696                 :            :         &cmd_showeeprom,
   13697                 :            :         &cmd_seteeprom,
   13698                 :            :         &cmd_showportall,
   13699                 :            :         &cmd_representor_info,
   13700                 :            :         &cmd_showdevice,
   13701                 :            :         &cmd_showcfg,
   13702                 :            :         &cmd_showfwdall,
   13703                 :            :         &cmd_start,
   13704                 :            :         &cmd_start_tx_first,
   13705                 :            :         &cmd_start_tx_first_n,
   13706                 :            :         &cmd_set_link_up,
   13707                 :            :         &cmd_set_link_down,
   13708                 :            :         &cmd_reset,
   13709                 :            :         &cmd_set_numbers,
   13710                 :            :         &cmd_set_log,
   13711                 :            :         &cmd_set_rxoffs,
   13712                 :            :         &cmd_set_rxpkts,
   13713                 :            :         &cmd_set_rxhdrs,
   13714                 :            :         &cmd_set_txpkts,
   13715                 :            :         &cmd_set_txsplit,
   13716                 :            :         &cmd_set_txtimes,
   13717                 :            :         &cmd_set_fwd_list,
   13718                 :            :         &cmd_set_fwd_mask,
   13719                 :            :         &cmd_set_fwd_mode,
   13720                 :            :         &cmd_set_fwd_retry_mode,
   13721                 :            :         &cmd_set_burst_tx_retry,
   13722                 :            :         &cmd_set_promisc_mode_one,
   13723                 :            :         &cmd_set_promisc_mode_all,
   13724                 :            :         &cmd_set_allmulti_mode_one,
   13725                 :            :         &cmd_set_allmulti_mode_all,
   13726                 :            :         &cmd_set_flush_rx,
   13727                 :            :         &cmd_set_link_check,
   13728                 :            :         &cmd_vlan_offload,
   13729                 :            :         &cmd_vlan_tpid,
   13730                 :            :         &cmd_rx_vlan_filter_all,
   13731                 :            :         &cmd_rx_vlan_filter,
   13732                 :            :         &cmd_tx_vlan_set,
   13733                 :            :         &cmd_tx_vlan_set_qinq,
   13734                 :            :         &cmd_tx_vlan_reset,
   13735                 :            :         &cmd_tx_vlan_set_pvid,
   13736                 :            :         &cmd_csum_set,
   13737                 :            :         &cmd_csum_show,
   13738                 :            :         &cmd_csum_tunnel,
   13739                 :            :         &cmd_csum_mac_swap,
   13740                 :            :         &cmd_tso_set,
   13741                 :            :         &cmd_tso_show,
   13742                 :            :         &cmd_tunnel_tso_set,
   13743                 :            :         &cmd_tunnel_tso_show,
   13744                 :            : #ifdef RTE_LIB_GRO
   13745                 :            :         &cmd_gro_enable,
   13746                 :            :         &cmd_gro_flush,
   13747                 :            :         &cmd_gro_show,
   13748                 :            : #endif
   13749                 :            : #ifdef RTE_LIB_GSO
   13750                 :            :         &cmd_gso_enable,
   13751                 :            :         &cmd_gso_size,
   13752                 :            :         &cmd_gso_show,
   13753                 :            : #endif
   13754                 :            :         &cmd_link_flow_control_set,
   13755                 :            :         &cmd_link_flow_control_set_rx,
   13756                 :            :         &cmd_link_flow_control_set_tx,
   13757                 :            :         &cmd_link_flow_control_set_hw,
   13758                 :            :         &cmd_link_flow_control_set_lw,
   13759                 :            :         &cmd_link_flow_control_set_pt,
   13760                 :            :         &cmd_link_flow_control_set_xon,
   13761                 :            :         &cmd_link_flow_control_set_macfwd,
   13762                 :            :         &cmd_link_flow_control_set_autoneg,
   13763                 :            :         &cmd_link_flow_control_show,
   13764                 :            :         &cmd_priority_flow_control_set,
   13765                 :            :         &cmd_queue_priority_flow_control_set,
   13766                 :            :         &cmd_config_dcb,
   13767                 :            :         &cmd_read_rxd_txd,
   13768                 :            :         &cmd_stop,
   13769                 :            :         &cmd_mac_addr,
   13770                 :            :         &cmd_set_fwd_eth_peer,
   13771                 :            :         &cmd_set_qmap,
   13772                 :            :         &cmd_set_xstats_hide_zero,
   13773                 :            :         &cmd_set_xstats_show_state,
   13774                 :            :         &cmd_set_xstats_hide_disabled,
   13775                 :            :         &cmd_operate_set_counter,
   13776                 :            :         &cmd_set_record_core_cycles,
   13777                 :            :         &cmd_set_record_burst_stats,
   13778                 :            :         &cmd_operate_port,
   13779                 :            :         &cmd_operate_specific_port,
   13780                 :            :         &cmd_operate_attach_port,
   13781                 :            :         &cmd_operate_detach_port,
   13782                 :            :         &cmd_operate_detach_device,
   13783                 :            :         &cmd_set_port_setup_on,
   13784                 :            :         &cmd_config_speed_all,
   13785                 :            :         &cmd_config_speed_specific,
   13786                 :            :         &cmd_config_speed_lanes_all,
   13787                 :            :         &cmd_config_speed_lanes_specific,
   13788                 :            :         &cmd_show_speed_lanes,
   13789                 :            :         &cmd_config_loopback_all,
   13790                 :            :         &cmd_config_loopback_specific,
   13791                 :            :         &cmd_config_rx_tx,
   13792                 :            :         &cmd_config_mtu,
   13793                 :            :         &cmd_config_max_pkt_len,
   13794                 :            :         &cmd_config_max_lro_pkt_size,
   13795                 :            :         &cmd_config_rx_mode_flag,
   13796                 :            :         &cmd_config_rss,
   13797                 :            :         &cmd_config_rxtx_ring_size,
   13798                 :            :         &cmd_config_rxtx_queue,
   13799                 :            :         &cmd_config_deferred_start_rxtx_queue,
   13800                 :            :         &cmd_setup_rxtx_queue,
   13801                 :            :         &cmd_config_rss_reta,
   13802                 :            :         &cmd_showport_reta,
   13803                 :            :         &cmd_showport_macs,
   13804                 :            :         &cmd_show_port_flow_transfer_proxy,
   13805                 :            :         &cmd_config_burst,
   13806                 :            :         &cmd_config_thresh,
   13807                 :            :         &cmd_config_threshold,
   13808                 :            :         &cmd_set_uc_hash_filter,
   13809                 :            :         &cmd_set_uc_all_hash_filter,
   13810                 :            :         &cmd_vf_mac_addr_filter,
   13811                 :            :         &cmd_queue_rate_limit,
   13812                 :            :         &cmd_tunnel_udp_config,
   13813                 :            :         &cmd_showport_rss_hash,
   13814                 :            :         &cmd_showport_rss_hash_key,
   13815                 :            :         &cmd_showport_rss_hash_algo,
   13816                 :            :         &cmd_config_rss_hash_key,
   13817                 :            :         &cmd_config_rss_hash_algo,
   13818                 :            :         &cmd_cleanup_txq_mbufs,
   13819                 :            :         &cmd_dump,
   13820                 :            :         &cmd_dump_one,
   13821                 :            :         &cmd_flow,
   13822                 :            :         &cmd_show_port_meter_cap,
   13823                 :            :         &cmd_add_port_meter_profile_srtcm,
   13824                 :            :         &cmd_add_port_meter_profile_trtcm,
   13825                 :            :         &cmd_add_port_meter_profile_trtcm_rfc4115,
   13826                 :            :         &cmd_del_port_meter_profile,
   13827                 :            :         &cmd_create_port_meter,
   13828                 :            :         &cmd_enable_port_meter,
   13829                 :            :         &cmd_disable_port_meter,
   13830                 :            :         &cmd_del_port_meter,
   13831                 :            :         &cmd_del_port_meter_policy,
   13832                 :            :         &cmd_set_port_meter_profile,
   13833                 :            :         &cmd_set_port_meter_dscp_table,
   13834                 :            :         &cmd_set_port_meter_vlan_table,
   13835                 :            :         &cmd_set_port_meter_in_proto,
   13836                 :            :         &cmd_get_port_meter_in_proto,
   13837                 :            :         &cmd_get_port_meter_in_proto_prio,
   13838                 :            :         &cmd_set_port_meter_stats_mask,
   13839                 :            :         &cmd_show_port_meter_stats,
   13840                 :            :         &cmd_mcast_addr,
   13841                 :            :         &cmd_mcast_addr_flush,
   13842                 :            :         &cmd_set_vf_vlan_anti_spoof,
   13843                 :            :         &cmd_set_vf_mac_anti_spoof,
   13844                 :            :         &cmd_set_vf_vlan_stripq,
   13845                 :            :         &cmd_set_vf_vlan_insert,
   13846                 :            :         &cmd_set_tx_loopback,
   13847                 :            :         &cmd_set_all_queues_drop_en,
   13848                 :            :         &cmd_set_vf_traffic,
   13849                 :            :         &cmd_set_vf_rxmode,
   13850                 :            :         &cmd_vf_rate_limit,
   13851                 :            :         &cmd_vf_rxvlan_filter,
   13852                 :            :         &cmd_set_vf_mac_addr,
   13853                 :            :         &cmd_set_vxlan,
   13854                 :            :         &cmd_set_vxlan_tos_ttl,
   13855                 :            :         &cmd_set_vxlan_with_vlan,
   13856                 :            :         &cmd_set_nvgre,
   13857                 :            :         &cmd_set_nvgre_with_vlan,
   13858                 :            :         &cmd_set_l2_encap,
   13859                 :            :         &cmd_set_l2_encap_with_vlan,
   13860                 :            :         &cmd_set_l2_decap,
   13861                 :            :         &cmd_set_l2_decap_with_vlan,
   13862                 :            :         &cmd_set_mplsogre_encap,
   13863                 :            :         &cmd_set_mplsogre_encap_with_vlan,
   13864                 :            :         &cmd_set_mplsogre_decap,
   13865                 :            :         &cmd_set_mplsogre_decap_with_vlan,
   13866                 :            :         &cmd_set_mplsoudp_encap,
   13867                 :            :         &cmd_set_mplsoudp_encap_with_vlan,
   13868                 :            :         &cmd_set_mplsoudp_decap,
   13869                 :            :         &cmd_set_mplsoudp_decap_with_vlan,
   13870                 :            :         &cmd_set_conntrack_common,
   13871                 :            :         &cmd_set_conntrack_dir,
   13872                 :            :         &cmd_show_vf_stats,
   13873                 :            :         &cmd_clear_vf_stats,
   13874                 :            :         &cmd_show_port_supported_ptypes,
   13875                 :            :         &cmd_set_port_ptypes,
   13876                 :            :         &cmd_show_port_tm_cap,
   13877                 :            :         &cmd_show_port_tm_level_cap,
   13878                 :            :         &cmd_show_port_tm_node,
   13879                 :            :         &cmd_show_port_tm_node_cap,
   13880                 :            :         &cmd_show_port_tm_node_type,
   13881                 :            :         &cmd_show_port_tm_node_stats,
   13882                 :            :         &cmd_add_port_tm_node_shaper_profile,
   13883                 :            :         &cmd_del_port_tm_node_shaper_profile,
   13884                 :            :         &cmd_add_port_tm_node_shared_shaper,
   13885                 :            :         &cmd_del_port_tm_node_shared_shaper,
   13886                 :            :         &cmd_add_port_tm_node_wred_profile,
   13887                 :            :         &cmd_del_port_tm_node_wred_profile,
   13888                 :            :         &cmd_set_port_tm_node_shaper_profile,
   13889                 :            :         &cmd_add_port_tm_nonleaf_node,
   13890                 :            :         &cmd_add_port_tm_nonleaf_node_pmode,
   13891                 :            :         &cmd_add_port_tm_leaf_node,
   13892                 :            :         &cmd_del_port_tm_node,
   13893                 :            :         &cmd_set_port_tm_node_parent,
   13894                 :            :         &cmd_suspend_port_tm_node,
   13895                 :            :         &cmd_resume_port_tm_node,
   13896                 :            :         &cmd_port_tm_hierarchy_commit,
   13897                 :            :         &cmd_port_tm_mark_ip_ecn,
   13898                 :            :         &cmd_port_tm_mark_ip_dscp,
   13899                 :            :         &cmd_port_tm_mark_vlan_dei,
   13900                 :            :         &cmd_cfg_tunnel_udp_port,
   13901                 :            :         &cmd_rx_offload_get_capa,
   13902                 :            :         &cmd_rx_offload_get_configuration,
   13903                 :            :         &cmd_config_per_port_rx_offload,
   13904                 :            :         &cmd_config_all_port_rx_offload,
   13905                 :            :         &cmd_config_per_queue_rx_offload,
   13906                 :            :         &cmd_tx_offload_get_capa,
   13907                 :            :         &cmd_tx_offload_get_configuration,
   13908                 :            :         &cmd_config_per_port_tx_offload,
   13909                 :            :         &cmd_config_all_port_tx_offload,
   13910                 :            :         &cmd_config_per_queue_tx_offload,
   13911                 :            : #ifdef RTE_LIB_BPF
   13912                 :            :         &cmd_operate_bpf_ld_parse,
   13913                 :            :         &cmd_operate_bpf_unld_parse,
   13914                 :            : #endif
   13915                 :            :         &cmd_config_tx_metadata_specific,
   13916                 :            :         &cmd_show_tx_metadata,
   13917                 :            :         &cmd_show_rx_tx_desc_status,
   13918                 :            :         &cmd_show_rx_tx_queue_desc_used_count,
   13919                 :            :         &cmd_set_raw,
   13920                 :            :         &cmd_show_set_raw,
   13921                 :            :         &cmd_show_set_raw_all,
   13922                 :            :         &cmd_config_tx_dynf_specific,
   13923                 :            :         &cmd_show_fec_mode,
   13924                 :            :         &cmd_set_fec_mode,
   13925                 :            :         &cmd_set_rxq_avail_thresh,
   13926                 :            :         &cmd_show_capability,
   13927                 :            :         &cmd_set_flex_is_pattern,
   13928                 :            :         &cmd_set_flex_spec_pattern,
   13929                 :            :         &cmd_show_port_cman_capa,
   13930                 :            :         &cmd_show_port_cman_config,
   13931                 :            :         &cmd_set_port_cman_config,
   13932                 :            :         &cmd_config_tx_affinity_map,
   13933                 :            :         &cmd_set_dev_led,
   13934                 :            :         NULL,
   13935                 :            : };
   13936                 :            : 
   13937                 :            : void
   13938                 :          0 : testpmd_add_driver_commands(struct testpmd_driver_commands *c)
   13939                 :            : {
   13940                 :          0 :         TAILQ_INSERT_TAIL(&driver_commands_head, c, next);
   13941                 :          0 : }
   13942                 :            : 
   13943                 :            : int
   13944                 :          0 : init_cmdline(void)
   13945                 :            : {
   13946                 :            :         struct testpmd_driver_commands *c;
   13947                 :            :         unsigned int count;
   13948                 :            :         unsigned int i;
   13949                 :            : 
   13950                 :            :         /* initialize non-constant commands */
   13951                 :          0 :         cmd_set_fwd_mode_init();
   13952                 :          0 :         cmd_set_fwd_retry_mode_init();
   13953                 :            : 
   13954                 :            :         count = 0;
   13955                 :          0 :         for (i = 0; builtin_ctx[i] != NULL; i++)
   13956                 :          0 :                 count++;
   13957                 :          0 :         TAILQ_FOREACH(c, &driver_commands_head, next) {
   13958                 :          0 :                 for (i = 0; c->commands[i].ctx != NULL; i++)
   13959                 :          0 :                         count++;
   13960                 :            :         }
   13961                 :            : 
   13962                 :            :         /* cmdline expects a NULL terminated array */
   13963                 :          0 :         main_ctx = calloc(count + 1, sizeof(main_ctx[0]));
   13964                 :          0 :         if (main_ctx == NULL)
   13965                 :            :                 return -1;
   13966                 :            : 
   13967                 :            :         count = 0;
   13968                 :          0 :         for (i = 0; builtin_ctx[i] != NULL; i++, count++)
   13969                 :          0 :                 main_ctx[count] = builtin_ctx[i];
   13970                 :          0 :         TAILQ_FOREACH(c, &driver_commands_head, next) {
   13971                 :          0 :                 for (i = 0; c->commands[i].ctx != NULL; i++, count++)
   13972                 :          0 :                         main_ctx[count] = c->commands[i].ctx;
   13973                 :            :         }
   13974                 :            : 
   13975                 :            :         return 0;
   13976                 :            : }
   13977                 :            : 
   13978                 :            : /* read cmdline commands from file */
   13979                 :            : void
   13980                 :          0 : cmdline_read_from_file(const char *filename)
   13981                 :            : {
   13982                 :            :         struct cmdline *cl;
   13983                 :            : 
   13984                 :            :         /* cmdline_file_new does not produce any output which is not ideal here.
   13985                 :            :          * Much better to show output of the commands, so we open filename directly
   13986                 :            :          * and then pass that to cmdline_new with stdout as the output path.
   13987                 :            :          */
   13988                 :            :         int fd = open(filename, O_RDONLY);
   13989                 :          0 :         if (fd < 0) {
   13990                 :          0 :                 fprintf(stderr, "Failed to open file %s: %s\n",
   13991                 :          0 :                         filename, strerror(errno));
   13992                 :          0 :                 return;
   13993                 :            :         }
   13994                 :            : 
   13995                 :          0 :         cl = cmdline_new(main_ctx, "testpmd> ", fd, STDOUT_FILENO);
   13996                 :          0 :         if (cl == NULL) {
   13997                 :          0 :                 fprintf(stderr,
   13998                 :            :                         "Failed to create file based cmdline context: %s\n",
   13999                 :            :                         filename);
   14000                 :          0 :                 return;
   14001                 :            :         }
   14002                 :            : 
   14003                 :          0 :         cmdline_interact(cl);
   14004                 :          0 :         cmdline_quit(cl);
   14005                 :            : 
   14006                 :          0 :         cmdline_free(cl);
   14007                 :            : 
   14008                 :            :         printf("Read CLI commands from %s\n", filename);
   14009                 :            : }
   14010                 :            : 
   14011                 :            : void
   14012                 :          0 : prompt_exit(void)
   14013                 :            : {
   14014                 :          0 :         cmdline_quit(testpmd_cl);
   14015                 :          0 : }
   14016                 :            : 
   14017                 :            : /* prompt function, called from main on MAIN lcore */
   14018                 :            : void
   14019                 :          0 : prompt(void)
   14020                 :            : {
   14021                 :          0 :         testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
   14022                 :          0 :         if (testpmd_cl == NULL) {
   14023                 :          0 :                 fprintf(stderr,
   14024                 :            :                         "Failed to create stdin based cmdline context\n");
   14025                 :          0 :                 return;
   14026                 :            :         }
   14027                 :            : 
   14028                 :          0 :         cmdline_interact(testpmd_cl);
   14029                 :          0 :         cmdline_stdin_exit(testpmd_cl);
   14030                 :            : }
   14031                 :            : 
   14032                 :            : void
   14033                 :          0 : cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
   14034                 :            : {
   14035                 :          0 :         if (id == (portid_t)RTE_PORT_ALL) {
   14036                 :            :                 portid_t pid;
   14037                 :            : 
   14038                 :          0 :                 RTE_ETH_FOREACH_DEV(pid) {
   14039                 :            :                         /* check if need_reconfig has been set to 1 */
   14040                 :          0 :                         if (ports[pid].need_reconfig == 0)
   14041                 :          0 :                                 ports[pid].need_reconfig = dev;
   14042                 :            :                         /* check if need_reconfig_queues has been set to 1 */
   14043                 :          0 :                         if (ports[pid].need_reconfig_queues == 0)
   14044                 :          0 :                                 ports[pid].need_reconfig_queues = queue;
   14045                 :            :                 }
   14046                 :          0 :         } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
   14047                 :            :                 /* check if need_reconfig has been set to 1 */
   14048                 :          0 :                 if (ports[id].need_reconfig == 0)
   14049                 :          0 :                         ports[id].need_reconfig = dev;
   14050                 :            :                 /* check if need_reconfig_queues has been set to 1 */
   14051                 :          0 :                 if (ports[id].need_reconfig_queues == 0)
   14052                 :          0 :                         ports[id].need_reconfig_queues = queue;
   14053                 :            :         }
   14054                 :          0 : }

Generated by: LCOV version 1.14