app/testpmd: VMDq and DCB updates
[dpdk.git] / app / test-pmd / cmdline.c
1 /*-
2  *   BSD LICENSE
3  * 
4  *   Copyright(c) 2010-2013 Intel Corporation. All rights reserved.
5  *   All rights reserved.
6  * 
7  *   Redistribution and use in source and binary forms, with or without
8  *   modification, are permitted provided that the following conditions
9  *   are met:
10  * 
11  *     * Redistributions of source code must retain the above copyright
12  *       notice, this list of conditions and the following disclaimer.
13  *     * Redistributions in binary form must reproduce the above copyright
14  *       notice, this list of conditions and the following disclaimer in
15  *       the documentation and/or other materials provided with the
16  *       distribution.
17  *     * Neither the name of Intel Corporation nor the names of its
18  *       contributors may be used to endorse or promote products derived
19  *       from this software without specific prior written permission.
20  * 
21  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24  *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25  *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26  *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27  *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28  *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29  *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  */
33
34 #include <stdarg.h>
35 #include <errno.h>
36 #include <stdio.h>
37 #include <stdint.h>
38 #include <stdarg.h>
39 #include <string.h>
40 #include <termios.h>
41 #include <unistd.h>
42 #include <inttypes.h>
43 #ifndef __linux__
44 #include <net/socket.h>
45 #endif
46 #include <netinet/in.h>
47
48 #include <sys/queue.h>
49
50 #include <rte_common.h>
51 #include <rte_byteorder.h>
52 #include <rte_log.h>
53 #include <rte_debug.h>
54 #include <rte_cycles.h>
55 #include <rte_memory.h>
56 #include <rte_memzone.h>
57 #include <rte_launch.h>
58 #include <rte_tailq.h>
59 #include <rte_eal.h>
60 #include <rte_per_lcore.h>
61 #include <rte_lcore.h>
62 #include <rte_atomic.h>
63 #include <rte_branch_prediction.h>
64 #include <rte_ring.h>
65 #include <rte_mempool.h>
66 #include <rte_interrupts.h>
67 #include <rte_pci.h>
68 #include <rte_ether.h>
69 #include <rte_ethdev.h>
70 #include <rte_string_fns.h>
71
72 #include <cmdline_rdline.h>
73 #include <cmdline_parse.h>
74 #include <cmdline_parse_num.h>
75 #include <cmdline_parse_string.h>
76 #include <cmdline_parse_ipaddr.h>
77 #include <cmdline_parse_etheraddr.h>
78 #include <cmdline_socket.h>
79 #include <cmdline.h>
80
81 #include "testpmd.h"
82
83 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
84
85 /* *** Help command with introduction. *** */
86 struct cmd_help_brief_result {
87         cmdline_fixed_string_t help;
88 };
89
90 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
91                                   struct cmdline *cl,
92                                   __attribute__((unused)) void *data)
93 {
94         cmdline_printf(
95                 cl,
96                 "\n"
97                 "Help is available for the following sections:\n\n"
98                 "    help control    : Start and stop forwarding.\n"
99                 "    help display    : Displaying port, stats and config "
100                 "information.\n"
101                 "    help config     : Configuration information.\n"
102                 "    help ports      : Configuring ports.\n"
103                 "    help flowdir    : Flow Director filter help.\n"
104                 "    help registers  : Reading and setting port registers.\n"
105                 "    help all        : All of the above sections.\n\n"
106         );
107
108 }
109
110 cmdline_parse_token_string_t cmd_help_brief_help =
111         TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
112
113 cmdline_parse_inst_t cmd_help_brief = {
114         .f = cmd_help_brief_parsed,
115         .data = NULL,
116         .help_str = "show help",
117         .tokens = {
118                 (void *)&cmd_help_brief_help,
119                 NULL,
120         },
121 };
122
123 /* *** Help command with help sections. *** */
124 struct cmd_help_long_result {
125         cmdline_fixed_string_t help;
126         cmdline_fixed_string_t section;
127 };
128
129 static void cmd_help_long_parsed(void *parsed_result,
130                                  struct cmdline *cl,
131                                  __attribute__((unused)) void *data)
132 {
133         int show_all = 0;
134         struct cmd_help_long_result *res = parsed_result;
135
136         if (!strcmp(res->section, "all"))
137                 show_all = 1;
138
139         if (show_all || !strcmp(res->section, "control")) {
140
141                 cmdline_printf(
142                         cl,
143                         "\n"
144                         "Control forwarding:\n"
145                         "-------------------\n\n"
146
147                         "start\n"
148                         "    Start packet forwarding with current configuration.\n\n"
149
150                         "start tx_first\n"
151                         "    Start packet forwarding with current config"
152                         " after sending one burst of packets.\n\n"
153
154                         "stop\n"
155                         "    Stop packet forwarding, and display accumulated"
156                         " statistics.\n\n"
157
158                         "quit\n"
159                         "    Quit to prompt in Linux and reboot on Baremetal.\n\n"
160                 );
161         }
162
163         if (show_all || !strcmp(res->section, "display")) {
164
165                 cmdline_printf(
166                         cl,
167                         "\n"
168                         "Display:\n"
169                         "--------\n\n"
170
171                         "show port (info|stats|fdir|stat_qmap) (port_id|all)\n"
172                         "    Display information for port_id, or all.\n\n"
173
174                         "clear port (info|stats|fdir|stat_qmap) (port_id|all)\n"
175                         "    Clear information for port_id, or all.\n\n"
176
177                         "show config (rxtx|cores|fwd)\n"
178                         "    Display the given configuration.\n\n"
179
180                         "read rxd (port_id) (queue_id) (rxd_id)\n"
181                         "    Display an RX descriptor of a port RX queue.\n\n"
182
183                         "read txd (port_id) (queue_id) (txd_id)\n"
184                         "    Display a TX descriptor of a port TX queue.\n\n"
185                 );
186         }
187
188         if (show_all || !strcmp(res->section, "config")) {
189                 cmdline_printf(
190                         cl,
191                         "\n"
192                         "Configuration:\n"
193                         "--------------\n"
194                         "Configuration changes only become active when"
195                         " forwarding is started/restarted.\n\n"
196
197                         "set default\n"
198                         "    Reset forwarding to the default configuration.\n\n"
199
200                         "set verbose (level)\n"
201                         "    Set the debug verbosity level X.\n\n"
202
203                         "set nbport (num)\n"
204                         "    Set number of ports.\n\n"
205
206                         "set nbcore (num)\n"
207                         "    Set number of cores.\n\n"
208
209                         "set coremask (mask)\n"
210                         "    Set the forwarding cores hexadecimal mask.\n\n"
211
212                         "set portmask (mask)\n"
213                         "    Set the forwarding ports hexadecimal mask.\n\n"
214
215                         "set burst (num)\n"
216                         "    Set number of packets per burst.\n\n"
217
218                         "set txpkts (x[,y]*)\n"
219                         "    Set the length of each segment of TXONLY"
220                         " packets.\n\n"
221
222                         "set corelist (x[,y]*)\n"
223                         "    Set the list of forwarding cores.\n\n"
224
225                         "set portlist (x[,y]*)\n"
226                         "    Set the list of forwarding ports.\n\n"
227
228                         "vlan set strip (on|off) (port_id)\n"
229                         "    Set the VLAN strip on a port.\n\n"
230
231                         "vlan set filter (on|off) (port_id)\n"
232                         "    Set the VLAN filter on a port.\n\n"
233
234                         "vlan set qinq (on|off) (port_id)\n"
235                         "    Set the VLAN QinQ (extended queue in queue)"
236                         " on a port.\n\n"
237
238                         "vlan set tpid (value) (port_id)\n"
239                         "    Set the outer VLAN TPID for Packet Filtering on"
240                         " a port\n\n"
241
242                         "rx_vlan add (vlan_id|all) (port_id)\n"
243                         "    Add a vlan_id, or all identifiers, to the set"
244                         " of VLAN identifiers filtered by port_id.\n\n"
245
246                         "rx_vlan rm (vlan_id|all) (port_id)\n"
247                         "    Remove a vlan_id, or all identifiers, from the set"
248                         " of VLAN identifiers filtered by port_id.\n\n"
249
250                         "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
251                         "    Add a vlan_id, to the set of VLAN identifiers"
252                         "filtered for VF(s) from port_id.\n\n"
253                         
254                         "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
255                         "    Remove a vlan_id, to the set of VLAN identifiers"
256                         "filtered for VF(s) from port_id.\n\n"                  
257
258                         "rx_vlan set tpid (value) (port_id)\n"
259                         "    Set the outer VLAN TPID for Packet Filtering on"
260                         " a port\n\n"
261
262                         "tx_vlan set vlan_id (port_id)\n"
263                         "    Set hardware insertion of VLAN ID in packets sent"
264                         " on a port.\n\n"
265
266                         "tx_vlan reset (port_id)\n"
267                         "    Disable hardware insertion of a VLAN header in"
268                         " packets sent on a port.\n\n"
269
270                         "tx_checksum set mask (port_id)\n"
271                         "    Enable hardware insertion of checksum offload with"
272                         " the 4-bit mask, 0~0xf, in packets sent on a port.\n"
273                         "        bit 0 - insert ip   checksum offload if set\n"
274                         "        bit 1 - insert udp  checksum offload if set\n"
275                         "        bit 2 - insert tcp  checksum offload if set\n"
276                         "        bit 3 - insert sctp checksum offload if set\n"
277                         "    Please check the NIC datasheet for HW limits.\n\n"
278
279 #ifdef RTE_LIBRTE_IEEE1588
280                         "set fwd (io|mac|rxonly|txonly|csum|ieee1588)\n"
281                         "    Set IO, MAC, RXONLY, CSUM or TXONLY or ieee1588"
282                         " packet forwarding mode.\n\n"
283
284 #else
285                         "set fwd (io|mac|rxonly|txonly|csum)\n"
286                         "    Set IO, MAC, RXONLY, CSUM or TXONLY packet"
287                         " forwarding mode.\n\n"
288
289 #endif
290                         "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
291                         "    Add a MAC address on port_id.\n\n"
292
293                         "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
294                         "    Remove a MAC address from port_id.\n\n"
295
296                         "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
297                         "    Add a MAC address for a VF on the port.\n\n"
298                         
299                         "set port (port_id) uta (mac_address|all) (on|off)\n"
300                         "    Add/Remove a or all unicast hash filter(s)" 
301                         "from port X.\n\n"
302
303                         "set promisc (port_id|all) (on|off)\n"
304                         "    Set the promiscuous mode on port_id, or all.\n\n"
305
306                         "set allmulti (port_id|all) (on|off)\n"
307                         "    Set the allmulti mode on port_id, or all.\n\n"
308
309                         "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
310                         " (low_water) (pause_time) (send_xon) (port_id)\n"
311                         "    Set the link flow control parameter on a port.\n\n"
312
313                         "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
314                         " (low_water) (pause_time) (priority) (port_id)\n"
315                         "    Set the priority flow control parameter on a"
316                         " port.\n\n"
317
318                         "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
319                         "    Set statistics mapping (qmapping 0..15) for RX/TX"
320                         " queue on port.\n"
321                         "    e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
322                         " on port 0 to mapping 5.\n\n"
323
324                         "set port (port_id) vf (vf_id) rx|tx on|off \n"
325                         "    Enable/Disable a VF receive/tranmit from a port\n\n"
326
327                         "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
328                         "|MPE) (on|off)\n"
329                         "    AUPE:accepts untagged VLAN;"
330                         "ROPE:accept unicast hash\n\n"
331                         "    BAM:accepts broadcast packets;"
332                         "MPE:accepts all multicast packets\n\n"
333                         "    Enable/Disable a VF receive mode of a port\n\n"
334                         
335                         "set port (port_id) mirror-rule (rule_id)" 
336                         "(pool-mirror|vlan-mirror)\n"
337                         " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
338                         "   Set pool or vlan type mirror rule on a port.\n"
339                         "   e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
340                         " dst-pool 0 on' enable mirror traffic with vlan 0,1"
341                         " to pool 0.\n\n"
342
343                         "set port (port_id) mirror-rule (rule_id)"
344                         "(uplink-mirror|downlink-mirror) dst-pool"
345                         "(pool_id) (on|off)\n"
346                         "   Set uplink or downlink type mirror rule on a port.\n"
347                         "   e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
348                         " 0 on' enable mirror income traffic to pool 0.\n\n"
349
350                         "reset port (port_id) mirror-rule (rule_id)\n"
351                         "   Reset a mirror rule.\n\n"
352
353                         ""
354                 );
355         }
356
357
358         if (show_all || !strcmp(res->section, "flowdir")) {
359
360                 cmdline_printf(
361                         cl,
362                         "\n"
363                         "Flow director mode:\n"
364                         "-------------------\n\n"
365
366                         "add_signature_filter (port_id) (ip|udp|tcp|sctp)"
367                         " src (src_ip_address) (src_port)"
368                         " dst (dst_ip_address) (dst_port)"
369                         " flexbytes (flexbytes_values) vlan (vlan_id)"
370                         " queue (queue_id)\n"
371                         "    Add a signature filter.\n\n"
372
373                         "upd_signature_filter (port_id) (ip|udp|tcp|sctp)"
374                         " src (src_ip_address) (src_port)"
375                         " dst (dst_ip_address) (dst_port)"
376                         " flexbytes (flexbytes_values) vlan (vlan_id)"
377                         " queue (queue_id)\n"
378                         "    Update a signature filter.\n\n"
379
380                         "rm_signature_filter (port_id) (ip|udp|tcp|sctp)"
381                         " src (src_ip_address) (src_port)"
382                         " dst (dst_ip_address) (dst_port)"
383                         " flexbytes (flexbytes_values) vlan (vlan_id)\n"
384                         "    Remove a signature filter.\n\n"
385
386                         "add_perfect_filter (port_id) (ip|udp|tcp|sctp)"
387                         " src (src_ip_address) (src_port)"
388                         " dst (dst_ip_address) (dst_port)"
389                         " flexbytes (flexbytes_values) vlan (vlan_id)"
390                         " queue (queue_id) soft (soft_id)\n"
391                         "    Add a perfect filter.\n\n"
392
393                         "upd_perfect_filter (port_id) (ip|udp|tcp|sctp)"
394                         " src (src_ip_address) (src_port)"
395                         " dst (dst_ip_address) (dst_port)"
396                         " flexbytes (flexbytes_values) vlan (vlan_id)"
397                         " queue (queue_id)\n"
398                         "    Update a perfect filter.\n\n"
399
400                         "rm_perfect_filter (port_id) (ip|udp|tcp|sctp)"
401                         " src (src_ip_address) (src_port)"
402                         " dst (dst_ip_address) (dst_port)"
403                         " flexbytes (flexbytes_values) vlan (vlan_id)"
404                         " soft (soft_id)\n"
405                         "    Remove a perfect filter.\n\n"
406
407                         "set_masks_filter (port_id) only_ip_flow (0|1)"
408                         " src_mask (ip_src_mask) (src_port_mask)"
409                         " dst_mask (ip_dst_mask) (dst_port_mask)"
410                         " flexbytes (0|1) vlan_id (0|1) vlan_prio (0|1)\n"
411                         "    Set IPv4 filter masks.\n\n"
412
413                         "set_ipv6_masks_filter (port_id) only_ip_flow (0|1)"
414                         " src_mask (ip_src_mask) (src_port_mask)"
415                         " dst_mask (ip_dst_mask) (dst_port_mask)"
416                         " flexbytes (0|1) vlan_id (0|1) vlan_prio (0|1)"
417                         " compare_dst (0|1)\n"
418                         "    Set IPv6 filter masks.\n\n"
419                 );
420         }
421
422         if (show_all || !strcmp(res->section, "ports")) {
423
424                 cmdline_printf(
425                         cl,
426                         "\n"
427                         "Port Operations:\n"
428                         "----------------\n\n"
429
430                         "port start (port_id|all)\n"
431                         "    Start all ports or port_id.\n\n"
432
433                         "port stop (port_id|all)\n"
434                         "    Stop all ports or port_id.\n\n"
435
436                         "port close (port_id|all)\n"
437                         "    Close all ports or port_id.\n\n"
438
439                         "port config (port_id|all) speed (10|100|1000|10000|auto)"
440                         " duplex (half|full|auto)\n"
441                         "    Set speed and duplex for all ports or port_id\n\n"
442
443                         "port config all (rxq|txq|rxd|txd) (value)\n"
444                         "    Set number for rxq/txq/rxd/txd.\n\n"
445
446                         "port config all max-pkt-len (value)\n"
447                         "    Set the max packet length.\n\n"
448
449                         "port config all (crc-strip|rx-cksum|hw-vlan|drop-en)"
450                         " (on|off)\n"
451                         "    Set crc-strip/rx-checksum/hardware-vlan/drop_en"
452                         " for ports.\n\n"
453
454                         "port config all rss (ip|udp|none)\n"
455                         "    Set the RSS mode.\n\n"
456
457                         "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
458                         "    Set the RSS redirection table.\n\n"
459
460                         "port config (port_id) dcb vt (on|off) (traffic_class)"
461                         " pfc (on|off)\n"
462                         "    Set the DCB mode.\n\n"
463
464                         "port config all burst (value)\n"
465                         "    Set the number of packets per burst.\n\n"
466
467                         "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
468                         " (value)\n"
469                         "    Set the ring prefetch/host/writeback threshold"
470                         " for tx/rx queue.\n\n"
471
472                         "port config all (txfreet|txrst|rxfreet) (value)\n"
473                         "    Set free threshold for rx/tx, or set"
474                         " tx rs bit threshold.\n\n"
475                 );
476         }
477
478         if (show_all || !strcmp(res->section, "registers")) {
479
480                 cmdline_printf(
481                         cl,
482                         "\n"
483                         "Registers:\n"
484                         "----------\n\n"
485
486                         "read reg (port_id) (address)\n"
487                         "    Display value of a port register.\n\n"
488
489                         "read regfield (port_id) (address) (bit_x) (bit_y)\n"
490                         "    Display a port register bit field.\n\n"
491
492                         "read regbit (port_id) (address) (bit_x)\n"
493                         "    Display a single port register bit.\n\n"
494
495                         "write reg (port_id) (address) (value)\n"
496                         "    Set value of a port register.\n\n"
497
498                         "write regfield (port_id) (address) (bit_x) (bit_y)"
499                         " (value)\n"
500                         "    Set bit field of a port register.\n\n"
501
502                         "write regbit (port_id) (address) (bit_x) (value)\n"
503                         "    Set single bit value of a port register.\n\n"
504                 );
505         }
506 }
507
508 cmdline_parse_token_string_t cmd_help_long_help =
509         TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
510
511 cmdline_parse_token_string_t cmd_help_long_section =
512         TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
513                         "all#control#display#config#flowdir#"
514                         "ports#registers");
515
516 cmdline_parse_inst_t cmd_help_long = {
517         .f = cmd_help_long_parsed,
518         .data = NULL,
519         .help_str = "show help",
520         .tokens = {
521                 (void *)&cmd_help_long_help,
522                 (void *)&cmd_help_long_section,
523                 NULL,
524         },
525 };
526
527
528 /* *** start/stop/close all ports *** */
529 struct cmd_operate_port_result {
530         cmdline_fixed_string_t keyword;
531         cmdline_fixed_string_t name;
532         cmdline_fixed_string_t value;
533 };
534
535 static void cmd_operate_port_parsed(void *parsed_result,
536                                 __attribute__((unused)) struct cmdline *cl,
537                                 __attribute__((unused)) void *data)
538 {
539         struct cmd_operate_port_result *res = parsed_result;
540
541         if (!strcmp(res->name, "start"))
542                 start_port(RTE_PORT_ALL);
543         else if (!strcmp(res->name, "stop"))
544                 stop_port(RTE_PORT_ALL);
545         else if (!strcmp(res->name, "close"))
546                 close_port(RTE_PORT_ALL);
547         else
548                 printf("Unknown parameter\n");
549 }
550
551 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
552         TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
553                                                                 "port");
554 cmdline_parse_token_string_t cmd_operate_port_all_port =
555         TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
556                                                 "start#stop#close");
557 cmdline_parse_token_string_t cmd_operate_port_all_all =
558         TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
559
560 cmdline_parse_inst_t cmd_operate_port = {
561         .f = cmd_operate_port_parsed,
562         .data = NULL,
563         .help_str = "port start|stop|close all: start/stop/close all ports",
564         .tokens = {
565                 (void *)&cmd_operate_port_all_cmd,
566                 (void *)&cmd_operate_port_all_port,
567                 (void *)&cmd_operate_port_all_all,
568                 NULL,
569         },
570 };
571
572 /* *** start/stop/close specific port *** */
573 struct cmd_operate_specific_port_result {
574         cmdline_fixed_string_t keyword;
575         cmdline_fixed_string_t name;
576         uint8_t value;
577 };
578
579 static void cmd_operate_specific_port_parsed(void *parsed_result,
580                         __attribute__((unused)) struct cmdline *cl,
581                                 __attribute__((unused)) void *data)
582 {
583         struct cmd_operate_specific_port_result *res = parsed_result;
584
585         if (!strcmp(res->name, "start"))
586                 start_port(res->value);
587         else if (!strcmp(res->name, "stop"))
588                 stop_port(res->value);
589         else if (!strcmp(res->name, "close"))
590                 close_port(res->value);
591         else
592                 printf("Unknown parameter\n");
593 }
594
595 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
596         TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
597                                                         keyword, "port");
598 cmdline_parse_token_string_t cmd_operate_specific_port_port =
599         TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
600                                                 name, "start#stop#close");
601 cmdline_parse_token_num_t cmd_operate_specific_port_id =
602         TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
603                                                         value, UINT8);
604
605 cmdline_parse_inst_t cmd_operate_specific_port = {
606         .f = cmd_operate_specific_port_parsed,
607         .data = NULL,
608         .help_str = "port start|stop|close X: start/stop/close port X",
609         .tokens = {
610                 (void *)&cmd_operate_specific_port_cmd,
611                 (void *)&cmd_operate_specific_port_port,
612                 (void *)&cmd_operate_specific_port_id,
613                 NULL,
614         },
615 };
616
617 /* *** configure speed for all ports *** */
618 struct cmd_config_speed_all {
619         cmdline_fixed_string_t port;
620         cmdline_fixed_string_t keyword;
621         cmdline_fixed_string_t all;
622         cmdline_fixed_string_t item1;
623         cmdline_fixed_string_t item2;
624         cmdline_fixed_string_t value1;
625         cmdline_fixed_string_t value2;
626 };
627
628 static void
629 cmd_config_speed_all_parsed(void *parsed_result,
630                         __attribute__((unused)) struct cmdline *cl,
631                         __attribute__((unused)) void *data)
632 {
633         struct cmd_config_speed_all *res = parsed_result;
634         uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
635         uint16_t link_duplex = 0;
636         portid_t pid;
637
638         if (!all_ports_stopped()) {
639                 printf("Please stop all ports first\n");
640                 return;
641         }
642
643         if (!strcmp(res->value1, "10"))
644                 link_speed = ETH_LINK_SPEED_10;
645         else if (!strcmp(res->value1, "100"))
646                 link_speed = ETH_LINK_SPEED_100;
647         else if (!strcmp(res->value1, "1000"))
648                 link_speed = ETH_LINK_SPEED_1000;
649         else if (!strcmp(res->value1, "10000"))
650                 link_speed = ETH_LINK_SPEED_10000;
651         else if (!strcmp(res->value1, "auto"))
652                 link_speed = ETH_LINK_SPEED_AUTONEG;
653         else {
654                 printf("Unknown parameter\n");
655                 return;
656         }
657
658         if (!strcmp(res->value2, "half"))
659                 link_duplex = ETH_LINK_HALF_DUPLEX;
660         else if (!strcmp(res->value2, "full"))
661                 link_duplex = ETH_LINK_FULL_DUPLEX;
662         else if (!strcmp(res->value2, "auto"))
663                 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
664         else {
665                 printf("Unknown parameter\n");
666                 return;
667         }
668
669         for (pid = 0; pid < nb_ports; pid++) {
670                 ports[pid].dev_conf.link_speed = link_speed;
671                 ports[pid].dev_conf.link_duplex = link_duplex;
672         }
673
674         cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
675 }
676
677 cmdline_parse_token_string_t cmd_config_speed_all_port =
678         TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
679 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
680         TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
681                                                         "config");
682 cmdline_parse_token_string_t cmd_config_speed_all_all =
683         TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
684 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
685         TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
686 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
687         TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
688                                                 "10#100#1000#10000#auto");
689 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
690         TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
691 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
692         TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
693                                                 "half#full#auto");
694
695 cmdline_parse_inst_t cmd_config_speed_all = {
696         .f = cmd_config_speed_all_parsed,
697         .data = NULL,
698         .help_str = "port config all speed 10|100|1000|10000|auto duplex "
699                                                         "half|full|auto",
700         .tokens = {
701                 (void *)&cmd_config_speed_all_port,
702                 (void *)&cmd_config_speed_all_keyword,
703                 (void *)&cmd_config_speed_all_all,
704                 (void *)&cmd_config_speed_all_item1,
705                 (void *)&cmd_config_speed_all_value1,
706                 (void *)&cmd_config_speed_all_item2,
707                 (void *)&cmd_config_speed_all_value2,
708                 NULL,
709         },
710 };
711
712 /* *** configure speed for specific port *** */
713 struct cmd_config_speed_specific {
714         cmdline_fixed_string_t port;
715         cmdline_fixed_string_t keyword;
716         uint8_t id;
717         cmdline_fixed_string_t item1;
718         cmdline_fixed_string_t item2;
719         cmdline_fixed_string_t value1;
720         cmdline_fixed_string_t value2;
721 };
722
723 static void
724 cmd_config_speed_specific_parsed(void *parsed_result,
725                                 __attribute__((unused)) struct cmdline *cl,
726                                 __attribute__((unused)) void *data)
727 {
728         struct cmd_config_speed_specific *res = parsed_result;
729         uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
730         uint16_t link_duplex = 0;
731
732         if (!all_ports_stopped()) {
733                 printf("Please stop all ports first\n");
734                 return;
735         }
736
737         if (res->id >= nb_ports) {
738                 printf("Port id %d must be less than %d\n", res->id, nb_ports);
739                 return;
740         }
741
742         if (!strcmp(res->value1, "10"))
743                 link_speed = ETH_LINK_SPEED_10;
744         else if (!strcmp(res->value1, "100"))
745                 link_speed = ETH_LINK_SPEED_100;
746         else if (!strcmp(res->value1, "1000"))
747                 link_speed = ETH_LINK_SPEED_1000;
748         else if (!strcmp(res->value1, "10000"))
749                 link_speed = ETH_LINK_SPEED_10000;
750         else if (!strcmp(res->value1, "auto"))
751                 link_speed = ETH_LINK_SPEED_AUTONEG;
752         else {
753                 printf("Unknown parameter\n");
754                 return;
755         }
756
757         if (!strcmp(res->value2, "half"))
758                 link_duplex = ETH_LINK_HALF_DUPLEX;
759         else if (!strcmp(res->value2, "full"))
760                 link_duplex = ETH_LINK_FULL_DUPLEX;
761         else if (!strcmp(res->value2, "auto"))
762                 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
763         else {
764                 printf("Unknown parameter\n");
765                 return;
766         }
767
768         ports[res->id].dev_conf.link_speed = link_speed;
769         ports[res->id].dev_conf.link_duplex = link_duplex;
770
771         cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
772 }
773
774
775 cmdline_parse_token_string_t cmd_config_speed_specific_port =
776         TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
777                                                                 "port");
778 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
779         TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
780                                                                 "config");
781 cmdline_parse_token_num_t cmd_config_speed_specific_id =
782         TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
783 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
784         TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
785                                                                 "speed");
786 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
787         TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
788                                                 "10#100#1000#10000#auto");
789 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
790         TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
791                                                                 "duplex");
792 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
793         TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
794                                                         "half#full#auto");
795
796 cmdline_parse_inst_t cmd_config_speed_specific = {
797         .f = cmd_config_speed_specific_parsed,
798         .data = NULL,
799         .help_str = "port config X speed 10|100|1000|10000|auto duplex "
800                                                         "half|full|auto",
801         .tokens = {
802                 (void *)&cmd_config_speed_specific_port,
803                 (void *)&cmd_config_speed_specific_keyword,
804                 (void *)&cmd_config_speed_specific_id,
805                 (void *)&cmd_config_speed_specific_item1,
806                 (void *)&cmd_config_speed_specific_value1,
807                 (void *)&cmd_config_speed_specific_item2,
808                 (void *)&cmd_config_speed_specific_value2,
809                 NULL,
810         },
811 };
812
813 /* *** configure txq/rxq, txd/rxd *** */
814 struct cmd_config_rx_tx {
815         cmdline_fixed_string_t port;
816         cmdline_fixed_string_t keyword;
817         cmdline_fixed_string_t all;
818         cmdline_fixed_string_t name;
819         uint16_t value;
820 };
821
822 static void
823 cmd_config_rx_tx_parsed(void *parsed_result,
824                         __attribute__((unused)) struct cmdline *cl,
825                         __attribute__((unused)) void *data)
826 {
827         struct cmd_config_rx_tx *res = parsed_result;
828
829         if (!all_ports_stopped()) {
830                 printf("Please stop all ports first\n");
831                 return;
832         }
833
834         if (!strcmp(res->name, "rxq")) {
835                 if (res->value <= 0) {
836                         printf("rxq %d invalid - must be > 0\n", res->value);
837                         return;
838                 }
839                 nb_rxq = res->value;
840         }
841         else if (!strcmp(res->name, "txq")) {
842                 if (res->value <= 0) {
843                         printf("txq %d invalid - must be > 0\n", res->value);
844                         return;
845                 }
846                 nb_txq = res->value;
847         }
848         else if (!strcmp(res->name, "rxd")) {
849                 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
850                         printf("rxd %d invalid - must be > 0 && <= %d\n",
851                                         res->value, RTE_TEST_RX_DESC_MAX);
852                         return;
853                 }
854                 nb_rxd = res->value;
855         } else if (!strcmp(res->name, "txd")) {
856                 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
857                         printf("txd %d invalid - must be > 0 && <= %d\n",
858                                         res->value, RTE_TEST_TX_DESC_MAX);
859                         return;
860                 }
861                 nb_txd = res->value;
862         } else {
863                 printf("Unknown parameter\n");
864                 return;
865         }
866
867         init_port_config();
868
869         cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
870 }
871
872 cmdline_parse_token_string_t cmd_config_rx_tx_port =
873         TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
874 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
875         TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
876 cmdline_parse_token_string_t cmd_config_rx_tx_all =
877         TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
878 cmdline_parse_token_string_t cmd_config_rx_tx_name =
879         TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
880                                                 "rxq#txq#rxd#txd");
881 cmdline_parse_token_num_t cmd_config_rx_tx_value =
882         TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
883
884 cmdline_parse_inst_t cmd_config_rx_tx = {
885         .f = cmd_config_rx_tx_parsed,
886         .data = NULL,
887         .help_str = "port config all rxq|txq|rxd|txd value",
888         .tokens = {
889                 (void *)&cmd_config_rx_tx_port,
890                 (void *)&cmd_config_rx_tx_keyword,
891                 (void *)&cmd_config_rx_tx_all,
892                 (void *)&cmd_config_rx_tx_name,
893                 (void *)&cmd_config_rx_tx_value,
894                 NULL,
895         },
896 };
897
898 /* *** config max packet length *** */
899 struct cmd_config_max_pkt_len_result {
900         cmdline_fixed_string_t port;
901         cmdline_fixed_string_t keyword;
902         cmdline_fixed_string_t all;
903         cmdline_fixed_string_t name;
904         uint32_t value;
905 };
906
907 static void
908 cmd_config_max_pkt_len_parsed(void *parsed_result,
909                                 __attribute__((unused)) struct cmdline *cl,
910                                 __attribute__((unused)) void *data)
911 {
912         struct cmd_config_max_pkt_len_result *res = parsed_result;
913
914         if (!all_ports_stopped()) {
915                 printf("Please stop all ports first\n");
916                 return;
917         }
918
919         if (!strcmp(res->name, "max-pkt-len")) {
920                 if (res->value < ETHER_MIN_LEN) {
921                         printf("max-pkt-len can not be less than %d\n",
922                                                         ETHER_MIN_LEN);
923                         return;
924                 }
925                 if (res->value == rx_mode.max_rx_pkt_len)
926                         return;
927
928                 rx_mode.max_rx_pkt_len = res->value;
929                 if (res->value > ETHER_MAX_LEN)
930                         rx_mode.jumbo_frame = 1;
931                 else
932                         rx_mode.jumbo_frame = 0;
933         } else {
934                 printf("Unknown parameter\n");
935                 return;
936         }
937
938         init_port_config();
939
940         cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
941 }
942
943 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
944         TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
945                                                                 "port");
946 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
947         TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
948                                                                 "config");
949 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
950         TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
951                                                                 "all");
952 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
953         TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
954                                                                 "max-pkt-len");
955 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
956         TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
957                                                                 UINT32);
958
959 cmdline_parse_inst_t cmd_config_max_pkt_len = {
960         .f = cmd_config_max_pkt_len_parsed,
961         .data = NULL,
962         .help_str = "port config all max-pkt-len value",
963         .tokens = {
964                 (void *)&cmd_config_max_pkt_len_port,
965                 (void *)&cmd_config_max_pkt_len_keyword,
966                 (void *)&cmd_config_max_pkt_len_all,
967                 (void *)&cmd_config_max_pkt_len_name,
968                 (void *)&cmd_config_max_pkt_len_value,
969                 NULL,
970         },
971 };
972
973 /* *** configure rx mode *** */
974 struct cmd_config_rx_mode_flag {
975         cmdline_fixed_string_t port;
976         cmdline_fixed_string_t keyword;
977         cmdline_fixed_string_t all;
978         cmdline_fixed_string_t name;
979         cmdline_fixed_string_t value;
980 };
981
982 static void
983 cmd_config_rx_mode_flag_parsed(void *parsed_result,
984                                 __attribute__((unused)) struct cmdline *cl,
985                                 __attribute__((unused)) void *data)
986 {
987         struct cmd_config_rx_mode_flag *res = parsed_result;
988
989         if (!all_ports_stopped()) {
990                 printf("Please stop all ports first\n");
991                 return;
992         }
993
994         if (!strcmp(res->name, "crc-strip")) {
995                 if (!strcmp(res->value, "on"))
996                         rx_mode.hw_strip_crc = 1;
997                 else if (!strcmp(res->value, "off"))
998                         rx_mode.hw_strip_crc = 0;
999                 else {
1000                         printf("Unknown parameter\n");
1001                         return;
1002                 }
1003         } else if (!strcmp(res->name, "rx-cksum")) {
1004                 if (!strcmp(res->value, "on"))
1005                         rx_mode.hw_ip_checksum = 1;
1006                 else if (!strcmp(res->value, "off"))
1007                         rx_mode.hw_ip_checksum = 0;
1008                 else {
1009                         printf("Unknown parameter\n");
1010                         return;
1011                 }
1012         } else if (!strcmp(res->name, "hw-vlan")) {
1013                 if (!strcmp(res->value, "on")) {
1014                         rx_mode.hw_vlan_filter = 1;
1015                         rx_mode.hw_vlan_strip  = 1;
1016                 }
1017                 else if (!strcmp(res->value, "off")) {
1018                         rx_mode.hw_vlan_filter = 0;
1019                         rx_mode.hw_vlan_strip  = 0;
1020                 }
1021                 else {
1022                         printf("Unknown parameter\n");
1023                         return;
1024                 }
1025         } else if (!strcmp(res->name, "drop-en")) {
1026                 if (!strcmp(res->value, "on"))
1027                         rx_drop_en = 1;
1028                 else if (!strcmp(res->value, "off"))
1029                         rx_drop_en = 0;
1030                 else {
1031                         printf("Unknown parameter\n");
1032                         return;
1033                 }
1034         } else {
1035                 printf("Unknown parameter\n");
1036                 return;
1037         }
1038
1039         init_port_config();
1040
1041         cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1042 }
1043
1044 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1045         TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1046 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1047         TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1048                                                                 "config");
1049 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1050         TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1051 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1052         TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1053                                         "crc-strip#rx-cksum#hw-vlan");
1054 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1055         TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1056                                                         "on#off");
1057
1058 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1059         .f = cmd_config_rx_mode_flag_parsed,
1060         .data = NULL,
1061         .help_str = "port config all crc-strip|rx-cksum|hw-vlan on|off",
1062         .tokens = {
1063                 (void *)&cmd_config_rx_mode_flag_port,
1064                 (void *)&cmd_config_rx_mode_flag_keyword,
1065                 (void *)&cmd_config_rx_mode_flag_all,
1066                 (void *)&cmd_config_rx_mode_flag_name,
1067                 (void *)&cmd_config_rx_mode_flag_value,
1068                 NULL,
1069         },
1070 };
1071
1072 /* *** configure rss *** */
1073 struct cmd_config_rss {
1074         cmdline_fixed_string_t port;
1075         cmdline_fixed_string_t keyword;
1076         cmdline_fixed_string_t all;
1077         cmdline_fixed_string_t name;
1078         cmdline_fixed_string_t value;
1079 };
1080
1081 static void
1082 cmd_config_rss_parsed(void *parsed_result,
1083                         __attribute__((unused)) struct cmdline *cl,
1084                         __attribute__((unused)) void *data)
1085 {
1086         struct cmd_config_rss *res = parsed_result;
1087
1088         if (!all_ports_stopped()) {
1089                 printf("Please stop all ports first\n");
1090                 return;
1091         }
1092
1093         if (!strcmp(res->value, "ip"))
1094                 rss_hf = ETH_RSS_IPV4 | ETH_RSS_IPV6;
1095         else if (!strcmp(res->value, "udp"))
1096                 rss_hf = ETH_RSS_IPV4 | ETH_RSS_IPV6 | ETH_RSS_IPV4_UDP;
1097         else if (!strcmp(res->value, "none"))
1098                 rss_hf = 0;
1099         else {
1100                 printf("Unknown parameter\n");
1101                 return;
1102         }
1103
1104         init_port_config();
1105
1106         cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1107 }
1108
1109 cmdline_parse_token_string_t cmd_config_rss_port =
1110         TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1111 cmdline_parse_token_string_t cmd_config_rss_keyword =
1112         TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1113 cmdline_parse_token_string_t cmd_config_rss_all =
1114         TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1115 cmdline_parse_token_string_t cmd_config_rss_name =
1116         TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1117 cmdline_parse_token_string_t cmd_config_rss_value =
1118         TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, "ip#udp#none");
1119
1120 cmdline_parse_inst_t cmd_config_rss = {
1121         .f = cmd_config_rss_parsed,
1122         .data = NULL,
1123         .help_str = "port config all rss ip|udp|none",
1124         .tokens = {
1125                 (void *)&cmd_config_rss_port,
1126                 (void *)&cmd_config_rss_keyword,
1127                 (void *)&cmd_config_rss_all,
1128                 (void *)&cmd_config_rss_name,
1129                 (void *)&cmd_config_rss_value,
1130                 NULL,
1131         },
1132 };
1133
1134 /* *** Configure RSS RETA *** */
1135 struct cmd_config_rss_reta {
1136         cmdline_fixed_string_t port;
1137         cmdline_fixed_string_t keyword;
1138         uint8_t port_id;
1139         cmdline_fixed_string_t name;
1140         cmdline_fixed_string_t list_name;
1141         cmdline_fixed_string_t list_of_items;
1142 };
1143
1144 static int
1145 parse_reta_config(const char *str, struct rte_eth_rss_reta *reta_conf)
1146 {
1147         int i;
1148         unsigned size;
1149         uint8_t hash_index;
1150         uint8_t nb_queue;
1151         char s[256];
1152         const char *p, *p0 = str;
1153         char *end;
1154         enum fieldnames {
1155                 FLD_HASH_INDEX = 0,
1156                 FLD_QUEUE,
1157                 _NUM_FLD
1158         };
1159         unsigned long int_fld[_NUM_FLD];
1160         char *str_fld[_NUM_FLD];
1161
1162         while ((p = strchr(p0,'(')) != NULL) {
1163                 ++p;
1164                 if((p0 = strchr(p,')')) == NULL)
1165                         return -1;
1166
1167                 size = p0 - p;
1168                 if(size >= sizeof(s))
1169                         return -1;
1170
1171                 rte_snprintf(s, sizeof(s), "%.*s", size, p);
1172                 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1173                         return -1;
1174                 for (i = 0; i < _NUM_FLD; i++) {
1175                         errno = 0;
1176                         int_fld[i] = strtoul(str_fld[i], &end, 0);
1177                         if (errno != 0 || end == str_fld[i] || int_fld[i] > 255)
1178                                 return -1;
1179                 }
1180
1181                 hash_index = (uint8_t)int_fld[FLD_HASH_INDEX];
1182                 nb_queue = (uint8_t)int_fld[FLD_QUEUE];
1183
1184                 if (hash_index >= ETH_RSS_RETA_NUM_ENTRIES) {
1185                         printf("Invalid RETA hash index=%d",hash_index);
1186                         return -1;
1187                 }
1188
1189                 if (hash_index < ETH_RSS_RETA_NUM_ENTRIES/2)
1190                         reta_conf->mask_lo |= (1ULL << hash_index);
1191                 else
1192                         reta_conf->mask_hi |= (1ULL << (hash_index - ETH_RSS_RETA_NUM_ENTRIES/2));
1193
1194                 reta_conf->reta[hash_index] = nb_queue;
1195         }
1196
1197         return 0;
1198 }
1199
1200 static void
1201 cmd_set_rss_reta_parsed(void *parsed_result,
1202                                 __attribute__((unused)) struct cmdline *cl,
1203                                 __attribute__((unused)) void *data)
1204 {
1205         int ret;
1206         struct rte_eth_rss_reta reta_conf;
1207         struct cmd_config_rss_reta *res = parsed_result;
1208
1209         memset(&reta_conf,0,sizeof(struct rte_eth_rss_reta));
1210         if (!strcmp(res->list_name, "reta")) {
1211                 if (parse_reta_config(res->list_of_items, &reta_conf)) {
1212                         printf("Invalid RSS Redirection Table config entered\n");
1213                         return;
1214                 }
1215                 ret = rte_eth_dev_rss_reta_update(res->port_id, &reta_conf);
1216                 if (ret != 0)
1217                         printf("Bad redirection table parameter, return code = %d \n",ret);
1218         }
1219 }
1220
1221 cmdline_parse_token_string_t cmd_config_rss_reta_port =
1222         TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
1223 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
1224         TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
1225 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
1226         TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
1227 cmdline_parse_token_string_t cmd_config_rss_reta_name =
1228         TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
1229 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
1230         TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
1231 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
1232         TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
1233                                  NULL);
1234 cmdline_parse_inst_t cmd_config_rss_reta = {
1235         .f = cmd_set_rss_reta_parsed,
1236         .data = NULL,
1237         .help_str = "port config X rss reta (hash,queue)[,(hash,queue)]",
1238         .tokens = {
1239                 (void *)&cmd_config_rss_reta_port,
1240                 (void *)&cmd_config_rss_reta_keyword,
1241                 (void *)&cmd_config_rss_reta_port_id,
1242                 (void *)&cmd_config_rss_reta_name,
1243                 (void *)&cmd_config_rss_reta_list_name,
1244                 (void *)&cmd_config_rss_reta_list_of_items,
1245                 NULL,
1246         },
1247 };
1248
1249 /* *** SHOW PORT INFO *** */
1250 struct cmd_showport_reta {
1251         cmdline_fixed_string_t show;
1252         cmdline_fixed_string_t port;
1253         uint8_t port_id;
1254         cmdline_fixed_string_t rss;
1255         cmdline_fixed_string_t reta;
1256         uint64_t mask_lo;
1257         uint64_t mask_hi;
1258 };
1259
1260 static void cmd_showport_reta_parsed(void *parsed_result,
1261                                 __attribute__((unused)) struct cmdline *cl,
1262                                 __attribute__((unused)) void *data)
1263 {
1264         struct cmd_showport_reta *res = parsed_result;
1265         struct rte_eth_rss_reta reta_conf;
1266
1267         if ((res->mask_lo == 0) && (res->mask_hi == 0)) {
1268                 printf("Invalid RSS Redirection Table config entered\n");
1269                 return;
1270         }
1271
1272         reta_conf.mask_lo = res->mask_lo;
1273         reta_conf.mask_hi = res->mask_hi;
1274
1275         port_rss_reta_info(res->port_id,&reta_conf);
1276 }
1277
1278 cmdline_parse_token_string_t cmd_showport_reta_show =
1279         TOKEN_STRING_INITIALIZER(struct  cmd_showport_reta, show, "show");
1280 cmdline_parse_token_string_t cmd_showport_reta_port =
1281         TOKEN_STRING_INITIALIZER(struct  cmd_showport_reta, port, "port");
1282 cmdline_parse_token_num_t cmd_showport_reta_port_id =
1283         TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
1284 cmdline_parse_token_string_t cmd_showport_reta_rss =
1285         TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
1286 cmdline_parse_token_string_t cmd_showport_reta_reta =
1287         TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
1288 cmdline_parse_token_num_t cmd_showport_reta_mask_lo =
1289         TOKEN_NUM_INITIALIZER(struct cmd_showport_reta,mask_lo,UINT64);
1290 cmdline_parse_token_num_t cmd_showport_reta_mask_hi =
1291         TOKEN_NUM_INITIALIZER(struct cmd_showport_reta,mask_hi,UINT64);
1292
1293 cmdline_parse_inst_t cmd_showport_reta = {
1294         .f = cmd_showport_reta_parsed,
1295         .data = NULL,
1296         .help_str = "show port X rss reta mask_lo mask_hi (X = port number)\n\
1297                         (mask_lo and mask_hi is UINT64)",
1298         .tokens = {
1299                 (void *)&cmd_showport_reta_show,
1300                 (void *)&cmd_showport_reta_port,
1301                 (void *)&cmd_showport_reta_port_id,
1302                 (void *)&cmd_showport_reta_rss,
1303                 (void *)&cmd_showport_reta_reta,
1304                 (void *)&cmd_showport_reta_mask_lo,
1305                 (void *)&cmd_showport_reta_mask_hi,
1306                 NULL,
1307         },
1308 };
1309
1310 /* *** Configure DCB *** */
1311 struct cmd_config_dcb {
1312         cmdline_fixed_string_t port;
1313         cmdline_fixed_string_t config;
1314         uint8_t port_id;
1315         cmdline_fixed_string_t dcb;
1316         cmdline_fixed_string_t vt;
1317         cmdline_fixed_string_t vt_en;
1318         uint8_t num_tcs;
1319         cmdline_fixed_string_t pfc;
1320         cmdline_fixed_string_t pfc_en;
1321 };
1322
1323 static void
1324 cmd_config_dcb_parsed(void *parsed_result,
1325                         __attribute__((unused)) struct cmdline *cl,
1326                         __attribute__((unused)) void *data)
1327 {
1328         struct cmd_config_dcb *res = parsed_result;
1329         struct dcb_config dcb_conf;
1330         portid_t port_id = res->port_id;
1331         struct rte_port *port;
1332
1333         port = &ports[port_id];
1334         /** Check if the port is not started **/
1335         if (port->port_status != RTE_PORT_STOPPED) {
1336                 printf("Please stop port %d first\n",port_id);
1337                 return;
1338         }
1339
1340         dcb_conf.num_tcs = (enum rte_eth_nb_tcs) res->num_tcs;
1341         if ((dcb_conf.num_tcs != ETH_4_TCS) && (dcb_conf.num_tcs != ETH_8_TCS)){
1342                 printf("The invalid number of traffic class,only 4 or 8 allowed\n");
1343                 return;
1344         }
1345
1346         /* DCB in VT mode */
1347         if (!strncmp(res->vt_en, "on",2))
1348                 dcb_conf.dcb_mode = DCB_VT_ENABLED;
1349         else
1350                 dcb_conf.dcb_mode = DCB_ENABLED;
1351
1352         if (!strncmp(res->pfc_en, "on",2)) {
1353                 dcb_conf.pfc_en = 1;
1354         }
1355         else
1356                 dcb_conf.pfc_en = 0;
1357
1358         if (init_port_dcb_config(port_id,&dcb_conf) != 0) {
1359                 printf("Cannot initialize network ports\n");
1360                 return;
1361         }
1362
1363         cmd_reconfig_device_queue(port_id, 1, 1);
1364 }
1365
1366 cmdline_parse_token_string_t cmd_config_dcb_port =
1367         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
1368 cmdline_parse_token_string_t cmd_config_dcb_config =
1369         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
1370 cmdline_parse_token_num_t cmd_config_dcb_port_id =
1371         TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
1372 cmdline_parse_token_string_t cmd_config_dcb_dcb =
1373         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
1374 cmdline_parse_token_string_t cmd_config_dcb_vt =
1375         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
1376 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
1377         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
1378 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
1379         TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
1380 cmdline_parse_token_string_t cmd_config_dcb_pfc=
1381         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
1382 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
1383         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
1384
1385 cmdline_parse_inst_t cmd_config_dcb = {
1386         .f = cmd_config_dcb_parsed,
1387         .data = NULL,
1388         .help_str = "port config port-id dcb vt on|off nb-tcs pfc on|off",
1389         .tokens = {
1390                 (void *)&cmd_config_dcb_port,
1391                 (void *)&cmd_config_dcb_config,
1392                 (void *)&cmd_config_dcb_port_id,
1393                 (void *)&cmd_config_dcb_dcb,
1394                 (void *)&cmd_config_dcb_vt,
1395                 (void *)&cmd_config_dcb_vt_en,
1396                 (void *)&cmd_config_dcb_num_tcs,
1397                 (void *)&cmd_config_dcb_pfc,
1398                 (void *)&cmd_config_dcb_pfc_en,
1399                 NULL,
1400         },
1401 };
1402
1403 /* *** configure number of packets per burst *** */
1404 struct cmd_config_burst {
1405         cmdline_fixed_string_t port;
1406         cmdline_fixed_string_t keyword;
1407         cmdline_fixed_string_t all;
1408         cmdline_fixed_string_t name;
1409         uint16_t value;
1410 };
1411
1412 static void
1413 cmd_config_burst_parsed(void *parsed_result,
1414                         __attribute__((unused)) struct cmdline *cl,
1415                         __attribute__((unused)) void *data)
1416 {
1417         struct cmd_config_burst *res = parsed_result;
1418
1419         if (!all_ports_stopped()) {
1420                 printf("Please stop all ports first\n");
1421                 return;
1422         }
1423
1424         if (!strcmp(res->name, "burst")) {
1425                 if (res->value < 1 || res->value > MAX_PKT_BURST) {
1426                         printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
1427                         return;
1428                 }
1429                 nb_pkt_per_burst = res->value;
1430         } else {
1431                 printf("Unknown parameter\n");
1432                 return;
1433         }
1434
1435         init_port_config();
1436
1437         cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1438 }
1439
1440 cmdline_parse_token_string_t cmd_config_burst_port =
1441         TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
1442 cmdline_parse_token_string_t cmd_config_burst_keyword =
1443         TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
1444 cmdline_parse_token_string_t cmd_config_burst_all =
1445         TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
1446 cmdline_parse_token_string_t cmd_config_burst_name =
1447         TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
1448 cmdline_parse_token_num_t cmd_config_burst_value =
1449         TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
1450
1451 cmdline_parse_inst_t cmd_config_burst = {
1452         .f = cmd_config_burst_parsed,
1453         .data = NULL,
1454         .help_str = "port config all burst value",
1455         .tokens = {
1456                 (void *)&cmd_config_burst_port,
1457                 (void *)&cmd_config_burst_keyword,
1458                 (void *)&cmd_config_burst_all,
1459                 (void *)&cmd_config_burst_name,
1460                 (void *)&cmd_config_burst_value,
1461                 NULL,
1462         },
1463 };
1464
1465 /* *** configure rx/tx queues *** */
1466 struct cmd_config_thresh {
1467         cmdline_fixed_string_t port;
1468         cmdline_fixed_string_t keyword;
1469         cmdline_fixed_string_t all;
1470         cmdline_fixed_string_t name;
1471         uint8_t value;
1472 };
1473
1474 static void
1475 cmd_config_thresh_parsed(void *parsed_result,
1476                         __attribute__((unused)) struct cmdline *cl,
1477                         __attribute__((unused)) void *data)
1478 {
1479         struct cmd_config_thresh *res = parsed_result;
1480
1481         if (!all_ports_stopped()) {
1482                 printf("Please stop all ports first\n");
1483                 return;
1484         }
1485
1486         if (!strcmp(res->name, "txpt"))
1487                 tx_thresh.pthresh = res->value;
1488         else if(!strcmp(res->name, "txht"))
1489                 tx_thresh.hthresh = res->value;
1490         else if(!strcmp(res->name, "txwt"))
1491                 tx_thresh.wthresh = res->value;
1492         else if(!strcmp(res->name, "rxpt"))
1493                 rx_thresh.pthresh = res->value;
1494         else if(!strcmp(res->name, "rxht"))
1495                 rx_thresh.hthresh = res->value;
1496         else if(!strcmp(res->name, "rxwt"))
1497                 rx_thresh.wthresh = res->value;
1498         else {
1499                 printf("Unknown parameter\n");
1500                 return;
1501         }
1502
1503         init_port_config();
1504
1505         cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1506 }
1507
1508 cmdline_parse_token_string_t cmd_config_thresh_port =
1509         TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
1510 cmdline_parse_token_string_t cmd_config_thresh_keyword =
1511         TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
1512 cmdline_parse_token_string_t cmd_config_thresh_all =
1513         TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
1514 cmdline_parse_token_string_t cmd_config_thresh_name =
1515         TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
1516                                 "txpt#txht#txwt#rxpt#rxht#rxwt");
1517 cmdline_parse_token_num_t cmd_config_thresh_value =
1518         TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
1519
1520 cmdline_parse_inst_t cmd_config_thresh = {
1521         .f = cmd_config_thresh_parsed,
1522         .data = NULL,
1523         .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt value",
1524         .tokens = {
1525                 (void *)&cmd_config_thresh_port,
1526                 (void *)&cmd_config_thresh_keyword,
1527                 (void *)&cmd_config_thresh_all,
1528                 (void *)&cmd_config_thresh_name,
1529                 (void *)&cmd_config_thresh_value,
1530                 NULL,
1531         },
1532 };
1533
1534 /* *** configure free/rs threshold *** */
1535 struct cmd_config_threshold {
1536         cmdline_fixed_string_t port;
1537         cmdline_fixed_string_t keyword;
1538         cmdline_fixed_string_t all;
1539         cmdline_fixed_string_t name;
1540         uint16_t value;
1541 };
1542
1543 static void
1544 cmd_config_threshold_parsed(void *parsed_result,
1545                         __attribute__((unused)) struct cmdline *cl,
1546                         __attribute__((unused)) void *data)
1547 {
1548         struct cmd_config_threshold *res = parsed_result;
1549
1550         if (!all_ports_stopped()) {
1551                 printf("Please stop all ports first\n");
1552                 return;
1553         }
1554
1555         if (!strcmp(res->name, "txfreet"))
1556                 tx_free_thresh = res->value;
1557         else if (!strcmp(res->name, "txrst"))
1558                 tx_rs_thresh = res->value;
1559         else if (!strcmp(res->name, "rxfreet"))
1560                 rx_free_thresh = res->value;
1561         else {
1562                 printf("Unknown parameter\n");
1563                 return;
1564         }
1565
1566         init_port_config();
1567
1568         cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1569 }
1570
1571 cmdline_parse_token_string_t cmd_config_threshold_port =
1572         TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
1573 cmdline_parse_token_string_t cmd_config_threshold_keyword =
1574         TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
1575                                                                 "config");
1576 cmdline_parse_token_string_t cmd_config_threshold_all =
1577         TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
1578 cmdline_parse_token_string_t cmd_config_threshold_name =
1579         TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
1580                                                 "txfreet#txrst#rxfreet");
1581 cmdline_parse_token_num_t cmd_config_threshold_value =
1582         TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
1583
1584 cmdline_parse_inst_t cmd_config_threshold = {
1585         .f = cmd_config_threshold_parsed,
1586         .data = NULL,
1587         .help_str = "port config all txfreet|txrst|rxfreet value",
1588         .tokens = {
1589                 (void *)&cmd_config_threshold_port,
1590                 (void *)&cmd_config_threshold_keyword,
1591                 (void *)&cmd_config_threshold_all,
1592                 (void *)&cmd_config_threshold_name,
1593                 (void *)&cmd_config_threshold_value,
1594                 NULL,
1595         },
1596 };
1597
1598 /* *** stop *** */
1599 struct cmd_stop_result {
1600         cmdline_fixed_string_t stop;
1601 };
1602
1603 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
1604                             __attribute__((unused)) struct cmdline *cl,
1605                             __attribute__((unused)) void *data)
1606 {
1607         stop_packet_forwarding();
1608 }
1609
1610 cmdline_parse_token_string_t cmd_stop_stop =
1611         TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
1612
1613 cmdline_parse_inst_t cmd_stop = {
1614         .f = cmd_stop_parsed,
1615         .data = NULL,
1616         .help_str = "stop - stop packet forwarding",
1617         .tokens = {
1618                 (void *)&cmd_stop_stop,
1619                 NULL,
1620         },
1621 };
1622
1623 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
1624
1625 static unsigned int
1626 parse_item_list(char* str, const char* item_name, unsigned int max_items,
1627                 unsigned int *parsed_items, int check_unique_values)
1628 {
1629         unsigned int nb_item;
1630         unsigned int value;
1631         unsigned int i;
1632         unsigned int j;
1633         int value_ok;
1634         char c;
1635
1636         /*
1637          * First parse all items in the list and store their value.
1638          */
1639         value = 0;
1640         nb_item = 0;
1641         value_ok = 0;
1642         for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
1643                 c = str[i];
1644                 if ((c >= '0') && (c <= '9')) {
1645                         value = (unsigned int) (value * 10 + (c - '0'));
1646                         value_ok = 1;
1647                         continue;
1648                 }
1649                 if (c != ',') {
1650                         printf("character %c is not a decimal digit\n", c);
1651                         return (0);
1652                 }
1653                 if (! value_ok) {
1654                         printf("No valid value before comma\n");
1655                         return (0);
1656                 }
1657                 if (nb_item < max_items) {
1658                         parsed_items[nb_item] = value;
1659                         value_ok = 0;
1660                         value = 0;
1661                 }
1662                 nb_item++;
1663         }
1664         if (nb_item >= max_items) {
1665                 printf("Number of %s = %u > %u (maximum items)\n",
1666                        item_name, nb_item + 1, max_items);
1667                 return (0);
1668         }
1669         parsed_items[nb_item++] = value;
1670         if (! check_unique_values)
1671                 return (nb_item);
1672
1673         /*
1674          * Then, check that all values in the list are differents.
1675          * No optimization here...
1676          */
1677         for (i = 0; i < nb_item; i++) {
1678                 for (j = i + 1; j < nb_item; j++) {
1679                         if (parsed_items[j] == parsed_items[i]) {
1680                                 printf("duplicated %s %u at index %u and %u\n",
1681                                        item_name, parsed_items[i], i, j);
1682                                 return (0);
1683                         }
1684                 }
1685         }
1686         return (nb_item);
1687 }
1688
1689 struct cmd_set_list_result {
1690         cmdline_fixed_string_t cmd_keyword;
1691         cmdline_fixed_string_t list_name;
1692         cmdline_fixed_string_t list_of_items;
1693 };
1694
1695 static void cmd_set_list_parsed(void *parsed_result,
1696                                 __attribute__((unused)) struct cmdline *cl,
1697                                 __attribute__((unused)) void *data)
1698 {
1699         struct cmd_set_list_result *res;
1700         union {
1701                 unsigned int lcorelist[RTE_MAX_LCORE];
1702                 unsigned int portlist[RTE_MAX_ETHPORTS];
1703         } parsed_items;
1704         unsigned int nb_item;
1705
1706         res = parsed_result;
1707         if (!strcmp(res->list_name, "corelist")) {
1708                 nb_item = parse_item_list(res->list_of_items, "core",
1709                                           RTE_MAX_LCORE,
1710                                           parsed_items.lcorelist, 1);
1711                 if (nb_item > 0)
1712                         set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
1713                 return;
1714         }
1715         if (!strcmp(res->list_name, "portlist")) {
1716                 nb_item = parse_item_list(res->list_of_items, "port",
1717                                           RTE_MAX_ETHPORTS,
1718                                           parsed_items.portlist, 1);
1719                 if (nb_item > 0)
1720                         set_fwd_ports_list(parsed_items.portlist, nb_item);
1721         }
1722 }
1723
1724 cmdline_parse_token_string_t cmd_set_list_keyword =
1725         TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
1726                                  "set");
1727 cmdline_parse_token_string_t cmd_set_list_name =
1728         TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
1729                                  "corelist#portlist");
1730 cmdline_parse_token_string_t cmd_set_list_of_items =
1731         TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
1732                                  NULL);
1733
1734 cmdline_parse_inst_t cmd_set_fwd_list = {
1735         .f = cmd_set_list_parsed,
1736         .data = NULL,
1737         .help_str = "set corelist|portlist x[,y]*",
1738         .tokens = {
1739                 (void *)&cmd_set_list_keyword,
1740                 (void *)&cmd_set_list_name,
1741                 (void *)&cmd_set_list_of_items,
1742                 NULL,
1743         },
1744 };
1745
1746 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
1747
1748 struct cmd_setmask_result {
1749         cmdline_fixed_string_t set;
1750         cmdline_fixed_string_t mask;
1751         uint64_t hexavalue;
1752 };
1753
1754 static void cmd_set_mask_parsed(void *parsed_result,
1755                                 __attribute__((unused)) struct cmdline *cl,
1756                                 __attribute__((unused)) void *data)
1757 {
1758         struct cmd_setmask_result *res = parsed_result;
1759
1760         if (!strcmp(res->mask, "coremask"))
1761                 set_fwd_lcores_mask(res->hexavalue);
1762         else if (!strcmp(res->mask, "portmask"))
1763                 set_fwd_ports_mask(res->hexavalue);
1764 }
1765
1766 cmdline_parse_token_string_t cmd_setmask_set =
1767         TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
1768 cmdline_parse_token_string_t cmd_setmask_mask =
1769         TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
1770                                  "coremask#portmask");
1771 cmdline_parse_token_num_t cmd_setmask_value =
1772         TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
1773
1774 cmdline_parse_inst_t cmd_set_fwd_mask = {
1775         .f = cmd_set_mask_parsed,
1776         .data = NULL,
1777         .help_str = "set coremask|portmask hexadecimal value",
1778         .tokens = {
1779                 (void *)&cmd_setmask_set,
1780                 (void *)&cmd_setmask_mask,
1781                 (void *)&cmd_setmask_value,
1782                 NULL,
1783         },
1784 };
1785
1786 /*
1787  * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
1788  */
1789 struct cmd_set_result {
1790         cmdline_fixed_string_t set;
1791         cmdline_fixed_string_t what;
1792         uint16_t value;
1793 };
1794
1795 static void cmd_set_parsed(void *parsed_result,
1796                            __attribute__((unused)) struct cmdline *cl,
1797                            __attribute__((unused)) void *data)
1798 {
1799         struct cmd_set_result *res = parsed_result;
1800         if (!strcmp(res->what, "nbport"))
1801                 set_fwd_ports_number(res->value);
1802         else if (!strcmp(res->what, "nbcore"))
1803                 set_fwd_lcores_number(res->value);
1804         else if (!strcmp(res->what, "burst"))
1805                 set_nb_pkt_per_burst(res->value);
1806         else if (!strcmp(res->what, "verbose"))
1807                 set_verbose_level(res->value);
1808 }
1809
1810 cmdline_parse_token_string_t cmd_set_set =
1811         TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
1812 cmdline_parse_token_string_t cmd_set_what =
1813         TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
1814                                  "nbport#nbcore#burst#verbose");
1815 cmdline_parse_token_num_t cmd_set_value =
1816         TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
1817
1818 cmdline_parse_inst_t cmd_set_numbers = {
1819         .f = cmd_set_parsed,
1820         .data = NULL,
1821         .help_str = "set nbport|nbcore|burst|verbose value",
1822         .tokens = {
1823                 (void *)&cmd_set_set,
1824                 (void *)&cmd_set_what,
1825                 (void *)&cmd_set_value,
1826                 NULL,
1827         },
1828 };
1829
1830 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
1831
1832 struct cmd_set_txpkts_result {
1833         cmdline_fixed_string_t cmd_keyword;
1834         cmdline_fixed_string_t txpkts;
1835         cmdline_fixed_string_t seg_lengths;
1836 };
1837
1838 static void
1839 cmd_set_txpkts_parsed(void *parsed_result,
1840                       __attribute__((unused)) struct cmdline *cl,
1841                       __attribute__((unused)) void *data)
1842 {
1843         struct cmd_set_txpkts_result *res;
1844         unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
1845         unsigned int nb_segs;
1846
1847         res = parsed_result;
1848         nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
1849                                   RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
1850         if (nb_segs > 0)
1851                 set_tx_pkt_segments(seg_lengths, nb_segs);
1852 }
1853
1854 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
1855         TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
1856                                  cmd_keyword, "set");
1857 cmdline_parse_token_string_t cmd_set_txpkts_name =
1858         TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
1859                                  txpkts, "txpkts");
1860 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
1861         TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
1862                                  seg_lengths, NULL);
1863
1864 cmdline_parse_inst_t cmd_set_txpkts = {
1865         .f = cmd_set_txpkts_parsed,
1866         .data = NULL,
1867         .help_str = "set txpkts x[,y]*",
1868         .tokens = {
1869                 (void *)&cmd_set_txpkts_keyword,
1870                 (void *)&cmd_set_txpkts_name,
1871                 (void *)&cmd_set_txpkts_lengths,
1872                 NULL,
1873         },
1874 };
1875
1876 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
1877 struct cmd_rx_vlan_filter_all_result {
1878         cmdline_fixed_string_t rx_vlan;
1879         cmdline_fixed_string_t what;
1880         cmdline_fixed_string_t all;
1881         uint8_t port_id;
1882 };
1883
1884 static void
1885 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
1886                               __attribute__((unused)) struct cmdline *cl,
1887                               __attribute__((unused)) void *data)
1888 {
1889         struct cmd_rx_vlan_filter_all_result *res = parsed_result;
1890
1891         if (!strcmp(res->what, "add"))
1892                 rx_vlan_all_filter_set(res->port_id, 1);
1893         else
1894                 rx_vlan_all_filter_set(res->port_id, 0);
1895 }
1896
1897 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
1898         TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
1899                                  rx_vlan, "rx_vlan");
1900 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
1901         TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
1902                                  what, "add#rm");
1903 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
1904         TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
1905                                  all, "all");
1906 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
1907         TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
1908                               port_id, UINT8);
1909
1910 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
1911         .f = cmd_rx_vlan_filter_all_parsed,
1912         .data = NULL,
1913         .help_str = "add/remove all identifiers to/from the set of VLAN "
1914         "Identifiers filtered by a port",
1915         .tokens = {
1916                 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
1917                 (void *)&cmd_rx_vlan_filter_all_what,
1918                 (void *)&cmd_rx_vlan_filter_all_all,
1919                 (void *)&cmd_rx_vlan_filter_all_portid,
1920                 NULL,
1921         },
1922 };
1923
1924 /* *** VLAN OFFLOAD SET ON A PORT *** */
1925 struct cmd_vlan_offload_result {
1926         cmdline_fixed_string_t vlan;
1927         cmdline_fixed_string_t set;
1928         cmdline_fixed_string_t what;
1929         cmdline_fixed_string_t on;
1930         cmdline_fixed_string_t port_id;
1931 };
1932
1933 static void
1934 cmd_vlan_offload_parsed(void *parsed_result,
1935                           __attribute__((unused)) struct cmdline *cl,
1936                           __attribute__((unused)) void *data)
1937 {
1938         int on;
1939         struct cmd_vlan_offload_result *res = parsed_result;
1940         char *str;
1941         int i, len = 0;
1942         portid_t port_id = 0;
1943         unsigned int tmp;
1944
1945         str = res->port_id;
1946         len = strnlen(str, STR_TOKEN_SIZE);
1947         i = 0;
1948         /* Get port_id first */
1949         while(i < len){
1950                 if(str[i] == ',')
1951                         break;
1952
1953                 i++;
1954         }
1955         str[i]='\0';
1956         tmp = strtoul(str, NULL, 0);
1957         /* If port_id greater that what portid_t can represent, return */
1958         if(tmp >= RTE_MAX_ETHPORTS)
1959                 return;
1960         port_id = (portid_t)tmp;
1961
1962         if (!strcmp(res->on, "on"))
1963                 on = 1;
1964         else
1965                 on = 0;
1966
1967         if (!strcmp(res->what, "strip"))
1968                 rx_vlan_strip_set(port_id,  on);
1969         else if(!strcmp(res->what, "stripq")){
1970                 uint16_t queue_id = 0;
1971
1972                 /* No queue_id, return */
1973                 if(i + 1 >= len)
1974                         return;
1975                 tmp = strtoul(str + i + 1, NULL, 0);
1976                 /* If queue_id greater that what 16-bits can represent, return */
1977                 if(tmp > 0xffff)
1978                         return;
1979
1980                 queue_id = (uint16_t)tmp;
1981                 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
1982         }
1983         else if (!strcmp(res->what, "filter"))
1984                 rx_vlan_filter_set(port_id, on);
1985         else
1986                 vlan_extend_set(port_id, on);
1987
1988         return;
1989 }
1990
1991 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
1992         TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
1993                                  vlan, "vlan");
1994 cmdline_parse_token_string_t cmd_vlan_offload_set =
1995         TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
1996                                  set, "set");
1997 cmdline_parse_token_string_t cmd_vlan_offload_what =
1998         TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
1999                                  what, "strip#filter#qinq#stripq");
2000 cmdline_parse_token_string_t cmd_vlan_offload_on =
2001         TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2002                               on, "on#off");
2003 cmdline_parse_token_string_t cmd_vlan_offload_portid =
2004         TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2005                               port_id, NULL);
2006
2007 cmdline_parse_inst_t cmd_vlan_offload = {
2008         .f = cmd_vlan_offload_parsed,
2009         .data = NULL,
2010         .help_str = "set strip|filter|qinq|stripq on|off port_id[,queue_id], filter/strip for rx side"
2011         " qinq(extended) for both rx/tx sides ",
2012         .tokens = {
2013                 (void *)&cmd_vlan_offload_vlan,
2014                 (void *)&cmd_vlan_offload_set,
2015                 (void *)&cmd_vlan_offload_what,
2016                 (void *)&cmd_vlan_offload_on,
2017                 (void *)&cmd_vlan_offload_portid,
2018                 NULL,
2019         },
2020 };
2021
2022 /* *** VLAN TPID SET ON A PORT *** */
2023 struct cmd_vlan_tpid_result {
2024         cmdline_fixed_string_t vlan;
2025         cmdline_fixed_string_t set;
2026         cmdline_fixed_string_t what;
2027         uint16_t tp_id;
2028         uint8_t port_id;
2029 };
2030
2031 static void
2032 cmd_vlan_tpid_parsed(void *parsed_result,
2033                           __attribute__((unused)) struct cmdline *cl,
2034                           __attribute__((unused)) void *data)
2035 {
2036         struct cmd_vlan_tpid_result *res = parsed_result;
2037         vlan_tpid_set(res->port_id, res->tp_id);
2038         return;
2039 }
2040
2041 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
2042         TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2043                                  vlan, "vlan");
2044 cmdline_parse_token_string_t cmd_vlan_tpid_set =
2045         TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2046                                  set, "set");
2047 cmdline_parse_token_string_t cmd_vlan_tpid_what =
2048         TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2049                                  what, "tpid");
2050 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
2051         TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2052                               tp_id, UINT16);
2053 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
2054         TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2055                               port_id, UINT8);
2056
2057 cmdline_parse_inst_t cmd_vlan_tpid = {
2058         .f = cmd_vlan_tpid_parsed,
2059         .data = NULL,
2060         .help_str = "set tpid tp_id port_id, set the Outer VLAN Ether type",
2061         .tokens = {
2062                 (void *)&cmd_vlan_tpid_vlan,
2063                 (void *)&cmd_vlan_tpid_set,
2064                 (void *)&cmd_vlan_tpid_what,
2065                 (void *)&cmd_vlan_tpid_tpid,
2066                 (void *)&cmd_vlan_tpid_portid,
2067                 NULL,
2068         },
2069 };
2070
2071 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
2072 struct cmd_rx_vlan_filter_result {
2073         cmdline_fixed_string_t rx_vlan;
2074         cmdline_fixed_string_t what;
2075         uint16_t vlan_id;
2076         uint8_t port_id;
2077 };
2078
2079 static void
2080 cmd_rx_vlan_filter_parsed(void *parsed_result,
2081                           __attribute__((unused)) struct cmdline *cl,
2082                           __attribute__((unused)) void *data)
2083 {
2084         struct cmd_rx_vlan_filter_result *res = parsed_result;
2085
2086         if (!strcmp(res->what, "add"))
2087                 rx_vft_set(res->port_id, res->vlan_id, 1);
2088         else
2089                 rx_vft_set(res->port_id, res->vlan_id, 0);
2090 }
2091
2092 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
2093         TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2094                                  rx_vlan, "rx_vlan");
2095 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
2096         TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2097                                  what, "add#rm");
2098 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
2099         TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2100                               vlan_id, UINT16);
2101 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
2102         TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2103                               port_id, UINT8);
2104
2105 cmdline_parse_inst_t cmd_rx_vlan_filter = {
2106         .f = cmd_rx_vlan_filter_parsed,
2107         .data = NULL,
2108         .help_str = "add/remove a VLAN identifier to/from the set of VLAN "
2109         "Identifiers filtered by a port",
2110         .tokens = {
2111                 (void *)&cmd_rx_vlan_filter_rx_vlan,
2112                 (void *)&cmd_rx_vlan_filter_what,
2113                 (void *)&cmd_rx_vlan_filter_vlanid,
2114                 (void *)&cmd_rx_vlan_filter_portid,
2115                 NULL,
2116         },
2117 };
2118
2119 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2120 struct cmd_tx_vlan_set_result {
2121         cmdline_fixed_string_t tx_vlan;
2122         cmdline_fixed_string_t set;
2123         uint16_t vlan_id;
2124         uint8_t port_id;
2125 };
2126
2127 static void
2128 cmd_tx_vlan_set_parsed(void *parsed_result,
2129                        __attribute__((unused)) struct cmdline *cl,
2130                        __attribute__((unused)) void *data)
2131 {
2132         struct cmd_tx_vlan_set_result *res = parsed_result;
2133         tx_vlan_set(res->port_id, res->vlan_id);
2134 }
2135
2136 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
2137         TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2138                                  tx_vlan, "tx_vlan");
2139 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
2140         TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2141                                  set, "set");
2142 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
2143         TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2144                               vlan_id, UINT16);
2145 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
2146         TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2147                               port_id, UINT8);
2148
2149 cmdline_parse_inst_t cmd_tx_vlan_set = {
2150         .f = cmd_tx_vlan_set_parsed,
2151         .data = NULL,
2152         .help_str = "enable hardware insertion of a VLAN header with a given "
2153         "TAG Identifier in packets sent on a port",
2154         .tokens = {
2155                 (void *)&cmd_tx_vlan_set_tx_vlan,
2156                 (void *)&cmd_tx_vlan_set_set,
2157                 (void *)&cmd_tx_vlan_set_vlanid,
2158                 (void *)&cmd_tx_vlan_set_portid,
2159                 NULL,
2160         },
2161 };
2162
2163 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2164 struct cmd_tx_vlan_reset_result {
2165         cmdline_fixed_string_t tx_vlan;
2166         cmdline_fixed_string_t reset;
2167         uint8_t port_id;
2168 };
2169
2170 static void
2171 cmd_tx_vlan_reset_parsed(void *parsed_result,
2172                          __attribute__((unused)) struct cmdline *cl,
2173                          __attribute__((unused)) void *data)
2174 {
2175         struct cmd_tx_vlan_reset_result *res = parsed_result;
2176
2177         tx_vlan_reset(res->port_id);
2178 }
2179
2180 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
2181         TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2182                                  tx_vlan, "tx_vlan");
2183 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
2184         TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2185                                  reset, "reset");
2186 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
2187         TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
2188                               port_id, UINT8);
2189
2190 cmdline_parse_inst_t cmd_tx_vlan_reset = {
2191         .f = cmd_tx_vlan_reset_parsed,
2192         .data = NULL,
2193         .help_str = "disable hardware insertion of a VLAN header in packets "
2194         "sent on a port",
2195         .tokens = {
2196                 (void *)&cmd_tx_vlan_reset_tx_vlan,
2197                 (void *)&cmd_tx_vlan_reset_reset,
2198                 (void *)&cmd_tx_vlan_reset_portid,
2199                 NULL,
2200         },
2201 };
2202
2203
2204 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
2205 struct cmd_tx_cksum_set_result {
2206         cmdline_fixed_string_t tx_cksum;
2207         cmdline_fixed_string_t set;
2208         uint8_t cksum_mask;
2209         uint8_t port_id;
2210 };
2211
2212 static void
2213 cmd_tx_cksum_set_parsed(void *parsed_result,
2214                        __attribute__((unused)) struct cmdline *cl,
2215                        __attribute__((unused)) void *data)
2216 {
2217         struct cmd_tx_cksum_set_result *res = parsed_result;
2218
2219         tx_cksum_set(res->port_id, res->cksum_mask);
2220 }
2221
2222 cmdline_parse_token_string_t cmd_tx_cksum_set_tx_cksum =
2223         TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
2224                                 tx_cksum, "tx_checksum");
2225 cmdline_parse_token_string_t cmd_tx_cksum_set_set =
2226         TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
2227                                 set, "set");
2228 cmdline_parse_token_num_t cmd_tx_cksum_set_cksum_mask =
2229         TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
2230                                 cksum_mask, UINT8);
2231 cmdline_parse_token_num_t cmd_tx_cksum_set_portid =
2232         TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
2233                                 port_id, UINT8);
2234
2235 cmdline_parse_inst_t cmd_tx_cksum_set = {
2236         .f = cmd_tx_cksum_set_parsed,
2237         .data = NULL,
2238         .help_str = "enable hardware insertion of L3/L4checksum with a given "
2239         "mask in packets sent on a port, the bit mapping is given as, Bit 0 for ip"
2240         "Bit 1 for UDP, Bit 2 for TCP, Bit 3 for SCTP",
2241         .tokens = {
2242                 (void *)&cmd_tx_cksum_set_tx_cksum,
2243                 (void *)&cmd_tx_cksum_set_set,
2244                 (void *)&cmd_tx_cksum_set_cksum_mask,
2245                 (void *)&cmd_tx_cksum_set_portid,
2246                 NULL,
2247         },
2248 };
2249
2250 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
2251 struct cmd_set_flush_rx {
2252         cmdline_fixed_string_t set;
2253         cmdline_fixed_string_t flush_rx;
2254         cmdline_fixed_string_t mode;
2255 };
2256
2257 static void
2258 cmd_set_flush_rx_parsed(void *parsed_result,
2259                 __attribute__((unused)) struct cmdline *cl,
2260                 __attribute__((unused)) void *data)
2261 {
2262         struct cmd_set_flush_rx *res = parsed_result;
2263         no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
2264 }
2265
2266 cmdline_parse_token_string_t cmd_setflushrx_set =
2267         TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2268                         set, "set");
2269 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
2270         TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2271                         flush_rx, "flush_rx");
2272 cmdline_parse_token_string_t cmd_setflushrx_mode =
2273         TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2274                         mode, "on#off");
2275
2276
2277 cmdline_parse_inst_t cmd_set_flush_rx = {
2278         .f = cmd_set_flush_rx_parsed,
2279         .help_str = "set flush_rx on|off: enable/disable flush on rx streams",
2280         .data = NULL,
2281         .tokens = {
2282                 (void *)&cmd_setflushrx_set,
2283                 (void *)&cmd_setflushrx_flush_rx,
2284                 (void *)&cmd_setflushrx_mode,
2285                 NULL,
2286         },
2287 };
2288
2289 /* *** SET FORWARDING MODE *** */
2290 struct cmd_set_fwd_mode_result {
2291         cmdline_fixed_string_t set;
2292         cmdline_fixed_string_t fwd;
2293         cmdline_fixed_string_t mode;
2294 };
2295
2296 static void cmd_set_fwd_mode_parsed(void *parsed_result,
2297                                     __attribute__((unused)) struct cmdline *cl,
2298                                     __attribute__((unused)) void *data)
2299 {
2300         struct cmd_set_fwd_mode_result *res = parsed_result;
2301
2302         set_pkt_forwarding_mode(res->mode);
2303 }
2304
2305 cmdline_parse_token_string_t cmd_setfwd_set =
2306         TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
2307 cmdline_parse_token_string_t cmd_setfwd_fwd =
2308         TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
2309 cmdline_parse_token_string_t cmd_setfwd_mode =
2310         TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
2311 #ifdef RTE_LIBRTE_IEEE1588
2312                                  "io#mac#rxonly#txonly#csum#ieee1588");
2313 #else
2314                                  "io#mac#rxonly#txonly#csum");
2315 #endif
2316
2317 cmdline_parse_inst_t cmd_set_fwd_mode = {
2318         .f = cmd_set_fwd_mode_parsed,
2319         .data = NULL,
2320 #ifdef RTE_LIBRTE_IEEE1588
2321         .help_str = "set fwd io|mac|rxonly|txonly|csum|ieee1588 - set IO, MAC,"
2322         " RXONLY, TXONLY, CSUM or IEEE1588 packet forwarding mode",
2323 #else
2324         .help_str = "set fwd io|mac|rxonly|txonly|csum - set IO, MAC,"
2325         " RXONLY, CSUM or TXONLY packet forwarding mode",
2326 #endif
2327         .tokens = {
2328                 (void *)&cmd_setfwd_set,
2329                 (void *)&cmd_setfwd_fwd,
2330                 (void *)&cmd_setfwd_mode,
2331                 NULL,
2332         },
2333 };
2334
2335 /* *** SET PROMISC MODE *** */
2336 struct cmd_set_promisc_mode_result {
2337         cmdline_fixed_string_t set;
2338         cmdline_fixed_string_t promisc;
2339         cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
2340         uint8_t port_num;                /* valid if "allports" argument == 0 */
2341         cmdline_fixed_string_t mode;
2342 };
2343
2344 static void cmd_set_promisc_mode_parsed(void *parsed_result,
2345                                         __attribute__((unused)) struct cmdline *cl,
2346                                         void *allports)
2347 {
2348         struct cmd_set_promisc_mode_result *res = parsed_result;
2349         int enable;
2350         portid_t i;
2351
2352         if (!strcmp(res->mode, "on"))
2353                 enable = 1;
2354         else
2355                 enable = 0;
2356
2357         /* all ports */
2358         if (allports) {
2359                 for (i = 0; i < nb_ports; i++) {
2360                         if (enable)
2361                                 rte_eth_promiscuous_enable(i);
2362                         else
2363                                 rte_eth_promiscuous_disable(i);
2364                 }
2365         }
2366         else {
2367                 if (enable)
2368                         rte_eth_promiscuous_enable(res->port_num);
2369                 else
2370                         rte_eth_promiscuous_disable(res->port_num);
2371         }
2372 }
2373
2374 cmdline_parse_token_string_t cmd_setpromisc_set =
2375         TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
2376 cmdline_parse_token_string_t cmd_setpromisc_promisc =
2377         TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
2378                                  "promisc");
2379 cmdline_parse_token_string_t cmd_setpromisc_portall =
2380         TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
2381                                  "all");
2382 cmdline_parse_token_num_t cmd_setpromisc_portnum =
2383         TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
2384                               UINT8);
2385 cmdline_parse_token_string_t cmd_setpromisc_mode =
2386         TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
2387                                  "on#off");
2388
2389 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
2390         .f = cmd_set_promisc_mode_parsed,
2391         .data = (void *)1,
2392         .help_str = "set promisc all on|off: set promisc mode for all ports",
2393         .tokens = {
2394                 (void *)&cmd_setpromisc_set,
2395                 (void *)&cmd_setpromisc_promisc,
2396                 (void *)&cmd_setpromisc_portall,
2397                 (void *)&cmd_setpromisc_mode,
2398                 NULL,
2399         },
2400 };
2401
2402 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
2403         .f = cmd_set_promisc_mode_parsed,
2404         .data = (void *)0,
2405         .help_str = "set promisc X on|off: set promisc mode on port X",
2406         .tokens = {
2407                 (void *)&cmd_setpromisc_set,
2408                 (void *)&cmd_setpromisc_promisc,
2409                 (void *)&cmd_setpromisc_portnum,
2410                 (void *)&cmd_setpromisc_mode,
2411                 NULL,
2412         },
2413 };
2414
2415 /* *** SET ALLMULTI MODE *** */
2416 struct cmd_set_allmulti_mode_result {
2417         cmdline_fixed_string_t set;
2418         cmdline_fixed_string_t allmulti;
2419         cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
2420         uint8_t port_num;                /* valid if "allports" argument == 0 */
2421         cmdline_fixed_string_t mode;
2422 };
2423
2424 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
2425                                         __attribute__((unused)) struct cmdline *cl,
2426                                         void *allports)
2427 {
2428         struct cmd_set_allmulti_mode_result *res = parsed_result;
2429         int enable;
2430         portid_t i;
2431
2432         if (!strcmp(res->mode, "on"))
2433                 enable = 1;
2434         else
2435                 enable = 0;
2436
2437         /* all ports */
2438         if (allports) {
2439                 for (i = 0; i < nb_ports; i++) {
2440                         if (enable)
2441                                 rte_eth_allmulticast_enable(i);
2442                         else
2443                                 rte_eth_allmulticast_disable(i);
2444                 }
2445         }
2446         else {
2447                 if (enable)
2448                         rte_eth_allmulticast_enable(res->port_num);
2449                 else
2450                         rte_eth_allmulticast_disable(res->port_num);
2451         }
2452 }
2453
2454 cmdline_parse_token_string_t cmd_setallmulti_set =
2455         TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
2456 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
2457         TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
2458                                  "allmulti");
2459 cmdline_parse_token_string_t cmd_setallmulti_portall =
2460         TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
2461                                  "all");
2462 cmdline_parse_token_num_t cmd_setallmulti_portnum =
2463         TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
2464                               UINT8);
2465 cmdline_parse_token_string_t cmd_setallmulti_mode =
2466         TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
2467                                  "on#off");
2468
2469 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
2470         .f = cmd_set_allmulti_mode_parsed,
2471         .data = (void *)1,
2472         .help_str = "set allmulti all on|off: set allmulti mode for all ports",
2473         .tokens = {
2474                 (void *)&cmd_setallmulti_set,
2475                 (void *)&cmd_setallmulti_allmulti,
2476                 (void *)&cmd_setallmulti_portall,
2477                 (void *)&cmd_setallmulti_mode,
2478                 NULL,
2479         },
2480 };
2481
2482 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
2483         .f = cmd_set_allmulti_mode_parsed,
2484         .data = (void *)0,
2485         .help_str = "set allmulti X on|off: set allmulti mode on port X",
2486         .tokens = {
2487                 (void *)&cmd_setallmulti_set,
2488                 (void *)&cmd_setallmulti_allmulti,
2489                 (void *)&cmd_setallmulti_portnum,
2490                 (void *)&cmd_setallmulti_mode,
2491                 NULL,
2492         },
2493 };
2494
2495 /* *** ADD/REMOVE A PKT FILTER *** */
2496 struct cmd_pkt_filter_result {
2497         cmdline_fixed_string_t pkt_filter;
2498         uint8_t  port_id;
2499         cmdline_fixed_string_t protocol;
2500         cmdline_fixed_string_t src;
2501         cmdline_ipaddr_t ip_src;
2502         uint16_t port_src;
2503         cmdline_fixed_string_t dst;
2504         cmdline_ipaddr_t ip_dst;
2505         uint16_t port_dst;
2506         cmdline_fixed_string_t flexbytes;
2507         uint16_t flexbytes_value;
2508         cmdline_fixed_string_t vlan;
2509         uint16_t  vlan_id;
2510         cmdline_fixed_string_t queue;
2511         int8_t  queue_id;
2512         cmdline_fixed_string_t soft;
2513         uint8_t  soft_id;
2514 };
2515
2516 static void
2517 cmd_pkt_filter_parsed(void *parsed_result,
2518                           __attribute__((unused)) struct cmdline *cl,
2519                           __attribute__((unused)) void *data)
2520 {
2521         struct rte_fdir_filter fdir_filter;
2522         struct cmd_pkt_filter_result *res = parsed_result;
2523
2524         memset(&fdir_filter, 0, sizeof(struct rte_fdir_filter));
2525
2526         if (res->ip_src.family == AF_INET)
2527                 fdir_filter.ip_src.ipv4_addr = res->ip_src.addr.ipv4.s_addr;
2528         else
2529                 memcpy(&(fdir_filter.ip_src.ipv6_addr),
2530                        &(res->ip_src.addr.ipv6),
2531                        sizeof(struct in6_addr));
2532
2533         if (res->ip_dst.family == AF_INET)
2534                 fdir_filter.ip_dst.ipv4_addr = res->ip_dst.addr.ipv4.s_addr;
2535         else
2536                 memcpy(&(fdir_filter.ip_dst.ipv6_addr),
2537                        &(res->ip_dst.addr.ipv6),
2538                        sizeof(struct in6_addr));
2539
2540         fdir_filter.port_dst = rte_cpu_to_be_16(res->port_dst);
2541         fdir_filter.port_src = rte_cpu_to_be_16(res->port_src);
2542
2543         if (!strcmp(res->protocol, "udp"))
2544                 fdir_filter.l4type = RTE_FDIR_L4TYPE_UDP;
2545         else if (!strcmp(res->protocol, "tcp"))
2546                 fdir_filter.l4type = RTE_FDIR_L4TYPE_TCP;
2547         else if (!strcmp(res->protocol, "sctp"))
2548                 fdir_filter.l4type = RTE_FDIR_L4TYPE_SCTP;
2549         else /* default only IP */
2550                 fdir_filter.l4type = RTE_FDIR_L4TYPE_NONE;
2551
2552         if (res->ip_dst.family == AF_INET6)
2553                 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV6;
2554         else
2555                 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV4;
2556
2557         fdir_filter.vlan_id    = rte_cpu_to_be_16(res->vlan_id);
2558         fdir_filter.flex_bytes = rte_cpu_to_be_16(res->flexbytes_value);
2559
2560         if (!strcmp(res->pkt_filter, "add_signature_filter"))
2561                 fdir_add_signature_filter(res->port_id, res->queue_id,
2562                                           &fdir_filter);
2563         else if (!strcmp(res->pkt_filter, "upd_signature_filter"))
2564                 fdir_update_signature_filter(res->port_id, res->queue_id,
2565                                              &fdir_filter);
2566         else if (!strcmp(res->pkt_filter, "rm_signature_filter"))
2567                 fdir_remove_signature_filter(res->port_id, &fdir_filter);
2568         else if (!strcmp(res->pkt_filter, "add_perfect_filter"))
2569                 fdir_add_perfect_filter(res->port_id, res->soft_id,
2570                                         res->queue_id,
2571                                         (uint8_t) (res->queue_id < 0),
2572                                         &fdir_filter);
2573         else if (!strcmp(res->pkt_filter, "upd_perfect_filter"))
2574                 fdir_update_perfect_filter(res->port_id, res->soft_id,
2575                                            res->queue_id,
2576                                            (uint8_t) (res->queue_id < 0),
2577                                            &fdir_filter);
2578         else if (!strcmp(res->pkt_filter, "rm_perfect_filter"))
2579                 fdir_remove_perfect_filter(res->port_id, res->soft_id,
2580                                            &fdir_filter);
2581
2582 }
2583
2584
2585 cmdline_parse_token_num_t cmd_pkt_filter_port_id =
2586         TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2587                               port_id, UINT8);
2588 cmdline_parse_token_string_t cmd_pkt_filter_protocol =
2589         TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2590                                  protocol, "ip#tcp#udp#sctp");
2591 cmdline_parse_token_string_t cmd_pkt_filter_src =
2592         TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2593                                  src, "src");
2594 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_src =
2595         TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
2596                                  ip_src);
2597 cmdline_parse_token_num_t cmd_pkt_filter_port_src =
2598         TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2599                               port_src, UINT16);
2600 cmdline_parse_token_string_t cmd_pkt_filter_dst =
2601         TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2602                                  dst, "dst");
2603 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_dst =
2604         TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
2605                                  ip_dst);
2606 cmdline_parse_token_num_t cmd_pkt_filter_port_dst =
2607         TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2608                               port_dst, UINT16);
2609 cmdline_parse_token_string_t cmd_pkt_filter_flexbytes =
2610         TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2611                                  flexbytes, "flexbytes");
2612 cmdline_parse_token_num_t cmd_pkt_filter_flexbytes_value =
2613         TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2614                               flexbytes_value, UINT16);
2615 cmdline_parse_token_string_t cmd_pkt_filter_vlan =
2616         TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2617                                  vlan, "vlan");
2618 cmdline_parse_token_num_t cmd_pkt_filter_vlan_id =
2619         TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2620                               vlan_id, UINT16);
2621 cmdline_parse_token_string_t cmd_pkt_filter_queue =
2622         TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2623                                  queue, "queue");
2624 cmdline_parse_token_num_t cmd_pkt_filter_queue_id =
2625         TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2626                               queue_id, INT8);
2627 cmdline_parse_token_string_t cmd_pkt_filter_soft =
2628         TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2629                                  soft, "soft");
2630 cmdline_parse_token_num_t cmd_pkt_filter_soft_id =
2631         TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2632                               soft_id, UINT16);
2633
2634
2635 cmdline_parse_token_string_t cmd_pkt_filter_add_signature_filter =
2636         TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2637                                  pkt_filter, "add_signature_filter");
2638 cmdline_parse_inst_t cmd_add_signature_filter = {
2639         .f = cmd_pkt_filter_parsed,
2640         .data = NULL,
2641         .help_str = "add a signature filter",
2642         .tokens = {
2643                 (void *)&cmd_pkt_filter_add_signature_filter,
2644                 (void *)&cmd_pkt_filter_port_id,
2645                 (void *)&cmd_pkt_filter_protocol,
2646                 (void *)&cmd_pkt_filter_src,
2647                 (void *)&cmd_pkt_filter_ip_src,
2648                 (void *)&cmd_pkt_filter_port_src,
2649                 (void *)&cmd_pkt_filter_dst,
2650                 (void *)&cmd_pkt_filter_ip_dst,
2651                 (void *)&cmd_pkt_filter_port_dst,
2652                 (void *)&cmd_pkt_filter_flexbytes,
2653                 (void *)&cmd_pkt_filter_flexbytes_value,
2654                 (void *)&cmd_pkt_filter_vlan,
2655                 (void *)&cmd_pkt_filter_vlan_id,
2656                 (void *)&cmd_pkt_filter_queue,
2657                 (void *)&cmd_pkt_filter_queue_id,
2658                 NULL,
2659         },
2660 };
2661
2662
2663 cmdline_parse_token_string_t cmd_pkt_filter_upd_signature_filter =
2664         TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2665                                  pkt_filter, "upd_signature_filter");
2666 cmdline_parse_inst_t cmd_upd_signature_filter = {
2667         .f = cmd_pkt_filter_parsed,
2668         .data = NULL,
2669         .help_str = "update a signature filter",
2670         .tokens = {
2671                 (void *)&cmd_pkt_filter_upd_signature_filter,
2672                 (void *)&cmd_pkt_filter_port_id,
2673                 (void *)&cmd_pkt_filter_protocol,
2674                 (void *)&cmd_pkt_filter_src,
2675                 (void *)&cmd_pkt_filter_ip_src,
2676                 (void *)&cmd_pkt_filter_port_src,
2677                 (void *)&cmd_pkt_filter_dst,
2678                 (void *)&cmd_pkt_filter_ip_dst,
2679                 (void *)&cmd_pkt_filter_port_dst,
2680                 (void *)&cmd_pkt_filter_flexbytes,
2681                 (void *)&cmd_pkt_filter_flexbytes_value,
2682                 (void *)&cmd_pkt_filter_vlan,
2683                 (void *)&cmd_pkt_filter_vlan_id,
2684                 (void *)&cmd_pkt_filter_queue,
2685                 (void *)&cmd_pkt_filter_queue_id,
2686                 NULL,
2687         },
2688 };
2689
2690
2691 cmdline_parse_token_string_t cmd_pkt_filter_rm_signature_filter =
2692         TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2693                                  pkt_filter, "rm_signature_filter");
2694 cmdline_parse_inst_t cmd_rm_signature_filter = {
2695         .f = cmd_pkt_filter_parsed,
2696         .data = NULL,
2697         .help_str = "remove a signature filter",
2698         .tokens = {
2699                 (void *)&cmd_pkt_filter_rm_signature_filter,
2700                 (void *)&cmd_pkt_filter_port_id,
2701                 (void *)&cmd_pkt_filter_protocol,
2702                 (void *)&cmd_pkt_filter_src,
2703                 (void *)&cmd_pkt_filter_ip_src,
2704                 (void *)&cmd_pkt_filter_port_src,
2705                 (void *)&cmd_pkt_filter_dst,
2706                 (void *)&cmd_pkt_filter_ip_dst,
2707                 (void *)&cmd_pkt_filter_port_dst,
2708                 (void *)&cmd_pkt_filter_flexbytes,
2709                 (void *)&cmd_pkt_filter_flexbytes_value,
2710                 (void *)&cmd_pkt_filter_vlan,
2711                 (void *)&cmd_pkt_filter_vlan_id,
2712                 NULL
2713                 },
2714 };
2715
2716
2717 cmdline_parse_token_string_t cmd_pkt_filter_add_perfect_filter =
2718         TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2719                                  pkt_filter, "add_perfect_filter");
2720 cmdline_parse_inst_t cmd_add_perfect_filter = {
2721         .f = cmd_pkt_filter_parsed,
2722         .data = NULL,
2723         .help_str = "add a perfect filter",
2724         .tokens = {
2725                 (void *)&cmd_pkt_filter_add_perfect_filter,
2726                 (void *)&cmd_pkt_filter_port_id,
2727                 (void *)&cmd_pkt_filter_protocol,
2728                 (void *)&cmd_pkt_filter_src,
2729                 (void *)&cmd_pkt_filter_ip_src,
2730                 (void *)&cmd_pkt_filter_port_src,
2731                 (void *)&cmd_pkt_filter_dst,
2732                 (void *)&cmd_pkt_filter_ip_dst,
2733                 (void *)&cmd_pkt_filter_port_dst,
2734                 (void *)&cmd_pkt_filter_flexbytes,
2735                 (void *)&cmd_pkt_filter_flexbytes_value,
2736                 (void *)&cmd_pkt_filter_vlan,
2737                 (void *)&cmd_pkt_filter_vlan_id,
2738                 (void *)&cmd_pkt_filter_queue,
2739                 (void *)&cmd_pkt_filter_queue_id,
2740                 (void *)&cmd_pkt_filter_soft,
2741                 (void *)&cmd_pkt_filter_soft_id,
2742                 NULL,
2743         },
2744 };
2745
2746
2747 cmdline_parse_token_string_t cmd_pkt_filter_upd_perfect_filter =
2748         TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2749                                  pkt_filter, "upd_perfect_filter");
2750 cmdline_parse_inst_t cmd_upd_perfect_filter = {
2751         .f = cmd_pkt_filter_parsed,
2752         .data = NULL,
2753         .help_str = "update a perfect filter",
2754         .tokens = {
2755                 (void *)&cmd_pkt_filter_upd_perfect_filter,
2756                 (void *)&cmd_pkt_filter_port_id,
2757                 (void *)&cmd_pkt_filter_protocol,
2758                 (void *)&cmd_pkt_filter_src,
2759                 (void *)&cmd_pkt_filter_ip_src,
2760                 (void *)&cmd_pkt_filter_port_src,
2761                 (void *)&cmd_pkt_filter_dst,
2762                 (void *)&cmd_pkt_filter_ip_dst,
2763                 (void *)&cmd_pkt_filter_port_dst,
2764                 (void *)&cmd_pkt_filter_flexbytes,
2765                 (void *)&cmd_pkt_filter_flexbytes_value,
2766                 (void *)&cmd_pkt_filter_vlan,
2767                 (void *)&cmd_pkt_filter_vlan_id,
2768                 (void *)&cmd_pkt_filter_queue,
2769                 (void *)&cmd_pkt_filter_queue_id,
2770                 (void *)&cmd_pkt_filter_soft,
2771                 (void *)&cmd_pkt_filter_soft_id,
2772                 NULL,
2773         },
2774 };
2775
2776
2777 cmdline_parse_token_string_t cmd_pkt_filter_rm_perfect_filter =
2778         TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2779                                  pkt_filter, "rm_perfect_filter");
2780 cmdline_parse_inst_t cmd_rm_perfect_filter = {
2781         .f = cmd_pkt_filter_parsed,
2782         .data = NULL,
2783         .help_str = "remove a perfect filter",
2784         .tokens = {
2785                 (void *)&cmd_pkt_filter_rm_perfect_filter,
2786                 (void *)&cmd_pkt_filter_port_id,
2787                 (void *)&cmd_pkt_filter_protocol,
2788                 (void *)&cmd_pkt_filter_src,
2789                 (void *)&cmd_pkt_filter_ip_src,
2790                 (void *)&cmd_pkt_filter_port_src,
2791                 (void *)&cmd_pkt_filter_dst,
2792                 (void *)&cmd_pkt_filter_ip_dst,
2793                 (void *)&cmd_pkt_filter_port_dst,
2794                 (void *)&cmd_pkt_filter_flexbytes,
2795                 (void *)&cmd_pkt_filter_flexbytes_value,
2796                 (void *)&cmd_pkt_filter_vlan,
2797                 (void *)&cmd_pkt_filter_vlan_id,
2798                 (void *)&cmd_pkt_filter_soft,
2799                 (void *)&cmd_pkt_filter_soft_id,
2800                 NULL,
2801         },
2802 };
2803
2804 /* *** SETUP MASKS FILTER *** */
2805 struct cmd_pkt_filter_masks_result {
2806         cmdline_fixed_string_t filter_mask;
2807         uint8_t  port_id;
2808         cmdline_fixed_string_t src_mask;
2809         uint32_t ip_src_mask;
2810         uint16_t ipv6_src_mask;
2811         uint16_t port_src_mask;
2812         cmdline_fixed_string_t dst_mask;
2813         uint32_t ip_dst_mask;
2814         uint16_t ipv6_dst_mask;
2815         uint16_t port_dst_mask;
2816         cmdline_fixed_string_t flexbytes;
2817         uint8_t flexbytes_value;
2818         cmdline_fixed_string_t vlan_id;
2819         uint8_t  vlan_id_value;
2820         cmdline_fixed_string_t vlan_prio;
2821         uint8_t  vlan_prio_value;
2822         cmdline_fixed_string_t only_ip_flow;
2823         uint8_t  only_ip_flow_value;
2824         cmdline_fixed_string_t comp_ipv6_dst;
2825         uint8_t  comp_ipv6_dst_value;
2826 };
2827
2828 static void
2829 cmd_pkt_filter_masks_parsed(void *parsed_result,
2830                           __attribute__((unused)) struct cmdline *cl,
2831                           __attribute__((unused)) void *data)
2832 {
2833         struct rte_fdir_masks fdir_masks;
2834         struct cmd_pkt_filter_masks_result *res = parsed_result;
2835
2836         memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
2837
2838         fdir_masks.only_ip_flow  = res->only_ip_flow_value;
2839         fdir_masks.vlan_id       = res->vlan_id_value;
2840         fdir_masks.vlan_prio     = res->vlan_prio_value;
2841         fdir_masks.dst_ipv4_mask = res->ip_dst_mask;
2842         fdir_masks.src_ipv4_mask = res->ip_src_mask;
2843         fdir_masks.src_port_mask = res->port_src_mask;
2844         fdir_masks.dst_port_mask = res->port_dst_mask;
2845         fdir_masks.flexbytes     = res->flexbytes_value;
2846
2847         fdir_set_masks(res->port_id, &fdir_masks);
2848 }
2849
2850 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask =
2851         TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
2852                                  filter_mask, "set_masks_filter");
2853 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_id =
2854         TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2855                               port_id, UINT8);
2856 cmdline_parse_token_string_t cmd_pkt_filter_masks_only_ip_flow =
2857         TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
2858                                  only_ip_flow, "only_ip_flow");
2859 cmdline_parse_token_num_t cmd_pkt_filter_masks_only_ip_flow_value =
2860         TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2861                               only_ip_flow_value, UINT8);
2862 cmdline_parse_token_string_t cmd_pkt_filter_masks_src_mask =
2863         TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
2864                                  src_mask, "src_mask");
2865 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_src_mask =
2866         TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2867                               ip_src_mask, UINT32);
2868 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_src_mask =
2869         TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2870                               port_src_mask, UINT16);
2871 cmdline_parse_token_string_t cmd_pkt_filter_masks_dst_mask =
2872         TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
2873                                  dst_mask, "dst_mask");
2874 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_dst_mask =
2875         TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2876                               ip_dst_mask, UINT32);
2877 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_dst_mask =
2878         TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2879                               port_dst_mask, UINT16);
2880 cmdline_parse_token_string_t cmd_pkt_filter_masks_flexbytes =
2881         TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
2882                                  flexbytes, "flexbytes");
2883 cmdline_parse_token_num_t cmd_pkt_filter_masks_flexbytes_value =
2884         TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2885                               flexbytes_value, UINT8);
2886 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_id =
2887         TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
2888                                  vlan_id, "vlan_id");
2889 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_id_value =
2890         TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2891                               vlan_id_value, UINT8);
2892 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_prio =
2893         TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
2894                                  vlan_prio, "vlan_prio");
2895 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_prio_value =
2896         TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2897                               vlan_prio_value, UINT8);
2898
2899 cmdline_parse_inst_t cmd_set_masks_filter = {
2900         .f = cmd_pkt_filter_masks_parsed,
2901         .data = NULL,
2902         .help_str = "setup masks filter",
2903         .tokens = {
2904                 (void *)&cmd_pkt_filter_masks_filter_mask,
2905                 (void *)&cmd_pkt_filter_masks_port_id,
2906                 (void *)&cmd_pkt_filter_masks_only_ip_flow,
2907                 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
2908                 (void *)&cmd_pkt_filter_masks_src_mask,
2909                 (void *)&cmd_pkt_filter_masks_ip_src_mask,
2910                 (void *)&cmd_pkt_filter_masks_port_src_mask,
2911                 (void *)&cmd_pkt_filter_masks_dst_mask,
2912                 (void *)&cmd_pkt_filter_masks_ip_dst_mask,
2913                 (void *)&cmd_pkt_filter_masks_port_dst_mask,
2914                 (void *)&cmd_pkt_filter_masks_flexbytes,
2915                 (void *)&cmd_pkt_filter_masks_flexbytes_value,
2916                 (void *)&cmd_pkt_filter_masks_vlan_id,
2917                 (void *)&cmd_pkt_filter_masks_vlan_id_value,
2918                 (void *)&cmd_pkt_filter_masks_vlan_prio,
2919                 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
2920                 NULL,
2921         },
2922 };
2923
2924 static void
2925 cmd_pkt_filter_masks_ipv6_parsed(void *parsed_result,
2926                           __attribute__((unused)) struct cmdline *cl,
2927                           __attribute__((unused)) void *data)
2928 {
2929         struct rte_fdir_masks fdir_masks;
2930         struct cmd_pkt_filter_masks_result *res = parsed_result;
2931
2932         memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
2933
2934         fdir_masks.set_ipv6_mask = 1;
2935         fdir_masks.only_ip_flow  = res->only_ip_flow_value;
2936         fdir_masks.vlan_id       = res->vlan_id_value;
2937         fdir_masks.vlan_prio     = res->vlan_prio_value;
2938         fdir_masks.dst_ipv6_mask = res->ipv6_dst_mask;
2939         fdir_masks.src_ipv6_mask = res->ipv6_src_mask;
2940         fdir_masks.src_port_mask = res->port_src_mask;
2941         fdir_masks.dst_port_mask = res->port_dst_mask;
2942         fdir_masks.flexbytes     = res->flexbytes_value;
2943         fdir_masks.comp_ipv6_dst = res->comp_ipv6_dst_value;
2944
2945         fdir_set_masks(res->port_id, &fdir_masks);
2946 }
2947
2948 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask_ipv6 =
2949         TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
2950                                  filter_mask, "set_ipv6_masks_filter");
2951 cmdline_parse_token_num_t cmd_pkt_filter_masks_src_mask_ipv6_value =
2952         TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2953                               ipv6_src_mask, UINT16);
2954 cmdline_parse_token_num_t cmd_pkt_filter_masks_dst_mask_ipv6_value =
2955         TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2956                               ipv6_dst_mask, UINT16);
2957
2958 cmdline_parse_token_string_t cmd_pkt_filter_masks_comp_ipv6_dst =
2959         TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
2960                                  comp_ipv6_dst, "compare_dst");
2961 cmdline_parse_token_num_t cmd_pkt_filter_masks_comp_ipv6_dst_value =
2962         TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2963                               comp_ipv6_dst_value, UINT8);
2964
2965 cmdline_parse_inst_t cmd_set_ipv6_masks_filter = {
2966         .f = cmd_pkt_filter_masks_ipv6_parsed,
2967         .data = NULL,
2968         .help_str = "setup ipv6 masks filter",
2969         .tokens = {
2970                 (void *)&cmd_pkt_filter_masks_filter_mask_ipv6,
2971                 (void *)&cmd_pkt_filter_masks_port_id,
2972                 (void *)&cmd_pkt_filter_masks_only_ip_flow,
2973                 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
2974                 (void *)&cmd_pkt_filter_masks_src_mask,
2975                 (void *)&cmd_pkt_filter_masks_src_mask_ipv6_value,
2976                 (void *)&cmd_pkt_filter_masks_port_src_mask,
2977                 (void *)&cmd_pkt_filter_masks_dst_mask,
2978                 (void *)&cmd_pkt_filter_masks_dst_mask_ipv6_value,
2979                 (void *)&cmd_pkt_filter_masks_port_dst_mask,
2980                 (void *)&cmd_pkt_filter_masks_flexbytes,
2981                 (void *)&cmd_pkt_filter_masks_flexbytes_value,
2982                 (void *)&cmd_pkt_filter_masks_vlan_id,
2983                 (void *)&cmd_pkt_filter_masks_vlan_id_value,
2984                 (void *)&cmd_pkt_filter_masks_vlan_prio,
2985                 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
2986                 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst,
2987                 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst_value,
2988                 NULL,
2989         },
2990 };
2991
2992 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
2993 struct cmd_link_flow_ctrl_set_result {
2994         cmdline_fixed_string_t set;
2995         cmdline_fixed_string_t flow_ctrl;
2996         cmdline_fixed_string_t rx;
2997         cmdline_fixed_string_t rx_lfc_mode;
2998         cmdline_fixed_string_t tx;
2999         cmdline_fixed_string_t tx_lfc_mode;
3000         uint32_t high_water;
3001         uint32_t low_water;
3002         uint16_t pause_time;
3003         uint16_t send_xon;
3004         uint8_t  port_id;
3005 };
3006
3007 static void
3008 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
3009                        __attribute__((unused)) struct cmdline *cl,
3010                        __attribute__((unused)) void *data)
3011 {
3012         struct cmd_link_flow_ctrl_set_result *res = parsed_result;
3013         struct rte_eth_fc_conf fc_conf;
3014         int rx_fc_enable, tx_fc_enable;
3015         int ret;
3016
3017         /*
3018          * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
3019          * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
3020          * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
3021          * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
3022          */
3023         static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
3024                         {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
3025         };
3026
3027         rx_fc_enable = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
3028         tx_fc_enable = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
3029
3030         fc_conf.mode       = rx_tx_onoff_2_lfc_mode[rx_fc_enable][tx_fc_enable];
3031         fc_conf.high_water = res->high_water;
3032         fc_conf.low_water  = res->low_water;
3033         fc_conf.pause_time = res->pause_time;
3034         fc_conf.send_xon   = res->send_xon;
3035
3036         ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
3037         if (ret != 0)
3038                 printf("bad flow contrl parameter, return code = %d \n", ret);
3039 }
3040
3041 cmdline_parse_token_string_t cmd_lfc_set_set =
3042         TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3043                                 set, "set");
3044 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
3045         TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3046                                 flow_ctrl, "flow_ctrl");
3047 cmdline_parse_token_string_t cmd_lfc_set_rx =
3048         TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3049                                 rx, "rx");
3050 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
3051         TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3052                                 rx_lfc_mode, "on#off");
3053 cmdline_parse_token_string_t cmd_lfc_set_tx =
3054         TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3055                                 tx, "tx");
3056 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
3057         TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3058                                 tx_lfc_mode, "on#off");
3059 cmdline_parse_token_num_t cmd_lfc_set_high_water =
3060         TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3061                                 high_water, UINT32);
3062 cmdline_parse_token_num_t cmd_lfc_set_low_water =
3063         TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3064                                 low_water, UINT32);
3065 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
3066         TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3067                                 pause_time, UINT16);
3068 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
3069         TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3070                                 send_xon, UINT16);
3071 cmdline_parse_token_num_t cmd_lfc_set_portid =
3072         TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3073                                 port_id, UINT8);
3074
3075 cmdline_parse_inst_t cmd_link_flow_control_set = {
3076         .f = cmd_link_flow_ctrl_set_parsed,
3077         .data = NULL,
3078         .help_str = "Configure the Ethernet link flow control...",
3079         .tokens = {
3080                 (void *)&cmd_lfc_set_set,
3081                 (void *)&cmd_lfc_set_flow_ctrl,
3082                 (void *)&cmd_lfc_set_rx,
3083                 (void *)&cmd_lfc_set_rx_mode,
3084                 (void *)&cmd_lfc_set_tx,
3085                 (void *)&cmd_lfc_set_tx_mode,
3086                 (void *)&cmd_lfc_set_high_water,
3087                 (void *)&cmd_lfc_set_low_water,
3088                 (void *)&cmd_lfc_set_pause_time,
3089                 (void *)&cmd_lfc_set_send_xon,
3090                 (void *)&cmd_lfc_set_portid,
3091                 NULL,
3092         },
3093 };
3094
3095 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
3096 struct cmd_priority_flow_ctrl_set_result {
3097         cmdline_fixed_string_t set;
3098         cmdline_fixed_string_t pfc_ctrl;
3099         cmdline_fixed_string_t rx;
3100         cmdline_fixed_string_t rx_pfc_mode;
3101         cmdline_fixed_string_t tx;
3102         cmdline_fixed_string_t tx_pfc_mode;
3103         uint32_t high_water;
3104         uint32_t low_water;
3105         uint16_t pause_time;
3106         uint8_t  priority;
3107         uint8_t  port_id;
3108 };
3109
3110 static void
3111 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
3112                        __attribute__((unused)) struct cmdline *cl,
3113                        __attribute__((unused)) void *data)
3114 {
3115         struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
3116         struct rte_eth_pfc_conf pfc_conf;
3117         int rx_fc_enable, tx_fc_enable;
3118         int ret;
3119
3120         /*
3121          * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
3122          * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
3123          * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
3124          * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
3125          */
3126         static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
3127                         {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
3128         };
3129
3130         rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
3131         tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
3132         pfc_conf.fc.mode       = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
3133         pfc_conf.fc.high_water = res->high_water;
3134         pfc_conf.fc.low_water  = res->low_water;
3135         pfc_conf.fc.pause_time = res->pause_time;
3136         pfc_conf.priority      = res->priority;
3137
3138         ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
3139         if (ret != 0)
3140                 printf("bad priority flow contrl parameter, return code = %d \n", ret);
3141 }
3142
3143 cmdline_parse_token_string_t cmd_pfc_set_set =
3144         TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3145                                 set, "set");
3146 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
3147         TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3148                                 pfc_ctrl, "pfc_ctrl");
3149 cmdline_parse_token_string_t cmd_pfc_set_rx =
3150         TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3151                                 rx, "rx");
3152 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
3153         TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3154                                 rx_pfc_mode, "on#off");
3155 cmdline_parse_token_string_t cmd_pfc_set_tx =
3156         TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3157                                 tx, "tx");
3158 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
3159         TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3160                                 tx_pfc_mode, "on#off");
3161 cmdline_parse_token_num_t cmd_pfc_set_high_water =
3162         TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3163                                 high_water, UINT32);
3164 cmdline_parse_token_num_t cmd_pfc_set_low_water =
3165         TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3166                                 low_water, UINT32);
3167 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
3168         TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3169                                 pause_time, UINT16);
3170 cmdline_parse_token_num_t cmd_pfc_set_priority =
3171         TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3172                                 priority, UINT8);
3173 cmdline_parse_token_num_t cmd_pfc_set_portid =
3174         TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3175                                 port_id, UINT8);
3176
3177 cmdline_parse_inst_t cmd_priority_flow_control_set = {
3178         .f = cmd_priority_flow_ctrl_set_parsed,
3179         .data = NULL,
3180         .help_str = "Configure the Ethernet priority flow control: set pfc_ctrl rx on|off\n\
3181                         tx on|off high_water low_water pause_time priority port_id",
3182         .tokens = {
3183                 (void *)&cmd_pfc_set_set,
3184                 (void *)&cmd_pfc_set_flow_ctrl,
3185                 (void *)&cmd_pfc_set_rx,
3186                 (void *)&cmd_pfc_set_rx_mode,
3187                 (void *)&cmd_pfc_set_tx,
3188                 (void *)&cmd_pfc_set_tx_mode,
3189                 (void *)&cmd_pfc_set_high_water,
3190                 (void *)&cmd_pfc_set_low_water,
3191                 (void *)&cmd_pfc_set_pause_time,
3192                 (void *)&cmd_pfc_set_priority,
3193                 (void *)&cmd_pfc_set_portid,
3194                 NULL,
3195         },
3196 };
3197
3198 /* *** RESET CONFIGURATION *** */
3199 struct cmd_reset_result {
3200         cmdline_fixed_string_t reset;
3201         cmdline_fixed_string_t def;
3202 };
3203
3204 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
3205                              struct cmdline *cl,
3206                              __attribute__((unused)) void *data)
3207 {
3208         cmdline_printf(cl, "Reset to default forwarding configuration...\n");
3209         set_def_fwd_config();
3210 }
3211
3212 cmdline_parse_token_string_t cmd_reset_set =
3213         TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
3214 cmdline_parse_token_string_t cmd_reset_def =
3215         TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
3216                                  "default");
3217
3218 cmdline_parse_inst_t cmd_reset = {
3219         .f = cmd_reset_parsed,
3220         .data = NULL,
3221         .help_str = "set default: reset default forwarding configuration",
3222         .tokens = {
3223                 (void *)&cmd_reset_set,
3224                 (void *)&cmd_reset_def,
3225                 NULL,
3226         },
3227 };
3228
3229 /* *** START FORWARDING *** */
3230 struct cmd_start_result {
3231         cmdline_fixed_string_t start;
3232 };
3233
3234 cmdline_parse_token_string_t cmd_start_start =
3235         TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
3236
3237 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
3238                              __attribute__((unused)) struct cmdline *cl,
3239                              __attribute__((unused)) void *data)
3240 {
3241         start_packet_forwarding(0);
3242 }
3243
3244 cmdline_parse_inst_t cmd_start = {
3245         .f = cmd_start_parsed,
3246         .data = NULL,
3247         .help_str = "start packet forwarding",
3248         .tokens = {
3249                 (void *)&cmd_start_start,
3250                 NULL,
3251         },
3252 };
3253
3254 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
3255 struct cmd_start_tx_first_result {
3256         cmdline_fixed_string_t start;
3257         cmdline_fixed_string_t tx_first;
3258 };
3259
3260 static void
3261 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
3262                           __attribute__((unused)) struct cmdline *cl,
3263                           __attribute__((unused)) void *data)
3264 {
3265         start_packet_forwarding(1);
3266 }
3267
3268 cmdline_parse_token_string_t cmd_start_tx_first_start =
3269         TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
3270                                  "start");
3271 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
3272         TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
3273                                  tx_first, "tx_first");
3274
3275 cmdline_parse_inst_t cmd_start_tx_first = {
3276         .f = cmd_start_tx_first_parsed,
3277         .data = NULL,
3278         .help_str = "start packet forwarding, after sending 1 burst of packets",
3279         .tokens = {
3280                 (void *)&cmd_start_tx_first_start,
3281                 (void *)&cmd_start_tx_first_tx_first,
3282                 NULL,
3283         },
3284 };
3285
3286 /* *** SHOW CFG *** */
3287 struct cmd_showcfg_result {
3288         cmdline_fixed_string_t show;
3289         cmdline_fixed_string_t cfg;
3290         cmdline_fixed_string_t what;
3291 };
3292
3293 static void cmd_showcfg_parsed(void *parsed_result,
3294                                __attribute__((unused)) struct cmdline *cl,
3295                                __attribute__((unused)) void *data)
3296 {
3297         struct cmd_showcfg_result *res = parsed_result;
3298         if (!strcmp(res->what, "rxtx"))
3299                 rxtx_config_display();
3300         else if (!strcmp(res->what, "cores"))
3301                 fwd_lcores_config_display();
3302         else if (!strcmp(res->what, "fwd"))
3303                 fwd_config_display();
3304 }
3305
3306 cmdline_parse_token_string_t cmd_showcfg_show =
3307         TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
3308 cmdline_parse_token_string_t cmd_showcfg_port =
3309         TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
3310 cmdline_parse_token_string_t cmd_showcfg_what =
3311         TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
3312                                  "rxtx#cores#fwd");
3313
3314 cmdline_parse_inst_t cmd_showcfg = {
3315         .f = cmd_showcfg_parsed,
3316         .data = NULL,
3317         .help_str = "show config rxtx|cores|fwd",
3318         .tokens = {
3319                 (void *)&cmd_showcfg_show,
3320                 (void *)&cmd_showcfg_port,
3321                 (void *)&cmd_showcfg_what,
3322                 NULL,
3323         },
3324 };
3325
3326 /* *** SHOW ALL PORT INFO *** */
3327 struct cmd_showportall_result {
3328         cmdline_fixed_string_t show;
3329         cmdline_fixed_string_t port;
3330         cmdline_fixed_string_t what;
3331         cmdline_fixed_string_t all;
3332 };
3333
3334 static void cmd_showportall_parsed(void *parsed_result,
3335                                 __attribute__((unused)) struct cmdline *cl,
3336                                 __attribute__((unused)) void *data)
3337 {
3338         portid_t i;
3339
3340         struct cmd_showportall_result *res = parsed_result;
3341         if (!strcmp(res->show, "clear")) {
3342                 if (!strcmp(res->what, "stats"))
3343                         for (i = 0; i < nb_ports; i++)
3344                                 nic_stats_clear(i);
3345         } else if (!strcmp(res->what, "info"))
3346                 for (i = 0; i < nb_ports; i++)
3347                         port_infos_display(i);
3348         else if (!strcmp(res->what, "stats"))
3349                 for (i = 0; i < nb_ports; i++)
3350                         nic_stats_display(i);
3351         else if (!strcmp(res->what, "fdir"))
3352                 for (i = 0; i < nb_ports; i++)
3353                         fdir_get_infos(i);
3354         else if (!strcmp(res->what, "stat_qmap"))
3355                 for (i = 0; i < nb_ports; i++)
3356                         nic_stats_mapping_display(i);
3357 }
3358
3359 cmdline_parse_token_string_t cmd_showportall_show =
3360         TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
3361                                  "show#clear");
3362 cmdline_parse_token_string_t cmd_showportall_port =
3363         TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
3364 cmdline_parse_token_string_t cmd_showportall_what =
3365         TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
3366                                  "info#stats#fdir#stat_qmap");
3367 cmdline_parse_token_string_t cmd_showportall_all =
3368         TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
3369 cmdline_parse_inst_t cmd_showportall = {
3370         .f = cmd_showportall_parsed,
3371         .data = NULL,
3372         .help_str = "show|clear port info|stats|fdir|stat_qmap all",
3373         .tokens = {
3374                 (void *)&cmd_showportall_show,
3375                 (void *)&cmd_showportall_port,
3376                 (void *)&cmd_showportall_what,
3377                 (void *)&cmd_showportall_all,
3378                 NULL,
3379         },
3380 };
3381
3382 /* *** SHOW PORT INFO *** */
3383 struct cmd_showport_result {
3384         cmdline_fixed_string_t show;
3385         cmdline_fixed_string_t port;
3386         cmdline_fixed_string_t what;
3387         uint8_t portnum;
3388 };
3389
3390 static void cmd_showport_parsed(void *parsed_result,
3391                                 __attribute__((unused)) struct cmdline *cl,
3392                                 __attribute__((unused)) void *data)
3393 {
3394         struct cmd_showport_result *res = parsed_result;
3395         if (!strcmp(res->show, "clear")) {
3396                 if (!strcmp(res->what, "stats"))
3397                         nic_stats_clear(res->portnum);
3398         } else if (!strcmp(res->what, "info"))
3399                 port_infos_display(res->portnum);
3400         else if (!strcmp(res->what, "stats"))
3401                 nic_stats_display(res->portnum);
3402         else if (!strcmp(res->what, "fdir"))
3403                  fdir_get_infos(res->portnum);
3404         else if (!strcmp(res->what, "stat_qmap"))
3405                 nic_stats_mapping_display(res->portnum);
3406 }
3407
3408 cmdline_parse_token_string_t cmd_showport_show =
3409         TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
3410                                  "show#clear");
3411 cmdline_parse_token_string_t cmd_showport_port =
3412         TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
3413 cmdline_parse_token_string_t cmd_showport_what =
3414         TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
3415                                  "info#stats#fdir#stat_qmap");
3416 cmdline_parse_token_num_t cmd_showport_portnum =
3417         TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, INT32);
3418
3419 cmdline_parse_inst_t cmd_showport = {
3420         .f = cmd_showport_parsed,
3421         .data = NULL,
3422         .help_str = "show|clear port info|stats|fdir|stat_qmap X (X = port number)",
3423         .tokens = {
3424                 (void *)&cmd_showport_show,
3425                 (void *)&cmd_showport_port,
3426                 (void *)&cmd_showport_what,
3427                 (void *)&cmd_showport_portnum,
3428                 NULL,
3429         },
3430 };
3431
3432 /* *** READ PORT REGISTER *** */
3433 struct cmd_read_reg_result {
3434         cmdline_fixed_string_t read;
3435         cmdline_fixed_string_t reg;
3436         uint8_t port_id;
3437         uint32_t reg_off;
3438 };
3439
3440 static void
3441 cmd_read_reg_parsed(void *parsed_result,
3442                     __attribute__((unused)) struct cmdline *cl,
3443                     __attribute__((unused)) void *data)
3444 {
3445         struct cmd_read_reg_result *res = parsed_result;
3446         port_reg_display(res->port_id, res->reg_off);
3447 }
3448
3449 cmdline_parse_token_string_t cmd_read_reg_read =
3450         TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
3451 cmdline_parse_token_string_t cmd_read_reg_reg =
3452         TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
3453 cmdline_parse_token_num_t cmd_read_reg_port_id =
3454         TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
3455 cmdline_parse_token_num_t cmd_read_reg_reg_off =
3456         TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
3457
3458 cmdline_parse_inst_t cmd_read_reg = {
3459         .f = cmd_read_reg_parsed,
3460         .data = NULL,
3461         .help_str = "read reg port_id reg_off",
3462         .tokens = {
3463                 (void *)&cmd_read_reg_read,
3464                 (void *)&cmd_read_reg_reg,
3465                 (void *)&cmd_read_reg_port_id,
3466                 (void *)&cmd_read_reg_reg_off,
3467                 NULL,
3468         },
3469 };
3470
3471 /* *** READ PORT REGISTER BIT FIELD *** */
3472 struct cmd_read_reg_bit_field_result {
3473         cmdline_fixed_string_t read;
3474         cmdline_fixed_string_t regfield;
3475         uint8_t port_id;
3476         uint32_t reg_off;
3477         uint8_t bit1_pos;
3478         uint8_t bit2_pos;
3479 };
3480
3481 static void
3482 cmd_read_reg_bit_field_parsed(void *parsed_result,
3483                               __attribute__((unused)) struct cmdline *cl,
3484                               __attribute__((unused)) void *data)
3485 {
3486         struct cmd_read_reg_bit_field_result *res = parsed_result;
3487         port_reg_bit_field_display(res->port_id, res->reg_off,
3488                                    res->bit1_pos, res->bit2_pos);
3489 }
3490
3491 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
3492         TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
3493                                  "read");
3494 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
3495         TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
3496                                  regfield, "regfield");
3497 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
3498         TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
3499                               UINT8);
3500 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
3501         TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
3502                               UINT32);
3503 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
3504         TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
3505                               UINT8);
3506 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
3507         TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
3508                               UINT8);
3509
3510 cmdline_parse_inst_t cmd_read_reg_bit_field = {
3511         .f = cmd_read_reg_bit_field_parsed,
3512         .data = NULL,
3513         .help_str = "read regfield port_id reg_off bit_x bit_y "
3514         "(read register bit field between bit_x and bit_y included)",
3515         .tokens = {
3516                 (void *)&cmd_read_reg_bit_field_read,
3517                 (void *)&cmd_read_reg_bit_field_regfield,
3518                 (void *)&cmd_read_reg_bit_field_port_id,
3519                 (void *)&cmd_read_reg_bit_field_reg_off,
3520                 (void *)&cmd_read_reg_bit_field_bit1_pos,
3521                 (void *)&cmd_read_reg_bit_field_bit2_pos,
3522                 NULL,
3523         },
3524 };
3525
3526 /* *** READ PORT REGISTER BIT *** */
3527 struct cmd_read_reg_bit_result {
3528         cmdline_fixed_string_t read;
3529         cmdline_fixed_string_t regbit;
3530         uint8_t port_id;
3531         uint32_t reg_off;
3532         uint8_t bit_pos;
3533 };
3534
3535 static void
3536 cmd_read_reg_bit_parsed(void *parsed_result,
3537                         __attribute__((unused)) struct cmdline *cl,
3538                         __attribute__((unused)) void *data)
3539 {
3540         struct cmd_read_reg_bit_result *res = parsed_result;
3541         port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
3542 }
3543
3544 cmdline_parse_token_string_t cmd_read_reg_bit_read =
3545         TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
3546 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
3547         TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
3548                                  regbit, "regbit");
3549 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
3550         TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
3551 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
3552         TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
3553 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
3554         TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
3555
3556 cmdline_parse_inst_t cmd_read_reg_bit = {
3557         .f = cmd_read_reg_bit_parsed,
3558         .data = NULL,
3559         .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
3560         .tokens = {
3561                 (void *)&cmd_read_reg_bit_read,
3562                 (void *)&cmd_read_reg_bit_regbit,
3563                 (void *)&cmd_read_reg_bit_port_id,
3564                 (void *)&cmd_read_reg_bit_reg_off,
3565                 (void *)&cmd_read_reg_bit_bit_pos,
3566                 NULL,
3567         },
3568 };
3569
3570 /* *** WRITE PORT REGISTER *** */
3571 struct cmd_write_reg_result {
3572         cmdline_fixed_string_t write;
3573         cmdline_fixed_string_t reg;
3574         uint8_t port_id;
3575         uint32_t reg_off;
3576         uint32_t value;
3577 };
3578
3579 static void
3580 cmd_write_reg_parsed(void *parsed_result,
3581                      __attribute__((unused)) struct cmdline *cl,
3582                      __attribute__((unused)) void *data)
3583 {
3584         struct cmd_write_reg_result *res = parsed_result;
3585         port_reg_set(res->port_id, res->reg_off, res->value);
3586 }
3587
3588 cmdline_parse_token_string_t cmd_write_reg_write =
3589         TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
3590 cmdline_parse_token_string_t cmd_write_reg_reg =
3591         TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
3592 cmdline_parse_token_num_t cmd_write_reg_port_id =
3593         TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
3594 cmdline_parse_token_num_t cmd_write_reg_reg_off =
3595         TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
3596 cmdline_parse_token_num_t cmd_write_reg_value =
3597         TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
3598
3599 cmdline_parse_inst_t cmd_write_reg = {
3600         .f = cmd_write_reg_parsed,
3601         .data = NULL,
3602         .help_str = "write reg port_id reg_off reg_value",
3603         .tokens = {
3604                 (void *)&cmd_write_reg_write,
3605                 (void *)&cmd_write_reg_reg,
3606                 (void *)&cmd_write_reg_port_id,
3607                 (void *)&cmd_write_reg_reg_off,
3608                 (void *)&cmd_write_reg_value,
3609                 NULL,
3610         },
3611 };
3612
3613 /* *** WRITE PORT REGISTER BIT FIELD *** */
3614 struct cmd_write_reg_bit_field_result {
3615         cmdline_fixed_string_t write;
3616         cmdline_fixed_string_t regfield;
3617         uint8_t port_id;
3618         uint32_t reg_off;
3619         uint8_t bit1_pos;
3620         uint8_t bit2_pos;
3621         uint32_t value;
3622 };
3623
3624 static void
3625 cmd_write_reg_bit_field_parsed(void *parsed_result,
3626                                __attribute__((unused)) struct cmdline *cl,
3627                                __attribute__((unused)) void *data)
3628 {
3629         struct cmd_write_reg_bit_field_result *res = parsed_result;
3630         port_reg_bit_field_set(res->port_id, res->reg_off,
3631                           res->bit1_pos, res->bit2_pos, res->value);
3632 }
3633
3634 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
3635         TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
3636                                  "write");
3637 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
3638         TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
3639                                  regfield, "regfield");
3640 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
3641         TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
3642                               UINT8);
3643 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
3644         TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
3645                               UINT32);
3646 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
3647         TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
3648                               UINT8);
3649 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
3650         TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
3651                               UINT8);
3652 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
3653         TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
3654                               UINT32);
3655
3656 cmdline_parse_inst_t cmd_write_reg_bit_field = {
3657         .f = cmd_write_reg_bit_field_parsed,
3658         .data = NULL,
3659         .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
3660         "(set register bit field between bit_x and bit_y included)",
3661         .tokens = {
3662                 (void *)&cmd_write_reg_bit_field_write,
3663                 (void *)&cmd_write_reg_bit_field_regfield,
3664                 (void *)&cmd_write_reg_bit_field_port_id,
3665                 (void *)&cmd_write_reg_bit_field_reg_off,
3666                 (void *)&cmd_write_reg_bit_field_bit1_pos,
3667                 (void *)&cmd_write_reg_bit_field_bit2_pos,
3668                 (void *)&cmd_write_reg_bit_field_value,
3669                 NULL,
3670         },
3671 };
3672
3673 /* *** WRITE PORT REGISTER BIT *** */
3674 struct cmd_write_reg_bit_result {
3675         cmdline_fixed_string_t write;
3676         cmdline_fixed_string_t regbit;
3677         uint8_t port_id;
3678         uint32_t reg_off;
3679         uint8_t bit_pos;
3680         uint8_t value;
3681 };
3682
3683 static void
3684 cmd_write_reg_bit_parsed(void *parsed_result,
3685                          __attribute__((unused)) struct cmdline *cl,
3686                          __attribute__((unused)) void *data)
3687 {
3688         struct cmd_write_reg_bit_result *res = parsed_result;
3689         port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
3690 }
3691
3692 cmdline_parse_token_string_t cmd_write_reg_bit_write =
3693         TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
3694                                  "write");
3695 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
3696         TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
3697                                  regbit, "regbit");
3698 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
3699         TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
3700 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
3701         TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
3702 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
3703         TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
3704 cmdline_parse_token_num_t cmd_write_reg_bit_value =
3705         TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
3706
3707 cmdline_parse_inst_t cmd_write_reg_bit = {
3708         .f = cmd_write_reg_bit_parsed,
3709         .data = NULL,
3710         .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
3711         .tokens = {
3712                 (void *)&cmd_write_reg_bit_write,
3713                 (void *)&cmd_write_reg_bit_regbit,
3714                 (void *)&cmd_write_reg_bit_port_id,
3715                 (void *)&cmd_write_reg_bit_reg_off,
3716                 (void *)&cmd_write_reg_bit_bit_pos,
3717                 (void *)&cmd_write_reg_bit_value,
3718                 NULL,
3719         },
3720 };
3721
3722 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
3723 struct cmd_read_rxd_txd_result {
3724         cmdline_fixed_string_t read;
3725         cmdline_fixed_string_t rxd_txd;
3726         uint8_t port_id;
3727         uint16_t queue_id;
3728         uint16_t desc_id;
3729 };
3730
3731 static void
3732 cmd_read_rxd_txd_parsed(void *parsed_result,
3733                         __attribute__((unused)) struct cmdline *cl,
3734                         __attribute__((unused)) void *data)
3735 {
3736         struct cmd_read_rxd_txd_result *res = parsed_result;
3737
3738         if (!strcmp(res->rxd_txd, "rxd"))
3739                 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
3740         else if (!strcmp(res->rxd_txd, "txd"))
3741                 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
3742 }
3743
3744 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
3745         TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
3746 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
3747         TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
3748                                  "rxd#txd");
3749 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
3750         TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
3751 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
3752         TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
3753 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
3754         TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
3755
3756 cmdline_parse_inst_t cmd_read_rxd_txd = {
3757         .f = cmd_read_rxd_txd_parsed,
3758         .data = NULL,
3759         .help_str = "read rxd|txd port_id queue_id rxd_id",
3760         .tokens = {
3761                 (void *)&cmd_read_rxd_txd_read,
3762                 (void *)&cmd_read_rxd_txd_rxd_txd,
3763                 (void *)&cmd_read_rxd_txd_port_id,
3764                 (void *)&cmd_read_rxd_txd_queue_id,
3765                 (void *)&cmd_read_rxd_txd_desc_id,
3766                 NULL,
3767         },
3768 };
3769
3770 /* *** QUIT *** */
3771 struct cmd_quit_result {
3772         cmdline_fixed_string_t quit;
3773 };
3774
3775 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
3776                             struct cmdline *cl,
3777                             __attribute__((unused)) void *data)
3778 {
3779         pmd_test_exit();
3780         cmdline_quit(cl);
3781 }
3782
3783 cmdline_parse_token_string_t cmd_quit_quit =
3784         TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
3785
3786 cmdline_parse_inst_t cmd_quit = {
3787         .f = cmd_quit_parsed,
3788         .data = NULL,
3789         .help_str = "exit application",
3790         .tokens = {
3791                 (void *)&cmd_quit_quit,
3792                 NULL,
3793         },
3794 };
3795
3796 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
3797 struct cmd_mac_addr_result {
3798         cmdline_fixed_string_t mac_addr_cmd;
3799         cmdline_fixed_string_t what;
3800         uint8_t port_num;
3801         struct ether_addr address;
3802 };
3803
3804 static void cmd_mac_addr_parsed(void *parsed_result,
3805                 __attribute__((unused)) struct cmdline *cl,
3806                 __attribute__((unused)) void *data)
3807 {
3808         struct cmd_mac_addr_result *res = parsed_result;
3809         int ret;
3810
3811         if (strcmp(res->what, "add") == 0)
3812                 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
3813         else
3814                 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
3815
3816         /* check the return value and print it if is < 0 */
3817         if(ret < 0)
3818                 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
3819
3820 }
3821
3822 cmdline_parse_token_string_t cmd_mac_addr_cmd =
3823         TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
3824                                 "mac_addr");
3825 cmdline_parse_token_string_t cmd_mac_addr_what =
3826         TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
3827                                 "add#remove");
3828 cmdline_parse_token_num_t cmd_mac_addr_portnum =
3829                 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
3830 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
3831                 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
3832
3833 cmdline_parse_inst_t cmd_mac_addr = {
3834         .f = cmd_mac_addr_parsed,
3835         .data = (void *)0,
3836         .help_str = "mac_addr add|remove X <address>: "
3837                         "add/remove MAC address on port X",
3838         .tokens = {
3839                 (void *)&cmd_mac_addr_cmd,
3840                 (void *)&cmd_mac_addr_what,
3841                 (void *)&cmd_mac_addr_portnum,
3842                 (void *)&cmd_mac_addr_addr,
3843                 NULL,
3844         },
3845 };
3846
3847
3848 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
3849 struct cmd_set_qmap_result {
3850         cmdline_fixed_string_t set;
3851         cmdline_fixed_string_t qmap;
3852         cmdline_fixed_string_t what;
3853         uint8_t port_id;
3854         uint16_t queue_id;
3855         uint8_t map_value;
3856 };
3857
3858 static void
3859 cmd_set_qmap_parsed(void *parsed_result,
3860                        __attribute__((unused)) struct cmdline *cl,
3861                        __attribute__((unused)) void *data)
3862 {
3863         struct cmd_set_qmap_result *res = parsed_result;
3864         int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
3865
3866         set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
3867 }
3868
3869 cmdline_parse_token_string_t cmd_setqmap_set =
3870         TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
3871                                  set, "set");
3872 cmdline_parse_token_string_t cmd_setqmap_qmap =
3873         TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
3874                                  qmap, "stat_qmap");
3875 cmdline_parse_token_string_t cmd_setqmap_what =
3876         TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
3877                                  what, "tx#rx");
3878 cmdline_parse_token_num_t cmd_setqmap_portid =
3879         TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
3880                               port_id, UINT8);
3881 cmdline_parse_token_num_t cmd_setqmap_queueid =
3882         TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
3883                               queue_id, UINT16);
3884 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
3885         TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
3886                               map_value, UINT8);
3887
3888 cmdline_parse_inst_t cmd_set_qmap = {
3889         .f = cmd_set_qmap_parsed,
3890         .data = NULL,
3891         .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
3892         .tokens = {
3893                 (void *)&cmd_setqmap_set,
3894                 (void *)&cmd_setqmap_qmap,
3895                 (void *)&cmd_setqmap_what,
3896                 (void *)&cmd_setqmap_portid,
3897                 (void *)&cmd_setqmap_queueid,
3898                 (void *)&cmd_setqmap_mapvalue,
3899                 NULL,
3900         },
3901 };
3902
3903 /* *** CONFIGURE UNICAST HASH TABLE *** */
3904 struct cmd_set_uc_hash_table {
3905         cmdline_fixed_string_t set;
3906         cmdline_fixed_string_t port;
3907         uint8_t port_id;
3908         cmdline_fixed_string_t what;
3909         struct ether_addr address;
3910         cmdline_fixed_string_t mode;
3911 };
3912
3913 static void
3914 cmd_set_uc_hash_parsed(void *parsed_result,
3915                        __attribute__((unused)) struct cmdline *cl,
3916                        __attribute__((unused)) void *data)
3917 {
3918         int ret=0;
3919         struct cmd_set_uc_hash_table *res = parsed_result;
3920         
3921         int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
3922         
3923         if (strcmp(res->what, "uta") == 0)
3924                 ret = rte_eth_dev_uc_hash_table_set(res->port_id, 
3925                                                 &res->address,(uint8_t)is_on);
3926         if (ret < 0)
3927                 printf("bad unicast hash table parameter, return code = %d \n", ret);
3928         
3929 }
3930
3931 cmdline_parse_token_string_t cmd_set_uc_hash_set =
3932         TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
3933                                  set, "set");
3934 cmdline_parse_token_string_t cmd_set_uc_hash_port =
3935         TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
3936                                  port, "port");
3937 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
3938         TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
3939                               port_id, UINT8);
3940 cmdline_parse_token_string_t cmd_set_uc_hash_what =
3941         TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
3942                                  what, "uta");
3943 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
3944         TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table, 
3945                                 address);
3946 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
3947         TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
3948                                  mode, "on#off");
3949
3950 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
3951         .f = cmd_set_uc_hash_parsed,
3952         .data = NULL,
3953         .help_str = "set port X uta Y on|off(X = port number,Y = MAC address)",
3954         .tokens = {
3955                 (void *)&cmd_set_uc_hash_set,
3956                 (void *)&cmd_set_uc_hash_port,
3957                 (void *)&cmd_set_uc_hash_portid,
3958                 (void *)&cmd_set_uc_hash_what,
3959                 (void *)&cmd_set_uc_hash_mac,
3960                 (void *)&cmd_set_uc_hash_mode,
3961                 NULL,
3962         },
3963 };
3964
3965 struct cmd_set_uc_all_hash_table {
3966         cmdline_fixed_string_t set;
3967         cmdline_fixed_string_t port;
3968         uint8_t port_id;
3969         cmdline_fixed_string_t what;
3970         cmdline_fixed_string_t value;
3971         cmdline_fixed_string_t mode;
3972 };
3973
3974 static void
3975 cmd_set_uc_all_hash_parsed(void *parsed_result,
3976                        __attribute__((unused)) struct cmdline *cl,
3977                        __attribute__((unused)) void *data)
3978 {
3979         int ret=0;
3980         struct cmd_set_uc_all_hash_table *res = parsed_result;
3981         
3982         int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
3983         
3984         if ((strcmp(res->what, "uta") == 0) && 
3985                 (strcmp(res->value, "all") == 0))
3986                 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
3987         if (ret < 0)
3988                 printf("bad unicast hash table parameter," 
3989                         "return code = %d \n", ret);
3990 }
3991
3992 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
3993         TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
3994                                  set, "set");
3995 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
3996         TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
3997                                  port, "port");
3998 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
3999         TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
4000                               port_id, UINT8);
4001 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
4002         TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4003                                  what, "uta");
4004 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
4005         TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 
4006                                 value,"all");
4007 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
4008         TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4009                                  mode, "on#off");
4010
4011 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
4012         .f = cmd_set_uc_all_hash_parsed,
4013         .data = NULL,
4014         .help_str = "set port X uta all on|off (X = port number)",
4015         .tokens = {
4016                 (void *)&cmd_set_uc_all_hash_set,
4017                 (void *)&cmd_set_uc_all_hash_port,
4018                 (void *)&cmd_set_uc_all_hash_portid,
4019                 (void *)&cmd_set_uc_all_hash_what,
4020                 (void *)&cmd_set_uc_all_hash_value,
4021                 (void *)&cmd_set_uc_all_hash_mode,
4022                 NULL,
4023         },
4024 };
4025
4026 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
4027 struct cmd_set_vf_traffic {
4028         cmdline_fixed_string_t set;
4029         cmdline_fixed_string_t port;
4030         uint8_t port_id;
4031         cmdline_fixed_string_t vf;
4032         uint8_t vf_id;
4033         cmdline_fixed_string_t what;
4034         cmdline_fixed_string_t mode;
4035 };
4036
4037 static void
4038 cmd_set_vf_traffic_parsed(void *parsed_result,
4039                        __attribute__((unused)) struct cmdline *cl,
4040                        __attribute__((unused)) void *data)
4041 {
4042         struct cmd_set_vf_traffic *res = parsed_result;
4043         int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
4044         int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
4045
4046         set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
4047 }
4048
4049 cmdline_parse_token_string_t cmd_setvf_traffic_set =
4050         TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4051                                  set, "set");
4052 cmdline_parse_token_string_t cmd_setvf_traffic_port =
4053         TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4054                                  port, "port");
4055 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
4056         TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
4057                               port_id, UINT8);
4058 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
4059         TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4060                                  vf, "vf");
4061 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
4062         TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
4063                               vf_id, UINT8);
4064 cmdline_parse_token_string_t cmd_setvf_traffic_what =
4065         TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4066                                  what, "tx#rx");
4067 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
4068         TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4069                                  mode, "on#off");
4070
4071 cmdline_parse_inst_t cmd_set_vf_traffic = {
4072         .f = cmd_set_vf_traffic_parsed,
4073         .data = NULL,
4074         .help_str = "set port X vf Y rx|tx on|off (X = port number,Y = vf id)",
4075         .tokens = {
4076                 (void *)&cmd_setvf_traffic_set,
4077                 (void *)&cmd_setvf_traffic_port,
4078                 (void *)&cmd_setvf_traffic_portid,
4079                 (void *)&cmd_setvf_traffic_vf,
4080                 (void *)&cmd_setvf_traffic_vfid,
4081                 (void *)&cmd_setvf_traffic_what,
4082                 (void *)&cmd_setvf_traffic_mode,
4083                 NULL,
4084         },
4085 };
4086
4087 /* *** CONFIGURE VF RECEIVE MODE *** */
4088 struct cmd_set_vf_rxmode {
4089         cmdline_fixed_string_t set;
4090         cmdline_fixed_string_t port;
4091         uint8_t port_id;
4092         cmdline_fixed_string_t vf;
4093         uint8_t vf_id;
4094         cmdline_fixed_string_t what;
4095         cmdline_fixed_string_t mode;
4096         cmdline_fixed_string_t on;
4097 };
4098
4099 static void
4100 cmd_set_vf_rxmode_parsed(void *parsed_result,
4101                        __attribute__((unused)) struct cmdline *cl,
4102                        __attribute__((unused)) void *data)
4103 {
4104         int ret;
4105         uint16_t rx_mode = 0;
4106         struct cmd_set_vf_rxmode *res = parsed_result;
4107         
4108         int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
4109         if (!strcmp(res->what,"rxmode")) {
4110                 if (!strcmp(res->mode, "AUPE"))
4111                         rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
4112                 else if (!strcmp(res->mode, "ROPE"))
4113                         rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
4114                 else if (!strcmp(res->mode, "BAM"))
4115                         rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
4116                 else if (!strncmp(res->mode, "MPE",3))
4117                         rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
4118         }
4119
4120         ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
4121         if (ret < 0)
4122                 printf("bad VF receive mode parameter, return code = %d \n",
4123                 ret);
4124 }
4125
4126 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
4127         TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4128                                  set, "set");
4129 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
4130         TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4131                                  port, "port");
4132 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
4133         TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
4134                               port_id, UINT8);
4135 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
4136         TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4137                                  vf, "vf");
4138 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
4139         TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
4140                               vf_id, UINT8);
4141 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
4142         TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4143                                  what, "rxmode");
4144 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
4145         TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4146                                  mode, "AUPE#ROPE#BAM#MPE");
4147 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
4148         TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4149                                  on, "on#off");
4150
4151 cmdline_parse_inst_t cmd_set_vf_rxmode = {
4152         .f = cmd_set_vf_rxmode_parsed,
4153         .data = NULL,
4154         .help_str = "set port X vf Y rxmode AUPE|ROPE|BAM|MPE on|off",
4155         .tokens = {
4156                 (void *)&cmd_set_vf_rxmode_set,
4157                 (void *)&cmd_set_vf_rxmode_port,
4158                 (void *)&cmd_set_vf_rxmode_portid,
4159                 (void *)&cmd_set_vf_rxmode_vf,
4160                 (void *)&cmd_set_vf_rxmode_vfid,
4161                 (void *)&cmd_set_vf_rxmode_what,
4162                 (void *)&cmd_set_vf_rxmode_mode,
4163                 (void *)&cmd_set_vf_rxmode_on,
4164                 NULL,
4165         },
4166 };
4167
4168 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
4169 struct cmd_vf_mac_addr_result {
4170         cmdline_fixed_string_t mac_addr_cmd;
4171         cmdline_fixed_string_t what;
4172         cmdline_fixed_string_t port;
4173         uint8_t port_num;
4174         cmdline_fixed_string_t vf;
4175         uint8_t vf_num;
4176         struct ether_addr address;
4177 };
4178
4179 static void cmd_vf_mac_addr_parsed(void *parsed_result,
4180                 __attribute__((unused)) struct cmdline *cl,
4181                 __attribute__((unused)) void *data)
4182 {
4183         struct cmd_vf_mac_addr_result *res = parsed_result;
4184         int ret = 0;
4185
4186         if (strcmp(res->what, "add") == 0)
4187                 ret = rte_eth_dev_mac_addr_add(res->port_num, 
4188                                         &res->address, res->vf_num);
4189         if(ret < 0)
4190                 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
4191
4192 }
4193
4194 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
4195         TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
4196                                 mac_addr_cmd,"mac_addr");
4197 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
4198         TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 
4199                                 what,"add");
4200 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
4201         TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 
4202                                 port,"port");
4203 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
4204         TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result, 
4205                                 port_num, UINT8);
4206 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
4207         TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 
4208                                 vf,"vf");
4209 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
4210         TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
4211                                 vf_num, UINT8);
4212 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
4213         TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result, 
4214                                 address);
4215
4216 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
4217         .f = cmd_vf_mac_addr_parsed,
4218         .data = (void *)0,
4219         .help_str = "mac_addr add port X vf Y ethaddr:(X = port number,"
4220         "Y = VF number)add MAC address filtering for a VF on port X",
4221         .tokens = {
4222                 (void *)&cmd_vf_mac_addr_cmd,
4223                 (void *)&cmd_vf_mac_addr_what,
4224                 (void *)&cmd_vf_mac_addr_port,
4225                 (void *)&cmd_vf_mac_addr_portnum,
4226                 (void *)&cmd_vf_mac_addr_vf,
4227                 (void *)&cmd_vf_mac_addr_vfnum,
4228                 (void *)&cmd_vf_mac_addr_addr,
4229                 NULL,
4230         },
4231 };
4232
4233 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4234 struct cmd_vf_rx_vlan_filter {
4235         cmdline_fixed_string_t rx_vlan;
4236         cmdline_fixed_string_t what;
4237         uint16_t vlan_id;
4238         cmdline_fixed_string_t port;
4239         uint8_t port_id;
4240         cmdline_fixed_string_t vf;
4241         uint64_t vf_mask;
4242 };
4243
4244 static void
4245 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
4246                           __attribute__((unused)) struct cmdline *cl,
4247                           __attribute__((unused)) void *data)
4248 {
4249         struct cmd_vf_rx_vlan_filter *res = parsed_result;
4250
4251         if (!strcmp(res->what, "add"))
4252                 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
4253         else
4254                 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
4255 }
4256
4257 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
4258         TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4259                                  rx_vlan, "rx_vlan");
4260 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
4261         TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4262                                  what, "add#rm");
4263 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
4264         TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4265                               vlan_id, UINT16);
4266 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
4267         TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4268                                  port, "port");
4269 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
4270         TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4271                               port_id, UINT8);
4272 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
4273         TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4274                                  vf, "vf");
4275 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
4276         TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4277                               vf_mask, UINT64);
4278
4279 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
4280         .f = cmd_vf_rx_vlan_filter_parsed,
4281         .data = NULL,
4282         .help_str = "rx_vlan add|rm X port Y vf Z (X = VLAN ID,"
4283                 "Y = port number,Z = hexadecimal VF mask)",
4284         .tokens = {
4285                 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
4286                 (void *)&cmd_vf_rx_vlan_filter_what,
4287                 (void *)&cmd_vf_rx_vlan_filter_vlanid,
4288                 (void *)&cmd_vf_rx_vlan_filter_port,
4289                 (void *)&cmd_vf_rx_vlan_filter_portid,
4290                 (void *)&cmd_vf_rx_vlan_filter_vf,
4291                 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
4292                 NULL,
4293         },
4294 };
4295
4296 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
4297 struct cmd_set_mirror_mask_result {
4298         cmdline_fixed_string_t set;
4299         cmdline_fixed_string_t port;
4300         uint8_t port_id;
4301         cmdline_fixed_string_t mirror;
4302         uint8_t rule_id;
4303         cmdline_fixed_string_t what;
4304         cmdline_fixed_string_t value;
4305         cmdline_fixed_string_t dstpool;
4306         uint8_t dstpool_id;
4307         cmdline_fixed_string_t on;
4308 };
4309
4310 cmdline_parse_token_string_t cmd_mirror_mask_set =
4311         TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4312                                 set, "set");
4313 cmdline_parse_token_string_t cmd_mirror_mask_port =
4314         TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4315                                 port, "port");
4316 cmdline_parse_token_string_t cmd_mirror_mask_portid =
4317         TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
4318                                 port_id, UINT8);
4319 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
4320         TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4321                                 mirror, "mirror-rule");
4322 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
4323         TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
4324                                 rule_id, UINT8);
4325 cmdline_parse_token_string_t cmd_mirror_mask_what =
4326         TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4327                                 what, "pool-mirror#vlan-mirror");
4328 cmdline_parse_token_string_t cmd_mirror_mask_value =
4329         TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4330                                 value, NULL);
4331 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
4332         TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4333                                 dstpool, "dst-pool");
4334 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
4335         TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
4336                                 dstpool_id, UINT8);
4337 cmdline_parse_token_string_t cmd_mirror_mask_on =
4338         TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4339                                 on, "on#off");
4340
4341 static void
4342 cmd_set_mirror_mask_parsed(void *parsed_result,
4343                        __attribute__((unused)) struct cmdline *cl,
4344                        __attribute__((unused)) void *data)
4345 {
4346         int ret,nb_item,i;
4347         struct cmd_set_mirror_mask_result *res = parsed_result;
4348         struct rte_eth_vmdq_mirror_conf mr_conf;
4349
4350         memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
4351
4352         unsigned int vlan_list[ETH_VMDQ_MAX_VLAN_FILTERS];
4353
4354         mr_conf.dst_pool = res->dstpool_id;
4355
4356         if (!strcmp(res->what, "pool-mirror")) {
4357                 mr_conf.pool_mask = strtoull(res->value,NULL,16);
4358                 mr_conf.rule_type_mask = ETH_VMDQ_POOL_MIRROR;
4359         } else if(!strcmp(res->what, "vlan-mirror")) {
4360                 mr_conf.rule_type_mask = ETH_VMDQ_VLAN_MIRROR;
4361                 nb_item = parse_item_list(res->value, "core",
4362                                         ETH_VMDQ_MAX_VLAN_FILTERS,vlan_list,1);
4363                 if (nb_item <= 0)
4364                         return;
4365
4366                 for(i=0; i < nb_item; i++) {
4367                         if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
4368                                 printf("Invalid vlan_id: must be < 4096\n");
4369                                 return;
4370                         }
4371
4372                         mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
4373                         mr_conf.vlan.vlan_mask |= 1ULL << i;
4374                 }
4375         }
4376
4377         if(!strcmp(res->on, "on"))
4378                 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
4379                                                 res->rule_id, 1);
4380         else
4381                 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
4382                                                 res->rule_id, 0);
4383         if(ret < 0)
4384                 printf("mirror rule add error: (%s)\n", strerror(-ret));
4385 }
4386
4387 cmdline_parse_inst_t cmd_set_mirror_mask = {
4388                 .f = cmd_set_mirror_mask_parsed,
4389                 .data = NULL,
4390                 .help_str = "set port X mirror-rule Y pool-mirror|vlan-mirror " 
4391                                 "pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
4392                 .tokens = {
4393                         (void *)&cmd_mirror_mask_set,
4394                         (void *)&cmd_mirror_mask_port,
4395                         (void *)&cmd_mirror_mask_portid,
4396                         (void *)&cmd_mirror_mask_mirror,
4397                         (void *)&cmd_mirror_mask_ruleid,
4398                         (void *)&cmd_mirror_mask_what,
4399                         (void *)&cmd_mirror_mask_value,
4400                         (void *)&cmd_mirror_mask_dstpool,
4401                         (void *)&cmd_mirror_mask_poolid,
4402                         (void *)&cmd_mirror_mask_on,
4403                         NULL,
4404                 },
4405 };
4406
4407 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
4408 struct cmd_set_mirror_link_result {
4409         cmdline_fixed_string_t set;
4410         cmdline_fixed_string_t port;
4411         uint8_t port_id;
4412         cmdline_fixed_string_t mirror;
4413         uint8_t rule_id;
4414         cmdline_fixed_string_t what;
4415         cmdline_fixed_string_t dstpool;
4416         uint8_t dstpool_id;
4417         cmdline_fixed_string_t on;
4418 };
4419
4420 cmdline_parse_token_string_t cmd_mirror_link_set =
4421         TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
4422                                  set, "set");
4423 cmdline_parse_token_string_t cmd_mirror_link_port =
4424         TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
4425                                 port, "port");
4426 cmdline_parse_token_string_t cmd_mirror_link_portid =
4427         TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
4428                                 port_id, UINT8);
4429 cmdline_parse_token_string_t cmd_mirror_link_mirror =
4430         TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
4431                                 mirror, "mirror-rule");
4432 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
4433         TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
4434                             rule_id, UINT8);
4435 cmdline_parse_token_string_t cmd_mirror_link_what =
4436         TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
4437                                 what, "uplink-mirror#downlink-mirror");
4438 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
4439         TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
4440                                 dstpool, "dst-pool");
4441 cmdline_parse_token_num_t cmd_mirror_link_poolid =
4442         TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
4443                                 dstpool_id, UINT8);
4444 cmdline_parse_token_string_t cmd_mirror_link_on =
4445         TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
4446                                 on, "on#off");
4447
4448 static void
4449 cmd_set_mirror_link_parsed(void *parsed_result,
4450                        __attribute__((unused)) struct cmdline *cl,
4451                        __attribute__((unused)) void *data)
4452 {
4453         int ret;
4454         struct cmd_set_mirror_link_result *res = parsed_result;
4455         struct rte_eth_vmdq_mirror_conf mr_conf;
4456
4457         memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
4458         if(!strcmp(res->what, "uplink-mirror")) {
4459                 mr_conf.rule_type_mask = ETH_VMDQ_UPLINK_MIRROR;
4460         }else if(!strcmp(res->what, "downlink-mirror"))
4461                 mr_conf.rule_type_mask = ETH_VMDQ_DOWNLIN_MIRROR;
4462
4463         mr_conf.dst_pool = res->dstpool_id;
4464
4465         if(!strcmp(res->on, "on"))
4466                 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
4467                                                 res->rule_id, 1);
4468         else
4469                 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
4470                                                 res->rule_id, 0);
4471
4472         /* check the return value and print it if is < 0 */
4473         if(ret < 0)
4474                 printf("mirror rule add error: (%s)\n", strerror(-ret));
4475
4476 }
4477
4478 cmdline_parse_inst_t cmd_set_mirror_link = {
4479                 .f = cmd_set_mirror_link_parsed,
4480                 .data = NULL,
4481                 .help_str = "set port X mirror-rule Y uplink-mirror|"
4482                         "downlink-mirror dst-pool Z on|off",
4483                 .tokens = {
4484                         (void *)&cmd_mirror_link_set,
4485                         (void *)&cmd_mirror_link_port,
4486                         (void *)&cmd_mirror_link_portid,
4487                         (void *)&cmd_mirror_link_mirror,
4488                         (void *)&cmd_mirror_link_ruleid,
4489                         (void *)&cmd_mirror_link_what,
4490                         (void *)&cmd_mirror_link_dstpool,
4491                         (void *)&cmd_mirror_link_poolid,
4492                         (void *)&cmd_mirror_link_on,
4493                         NULL,
4494                 },
4495 };
4496
4497 /* *** RESET VM MIRROR RULE *** */
4498 struct cmd_rm_mirror_rule_result {
4499         cmdline_fixed_string_t reset;
4500         cmdline_fixed_string_t port;
4501         uint8_t port_id;
4502         cmdline_fixed_string_t mirror;
4503         uint8_t rule_id;
4504 };
4505
4506 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
4507         TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
4508                                  reset, "reset");
4509 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
4510         TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
4511                                 port, "port");
4512 cmdline_parse_token_string_t cmd_rm_mirror_rule_portid =
4513         TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
4514                                 port_id, UINT8);
4515 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
4516         TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
4517                                 mirror, "mirror-rule");
4518 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
4519         TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
4520                                 rule_id, UINT8);
4521
4522 static void
4523 cmd_reset_mirror_rule_parsed(void *parsed_result,
4524                        __attribute__((unused)) struct cmdline *cl,
4525                        __attribute__((unused)) void *data)
4526 {
4527         int ret;
4528         struct cmd_set_mirror_link_result *res = parsed_result;
4529         /* check rule_id */
4530         ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
4531         if(ret < 0)
4532                 printf("mirror rule remove error: (%s)\n", strerror(-ret));
4533 }
4534
4535 cmdline_parse_inst_t cmd_reset_mirror_rule = {
4536                 .f = cmd_reset_mirror_rule_parsed,
4537                 .data = NULL,
4538                 .help_str = "reset port X mirror-rule Y",
4539                 .tokens = {
4540                         (void *)&cmd_rm_mirror_rule_reset,
4541                         (void *)&cmd_rm_mirror_rule_port,
4542                         (void *)&cmd_rm_mirror_rule_portid,
4543                         (void *)&cmd_rm_mirror_rule_mirror,
4544                         (void *)&cmd_rm_mirror_rule_ruleid,
4545                         NULL,
4546                 },
4547 };
4548
4549 /* ******************************************************************************** */
4550
4551 /* list of instructions */
4552 cmdline_parse_ctx_t main_ctx[] = {
4553         (cmdline_parse_inst_t *)&cmd_help_brief,
4554         (cmdline_parse_inst_t *)&cmd_help_long,
4555         (cmdline_parse_inst_t *)&cmd_quit,
4556         (cmdline_parse_inst_t *)&cmd_showport,
4557         (cmdline_parse_inst_t *)&cmd_showportall,
4558         (cmdline_parse_inst_t *)&cmd_showcfg,
4559         (cmdline_parse_inst_t *)&cmd_start,
4560         (cmdline_parse_inst_t *)&cmd_start_tx_first,
4561         (cmdline_parse_inst_t *)&cmd_reset,
4562         (cmdline_parse_inst_t *)&cmd_set_numbers,
4563         (cmdline_parse_inst_t *)&cmd_set_txpkts,
4564         (cmdline_parse_inst_t *)&cmd_set_fwd_list,
4565         (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
4566         (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
4567         (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
4568         (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
4569         (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
4570         (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
4571         (cmdline_parse_inst_t *)&cmd_set_flush_rx,
4572         (cmdline_parse_inst_t *)&cmd_vlan_offload,
4573         (cmdline_parse_inst_t *)&cmd_vlan_tpid,
4574         (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
4575         (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
4576         (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
4577         (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
4578         (cmdline_parse_inst_t *)&cmd_tx_cksum_set,
4579         (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
4580         (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
4581         (cmdline_parse_inst_t *)&cmd_config_dcb,
4582         (cmdline_parse_inst_t *)&cmd_read_reg,
4583         (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
4584         (cmdline_parse_inst_t *)&cmd_read_reg_bit,
4585         (cmdline_parse_inst_t *)&cmd_write_reg,
4586         (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
4587         (cmdline_parse_inst_t *)&cmd_write_reg_bit,
4588         (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
4589         (cmdline_parse_inst_t *)&cmd_add_signature_filter,
4590         (cmdline_parse_inst_t *)&cmd_upd_signature_filter,
4591         (cmdline_parse_inst_t *)&cmd_rm_signature_filter,
4592         (cmdline_parse_inst_t *)&cmd_add_perfect_filter,
4593         (cmdline_parse_inst_t *)&cmd_upd_perfect_filter,
4594         (cmdline_parse_inst_t *)&cmd_rm_perfect_filter,
4595         (cmdline_parse_inst_t *)&cmd_set_masks_filter,
4596         (cmdline_parse_inst_t *)&cmd_set_ipv6_masks_filter,
4597         (cmdline_parse_inst_t *)&cmd_stop,
4598         (cmdline_parse_inst_t *)&cmd_mac_addr,
4599         (cmdline_parse_inst_t *)&cmd_set_qmap,
4600         (cmdline_parse_inst_t *)&cmd_operate_port,
4601         (cmdline_parse_inst_t *)&cmd_operate_specific_port,
4602         (cmdline_parse_inst_t *)&cmd_config_speed_all,
4603         (cmdline_parse_inst_t *)&cmd_config_speed_specific,
4604         (cmdline_parse_inst_t *)&cmd_config_rx_tx,
4605         (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
4606         (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
4607         (cmdline_parse_inst_t *)&cmd_config_rss,
4608         (cmdline_parse_inst_t *)&cmd_config_rss_reta,
4609         (cmdline_parse_inst_t *)&cmd_showport_reta,
4610         (cmdline_parse_inst_t *)&cmd_config_burst,
4611         (cmdline_parse_inst_t *)&cmd_config_thresh,
4612         (cmdline_parse_inst_t *)&cmd_config_threshold,
4613         (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
4614         (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
4615         (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
4616         (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter ,
4617         (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
4618         (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
4619         (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
4620         (cmdline_parse_inst_t *)&cmd_set_mirror_link,
4621         (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
4622         NULL,
4623 };
4624
4625 /* prompt function, called from main on MASTER lcore */
4626 void
4627 prompt(void)
4628 {
4629         struct cmdline *cl;
4630
4631         cl = cmdline_stdin_new(main_ctx, "testpmd> ");
4632         if (cl == NULL) {
4633                 return;
4634         }
4635         cmdline_interact(cl);
4636         cmdline_stdin_exit(cl);
4637 }
4638
4639 static void
4640 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
4641 {
4642         if (id < nb_ports) {
4643                 /* check if need_reconfig has been set to 1 */
4644                 if (ports[id].need_reconfig == 0)
4645                         ports[id].need_reconfig = dev;
4646                 /* check if need_reconfig_queues has been set to 1 */
4647                 if (ports[id].need_reconfig_queues == 0)
4648                         ports[id].need_reconfig_queues = queue;
4649         } else {
4650                 portid_t pid;
4651
4652                 for (pid = 0; pid < nb_ports; pid++) {
4653                         /* check if need_reconfig has been set to 1 */
4654                         if (ports[pid].need_reconfig == 0)
4655                                 ports[pid].need_reconfig = dev;
4656                         /* check if need_reconfig_queues has been set to 1 */
4657                         if (ports[pid].need_reconfig_queues == 0)
4658                                 ports[pid].need_reconfig_queues = queue;
4659                 }
4660         }
4661 }