1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2016 Intel Corporation.
3 * Copyright(c) 2014 6WIND S.A.
16 #include <net/socket.h>
18 #include <sys/socket.h>
21 #include <netinet/in.h>
23 #include <sys/queue.h>
25 #include <rte_common.h>
26 #include <rte_byteorder.h>
28 #include <rte_debug.h>
29 #include <rte_cycles.h>
30 #include <rte_memory.h>
31 #include <rte_memzone.h>
32 #include <rte_malloc.h>
33 #include <rte_launch.h>
35 #include <rte_per_lcore.h>
36 #include <rte_lcore.h>
37 #include <rte_atomic.h>
38 #include <rte_branch_prediction.h>
40 #include <rte_mempool.h>
41 #include <rte_interrupts.h>
43 #include <rte_ether.h>
44 #include <rte_ethdev.h>
45 #include <rte_string_fns.h>
46 #include <rte_devargs.h>
47 #include <rte_eth_ctrl.h>
51 #include <cmdline_rdline.h>
52 #include <cmdline_parse.h>
53 #include <cmdline_parse_num.h>
54 #include <cmdline_parse_string.h>
55 #include <cmdline_parse_ipaddr.h>
56 #include <cmdline_parse_etheraddr.h>
57 #include <cmdline_socket.h>
59 #ifdef RTE_LIBRTE_PMD_BOND
60 #include <rte_eth_bond.h>
61 #include <rte_eth_bond_8023ad.h>
63 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
64 #include <rte_pmd_dpaa.h>
66 #ifdef RTE_LIBRTE_IXGBE_PMD
67 #include <rte_pmd_ixgbe.h>
69 #ifdef RTE_LIBRTE_I40E_PMD
70 #include <rte_pmd_i40e.h>
72 #ifdef RTE_LIBRTE_BNXT_PMD
73 #include <rte_pmd_bnxt.h>
76 #include "cmdline_mtr.h"
77 #include "cmdline_tm.h"
79 static struct cmdline *testpmd_cl;
81 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
83 /* *** Help command with introduction. *** */
84 struct cmd_help_brief_result {
85 cmdline_fixed_string_t help;
88 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
90 __attribute__((unused)) void *data)
95 "Help is available for the following sections:\n\n"
96 " help control : Start and stop forwarding.\n"
97 " help display : Displaying port, stats and config "
99 " help config : Configuration information.\n"
100 " help ports : Configuring ports.\n"
101 " help registers : Reading and setting port registers.\n"
102 " help filters : Filters configuration help.\n"
103 " help all : All of the above sections.\n\n"
108 cmdline_parse_token_string_t cmd_help_brief_help =
109 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
111 cmdline_parse_inst_t cmd_help_brief = {
112 .f = cmd_help_brief_parsed,
114 .help_str = "help: Show help",
116 (void *)&cmd_help_brief_help,
121 /* *** Help command with help sections. *** */
122 struct cmd_help_long_result {
123 cmdline_fixed_string_t help;
124 cmdline_fixed_string_t section;
127 static void cmd_help_long_parsed(void *parsed_result,
129 __attribute__((unused)) void *data)
132 struct cmd_help_long_result *res = parsed_result;
134 if (!strcmp(res->section, "all"))
137 if (show_all || !strcmp(res->section, "control")) {
142 "Control forwarding:\n"
143 "-------------------\n\n"
146 " Start packet forwarding with current configuration.\n\n"
149 " Start packet forwarding with current config"
150 " after sending one burst of packets.\n\n"
153 " Stop packet forwarding, and display accumulated"
157 " Quit to prompt.\n\n"
161 if (show_all || !strcmp(res->section, "display")) {
169 "show port (info|stats|xstats|fdir|stat_qmap|dcb_tc|cap) (port_id|all)\n"
170 " Display information for port_id, or all.\n\n"
172 "show port X rss reta (size) (mask0,mask1,...)\n"
173 " Display the rss redirection table entry indicated"
174 " by masks on port X. size is used to indicate the"
175 " hardware supported reta size\n\n"
177 "show port rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
178 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
179 "ipv6-other|l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex [key]\n"
180 " Display the RSS hash functions and RSS hash key"
183 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
184 " Clear information for port_id, or all.\n\n"
186 "show (rxq|txq) info (port_id) (queue_id)\n"
187 " Display information for configured RX/TX queue.\n\n"
189 "show config (rxtx|cores|fwd|txpkts)\n"
190 " Display the given configuration.\n\n"
192 "read rxd (port_id) (queue_id) (rxd_id)\n"
193 " Display an RX descriptor of a port RX queue.\n\n"
195 "read txd (port_id) (queue_id) (txd_id)\n"
196 " Display a TX descriptor of a port TX queue.\n\n"
198 "ddp get list (port_id)\n"
199 " Get ddp profile info list\n\n"
201 "ddp get info (profile_path)\n"
202 " Get ddp profile information.\n\n"
204 "show vf stats (port_id) (vf_id)\n"
205 " Display a VF's statistics.\n\n"
207 "clear vf stats (port_id) (vf_id)\n"
208 " Reset a VF's statistics.\n\n"
210 "show port (port_id) pctype mapping\n"
211 " Get flow ptype to pctype mapping on a port\n\n"
213 "show port meter stats (port_id) (meter_id) (clear)\n"
214 " Get meter stats on a port\n\n"
215 "show port tm cap (port_id)\n"
216 " Display the port TM capability.\n\n"
218 "show port tm level cap (port_id) (level_id)\n"
219 " Display the port TM hierarchical level capability.\n\n"
221 "show port tm node cap (port_id) (node_id)\n"
222 " Display the port TM node capability.\n\n"
224 "show port tm node type (port_id) (node_id)\n"
225 " Display the port TM node type.\n\n"
227 "show port tm node stats (port_id) (node_id) (clear)\n"
228 " Display the port TM node stats.\n\n"
233 if (show_all || !strcmp(res->section, "config")) {
239 "Configuration changes only become active when"
240 " forwarding is started/restarted.\n\n"
243 " Reset forwarding to the default configuration.\n\n"
245 "set verbose (level)\n"
246 " Set the debug verbosity level X.\n\n"
248 "set log global|(type) (level)\n"
249 " Set the log level.\n\n"
252 " Set number of ports.\n\n"
255 " Set number of cores.\n\n"
257 "set coremask (mask)\n"
258 " Set the forwarding cores hexadecimal mask.\n\n"
260 "set portmask (mask)\n"
261 " Set the forwarding ports hexadecimal mask.\n\n"
264 " Set number of packets per burst.\n\n"
266 "set burst tx delay (microseconds) retry (num)\n"
267 " Set the transmit delay time and number of retries,"
268 " effective when retry is enabled.\n\n"
270 "set txpkts (x[,y]*)\n"
271 " Set the length of each segment of TXONLY"
272 " and optionally CSUM packets.\n\n"
274 "set txsplit (off|on|rand)\n"
275 " Set the split policy for the TX packets."
276 " Right now only applicable for CSUM and TXONLY"
279 "set corelist (x[,y]*)\n"
280 " Set the list of forwarding cores.\n\n"
282 "set portlist (x[,y]*)\n"
283 " Set the list of forwarding ports.\n\n"
285 "set tx loopback (port_id) (on|off)\n"
286 " Enable or disable tx loopback.\n\n"
288 "set all queues drop (port_id) (on|off)\n"
289 " Set drop enable bit for all queues.\n\n"
291 "set vf split drop (port_id) (vf_id) (on|off)\n"
292 " Set split drop enable bit for a VF from the PF.\n\n"
294 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
295 " Set MAC antispoof for a VF from the PF.\n\n"
297 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
298 " Enable MACsec offload.\n\n"
300 "set macsec offload (port_id) off\n"
301 " Disable MACsec offload.\n\n"
303 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
304 " Configure MACsec secure connection (SC).\n\n"
306 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
307 " Configure MACsec secure association (SA).\n\n"
309 "set vf broadcast (port_id) (vf_id) (on|off)\n"
310 " Set VF broadcast for a VF from the PF.\n\n"
312 "vlan set strip (on|off) (port_id)\n"
313 " Set the VLAN strip on a port.\n\n"
315 "vlan set stripq (on|off) (port_id,queue_id)\n"
316 " Set the VLAN strip for a queue on a port.\n\n"
318 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
319 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
321 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
322 " Set VLAN insert for a VF from the PF.\n\n"
324 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
325 " Set VLAN antispoof for a VF from the PF.\n\n"
327 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
328 " Set VLAN tag for a VF from the PF.\n\n"
330 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
331 " Set a VF's max bandwidth(Mbps).\n\n"
333 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
334 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
336 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
337 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
339 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
340 " Set some TCs' strict link priority mode on a physical port.\n\n"
342 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
343 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
345 "vlan set filter (on|off) (port_id)\n"
346 " Set the VLAN filter on a port.\n\n"
348 "vlan set qinq (on|off) (port_id)\n"
349 " Set the VLAN QinQ (extended queue in queue)"
352 "vlan set (inner|outer) tpid (value) (port_id)\n"
353 " Set the VLAN TPID for Packet Filtering on"
356 "rx_vlan add (vlan_id|all) (port_id)\n"
357 " Add a vlan_id, or all identifiers, to the set"
358 " of VLAN identifiers filtered by port_id.\n\n"
360 "rx_vlan rm (vlan_id|all) (port_id)\n"
361 " Remove a vlan_id, or all identifiers, from the set"
362 " of VLAN identifiers filtered by port_id.\n\n"
364 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
365 " Add a vlan_id, to the set of VLAN identifiers"
366 "filtered for VF(s) from port_id.\n\n"
368 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
369 " Remove a vlan_id, to the set of VLAN identifiers"
370 "filtered for VF(s) from port_id.\n\n"
372 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
373 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
374 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
375 " add a tunnel filter of a port.\n\n"
377 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
378 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
379 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
380 " remove a tunnel filter of a port.\n\n"
382 "rx_vxlan_port add (udp_port) (port_id)\n"
383 " Add an UDP port for VXLAN packet filter on a port\n\n"
385 "rx_vxlan_port rm (udp_port) (port_id)\n"
386 " Remove an UDP port for VXLAN packet filter on a port\n\n"
388 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
389 " Set hardware insertion of VLAN IDs (single or double VLAN "
390 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
392 "tx_vlan set pvid port_id vlan_id (on|off)\n"
393 " Set port based TX VLAN insertion.\n\n"
395 "tx_vlan reset (port_id)\n"
396 " Disable hardware insertion of a VLAN header in"
397 " packets sent on a port.\n\n"
399 "csum set (ip|udp|tcp|sctp|outer-ip) (hw|sw) (port_id)\n"
400 " Select hardware or software calculation of the"
401 " checksum when transmitting a packet using the"
402 " csum forward engine.\n"
403 " ip|udp|tcp|sctp always concern the inner layer.\n"
404 " outer-ip concerns the outer IP layer in"
405 " case the packet is recognized as a tunnel packet by"
406 " the forward engine (vxlan, gre and ipip are supported)\n"
407 " Please check the NIC datasheet for HW limits.\n\n"
409 "csum parse-tunnel (on|off) (tx_port_id)\n"
410 " If disabled, treat tunnel packets as non-tunneled"
411 " packets (treat inner headers as payload). The port\n"
412 " argument is the port used for TX in csum forward"
415 "csum show (port_id)\n"
416 " Display tx checksum offload configuration\n\n"
418 "tso set (segsize) (portid)\n"
419 " Enable TCP Segmentation Offload in csum forward"
421 " Please check the NIC datasheet for HW limits.\n\n"
424 " Display the status of TCP Segmentation Offload.\n\n"
426 "set port (port_id) gro on|off\n"
427 " Enable or disable Generic Receive Offload in"
428 " csum forwarding engine.\n\n"
430 "show port (port_id) gro\n"
431 " Display GRO configuration.\n\n"
433 "set gro flush (cycles)\n"
434 " Set the cycle to flush GROed packets from"
435 " reassembly tables.\n\n"
437 "set port (port_id) gso (on|off)"
438 " Enable or disable Generic Segmentation Offload in"
439 " csum forwarding engine.\n\n"
441 "set gso segsz (length)\n"
442 " Set max packet length for output GSO segments,"
443 " including packet header and payload.\n\n"
445 "show port (port_id) gso\n"
446 " Show GSO configuration.\n\n"
449 " Set packet forwarding mode.\n\n"
451 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
452 " Add a MAC address on port_id.\n\n"
454 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
455 " Remove a MAC address from port_id.\n\n"
457 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
458 " Set the default MAC address for port_id.\n\n"
460 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
461 " Add a MAC address for a VF on the port.\n\n"
463 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
464 " Set the MAC address for a VF from the PF.\n\n"
466 "set eth-peer (port_id) (peer_addr)\n"
467 " set the peer address for certain port.\n\n"
469 "set port (port_id) uta (mac_address|all) (on|off)\n"
470 " Add/Remove a or all unicast hash filter(s)"
473 "set promisc (port_id|all) (on|off)\n"
474 " Set the promiscuous mode on port_id, or all.\n\n"
476 "set allmulti (port_id|all) (on|off)\n"
477 " Set the allmulti mode on port_id, or all.\n\n"
479 "set vf promisc (port_id) (vf_id) (on|off)\n"
480 " Set unicast promiscuous mode for a VF from the PF.\n\n"
482 "set vf allmulti (port_id) (vf_id) (on|off)\n"
483 " Set multicast promiscuous mode for a VF from the PF.\n\n"
485 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
486 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
487 " (on|off) autoneg (on|off) (port_id)\n"
488 "set flow_ctrl rx (on|off) (portid)\n"
489 "set flow_ctrl tx (on|off) (portid)\n"
490 "set flow_ctrl high_water (high_water) (portid)\n"
491 "set flow_ctrl low_water (low_water) (portid)\n"
492 "set flow_ctrl pause_time (pause_time) (portid)\n"
493 "set flow_ctrl send_xon (send_xon) (portid)\n"
494 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
495 "set flow_ctrl autoneg (on|off) (port_id)\n"
496 " Set the link flow control parameter on a port.\n\n"
498 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
499 " (low_water) (pause_time) (priority) (port_id)\n"
500 " Set the priority flow control parameter on a"
503 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
504 " Set statistics mapping (qmapping 0..15) for RX/TX"
506 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
507 " on port 0 to mapping 5.\n\n"
509 "set xstats-hide-zero on|off\n"
510 " Set the option to hide the zero values"
511 " for xstats display.\n"
513 "set port (port_id) vf (vf_id) rx|tx on|off\n"
514 " Enable/Disable a VF receive/tranmit from a port\n\n"
516 "set port (port_id) vf (vf_id) (mac_addr)"
517 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
518 " Add/Remove unicast or multicast MAC addr filter"
521 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
523 " AUPE:accepts untagged VLAN;"
524 "ROPE:accept unicast hash\n\n"
525 " BAM:accepts broadcast packets;"
526 "MPE:accepts all multicast packets\n\n"
527 " Enable/Disable a VF receive mode of a port\n\n"
529 "set port (port_id) queue (queue_id) rate (rate_num)\n"
530 " Set rate limit for a queue of a port\n\n"
532 "set port (port_id) vf (vf_id) rate (rate_num) "
533 "queue_mask (queue_mask_value)\n"
534 " Set rate limit for queues in VF of a port\n\n"
536 "set port (port_id) mirror-rule (rule_id)"
537 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
538 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
539 " Set pool or vlan type mirror rule on a port.\n"
540 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
541 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
544 "set port (port_id) mirror-rule (rule_id)"
545 " (uplink-mirror|downlink-mirror) dst-pool"
546 " (pool_id) (on|off)\n"
547 " Set uplink or downlink type mirror rule on a port.\n"
548 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
549 " 0 on' enable mirror income traffic to pool 0.\n\n"
551 "reset port (port_id) mirror-rule (rule_id)\n"
552 " Reset a mirror rule.\n\n"
554 "set flush_rx (on|off)\n"
555 " Flush (default) or don't flush RX streams before"
556 " forwarding. Mainly used with PCAP drivers.\n\n"
558 "set bypass mode (normal|bypass|isolate) (port_id)\n"
559 " Set the bypass mode for the lowest port on bypass enabled"
562 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
563 "mode (normal|bypass|isolate) (port_id)\n"
564 " Set the event required to initiate specified bypass mode for"
565 " the lowest port on a bypass enabled NIC where:\n"
566 " timeout = enable bypass after watchdog timeout.\n"
567 " os_on = enable bypass when OS/board is powered on.\n"
568 " os_off = enable bypass when OS/board is powered off.\n"
569 " power_on = enable bypass when power supply is turned on.\n"
570 " power_off = enable bypass when power supply is turned off."
573 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
574 " Set the bypass watchdog timeout to 'n' seconds"
575 " where 0 = instant.\n\n"
577 "show bypass config (port_id)\n"
578 " Show the bypass configuration for a bypass enabled NIC"
579 " using the lowest port on the NIC.\n\n"
581 #ifdef RTE_LIBRTE_PMD_BOND
582 "create bonded device (mode) (socket)\n"
583 " Create a new bonded device with specific bonding mode and socket.\n\n"
585 "add bonding slave (slave_id) (port_id)\n"
586 " Add a slave device to a bonded device.\n\n"
588 "remove bonding slave (slave_id) (port_id)\n"
589 " Remove a slave device from a bonded device.\n\n"
591 "set bonding mode (value) (port_id)\n"
592 " Set the bonding mode on a bonded device.\n\n"
594 "set bonding primary (slave_id) (port_id)\n"
595 " Set the primary slave for a bonded device.\n\n"
597 "show bonding config (port_id)\n"
598 " Show the bonding config for port_id.\n\n"
600 "set bonding mac_addr (port_id) (address)\n"
601 " Set the MAC address of a bonded device.\n\n"
603 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
604 " Set Aggregation mode for IEEE802.3AD (mode 4)"
606 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
607 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
609 "set bonding mon_period (port_id) (value)\n"
610 " Set the bonding link status monitoring polling period in ms.\n\n"
612 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
613 " Enable/disable dedicated queues for LACP control traffic.\n\n"
616 "set link-up port (port_id)\n"
617 " Set link up for a port.\n\n"
619 "set link-down port (port_id)\n"
620 " Set link down for a port.\n\n"
622 "E-tag set insertion on port-tag-id (value)"
623 " port (port_id) vf (vf_id)\n"
624 " Enable E-tag insertion for a VF on a port\n\n"
626 "E-tag set insertion off port (port_id) vf (vf_id)\n"
627 " Disable E-tag insertion for a VF on a port\n\n"
629 "E-tag set stripping (on|off) port (port_id)\n"
630 " Enable/disable E-tag stripping on a port\n\n"
632 "E-tag set forwarding (on|off) port (port_id)\n"
633 " Enable/disable E-tag based forwarding"
636 "E-tag set filter add e-tag-id (value) dst-pool"
637 " (pool_id) port (port_id)\n"
638 " Add an E-tag forwarding filter on a port\n\n"
640 "E-tag set filter del e-tag-id (value) port (port_id)\n"
641 " Delete an E-tag forwarding filter on a port\n\n"
643 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
644 "set port tm hierarchy default (port_id)\n"
645 " Set default traffic Management hierarchy on a port\n\n"
648 "ddp add (port_id) (profile_path[,backup_profile_path])\n"
649 " Load a profile package on a port\n\n"
651 "ddp del (port_id) (backup_profile_path)\n"
652 " Delete a profile package from a port\n\n"
654 "ptype mapping get (port_id) (valid_only)\n"
655 " Get ptype mapping on a port\n\n"
657 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
658 " Replace target with the pkt_type in ptype mapping\n\n"
660 "ptype mapping reset (port_id)\n"
661 " Reset ptype mapping on a port\n\n"
663 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
664 " Update a ptype mapping item on a port\n\n"
666 "set port (port_id) queue-region region_id (value) "
667 "queue_start_index (value) queue_num (value)\n"
668 " Set a queue region on a port\n\n"
670 "set port (port_id) queue-region region_id (value) "
672 " Set a flowtype region index on a port\n\n"
674 "set port (port_id) queue-region UP (value) region_id (value)\n"
675 " Set the mapping of User Priority to "
676 "queue region on a port\n\n"
678 "set port (port_id) queue-region flush (on|off)\n"
679 " flush all queue region related configuration\n\n"
681 "show port meter cap (port_id)\n"
682 " Show port meter capability information\n\n"
684 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs)\n"
685 " meter profile add - srtcm rfc 2697\n\n"
687 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n"
688 " meter profile add - trtcm rfc 2698\n\n"
690 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n"
691 " meter profile add - trtcm rfc 4115\n\n"
693 "del port meter profile (port_id) (profile_id)\n"
694 " meter profile delete\n\n"
696 "create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n"
697 "(g_action) (y_action) (r_action) (stats_mask) (shared)\n"
698 "(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
699 "(dscp_tbl_entry63)]\n"
702 "enable port meter (port_id) (mtr_id)\n"
705 "disable port meter (port_id) (mtr_id)\n"
708 "del port meter (port_id) (mtr_id)\n"
711 "set port meter profile (port_id) (mtr_id) (profile_id)\n"
712 " meter update meter profile\n\n"
714 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
715 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
716 " update meter dscp table entries\n\n"
718 "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
719 "(action0) [(action1) (action2)]\n"
720 " meter update policer action\n\n"
722 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
723 " meter update stats\n\n"
725 "show port (port_id) queue-region\n"
726 " show all queue region related configuration info\n\n"
728 "add port tm node shaper profile (port_id) (shaper_profile_id)"
729 " (tb_rate) (tb_size) (packet_length_adjust)\n"
730 " Add port tm node private shaper profile.\n\n"
732 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
733 " Delete port tm node private shaper profile.\n\n"
735 "add port tm node shared shaper (port_id) (shared_shaper_id)"
736 " (shaper_profile_id)\n"
737 " Add/update port tm node shared shaper.\n\n"
739 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
740 " Delete port tm node shared shaper.\n\n"
742 "set port tm node shaper profile (port_id) (node_id)"
743 " (shaper_profile_id)\n"
744 " Set port tm node shaper profile.\n\n"
746 "add port tm node wred profile (port_id) (wred_profile_id)"
747 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
748 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
749 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
750 " Add port tm node wred profile.\n\n"
752 "del port tm node wred profile (port_id) (wred_profile_id)\n"
753 " Delete port tm node wred profile.\n\n"
755 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
756 " (priority) (weight) (level_id) (shaper_profile_id)"
757 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
758 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
759 " Add port tm nonleaf node.\n\n"
761 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
762 " (priority) (weight) (level_id) (shaper_profile_id)"
763 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
764 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
765 " Add port tm leaf node.\n\n"
767 "del port tm node (port_id) (node_id)\n"
768 " Delete port tm node.\n\n"
770 "set port tm node parent (port_id) (node_id) (parent_node_id)"
771 " (priority) (weight)\n"
772 " Set port tm node parent.\n\n"
774 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
775 " Commit tm hierarchy.\n\n"
777 , list_pkt_forwarding_modes()
781 if (show_all || !strcmp(res->section, "ports")) {
787 "----------------\n\n"
789 "port start (port_id|all)\n"
790 " Start all ports or port_id.\n\n"
792 "port stop (port_id|all)\n"
793 " Stop all ports or port_id.\n\n"
795 "port close (port_id|all)\n"
796 " Close all ports or port_id.\n\n"
798 "port attach (ident)\n"
799 " Attach physical or virtual dev by pci address or virtual device name\n\n"
801 "port detach (port_id)\n"
802 " Detach physical or virtual dev by port_id\n\n"
804 "port config (port_id|all)"
805 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
806 " duplex (half|full|auto)\n"
807 " Set speed and duplex for all ports or port_id\n\n"
809 "port config (port_id|all) loopback (mode)\n"
810 " Set loopback mode for all ports or port_id\n\n"
812 "port config all (rxq|txq|rxd|txd) (value)\n"
813 " Set number for rxq/txq/rxd/txd.\n\n"
815 "port config all max-pkt-len (value)\n"
816 " Set the max packet length.\n\n"
818 "port config all (crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|hw-vlan-filter|"
819 "hw-vlan-strip|hw-vlan-extend|drop-en)"
821 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
824 "port config all rss (all|default|ip|tcp|udp|sctp|"
825 "ether|port|vxlan|geneve|nvgre|none|<flowtype_id>)\n"
826 " Set the RSS mode.\n\n"
828 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
829 " Set the RSS redirection table.\n\n"
831 "port config (port_id) dcb vt (on|off) (traffic_class)"
833 " Set the DCB mode.\n\n"
835 "port config all burst (value)\n"
836 " Set the number of packets per burst.\n\n"
838 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
840 " Set the ring prefetch/host/writeback threshold"
841 " for tx/rx queue.\n\n"
843 "port config all (txfreet|txrst|rxfreet) (value)\n"
844 " Set free threshold for rx/tx, or set"
845 " tx rs bit threshold.\n\n"
846 "port config mtu X value\n"
847 " Set the MTU of port X to a given value\n\n"
849 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
850 " Set a rx/tx queue's ring size configuration, the new"
851 " value will take effect after command that (re-)start the port"
852 " or command that setup the specific queue\n\n"
854 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
855 " Start/stop a rx/tx queue of port X. Only take effect"
856 " when port X is started\n\n"
858 "port (port_id) (rxq|txq) (queue_id) setup\n"
859 " Setup a rx/tx queue of port X.\n\n"
861 "port config (port_id|all) l2-tunnel E-tag ether-type"
863 " Set the value of E-tag ether-type.\n\n"
865 "port config (port_id|all) l2-tunnel E-tag"
866 " (enable|disable)\n"
867 " Enable/disable the E-tag support.\n\n"
869 "port config (port_id) pctype mapping reset\n"
870 " Reset flow type to pctype mapping on a port\n\n"
872 "port config (port_id) pctype mapping update"
873 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
874 " Update a flow type to pctype mapping item on a port\n\n"
876 "port config (port_id) pctype (pctype_id) hash_inset|"
877 "fdir_inset|fdir_flx_inset get|set|clear field\n"
879 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
881 "port config (port_id) pctype (pctype_id) hash_inset|"
882 "fdir_inset|fdir_flx_inset clear all"
883 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
887 if (show_all || !strcmp(res->section, "registers")) {
895 "read reg (port_id) (address)\n"
896 " Display value of a port register.\n\n"
898 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
899 " Display a port register bit field.\n\n"
901 "read regbit (port_id) (address) (bit_x)\n"
902 " Display a single port register bit.\n\n"
904 "write reg (port_id) (address) (value)\n"
905 " Set value of a port register.\n\n"
907 "write regfield (port_id) (address) (bit_x) (bit_y)"
909 " Set bit field of a port register.\n\n"
911 "write regbit (port_id) (address) (bit_x) (value)\n"
912 " Set single bit value of a port register.\n\n"
915 if (show_all || !strcmp(res->section, "filters")) {
923 "ethertype_filter (port_id) (add|del)"
924 " (mac_addr|mac_ignr) (mac_address) ethertype"
925 " (ether_type) (drop|fwd) queue (queue_id)\n"
926 " Add/Del an ethertype filter.\n\n"
928 "2tuple_filter (port_id) (add|del)"
929 " dst_port (dst_port_value) protocol (protocol_value)"
930 " mask (mask_value) tcp_flags (tcp_flags_value)"
931 " priority (prio_value) queue (queue_id)\n"
932 " Add/Del a 2tuple filter.\n\n"
934 "5tuple_filter (port_id) (add|del)"
935 " dst_ip (dst_address) src_ip (src_address)"
936 " dst_port (dst_port_value) src_port (src_port_value)"
937 " protocol (protocol_value)"
938 " mask (mask_value) tcp_flags (tcp_flags_value)"
939 " priority (prio_value) queue (queue_id)\n"
940 " Add/Del a 5tuple filter.\n\n"
942 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
943 " Add/Del syn filter.\n\n"
945 "flex_filter (port_id) (add|del) len (len_value)"
946 " bytes (bytes_value) mask (mask_value)"
947 " priority (prio_value) queue (queue_id)\n"
948 " Add/Del a flex filter.\n\n"
950 "flow_director_filter (port_id) mode IP (add|del|update)"
951 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
952 " src (src_ip_address) dst (dst_ip_address)"
953 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
954 " vlan (vlan_value) flexbytes (flexbytes_value)"
955 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
956 " fd_id (fd_id_value)\n"
957 " Add/Del an IP type flow director filter.\n\n"
959 "flow_director_filter (port_id) mode IP (add|del|update)"
960 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
961 " src (src_ip_address) (src_port)"
962 " dst (dst_ip_address) (dst_port)"
963 " tos (tos_value) ttl (ttl_value)"
964 " vlan (vlan_value) flexbytes (flexbytes_value)"
965 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
966 " fd_id (fd_id_value)\n"
967 " Add/Del an UDP/TCP type flow director filter.\n\n"
969 "flow_director_filter (port_id) mode IP (add|del|update)"
970 " flow (ipv4-sctp|ipv6-sctp)"
971 " src (src_ip_address) (src_port)"
972 " dst (dst_ip_address) (dst_port)"
973 " tag (verification_tag) "
974 " tos (tos_value) ttl (ttl_value)"
976 " flexbytes (flexbytes_value) (drop|fwd)"
977 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
978 " Add/Del a SCTP type flow director filter.\n\n"
980 "flow_director_filter (port_id) mode IP (add|del|update)"
981 " flow l2_payload ether (ethertype)"
982 " flexbytes (flexbytes_value) (drop|fwd)"
983 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
984 " Add/Del a l2 payload type flow director filter.\n\n"
986 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
987 " mac (mac_address) vlan (vlan_value)"
988 " flexbytes (flexbytes_value) (drop|fwd)"
989 " queue (queue_id) fd_id (fd_id_value)\n"
990 " Add/Del a MAC-VLAN flow director filter.\n\n"
992 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
993 " mac (mac_address) vlan (vlan_value)"
994 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
995 " flexbytes (flexbytes_value) (drop|fwd)"
996 " queue (queue_id) fd_id (fd_id_value)\n"
997 " Add/Del a Tunnel flow director filter.\n\n"
999 "flow_director_filter (port_id) mode raw (add|del|update)"
1000 " flow (flow_id) (drop|fwd) queue (queue_id)"
1001 " fd_id (fd_id_value) packet (packet file name)\n"
1002 " Add/Del a raw type flow director filter.\n\n"
1004 "flush_flow_director (port_id)\n"
1005 " Flush all flow director entries of a device.\n\n"
1007 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
1008 " src_mask (ipv4_src) (ipv6_src) (src_port)"
1009 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
1010 " Set flow director IP mask.\n\n"
1012 "flow_director_mask (port_id) mode MAC-VLAN"
1013 " vlan (vlan_value)\n"
1014 " Set flow director MAC-VLAN mask.\n\n"
1016 "flow_director_mask (port_id) mode Tunnel"
1017 " vlan (vlan_value) mac (mac_value)"
1018 " tunnel-type (tunnel_type_value)"
1019 " tunnel-id (tunnel_id_value)\n"
1020 " Set flow director Tunnel mask.\n\n"
1022 "flow_director_flex_mask (port_id)"
1023 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
1024 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
1026 " Configure mask of flex payload.\n\n"
1028 "flow_director_flex_payload (port_id)"
1029 " (raw|l2|l3|l4) (config)\n"
1030 " Configure flex payload selection.\n\n"
1032 "get_sym_hash_ena_per_port (port_id)\n"
1033 " get symmetric hash enable configuration per port.\n\n"
1035 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
1036 " set symmetric hash enable configuration per port"
1037 " to enable or disable.\n\n"
1039 "get_hash_global_config (port_id)\n"
1040 " Get the global configurations of hash filters.\n\n"
1042 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
1043 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1044 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
1045 " (enable|disable)\n"
1046 " Set the global configurations of hash filters.\n\n"
1048 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
1049 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1050 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1051 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
1052 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
1053 "ipv6-next-header|udp-src-port|udp-dst-port|"
1054 "tcp-src-port|tcp-dst-port|sctp-src-port|"
1055 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
1056 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
1057 "fld-8th|none) (select|add)\n"
1058 " Set the input set for hash.\n\n"
1060 "set_fdir_input_set (port_id) "
1061 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1062 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1063 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
1064 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
1065 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
1066 "udp-dst-port|tcp-src-port|tcp-dst-port|"
1067 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
1069 " Set the input set for FDir.\n\n"
1071 "flow validate {port_id}"
1072 " [group {group_id}] [priority {level}]"
1073 " [ingress] [egress]"
1074 " pattern {item} [/ {item} [...]] / end"
1075 " actions {action} [/ {action} [...]] / end\n"
1076 " Check whether a flow rule can be created.\n\n"
1078 "flow create {port_id}"
1079 " [group {group_id}] [priority {level}]"
1080 " [ingress] [egress]"
1081 " pattern {item} [/ {item} [...]] / end"
1082 " actions {action} [/ {action} [...]] / end\n"
1083 " Create a flow rule.\n\n"
1085 "flow destroy {port_id} rule {rule_id} [...]\n"
1086 " Destroy specific flow rules.\n\n"
1088 "flow flush {port_id}\n"
1089 " Destroy all flow rules.\n\n"
1091 "flow query {port_id} {rule_id} {action}\n"
1092 " Query an existing flow rule.\n\n"
1094 "flow list {port_id} [group {group_id}] [...]\n"
1095 " List existing flow rules sorted by priority,"
1096 " filtered by group identifiers.\n\n"
1098 "flow isolate {port_id} {boolean}\n"
1099 " Restrict ingress traffic to the defined"
1105 cmdline_parse_token_string_t cmd_help_long_help =
1106 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1108 cmdline_parse_token_string_t cmd_help_long_section =
1109 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1110 "all#control#display#config#"
1111 "ports#registers#filters");
1113 cmdline_parse_inst_t cmd_help_long = {
1114 .f = cmd_help_long_parsed,
1116 .help_str = "help all|control|display|config|ports|register|filters: "
1119 (void *)&cmd_help_long_help,
1120 (void *)&cmd_help_long_section,
1126 /* *** start/stop/close all ports *** */
1127 struct cmd_operate_port_result {
1128 cmdline_fixed_string_t keyword;
1129 cmdline_fixed_string_t name;
1130 cmdline_fixed_string_t value;
1133 static void cmd_operate_port_parsed(void *parsed_result,
1134 __attribute__((unused)) struct cmdline *cl,
1135 __attribute__((unused)) void *data)
1137 struct cmd_operate_port_result *res = parsed_result;
1139 if (!strcmp(res->name, "start"))
1140 start_port(RTE_PORT_ALL);
1141 else if (!strcmp(res->name, "stop"))
1142 stop_port(RTE_PORT_ALL);
1143 else if (!strcmp(res->name, "close"))
1144 close_port(RTE_PORT_ALL);
1145 else if (!strcmp(res->name, "reset"))
1146 reset_port(RTE_PORT_ALL);
1148 printf("Unknown parameter\n");
1151 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1152 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1154 cmdline_parse_token_string_t cmd_operate_port_all_port =
1155 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1156 "start#stop#close#reset");
1157 cmdline_parse_token_string_t cmd_operate_port_all_all =
1158 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1160 cmdline_parse_inst_t cmd_operate_port = {
1161 .f = cmd_operate_port_parsed,
1163 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1165 (void *)&cmd_operate_port_all_cmd,
1166 (void *)&cmd_operate_port_all_port,
1167 (void *)&cmd_operate_port_all_all,
1172 /* *** start/stop/close specific port *** */
1173 struct cmd_operate_specific_port_result {
1174 cmdline_fixed_string_t keyword;
1175 cmdline_fixed_string_t name;
1179 static void cmd_operate_specific_port_parsed(void *parsed_result,
1180 __attribute__((unused)) struct cmdline *cl,
1181 __attribute__((unused)) void *data)
1183 struct cmd_operate_specific_port_result *res = parsed_result;
1185 if (!strcmp(res->name, "start"))
1186 start_port(res->value);
1187 else if (!strcmp(res->name, "stop"))
1188 stop_port(res->value);
1189 else if (!strcmp(res->name, "close"))
1190 close_port(res->value);
1191 else if (!strcmp(res->name, "reset"))
1192 reset_port(res->value);
1194 printf("Unknown parameter\n");
1197 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1198 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1200 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1201 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1202 name, "start#stop#close#reset");
1203 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1204 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1207 cmdline_parse_inst_t cmd_operate_specific_port = {
1208 .f = cmd_operate_specific_port_parsed,
1210 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1212 (void *)&cmd_operate_specific_port_cmd,
1213 (void *)&cmd_operate_specific_port_port,
1214 (void *)&cmd_operate_specific_port_id,
1219 /* *** attach a specified port *** */
1220 struct cmd_operate_attach_port_result {
1221 cmdline_fixed_string_t port;
1222 cmdline_fixed_string_t keyword;
1223 cmdline_fixed_string_t identifier;
1226 static void cmd_operate_attach_port_parsed(void *parsed_result,
1227 __attribute__((unused)) struct cmdline *cl,
1228 __attribute__((unused)) void *data)
1230 struct cmd_operate_attach_port_result *res = parsed_result;
1232 if (!strcmp(res->keyword, "attach"))
1233 attach_port(res->identifier);
1235 printf("Unknown parameter\n");
1238 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1239 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1241 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1242 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1244 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1245 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1248 cmdline_parse_inst_t cmd_operate_attach_port = {
1249 .f = cmd_operate_attach_port_parsed,
1251 .help_str = "port attach <identifier>: "
1252 "(identifier: pci address or virtual dev name)",
1254 (void *)&cmd_operate_attach_port_port,
1255 (void *)&cmd_operate_attach_port_keyword,
1256 (void *)&cmd_operate_attach_port_identifier,
1261 /* *** detach a specified port *** */
1262 struct cmd_operate_detach_port_result {
1263 cmdline_fixed_string_t port;
1264 cmdline_fixed_string_t keyword;
1268 static void cmd_operate_detach_port_parsed(void *parsed_result,
1269 __attribute__((unused)) struct cmdline *cl,
1270 __attribute__((unused)) void *data)
1272 struct cmd_operate_detach_port_result *res = parsed_result;
1274 if (!strcmp(res->keyword, "detach"))
1275 detach_port(res->port_id);
1277 printf("Unknown parameter\n");
1280 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1281 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1283 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1284 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1286 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1287 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1290 cmdline_parse_inst_t cmd_operate_detach_port = {
1291 .f = cmd_operate_detach_port_parsed,
1293 .help_str = "port detach <port_id>",
1295 (void *)&cmd_operate_detach_port_port,
1296 (void *)&cmd_operate_detach_port_keyword,
1297 (void *)&cmd_operate_detach_port_port_id,
1302 /* *** configure speed for all ports *** */
1303 struct cmd_config_speed_all {
1304 cmdline_fixed_string_t port;
1305 cmdline_fixed_string_t keyword;
1306 cmdline_fixed_string_t all;
1307 cmdline_fixed_string_t item1;
1308 cmdline_fixed_string_t item2;
1309 cmdline_fixed_string_t value1;
1310 cmdline_fixed_string_t value2;
1314 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1319 if (!strcmp(duplexstr, "half")) {
1320 duplex = ETH_LINK_HALF_DUPLEX;
1321 } else if (!strcmp(duplexstr, "full")) {
1322 duplex = ETH_LINK_FULL_DUPLEX;
1323 } else if (!strcmp(duplexstr, "auto")) {
1324 duplex = ETH_LINK_FULL_DUPLEX;
1326 printf("Unknown duplex parameter\n");
1330 if (!strcmp(speedstr, "10")) {
1331 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1332 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1333 } else if (!strcmp(speedstr, "100")) {
1334 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1335 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1337 if (duplex != ETH_LINK_FULL_DUPLEX) {
1338 printf("Invalid speed/duplex parameters\n");
1341 if (!strcmp(speedstr, "1000")) {
1342 *speed = ETH_LINK_SPEED_1G;
1343 } else if (!strcmp(speedstr, "10000")) {
1344 *speed = ETH_LINK_SPEED_10G;
1345 } else if (!strcmp(speedstr, "25000")) {
1346 *speed = ETH_LINK_SPEED_25G;
1347 } else if (!strcmp(speedstr, "40000")) {
1348 *speed = ETH_LINK_SPEED_40G;
1349 } else if (!strcmp(speedstr, "50000")) {
1350 *speed = ETH_LINK_SPEED_50G;
1351 } else if (!strcmp(speedstr, "100000")) {
1352 *speed = ETH_LINK_SPEED_100G;
1353 } else if (!strcmp(speedstr, "auto")) {
1354 *speed = ETH_LINK_SPEED_AUTONEG;
1356 printf("Unknown speed parameter\n");
1365 cmd_config_speed_all_parsed(void *parsed_result,
1366 __attribute__((unused)) struct cmdline *cl,
1367 __attribute__((unused)) void *data)
1369 struct cmd_config_speed_all *res = parsed_result;
1370 uint32_t link_speed;
1373 if (!all_ports_stopped()) {
1374 printf("Please stop all ports first\n");
1378 if (parse_and_check_speed_duplex(res->value1, res->value2,
1382 RTE_ETH_FOREACH_DEV(pid) {
1383 ports[pid].dev_conf.link_speeds = link_speed;
1386 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1389 cmdline_parse_token_string_t cmd_config_speed_all_port =
1390 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1391 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1392 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1394 cmdline_parse_token_string_t cmd_config_speed_all_all =
1395 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1396 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1397 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1398 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1399 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1400 "10#100#1000#10000#25000#40000#50000#100000#auto");
1401 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1402 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1403 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1404 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1407 cmdline_parse_inst_t cmd_config_speed_all = {
1408 .f = cmd_config_speed_all_parsed,
1410 .help_str = "port config all speed "
1411 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1414 (void *)&cmd_config_speed_all_port,
1415 (void *)&cmd_config_speed_all_keyword,
1416 (void *)&cmd_config_speed_all_all,
1417 (void *)&cmd_config_speed_all_item1,
1418 (void *)&cmd_config_speed_all_value1,
1419 (void *)&cmd_config_speed_all_item2,
1420 (void *)&cmd_config_speed_all_value2,
1425 /* *** configure speed for specific port *** */
1426 struct cmd_config_speed_specific {
1427 cmdline_fixed_string_t port;
1428 cmdline_fixed_string_t keyword;
1430 cmdline_fixed_string_t item1;
1431 cmdline_fixed_string_t item2;
1432 cmdline_fixed_string_t value1;
1433 cmdline_fixed_string_t value2;
1437 cmd_config_speed_specific_parsed(void *parsed_result,
1438 __attribute__((unused)) struct cmdline *cl,
1439 __attribute__((unused)) void *data)
1441 struct cmd_config_speed_specific *res = parsed_result;
1442 uint32_t link_speed;
1444 if (!all_ports_stopped()) {
1445 printf("Please stop all ports first\n");
1449 if (port_id_is_invalid(res->id, ENABLED_WARN))
1452 if (parse_and_check_speed_duplex(res->value1, res->value2,
1456 ports[res->id].dev_conf.link_speeds = link_speed;
1458 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1462 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1463 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1465 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1466 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1468 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1469 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT16);
1470 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1471 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1473 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1474 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1475 "10#100#1000#10000#25000#40000#50000#100000#auto");
1476 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1477 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1479 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1480 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1483 cmdline_parse_inst_t cmd_config_speed_specific = {
1484 .f = cmd_config_speed_specific_parsed,
1486 .help_str = "port config <port_id> speed "
1487 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1490 (void *)&cmd_config_speed_specific_port,
1491 (void *)&cmd_config_speed_specific_keyword,
1492 (void *)&cmd_config_speed_specific_id,
1493 (void *)&cmd_config_speed_specific_item1,
1494 (void *)&cmd_config_speed_specific_value1,
1495 (void *)&cmd_config_speed_specific_item2,
1496 (void *)&cmd_config_speed_specific_value2,
1501 /* *** configure loopback for all ports *** */
1502 struct cmd_config_loopback_all {
1503 cmdline_fixed_string_t port;
1504 cmdline_fixed_string_t keyword;
1505 cmdline_fixed_string_t all;
1506 cmdline_fixed_string_t item;
1511 cmd_config_loopback_all_parsed(void *parsed_result,
1512 __attribute__((unused)) struct cmdline *cl,
1513 __attribute__((unused)) void *data)
1515 struct cmd_config_loopback_all *res = parsed_result;
1518 if (!all_ports_stopped()) {
1519 printf("Please stop all ports first\n");
1523 RTE_ETH_FOREACH_DEV(pid) {
1524 ports[pid].dev_conf.lpbk_mode = res->mode;
1527 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1530 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1531 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1532 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1533 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1535 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1536 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1537 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1538 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1540 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1541 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32);
1543 cmdline_parse_inst_t cmd_config_loopback_all = {
1544 .f = cmd_config_loopback_all_parsed,
1546 .help_str = "port config all loopback <mode>",
1548 (void *)&cmd_config_loopback_all_port,
1549 (void *)&cmd_config_loopback_all_keyword,
1550 (void *)&cmd_config_loopback_all_all,
1551 (void *)&cmd_config_loopback_all_item,
1552 (void *)&cmd_config_loopback_all_mode,
1557 /* *** configure loopback for specific port *** */
1558 struct cmd_config_loopback_specific {
1559 cmdline_fixed_string_t port;
1560 cmdline_fixed_string_t keyword;
1562 cmdline_fixed_string_t item;
1567 cmd_config_loopback_specific_parsed(void *parsed_result,
1568 __attribute__((unused)) struct cmdline *cl,
1569 __attribute__((unused)) void *data)
1571 struct cmd_config_loopback_specific *res = parsed_result;
1573 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1576 if (!port_is_stopped(res->port_id)) {
1577 printf("Please stop port %u first\n", res->port_id);
1581 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1583 cmd_reconfig_device_queue(res->port_id, 1, 1);
1587 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1588 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1590 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1591 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1593 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1594 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1596 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1597 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1599 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1600 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1603 cmdline_parse_inst_t cmd_config_loopback_specific = {
1604 .f = cmd_config_loopback_specific_parsed,
1606 .help_str = "port config <port_id> loopback <mode>",
1608 (void *)&cmd_config_loopback_specific_port,
1609 (void *)&cmd_config_loopback_specific_keyword,
1610 (void *)&cmd_config_loopback_specific_id,
1611 (void *)&cmd_config_loopback_specific_item,
1612 (void *)&cmd_config_loopback_specific_mode,
1617 /* *** configure txq/rxq, txd/rxd *** */
1618 struct cmd_config_rx_tx {
1619 cmdline_fixed_string_t port;
1620 cmdline_fixed_string_t keyword;
1621 cmdline_fixed_string_t all;
1622 cmdline_fixed_string_t name;
1627 cmd_config_rx_tx_parsed(void *parsed_result,
1628 __attribute__((unused)) struct cmdline *cl,
1629 __attribute__((unused)) void *data)
1631 struct cmd_config_rx_tx *res = parsed_result;
1633 if (!all_ports_stopped()) {
1634 printf("Please stop all ports first\n");
1637 if (!strcmp(res->name, "rxq")) {
1638 if (!res->value && !nb_txq) {
1639 printf("Warning: Either rx or tx queues should be non zero\n");
1642 if (check_nb_rxq(res->value) != 0)
1644 nb_rxq = res->value;
1646 else if (!strcmp(res->name, "txq")) {
1647 if (!res->value && !nb_rxq) {
1648 printf("Warning: Either rx or tx queues should be non zero\n");
1651 if (check_nb_txq(res->value) != 0)
1653 nb_txq = res->value;
1655 else if (!strcmp(res->name, "rxd")) {
1656 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1657 printf("rxd %d invalid - must be > 0 && <= %d\n",
1658 res->value, RTE_TEST_RX_DESC_MAX);
1661 nb_rxd = res->value;
1662 } else if (!strcmp(res->name, "txd")) {
1663 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1664 printf("txd %d invalid - must be > 0 && <= %d\n",
1665 res->value, RTE_TEST_TX_DESC_MAX);
1668 nb_txd = res->value;
1670 printf("Unknown parameter\n");
1678 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1681 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1682 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1683 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1684 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1685 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1686 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1687 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1688 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1690 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1691 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1693 cmdline_parse_inst_t cmd_config_rx_tx = {
1694 .f = cmd_config_rx_tx_parsed,
1696 .help_str = "port config all rxq|txq|rxd|txd <value>",
1698 (void *)&cmd_config_rx_tx_port,
1699 (void *)&cmd_config_rx_tx_keyword,
1700 (void *)&cmd_config_rx_tx_all,
1701 (void *)&cmd_config_rx_tx_name,
1702 (void *)&cmd_config_rx_tx_value,
1707 /* *** config max packet length *** */
1708 struct cmd_config_max_pkt_len_result {
1709 cmdline_fixed_string_t port;
1710 cmdline_fixed_string_t keyword;
1711 cmdline_fixed_string_t all;
1712 cmdline_fixed_string_t name;
1717 cmd_config_max_pkt_len_parsed(void *parsed_result,
1718 __attribute__((unused)) struct cmdline *cl,
1719 __attribute__((unused)) void *data)
1721 struct cmd_config_max_pkt_len_result *res = parsed_result;
1724 if (!all_ports_stopped()) {
1725 printf("Please stop all ports first\n");
1729 RTE_ETH_FOREACH_DEV(pid) {
1730 struct rte_port *port = &ports[pid];
1731 uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
1733 if (!strcmp(res->name, "max-pkt-len")) {
1734 if (res->value < ETHER_MIN_LEN) {
1735 printf("max-pkt-len can not be less than %d\n",
1739 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
1742 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
1743 if (res->value > ETHER_MAX_LEN)
1744 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
1746 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
1747 port->dev_conf.rxmode.offloads = rx_offloads;
1749 printf("Unknown parameter\n");
1756 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1759 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1760 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1762 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1763 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1765 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1766 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1768 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1769 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1771 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1772 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1775 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1776 .f = cmd_config_max_pkt_len_parsed,
1778 .help_str = "port config all max-pkt-len <value>",
1780 (void *)&cmd_config_max_pkt_len_port,
1781 (void *)&cmd_config_max_pkt_len_keyword,
1782 (void *)&cmd_config_max_pkt_len_all,
1783 (void *)&cmd_config_max_pkt_len_name,
1784 (void *)&cmd_config_max_pkt_len_value,
1789 /* *** configure port MTU *** */
1790 struct cmd_config_mtu_result {
1791 cmdline_fixed_string_t port;
1792 cmdline_fixed_string_t keyword;
1793 cmdline_fixed_string_t mtu;
1799 cmd_config_mtu_parsed(void *parsed_result,
1800 __attribute__((unused)) struct cmdline *cl,
1801 __attribute__((unused)) void *data)
1803 struct cmd_config_mtu_result *res = parsed_result;
1805 if (res->value < ETHER_MIN_LEN) {
1806 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1809 port_mtu_set(res->port_id, res->value);
1812 cmdline_parse_token_string_t cmd_config_mtu_port =
1813 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1815 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1816 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1818 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1819 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1821 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1822 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
1823 cmdline_parse_token_num_t cmd_config_mtu_value =
1824 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1826 cmdline_parse_inst_t cmd_config_mtu = {
1827 .f = cmd_config_mtu_parsed,
1829 .help_str = "port config mtu <port_id> <value>",
1831 (void *)&cmd_config_mtu_port,
1832 (void *)&cmd_config_mtu_keyword,
1833 (void *)&cmd_config_mtu_mtu,
1834 (void *)&cmd_config_mtu_port_id,
1835 (void *)&cmd_config_mtu_value,
1840 /* *** configure rx mode *** */
1841 struct cmd_config_rx_mode_flag {
1842 cmdline_fixed_string_t port;
1843 cmdline_fixed_string_t keyword;
1844 cmdline_fixed_string_t all;
1845 cmdline_fixed_string_t name;
1846 cmdline_fixed_string_t value;
1850 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1851 __attribute__((unused)) struct cmdline *cl,
1852 __attribute__((unused)) void *data)
1854 struct cmd_config_rx_mode_flag *res = parsed_result;
1857 if (!all_ports_stopped()) {
1858 printf("Please stop all ports first\n");
1862 RTE_ETH_FOREACH_DEV(pid) {
1863 struct rte_port *port;
1864 uint64_t rx_offloads;
1867 rx_offloads = port->dev_conf.rxmode.offloads;
1868 if (!strcmp(res->name, "crc-strip")) {
1869 if (!strcmp(res->value, "on"))
1870 rx_offloads |= DEV_RX_OFFLOAD_CRC_STRIP;
1871 else if (!strcmp(res->value, "off"))
1872 rx_offloads &= ~DEV_RX_OFFLOAD_CRC_STRIP;
1874 printf("Unknown parameter\n");
1877 } else if (!strcmp(res->name, "scatter")) {
1878 if (!strcmp(res->value, "on")) {
1879 rx_offloads |= DEV_RX_OFFLOAD_SCATTER;
1880 } else if (!strcmp(res->value, "off")) {
1881 rx_offloads &= ~DEV_RX_OFFLOAD_SCATTER;
1883 printf("Unknown parameter\n");
1886 } else if (!strcmp(res->name, "rx-cksum")) {
1887 if (!strcmp(res->value, "on"))
1888 rx_offloads |= DEV_RX_OFFLOAD_CHECKSUM;
1889 else if (!strcmp(res->value, "off"))
1890 rx_offloads &= ~DEV_RX_OFFLOAD_CHECKSUM;
1892 printf("Unknown parameter\n");
1895 } else if (!strcmp(res->name, "rx-timestamp")) {
1896 if (!strcmp(res->value, "on"))
1897 rx_offloads |= DEV_RX_OFFLOAD_TIMESTAMP;
1898 else if (!strcmp(res->value, "off"))
1899 rx_offloads &= ~DEV_RX_OFFLOAD_TIMESTAMP;
1901 printf("Unknown parameter\n");
1904 } else if (!strcmp(res->name, "hw-vlan")) {
1905 if (!strcmp(res->value, "on")) {
1906 rx_offloads |= (DEV_RX_OFFLOAD_VLAN_FILTER |
1907 DEV_RX_OFFLOAD_VLAN_STRIP);
1908 } else if (!strcmp(res->value, "off")) {
1909 rx_offloads &= ~(DEV_RX_OFFLOAD_VLAN_FILTER |
1910 DEV_RX_OFFLOAD_VLAN_STRIP);
1912 printf("Unknown parameter\n");
1915 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1916 if (!strcmp(res->value, "on"))
1917 rx_offloads |= DEV_RX_OFFLOAD_VLAN_FILTER;
1918 else if (!strcmp(res->value, "off"))
1919 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_FILTER;
1921 printf("Unknown parameter\n");
1924 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1925 if (!strcmp(res->value, "on"))
1926 rx_offloads |= DEV_RX_OFFLOAD_VLAN_STRIP;
1927 else if (!strcmp(res->value, "off"))
1928 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_STRIP;
1930 printf("Unknown parameter\n");
1933 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1934 if (!strcmp(res->value, "on"))
1935 rx_offloads |= DEV_RX_OFFLOAD_VLAN_EXTEND;
1936 else if (!strcmp(res->value, "off"))
1937 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_EXTEND;
1939 printf("Unknown parameter\n");
1942 } else if (!strcmp(res->name, "drop-en")) {
1943 if (!strcmp(res->value, "on"))
1945 else if (!strcmp(res->value, "off"))
1948 printf("Unknown parameter\n");
1952 printf("Unknown parameter\n");
1955 port->dev_conf.rxmode.offloads = rx_offloads;
1960 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1963 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1964 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1965 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1966 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1968 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1969 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1970 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1971 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1972 "crc-strip#scatter#rx-cksum#rx-timestamp#hw-vlan#"
1973 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1974 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1975 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1978 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1979 .f = cmd_config_rx_mode_flag_parsed,
1981 .help_str = "port config all crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|"
1982 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1984 (void *)&cmd_config_rx_mode_flag_port,
1985 (void *)&cmd_config_rx_mode_flag_keyword,
1986 (void *)&cmd_config_rx_mode_flag_all,
1987 (void *)&cmd_config_rx_mode_flag_name,
1988 (void *)&cmd_config_rx_mode_flag_value,
1993 /* *** configure rss *** */
1994 struct cmd_config_rss {
1995 cmdline_fixed_string_t port;
1996 cmdline_fixed_string_t keyword;
1997 cmdline_fixed_string_t all;
1998 cmdline_fixed_string_t name;
1999 cmdline_fixed_string_t value;
2003 cmd_config_rss_parsed(void *parsed_result,
2004 __attribute__((unused)) struct cmdline *cl,
2005 __attribute__((unused)) void *data)
2007 struct cmd_config_rss *res = parsed_result;
2008 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2009 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2013 if (!strcmp(res->value, "all"))
2014 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
2015 ETH_RSS_UDP | ETH_RSS_SCTP |
2017 else if (!strcmp(res->value, "ip"))
2018 rss_conf.rss_hf = ETH_RSS_IP;
2019 else if (!strcmp(res->value, "udp"))
2020 rss_conf.rss_hf = ETH_RSS_UDP;
2021 else if (!strcmp(res->value, "tcp"))
2022 rss_conf.rss_hf = ETH_RSS_TCP;
2023 else if (!strcmp(res->value, "sctp"))
2024 rss_conf.rss_hf = ETH_RSS_SCTP;
2025 else if (!strcmp(res->value, "ether"))
2026 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2027 else if (!strcmp(res->value, "port"))
2028 rss_conf.rss_hf = ETH_RSS_PORT;
2029 else if (!strcmp(res->value, "vxlan"))
2030 rss_conf.rss_hf = ETH_RSS_VXLAN;
2031 else if (!strcmp(res->value, "geneve"))
2032 rss_conf.rss_hf = ETH_RSS_GENEVE;
2033 else if (!strcmp(res->value, "nvgre"))
2034 rss_conf.rss_hf = ETH_RSS_NVGRE;
2035 else if (!strcmp(res->value, "none") || !strcmp(res->value, "default"))
2036 rss_conf.rss_hf = 0;
2037 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2038 atoi(res->value) < 64)
2039 rss_conf.rss_hf = 1ULL << atoi(res->value);
2041 printf("Unknown parameter\n");
2044 rss_conf.rss_key = NULL;
2045 /* Update global configuration for RSS types. */
2046 rss_hf = rss_conf.rss_hf;
2047 RTE_ETH_FOREACH_DEV(i) {
2048 if (!strcmp(res->value, "default")) {
2049 rte_eth_dev_info_get(i, &dev_info);
2050 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2052 diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
2054 printf("Configuration of RSS hash at ethernet port %d "
2055 "failed with error (%d): %s.\n",
2056 i, -diag, strerror(-diag));
2060 cmdline_parse_token_string_t cmd_config_rss_port =
2061 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2062 cmdline_parse_token_string_t cmd_config_rss_keyword =
2063 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2064 cmdline_parse_token_string_t cmd_config_rss_all =
2065 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2066 cmdline_parse_token_string_t cmd_config_rss_name =
2067 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2068 cmdline_parse_token_string_t cmd_config_rss_value =
2069 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2071 cmdline_parse_inst_t cmd_config_rss = {
2072 .f = cmd_config_rss_parsed,
2074 .help_str = "port config all rss "
2075 "all|default|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none|<flowtype_id>",
2077 (void *)&cmd_config_rss_port,
2078 (void *)&cmd_config_rss_keyword,
2079 (void *)&cmd_config_rss_all,
2080 (void *)&cmd_config_rss_name,
2081 (void *)&cmd_config_rss_value,
2086 /* *** configure rss hash key *** */
2087 struct cmd_config_rss_hash_key {
2088 cmdline_fixed_string_t port;
2089 cmdline_fixed_string_t config;
2091 cmdline_fixed_string_t rss_hash_key;
2092 cmdline_fixed_string_t rss_type;
2093 cmdline_fixed_string_t key;
2097 hexa_digit_to_value(char hexa_digit)
2099 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2100 return (uint8_t) (hexa_digit - '0');
2101 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2102 return (uint8_t) ((hexa_digit - 'a') + 10);
2103 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2104 return (uint8_t) ((hexa_digit - 'A') + 10);
2105 /* Invalid hexa digit */
2110 parse_and_check_key_hexa_digit(char *key, int idx)
2114 hexa_v = hexa_digit_to_value(key[idx]);
2116 printf("invalid key: character %c at position %d is not a "
2117 "valid hexa digit\n", key[idx], idx);
2122 cmd_config_rss_hash_key_parsed(void *parsed_result,
2123 __attribute__((unused)) struct cmdline *cl,
2124 __attribute__((unused)) void *data)
2126 struct cmd_config_rss_hash_key *res = parsed_result;
2127 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2131 struct rte_eth_dev_info dev_info;
2132 uint8_t hash_key_size;
2135 memset(&dev_info, 0, sizeof(dev_info));
2136 rte_eth_dev_info_get(res->port_id, &dev_info);
2137 if (dev_info.hash_key_size > 0 &&
2138 dev_info.hash_key_size <= sizeof(hash_key))
2139 hash_key_size = dev_info.hash_key_size;
2141 printf("dev_info did not provide a valid hash key size\n");
2144 /* Check the length of the RSS hash key */
2145 key_len = strlen(res->key);
2146 if (key_len != (hash_key_size * 2)) {
2147 printf("key length: %d invalid - key must be a string of %d"
2148 " hexa-decimal numbers\n",
2149 (int) key_len, hash_key_size * 2);
2152 /* Translate RSS hash key into binary representation */
2153 for (i = 0; i < hash_key_size; i++) {
2154 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2157 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2160 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2162 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2166 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2167 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2168 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2169 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2171 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2172 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2173 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2174 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2175 rss_hash_key, "rss-hash-key");
2176 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2177 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2178 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2179 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2180 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2181 "ipv6-tcp-ex#ipv6-udp-ex");
2182 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2183 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2185 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2186 .f = cmd_config_rss_hash_key_parsed,
2188 .help_str = "port config <port_id> rss-hash-key "
2189 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2190 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2191 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
2192 "<string of hex digits (variable length, NIC dependent)>",
2194 (void *)&cmd_config_rss_hash_key_port,
2195 (void *)&cmd_config_rss_hash_key_config,
2196 (void *)&cmd_config_rss_hash_key_port_id,
2197 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2198 (void *)&cmd_config_rss_hash_key_rss_type,
2199 (void *)&cmd_config_rss_hash_key_value,
2204 /* *** configure port rxq/txq ring size *** */
2205 struct cmd_config_rxtx_ring_size {
2206 cmdline_fixed_string_t port;
2207 cmdline_fixed_string_t config;
2209 cmdline_fixed_string_t rxtxq;
2211 cmdline_fixed_string_t rsize;
2216 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2217 __attribute__((unused)) struct cmdline *cl,
2218 __attribute__((unused)) void *data)
2220 struct cmd_config_rxtx_ring_size *res = parsed_result;
2221 struct rte_port *port;
2224 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2227 if (res->portid == (portid_t)RTE_PORT_ALL) {
2228 printf("Invalid port id\n");
2232 port = &ports[res->portid];
2234 if (!strcmp(res->rxtxq, "rxq"))
2236 else if (!strcmp(res->rxtxq, "txq"))
2239 printf("Unknown parameter\n");
2243 if (isrx && rx_queue_id_is_invalid(res->qid))
2245 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2248 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2249 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2255 port->nb_rx_desc[res->qid] = res->size;
2257 port->nb_tx_desc[res->qid] = res->size;
2259 cmd_reconfig_device_queue(res->portid, 0, 1);
2262 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2263 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2265 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2266 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2268 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2269 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2271 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2272 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2274 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2275 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2277 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2278 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2279 rsize, "ring_size");
2280 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2281 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2284 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2285 .f = cmd_config_rxtx_ring_size_parsed,
2287 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2289 (void *)&cmd_config_rxtx_ring_size_port,
2290 (void *)&cmd_config_rxtx_ring_size_config,
2291 (void *)&cmd_config_rxtx_ring_size_portid,
2292 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2293 (void *)&cmd_config_rxtx_ring_size_qid,
2294 (void *)&cmd_config_rxtx_ring_size_rsize,
2295 (void *)&cmd_config_rxtx_ring_size_size,
2300 /* *** configure port rxq/txq start/stop *** */
2301 struct cmd_config_rxtx_queue {
2302 cmdline_fixed_string_t port;
2304 cmdline_fixed_string_t rxtxq;
2306 cmdline_fixed_string_t opname;
2310 cmd_config_rxtx_queue_parsed(void *parsed_result,
2311 __attribute__((unused)) struct cmdline *cl,
2312 __attribute__((unused)) void *data)
2314 struct cmd_config_rxtx_queue *res = parsed_result;
2319 if (test_done == 0) {
2320 printf("Please stop forwarding first\n");
2324 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2327 if (port_is_started(res->portid) != 1) {
2328 printf("Please start port %u first\n", res->portid);
2332 if (!strcmp(res->rxtxq, "rxq"))
2334 else if (!strcmp(res->rxtxq, "txq"))
2337 printf("Unknown parameter\n");
2341 if (isrx && rx_queue_id_is_invalid(res->qid))
2343 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2346 if (!strcmp(res->opname, "start"))
2348 else if (!strcmp(res->opname, "stop"))
2351 printf("Unknown parameter\n");
2355 if (isstart && isrx)
2356 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2357 else if (!isstart && isrx)
2358 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2359 else if (isstart && !isrx)
2360 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2362 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2364 if (ret == -ENOTSUP)
2365 printf("Function not supported in PMD driver\n");
2368 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2369 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2370 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2371 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2372 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2373 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2374 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2375 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2376 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2377 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2380 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2381 .f = cmd_config_rxtx_queue_parsed,
2383 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2385 (void *)&cmd_config_rxtx_queue_port,
2386 (void *)&cmd_config_rxtx_queue_portid,
2387 (void *)&cmd_config_rxtx_queue_rxtxq,
2388 (void *)&cmd_config_rxtx_queue_qid,
2389 (void *)&cmd_config_rxtx_queue_opname,
2394 /* *** configure port rxq/txq setup *** */
2395 struct cmd_setup_rxtx_queue {
2396 cmdline_fixed_string_t port;
2398 cmdline_fixed_string_t rxtxq;
2400 cmdline_fixed_string_t setup;
2403 /* Common CLI fields for queue setup */
2404 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2405 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2406 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2407 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16);
2408 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2409 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2410 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2411 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16);
2412 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2413 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2416 cmd_setup_rxtx_queue_parsed(
2417 void *parsed_result,
2418 __attribute__((unused)) struct cmdline *cl,
2419 __attribute__((unused)) void *data)
2421 struct cmd_setup_rxtx_queue *res = parsed_result;
2422 struct rte_port *port;
2423 struct rte_mempool *mp;
2424 unsigned int socket_id;
2428 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2431 if (res->portid == (portid_t)RTE_PORT_ALL) {
2432 printf("Invalid port id\n");
2436 if (!strcmp(res->rxtxq, "rxq"))
2438 else if (!strcmp(res->rxtxq, "txq"))
2441 printf("Unknown parameter\n");
2445 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2446 printf("Invalid rx queue\n");
2448 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2449 printf("Invalid tx queue\n");
2453 port = &ports[res->portid];
2455 socket_id = rxring_numa[res->portid];
2456 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2457 socket_id = port->socket_id;
2459 mp = mbuf_pool_find(socket_id);
2461 printf("Failed to setup RX queue: "
2462 "No mempool allocation"
2463 " on the socket %d\n",
2464 rxring_numa[res->portid]);
2467 ret = rte_eth_rx_queue_setup(res->portid,
2469 port->nb_rx_desc[res->qid],
2471 &port->rx_conf[res->qid],
2474 printf("Failed to setup RX queue\n");
2476 socket_id = txring_numa[res->portid];
2477 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2478 socket_id = port->socket_id;
2480 ret = rte_eth_tx_queue_setup(res->portid,
2482 port->nb_tx_desc[res->qid],
2484 &port->tx_conf[res->qid]);
2486 printf("Failed to setup TX queue\n");
2490 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2491 .f = cmd_setup_rxtx_queue_parsed,
2493 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2495 (void *)&cmd_setup_rxtx_queue_port,
2496 (void *)&cmd_setup_rxtx_queue_portid,
2497 (void *)&cmd_setup_rxtx_queue_rxtxq,
2498 (void *)&cmd_setup_rxtx_queue_qid,
2499 (void *)&cmd_setup_rxtx_queue_setup,
2505 /* *** Configure RSS RETA *** */
2506 struct cmd_config_rss_reta {
2507 cmdline_fixed_string_t port;
2508 cmdline_fixed_string_t keyword;
2510 cmdline_fixed_string_t name;
2511 cmdline_fixed_string_t list_name;
2512 cmdline_fixed_string_t list_of_items;
2516 parse_reta_config(const char *str,
2517 struct rte_eth_rss_reta_entry64 *reta_conf,
2518 uint16_t nb_entries)
2522 uint16_t hash_index, idx, shift;
2525 const char *p, *p0 = str;
2532 unsigned long int_fld[_NUM_FLD];
2533 char *str_fld[_NUM_FLD];
2535 while ((p = strchr(p0,'(')) != NULL) {
2537 if((p0 = strchr(p,')')) == NULL)
2541 if(size >= sizeof(s))
2544 snprintf(s, sizeof(s), "%.*s", size, p);
2545 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2547 for (i = 0; i < _NUM_FLD; i++) {
2549 int_fld[i] = strtoul(str_fld[i], &end, 0);
2550 if (errno != 0 || end == str_fld[i] ||
2555 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2556 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2558 if (hash_index >= nb_entries) {
2559 printf("Invalid RETA hash index=%d\n", hash_index);
2563 idx = hash_index / RTE_RETA_GROUP_SIZE;
2564 shift = hash_index % RTE_RETA_GROUP_SIZE;
2565 reta_conf[idx].mask |= (1ULL << shift);
2566 reta_conf[idx].reta[shift] = nb_queue;
2573 cmd_set_rss_reta_parsed(void *parsed_result,
2574 __attribute__((unused)) struct cmdline *cl,
2575 __attribute__((unused)) void *data)
2578 struct rte_eth_dev_info dev_info;
2579 struct rte_eth_rss_reta_entry64 reta_conf[8];
2580 struct cmd_config_rss_reta *res = parsed_result;
2582 memset(&dev_info, 0, sizeof(dev_info));
2583 rte_eth_dev_info_get(res->port_id, &dev_info);
2584 if (dev_info.reta_size == 0) {
2585 printf("Redirection table size is 0 which is "
2586 "invalid for RSS\n");
2589 printf("The reta size of port %d is %u\n",
2590 res->port_id, dev_info.reta_size);
2591 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2592 printf("Currently do not support more than %u entries of "
2593 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2597 memset(reta_conf, 0, sizeof(reta_conf));
2598 if (!strcmp(res->list_name, "reta")) {
2599 if (parse_reta_config(res->list_of_items, reta_conf,
2600 dev_info.reta_size)) {
2601 printf("Invalid RSS Redirection Table "
2602 "config entered\n");
2605 ret = rte_eth_dev_rss_reta_update(res->port_id,
2606 reta_conf, dev_info.reta_size);
2608 printf("Bad redirection table parameter, "
2609 "return code = %d \n", ret);
2613 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2614 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2615 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2616 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2617 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2618 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
2619 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2620 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2621 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2622 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2623 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2624 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2626 cmdline_parse_inst_t cmd_config_rss_reta = {
2627 .f = cmd_set_rss_reta_parsed,
2629 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2631 (void *)&cmd_config_rss_reta_port,
2632 (void *)&cmd_config_rss_reta_keyword,
2633 (void *)&cmd_config_rss_reta_port_id,
2634 (void *)&cmd_config_rss_reta_name,
2635 (void *)&cmd_config_rss_reta_list_name,
2636 (void *)&cmd_config_rss_reta_list_of_items,
2641 /* *** SHOW PORT RETA INFO *** */
2642 struct cmd_showport_reta {
2643 cmdline_fixed_string_t show;
2644 cmdline_fixed_string_t port;
2646 cmdline_fixed_string_t rss;
2647 cmdline_fixed_string_t reta;
2649 cmdline_fixed_string_t list_of_items;
2653 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2654 uint16_t nb_entries,
2658 const char *p, *p0 = str;
2663 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2664 RTE_RETA_GROUP_SIZE;
2667 p = strchr(p0, '(');
2671 p0 = strchr(p, ')');
2675 if (size >= sizeof(s)) {
2676 printf("The string size exceeds the internal buffer size\n");
2679 snprintf(s, sizeof(s), "%.*s", size, p);
2680 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2681 if (ret <= 0 || ret != num) {
2682 printf("The bits of masks do not match the number of "
2683 "reta entries: %u\n", num);
2686 for (i = 0; i < ret; i++)
2687 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2693 cmd_showport_reta_parsed(void *parsed_result,
2694 __attribute__((unused)) struct cmdline *cl,
2695 __attribute__((unused)) void *data)
2697 struct cmd_showport_reta *res = parsed_result;
2698 struct rte_eth_rss_reta_entry64 reta_conf[8];
2699 struct rte_eth_dev_info dev_info;
2700 uint16_t max_reta_size;
2702 memset(&dev_info, 0, sizeof(dev_info));
2703 rte_eth_dev_info_get(res->port_id, &dev_info);
2704 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
2705 if (res->size == 0 || res->size > max_reta_size) {
2706 printf("Invalid redirection table size: %u (1-%u)\n",
2707 res->size, max_reta_size);
2711 memset(reta_conf, 0, sizeof(reta_conf));
2712 if (showport_parse_reta_config(reta_conf, res->size,
2713 res->list_of_items) < 0) {
2714 printf("Invalid string: %s for reta masks\n",
2715 res->list_of_items);
2718 port_rss_reta_info(res->port_id, reta_conf, res->size);
2721 cmdline_parse_token_string_t cmd_showport_reta_show =
2722 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2723 cmdline_parse_token_string_t cmd_showport_reta_port =
2724 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2725 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2726 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
2727 cmdline_parse_token_string_t cmd_showport_reta_rss =
2728 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2729 cmdline_parse_token_string_t cmd_showport_reta_reta =
2730 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2731 cmdline_parse_token_num_t cmd_showport_reta_size =
2732 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2733 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2734 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2735 list_of_items, NULL);
2737 cmdline_parse_inst_t cmd_showport_reta = {
2738 .f = cmd_showport_reta_parsed,
2740 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2742 (void *)&cmd_showport_reta_show,
2743 (void *)&cmd_showport_reta_port,
2744 (void *)&cmd_showport_reta_port_id,
2745 (void *)&cmd_showport_reta_rss,
2746 (void *)&cmd_showport_reta_reta,
2747 (void *)&cmd_showport_reta_size,
2748 (void *)&cmd_showport_reta_list_of_items,
2753 /* *** Show RSS hash configuration *** */
2754 struct cmd_showport_rss_hash {
2755 cmdline_fixed_string_t show;
2756 cmdline_fixed_string_t port;
2758 cmdline_fixed_string_t rss_hash;
2759 cmdline_fixed_string_t rss_type;
2760 cmdline_fixed_string_t key; /* optional argument */
2763 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2764 __attribute__((unused)) struct cmdline *cl,
2767 struct cmd_showport_rss_hash *res = parsed_result;
2769 port_rss_hash_conf_show(res->port_id, res->rss_type,
2770 show_rss_key != NULL);
2773 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2774 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2775 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2776 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2777 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2778 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
2779 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2780 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2782 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2783 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2784 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2785 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2786 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2787 "ipv6-tcp-ex#ipv6-udp-ex");
2788 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2789 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2791 cmdline_parse_inst_t cmd_showport_rss_hash = {
2792 .f = cmd_showport_rss_hash_parsed,
2794 .help_str = "show port <port_id> rss-hash "
2795 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2796 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2797 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex",
2799 (void *)&cmd_showport_rss_hash_show,
2800 (void *)&cmd_showport_rss_hash_port,
2801 (void *)&cmd_showport_rss_hash_port_id,
2802 (void *)&cmd_showport_rss_hash_rss_hash,
2803 (void *)&cmd_showport_rss_hash_rss_hash_info,
2808 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2809 .f = cmd_showport_rss_hash_parsed,
2811 .help_str = "show port <port_id> rss-hash "
2812 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2813 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2814 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key",
2816 (void *)&cmd_showport_rss_hash_show,
2817 (void *)&cmd_showport_rss_hash_port,
2818 (void *)&cmd_showport_rss_hash_port_id,
2819 (void *)&cmd_showport_rss_hash_rss_hash,
2820 (void *)&cmd_showport_rss_hash_rss_hash_info,
2821 (void *)&cmd_showport_rss_hash_rss_key,
2826 /* *** Configure DCB *** */
2827 struct cmd_config_dcb {
2828 cmdline_fixed_string_t port;
2829 cmdline_fixed_string_t config;
2831 cmdline_fixed_string_t dcb;
2832 cmdline_fixed_string_t vt;
2833 cmdline_fixed_string_t vt_en;
2835 cmdline_fixed_string_t pfc;
2836 cmdline_fixed_string_t pfc_en;
2840 cmd_config_dcb_parsed(void *parsed_result,
2841 __attribute__((unused)) struct cmdline *cl,
2842 __attribute__((unused)) void *data)
2844 struct cmd_config_dcb *res = parsed_result;
2845 portid_t port_id = res->port_id;
2846 struct rte_port *port;
2850 port = &ports[port_id];
2851 /** Check if the port is not started **/
2852 if (port->port_status != RTE_PORT_STOPPED) {
2853 printf("Please stop port %d first\n", port_id);
2857 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2858 printf("The invalid number of traffic class,"
2859 " only 4 or 8 allowed.\n");
2863 if (nb_fwd_lcores < res->num_tcs) {
2864 printf("nb_cores shouldn't be less than number of TCs.\n");
2867 if (!strncmp(res->pfc_en, "on", 2))
2872 /* DCB in VT mode */
2873 if (!strncmp(res->vt_en, "on", 2))
2874 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2875 (enum rte_eth_nb_tcs)res->num_tcs,
2878 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2879 (enum rte_eth_nb_tcs)res->num_tcs,
2884 printf("Cannot initialize network ports.\n");
2888 cmd_reconfig_device_queue(port_id, 1, 1);
2891 cmdline_parse_token_string_t cmd_config_dcb_port =
2892 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2893 cmdline_parse_token_string_t cmd_config_dcb_config =
2894 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2895 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2896 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
2897 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2898 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2899 cmdline_parse_token_string_t cmd_config_dcb_vt =
2900 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2901 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2902 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2903 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2904 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2905 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2906 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2907 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2908 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2910 cmdline_parse_inst_t cmd_config_dcb = {
2911 .f = cmd_config_dcb_parsed,
2913 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
2915 (void *)&cmd_config_dcb_port,
2916 (void *)&cmd_config_dcb_config,
2917 (void *)&cmd_config_dcb_port_id,
2918 (void *)&cmd_config_dcb_dcb,
2919 (void *)&cmd_config_dcb_vt,
2920 (void *)&cmd_config_dcb_vt_en,
2921 (void *)&cmd_config_dcb_num_tcs,
2922 (void *)&cmd_config_dcb_pfc,
2923 (void *)&cmd_config_dcb_pfc_en,
2928 /* *** configure number of packets per burst *** */
2929 struct cmd_config_burst {
2930 cmdline_fixed_string_t port;
2931 cmdline_fixed_string_t keyword;
2932 cmdline_fixed_string_t all;
2933 cmdline_fixed_string_t name;
2938 cmd_config_burst_parsed(void *parsed_result,
2939 __attribute__((unused)) struct cmdline *cl,
2940 __attribute__((unused)) void *data)
2942 struct cmd_config_burst *res = parsed_result;
2943 struct rte_eth_dev_info dev_info;
2944 uint16_t rec_nb_pkts;
2946 if (!all_ports_stopped()) {
2947 printf("Please stop all ports first\n");
2951 if (!strcmp(res->name, "burst")) {
2952 if (res->value == 0) {
2953 /* If user gives a value of zero, query the PMD for
2954 * its recommended Rx burst size. Testpmd uses a single
2955 * size for all ports, so assume all ports are the same
2956 * NIC model and use the values from Port 0.
2958 rte_eth_dev_info_get(0, &dev_info);
2959 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
2961 if (rec_nb_pkts == 0) {
2962 printf("PMD does not recommend a burst size.\n"
2963 "User provided value must be between"
2964 " 1 and %d\n", MAX_PKT_BURST);
2966 } else if (rec_nb_pkts > MAX_PKT_BURST) {
2967 printf("PMD recommended burst size of %d"
2968 " exceeds maximum value of %d\n",
2969 rec_nb_pkts, MAX_PKT_BURST);
2972 printf("Using PMD-provided burst value of %d\n",
2974 nb_pkt_per_burst = rec_nb_pkts;
2975 } else if (res->value > MAX_PKT_BURST) {
2976 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2979 nb_pkt_per_burst = res->value;
2981 printf("Unknown parameter\n");
2987 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2990 cmdline_parse_token_string_t cmd_config_burst_port =
2991 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2992 cmdline_parse_token_string_t cmd_config_burst_keyword =
2993 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2994 cmdline_parse_token_string_t cmd_config_burst_all =
2995 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2996 cmdline_parse_token_string_t cmd_config_burst_name =
2997 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2998 cmdline_parse_token_num_t cmd_config_burst_value =
2999 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
3001 cmdline_parse_inst_t cmd_config_burst = {
3002 .f = cmd_config_burst_parsed,
3004 .help_str = "port config all burst <value>",
3006 (void *)&cmd_config_burst_port,
3007 (void *)&cmd_config_burst_keyword,
3008 (void *)&cmd_config_burst_all,
3009 (void *)&cmd_config_burst_name,
3010 (void *)&cmd_config_burst_value,
3015 /* *** configure rx/tx queues *** */
3016 struct cmd_config_thresh {
3017 cmdline_fixed_string_t port;
3018 cmdline_fixed_string_t keyword;
3019 cmdline_fixed_string_t all;
3020 cmdline_fixed_string_t name;
3025 cmd_config_thresh_parsed(void *parsed_result,
3026 __attribute__((unused)) struct cmdline *cl,
3027 __attribute__((unused)) void *data)
3029 struct cmd_config_thresh *res = parsed_result;
3031 if (!all_ports_stopped()) {
3032 printf("Please stop all ports first\n");
3036 if (!strcmp(res->name, "txpt"))
3037 tx_pthresh = res->value;
3038 else if(!strcmp(res->name, "txht"))
3039 tx_hthresh = res->value;
3040 else if(!strcmp(res->name, "txwt"))
3041 tx_wthresh = res->value;
3042 else if(!strcmp(res->name, "rxpt"))
3043 rx_pthresh = res->value;
3044 else if(!strcmp(res->name, "rxht"))
3045 rx_hthresh = res->value;
3046 else if(!strcmp(res->name, "rxwt"))
3047 rx_wthresh = res->value;
3049 printf("Unknown parameter\n");
3055 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3058 cmdline_parse_token_string_t cmd_config_thresh_port =
3059 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3060 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3061 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3062 cmdline_parse_token_string_t cmd_config_thresh_all =
3063 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3064 cmdline_parse_token_string_t cmd_config_thresh_name =
3065 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3066 "txpt#txht#txwt#rxpt#rxht#rxwt");
3067 cmdline_parse_token_num_t cmd_config_thresh_value =
3068 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
3070 cmdline_parse_inst_t cmd_config_thresh = {
3071 .f = cmd_config_thresh_parsed,
3073 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3075 (void *)&cmd_config_thresh_port,
3076 (void *)&cmd_config_thresh_keyword,
3077 (void *)&cmd_config_thresh_all,
3078 (void *)&cmd_config_thresh_name,
3079 (void *)&cmd_config_thresh_value,
3084 /* *** configure free/rs threshold *** */
3085 struct cmd_config_threshold {
3086 cmdline_fixed_string_t port;
3087 cmdline_fixed_string_t keyword;
3088 cmdline_fixed_string_t all;
3089 cmdline_fixed_string_t name;
3094 cmd_config_threshold_parsed(void *parsed_result,
3095 __attribute__((unused)) struct cmdline *cl,
3096 __attribute__((unused)) void *data)
3098 struct cmd_config_threshold *res = parsed_result;
3100 if (!all_ports_stopped()) {
3101 printf("Please stop all ports first\n");
3105 if (!strcmp(res->name, "txfreet"))
3106 tx_free_thresh = res->value;
3107 else if (!strcmp(res->name, "txrst"))
3108 tx_rs_thresh = res->value;
3109 else if (!strcmp(res->name, "rxfreet"))
3110 rx_free_thresh = res->value;
3112 printf("Unknown parameter\n");
3118 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3121 cmdline_parse_token_string_t cmd_config_threshold_port =
3122 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3123 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3124 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3126 cmdline_parse_token_string_t cmd_config_threshold_all =
3127 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3128 cmdline_parse_token_string_t cmd_config_threshold_name =
3129 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3130 "txfreet#txrst#rxfreet");
3131 cmdline_parse_token_num_t cmd_config_threshold_value =
3132 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
3134 cmdline_parse_inst_t cmd_config_threshold = {
3135 .f = cmd_config_threshold_parsed,
3137 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3139 (void *)&cmd_config_threshold_port,
3140 (void *)&cmd_config_threshold_keyword,
3141 (void *)&cmd_config_threshold_all,
3142 (void *)&cmd_config_threshold_name,
3143 (void *)&cmd_config_threshold_value,
3149 struct cmd_stop_result {
3150 cmdline_fixed_string_t stop;
3153 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
3154 __attribute__((unused)) struct cmdline *cl,
3155 __attribute__((unused)) void *data)
3157 stop_packet_forwarding();
3160 cmdline_parse_token_string_t cmd_stop_stop =
3161 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3163 cmdline_parse_inst_t cmd_stop = {
3164 .f = cmd_stop_parsed,
3166 .help_str = "stop: Stop packet forwarding",
3168 (void *)&cmd_stop_stop,
3173 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3176 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3177 unsigned int *parsed_items, int check_unique_values)
3179 unsigned int nb_item;
3187 * First parse all items in the list and store their value.
3192 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3194 if ((c >= '0') && (c <= '9')) {
3195 value = (unsigned int) (value * 10 + (c - '0'));
3200 printf("character %c is not a decimal digit\n", c);
3204 printf("No valid value before comma\n");
3207 if (nb_item < max_items) {
3208 parsed_items[nb_item] = value;
3214 if (nb_item >= max_items) {
3215 printf("Number of %s = %u > %u (maximum items)\n",
3216 item_name, nb_item + 1, max_items);
3219 parsed_items[nb_item++] = value;
3220 if (! check_unique_values)
3224 * Then, check that all values in the list are differents.
3225 * No optimization here...
3227 for (i = 0; i < nb_item; i++) {
3228 for (j = i + 1; j < nb_item; j++) {
3229 if (parsed_items[j] == parsed_items[i]) {
3230 printf("duplicated %s %u at index %u and %u\n",
3231 item_name, parsed_items[i], i, j);
3239 struct cmd_set_list_result {
3240 cmdline_fixed_string_t cmd_keyword;
3241 cmdline_fixed_string_t list_name;
3242 cmdline_fixed_string_t list_of_items;
3245 static void cmd_set_list_parsed(void *parsed_result,
3246 __attribute__((unused)) struct cmdline *cl,
3247 __attribute__((unused)) void *data)
3249 struct cmd_set_list_result *res;
3251 unsigned int lcorelist[RTE_MAX_LCORE];
3252 unsigned int portlist[RTE_MAX_ETHPORTS];
3254 unsigned int nb_item;
3256 if (test_done == 0) {
3257 printf("Please stop forwarding first\n");
3261 res = parsed_result;
3262 if (!strcmp(res->list_name, "corelist")) {
3263 nb_item = parse_item_list(res->list_of_items, "core",
3265 parsed_items.lcorelist, 1);
3267 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3272 if (!strcmp(res->list_name, "portlist")) {
3273 nb_item = parse_item_list(res->list_of_items, "port",
3275 parsed_items.portlist, 1);
3277 set_fwd_ports_list(parsed_items.portlist, nb_item);
3283 cmdline_parse_token_string_t cmd_set_list_keyword =
3284 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3286 cmdline_parse_token_string_t cmd_set_list_name =
3287 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3288 "corelist#portlist");
3289 cmdline_parse_token_string_t cmd_set_list_of_items =
3290 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3293 cmdline_parse_inst_t cmd_set_fwd_list = {
3294 .f = cmd_set_list_parsed,
3296 .help_str = "set corelist|portlist <list0[,list1]*>",
3298 (void *)&cmd_set_list_keyword,
3299 (void *)&cmd_set_list_name,
3300 (void *)&cmd_set_list_of_items,
3305 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3307 struct cmd_setmask_result {
3308 cmdline_fixed_string_t set;
3309 cmdline_fixed_string_t mask;
3313 static void cmd_set_mask_parsed(void *parsed_result,
3314 __attribute__((unused)) struct cmdline *cl,
3315 __attribute__((unused)) void *data)
3317 struct cmd_setmask_result *res = parsed_result;
3319 if (test_done == 0) {
3320 printf("Please stop forwarding first\n");
3323 if (!strcmp(res->mask, "coremask")) {
3324 set_fwd_lcores_mask(res->hexavalue);
3326 } else if (!strcmp(res->mask, "portmask")) {
3327 set_fwd_ports_mask(res->hexavalue);
3332 cmdline_parse_token_string_t cmd_setmask_set =
3333 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3334 cmdline_parse_token_string_t cmd_setmask_mask =
3335 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3336 "coremask#portmask");
3337 cmdline_parse_token_num_t cmd_setmask_value =
3338 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3340 cmdline_parse_inst_t cmd_set_fwd_mask = {
3341 .f = cmd_set_mask_parsed,
3343 .help_str = "set coremask|portmask <hexadecimal value>",
3345 (void *)&cmd_setmask_set,
3346 (void *)&cmd_setmask_mask,
3347 (void *)&cmd_setmask_value,
3353 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3355 struct cmd_set_result {
3356 cmdline_fixed_string_t set;
3357 cmdline_fixed_string_t what;
3361 static void cmd_set_parsed(void *parsed_result,
3362 __attribute__((unused)) struct cmdline *cl,
3363 __attribute__((unused)) void *data)
3365 struct cmd_set_result *res = parsed_result;
3366 if (!strcmp(res->what, "nbport")) {
3367 set_fwd_ports_number(res->value);
3369 } else if (!strcmp(res->what, "nbcore")) {
3370 set_fwd_lcores_number(res->value);
3372 } else if (!strcmp(res->what, "burst"))
3373 set_nb_pkt_per_burst(res->value);
3374 else if (!strcmp(res->what, "verbose"))
3375 set_verbose_level(res->value);
3378 cmdline_parse_token_string_t cmd_set_set =
3379 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3380 cmdline_parse_token_string_t cmd_set_what =
3381 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3382 "nbport#nbcore#burst#verbose");
3383 cmdline_parse_token_num_t cmd_set_value =
3384 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3386 cmdline_parse_inst_t cmd_set_numbers = {
3387 .f = cmd_set_parsed,
3389 .help_str = "set nbport|nbcore|burst|verbose <value>",
3391 (void *)&cmd_set_set,
3392 (void *)&cmd_set_what,
3393 (void *)&cmd_set_value,
3398 /* *** SET LOG LEVEL CONFIGURATION *** */
3400 struct cmd_set_log_result {
3401 cmdline_fixed_string_t set;
3402 cmdline_fixed_string_t log;
3403 cmdline_fixed_string_t type;
3408 cmd_set_log_parsed(void *parsed_result,
3409 __attribute__((unused)) struct cmdline *cl,
3410 __attribute__((unused)) void *data)
3412 struct cmd_set_log_result *res;
3415 res = parsed_result;
3416 if (!strcmp(res->type, "global"))
3417 rte_log_set_global_level(res->level);
3419 ret = rte_log_set_level_regexp(res->type, res->level);
3421 printf("Unable to set log level\n");
3425 cmdline_parse_token_string_t cmd_set_log_set =
3426 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3427 cmdline_parse_token_string_t cmd_set_log_log =
3428 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3429 cmdline_parse_token_string_t cmd_set_log_type =
3430 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3431 cmdline_parse_token_num_t cmd_set_log_level =
3432 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3434 cmdline_parse_inst_t cmd_set_log = {
3435 .f = cmd_set_log_parsed,
3437 .help_str = "set log global|<type> <level>",
3439 (void *)&cmd_set_log_set,
3440 (void *)&cmd_set_log_log,
3441 (void *)&cmd_set_log_type,
3442 (void *)&cmd_set_log_level,
3447 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3449 struct cmd_set_txpkts_result {
3450 cmdline_fixed_string_t cmd_keyword;
3451 cmdline_fixed_string_t txpkts;
3452 cmdline_fixed_string_t seg_lengths;
3456 cmd_set_txpkts_parsed(void *parsed_result,
3457 __attribute__((unused)) struct cmdline *cl,
3458 __attribute__((unused)) void *data)
3460 struct cmd_set_txpkts_result *res;
3461 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3462 unsigned int nb_segs;
3464 res = parsed_result;
3465 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3466 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3468 set_tx_pkt_segments(seg_lengths, nb_segs);
3471 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3472 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3473 cmd_keyword, "set");
3474 cmdline_parse_token_string_t cmd_set_txpkts_name =
3475 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3477 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3478 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3481 cmdline_parse_inst_t cmd_set_txpkts = {
3482 .f = cmd_set_txpkts_parsed,
3484 .help_str = "set txpkts <len0[,len1]*>",
3486 (void *)&cmd_set_txpkts_keyword,
3487 (void *)&cmd_set_txpkts_name,
3488 (void *)&cmd_set_txpkts_lengths,
3493 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3495 struct cmd_set_txsplit_result {
3496 cmdline_fixed_string_t cmd_keyword;
3497 cmdline_fixed_string_t txsplit;
3498 cmdline_fixed_string_t mode;
3502 cmd_set_txsplit_parsed(void *parsed_result,
3503 __attribute__((unused)) struct cmdline *cl,
3504 __attribute__((unused)) void *data)
3506 struct cmd_set_txsplit_result *res;
3508 res = parsed_result;
3509 set_tx_pkt_split(res->mode);
3512 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3513 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3514 cmd_keyword, "set");
3515 cmdline_parse_token_string_t cmd_set_txsplit_name =
3516 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3517 txsplit, "txsplit");
3518 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3519 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3522 cmdline_parse_inst_t cmd_set_txsplit = {
3523 .f = cmd_set_txsplit_parsed,
3525 .help_str = "set txsplit on|off|rand",
3527 (void *)&cmd_set_txsplit_keyword,
3528 (void *)&cmd_set_txsplit_name,
3529 (void *)&cmd_set_txsplit_mode,
3534 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3535 struct cmd_rx_vlan_filter_all_result {
3536 cmdline_fixed_string_t rx_vlan;
3537 cmdline_fixed_string_t what;
3538 cmdline_fixed_string_t all;
3543 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3544 __attribute__((unused)) struct cmdline *cl,
3545 __attribute__((unused)) void *data)
3547 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3549 if (!strcmp(res->what, "add"))
3550 rx_vlan_all_filter_set(res->port_id, 1);
3552 rx_vlan_all_filter_set(res->port_id, 0);
3555 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3556 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3557 rx_vlan, "rx_vlan");
3558 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3559 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3561 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3562 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3564 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3565 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3568 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3569 .f = cmd_rx_vlan_filter_all_parsed,
3571 .help_str = "rx_vlan add|rm all <port_id>: "
3572 "Add/Remove all identifiers to/from the set of VLAN "
3573 "identifiers filtered by a port",
3575 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3576 (void *)&cmd_rx_vlan_filter_all_what,
3577 (void *)&cmd_rx_vlan_filter_all_all,
3578 (void *)&cmd_rx_vlan_filter_all_portid,
3583 /* *** VLAN OFFLOAD SET ON A PORT *** */
3584 struct cmd_vlan_offload_result {
3585 cmdline_fixed_string_t vlan;
3586 cmdline_fixed_string_t set;
3587 cmdline_fixed_string_t vlan_type;
3588 cmdline_fixed_string_t what;
3589 cmdline_fixed_string_t on;
3590 cmdline_fixed_string_t port_id;
3594 cmd_vlan_offload_parsed(void *parsed_result,
3595 __attribute__((unused)) struct cmdline *cl,
3596 __attribute__((unused)) void *data)
3599 struct cmd_vlan_offload_result *res = parsed_result;
3602 portid_t port_id = 0;
3606 len = strnlen(str, STR_TOKEN_SIZE);
3608 /* Get port_id first */
3616 tmp = strtoul(str, NULL, 0);
3617 /* If port_id greater that what portid_t can represent, return */
3618 if(tmp >= RTE_MAX_ETHPORTS)
3620 port_id = (portid_t)tmp;
3622 if (!strcmp(res->on, "on"))
3627 if (!strcmp(res->what, "strip"))
3628 rx_vlan_strip_set(port_id, on);
3629 else if(!strcmp(res->what, "stripq")){
3630 uint16_t queue_id = 0;
3632 /* No queue_id, return */
3634 printf("must specify (port,queue_id)\n");
3637 tmp = strtoul(str + i + 1, NULL, 0);
3638 /* If queue_id greater that what 16-bits can represent, return */
3642 queue_id = (uint16_t)tmp;
3643 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3645 else if (!strcmp(res->what, "filter"))
3646 rx_vlan_filter_set(port_id, on);
3648 vlan_extend_set(port_id, on);
3653 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3654 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3656 cmdline_parse_token_string_t cmd_vlan_offload_set =
3657 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3659 cmdline_parse_token_string_t cmd_vlan_offload_what =
3660 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3661 what, "strip#filter#qinq#stripq");
3662 cmdline_parse_token_string_t cmd_vlan_offload_on =
3663 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3665 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3666 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3669 cmdline_parse_inst_t cmd_vlan_offload = {
3670 .f = cmd_vlan_offload_parsed,
3672 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3673 "<port_id[,queue_id]>: "
3674 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3676 (void *)&cmd_vlan_offload_vlan,
3677 (void *)&cmd_vlan_offload_set,
3678 (void *)&cmd_vlan_offload_what,
3679 (void *)&cmd_vlan_offload_on,
3680 (void *)&cmd_vlan_offload_portid,
3685 /* *** VLAN TPID SET ON A PORT *** */
3686 struct cmd_vlan_tpid_result {
3687 cmdline_fixed_string_t vlan;
3688 cmdline_fixed_string_t set;
3689 cmdline_fixed_string_t vlan_type;
3690 cmdline_fixed_string_t what;
3696 cmd_vlan_tpid_parsed(void *parsed_result,
3697 __attribute__((unused)) struct cmdline *cl,
3698 __attribute__((unused)) void *data)
3700 struct cmd_vlan_tpid_result *res = parsed_result;
3701 enum rte_vlan_type vlan_type;
3703 if (!strcmp(res->vlan_type, "inner"))
3704 vlan_type = ETH_VLAN_TYPE_INNER;
3705 else if (!strcmp(res->vlan_type, "outer"))
3706 vlan_type = ETH_VLAN_TYPE_OUTER;
3708 printf("Unknown vlan type\n");
3711 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3714 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3715 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3717 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3718 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3720 cmdline_parse_token_string_t cmd_vlan_type =
3721 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3722 vlan_type, "inner#outer");
3723 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3724 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3726 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3727 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3729 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3730 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3733 cmdline_parse_inst_t cmd_vlan_tpid = {
3734 .f = cmd_vlan_tpid_parsed,
3736 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3737 "Set the VLAN Ether type",
3739 (void *)&cmd_vlan_tpid_vlan,
3740 (void *)&cmd_vlan_tpid_set,
3741 (void *)&cmd_vlan_type,
3742 (void *)&cmd_vlan_tpid_what,
3743 (void *)&cmd_vlan_tpid_tpid,
3744 (void *)&cmd_vlan_tpid_portid,
3749 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3750 struct cmd_rx_vlan_filter_result {
3751 cmdline_fixed_string_t rx_vlan;
3752 cmdline_fixed_string_t what;
3758 cmd_rx_vlan_filter_parsed(void *parsed_result,
3759 __attribute__((unused)) struct cmdline *cl,
3760 __attribute__((unused)) void *data)
3762 struct cmd_rx_vlan_filter_result *res = parsed_result;
3764 if (!strcmp(res->what, "add"))
3765 rx_vft_set(res->port_id, res->vlan_id, 1);
3767 rx_vft_set(res->port_id, res->vlan_id, 0);
3770 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3771 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3772 rx_vlan, "rx_vlan");
3773 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3774 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3776 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3777 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3779 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3780 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3783 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3784 .f = cmd_rx_vlan_filter_parsed,
3786 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3787 "Add/Remove a VLAN identifier to/from the set of VLAN "
3788 "identifiers filtered by a port",
3790 (void *)&cmd_rx_vlan_filter_rx_vlan,
3791 (void *)&cmd_rx_vlan_filter_what,
3792 (void *)&cmd_rx_vlan_filter_vlanid,
3793 (void *)&cmd_rx_vlan_filter_portid,
3798 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3799 struct cmd_tx_vlan_set_result {
3800 cmdline_fixed_string_t tx_vlan;
3801 cmdline_fixed_string_t set;
3807 cmd_tx_vlan_set_parsed(void *parsed_result,
3808 __attribute__((unused)) struct cmdline *cl,
3809 __attribute__((unused)) void *data)
3811 struct cmd_tx_vlan_set_result *res = parsed_result;
3813 if (!port_is_stopped(res->port_id)) {
3814 printf("Please stop port %d first\n", res->port_id);
3818 tx_vlan_set(res->port_id, res->vlan_id);
3820 cmd_reconfig_device_queue(res->port_id, 1, 1);
3823 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3824 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3825 tx_vlan, "tx_vlan");
3826 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3827 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3829 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3830 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3832 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3833 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3836 cmdline_parse_inst_t cmd_tx_vlan_set = {
3837 .f = cmd_tx_vlan_set_parsed,
3839 .help_str = "tx_vlan set <port_id> <vlan_id>: "
3840 "Enable hardware insertion of a single VLAN header "
3841 "with a given TAG Identifier in packets sent on a port",
3843 (void *)&cmd_tx_vlan_set_tx_vlan,
3844 (void *)&cmd_tx_vlan_set_set,
3845 (void *)&cmd_tx_vlan_set_portid,
3846 (void *)&cmd_tx_vlan_set_vlanid,
3851 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3852 struct cmd_tx_vlan_set_qinq_result {
3853 cmdline_fixed_string_t tx_vlan;
3854 cmdline_fixed_string_t set;
3857 uint16_t vlan_id_outer;
3861 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3862 __attribute__((unused)) struct cmdline *cl,
3863 __attribute__((unused)) void *data)
3865 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3867 if (!port_is_stopped(res->port_id)) {
3868 printf("Please stop port %d first\n", res->port_id);
3872 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3874 cmd_reconfig_device_queue(res->port_id, 1, 1);
3877 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3878 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3879 tx_vlan, "tx_vlan");
3880 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3881 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3883 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3884 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3886 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3887 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3889 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3890 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3891 vlan_id_outer, UINT16);
3893 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3894 .f = cmd_tx_vlan_set_qinq_parsed,
3896 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3897 "Enable hardware insertion of double VLAN header "
3898 "with given TAG Identifiers in packets sent on a port",
3900 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3901 (void *)&cmd_tx_vlan_set_qinq_set,
3902 (void *)&cmd_tx_vlan_set_qinq_portid,
3903 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3904 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3909 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3910 struct cmd_tx_vlan_set_pvid_result {
3911 cmdline_fixed_string_t tx_vlan;
3912 cmdline_fixed_string_t set;
3913 cmdline_fixed_string_t pvid;
3916 cmdline_fixed_string_t mode;
3920 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3921 __attribute__((unused)) struct cmdline *cl,
3922 __attribute__((unused)) void *data)
3924 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3926 if (strcmp(res->mode, "on") == 0)
3927 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3929 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3932 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3933 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3934 tx_vlan, "tx_vlan");
3935 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3936 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3938 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3939 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3941 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3942 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3944 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3945 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3947 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3948 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3951 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3952 .f = cmd_tx_vlan_set_pvid_parsed,
3954 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
3956 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3957 (void *)&cmd_tx_vlan_set_pvid_set,
3958 (void *)&cmd_tx_vlan_set_pvid_pvid,
3959 (void *)&cmd_tx_vlan_set_pvid_port_id,
3960 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3961 (void *)&cmd_tx_vlan_set_pvid_mode,
3966 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3967 struct cmd_tx_vlan_reset_result {
3968 cmdline_fixed_string_t tx_vlan;
3969 cmdline_fixed_string_t reset;
3974 cmd_tx_vlan_reset_parsed(void *parsed_result,
3975 __attribute__((unused)) struct cmdline *cl,
3976 __attribute__((unused)) void *data)
3978 struct cmd_tx_vlan_reset_result *res = parsed_result;
3980 if (!port_is_stopped(res->port_id)) {
3981 printf("Please stop port %d first\n", res->port_id);
3985 tx_vlan_reset(res->port_id);
3987 cmd_reconfig_device_queue(res->port_id, 1, 1);
3990 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3991 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3992 tx_vlan, "tx_vlan");
3993 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3994 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3996 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3997 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4000 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4001 .f = cmd_tx_vlan_reset_parsed,
4003 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4004 "VLAN header in packets sent on a port",
4006 (void *)&cmd_tx_vlan_reset_tx_vlan,
4007 (void *)&cmd_tx_vlan_reset_reset,
4008 (void *)&cmd_tx_vlan_reset_portid,
4014 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4015 struct cmd_csum_result {
4016 cmdline_fixed_string_t csum;
4017 cmdline_fixed_string_t mode;
4018 cmdline_fixed_string_t proto;
4019 cmdline_fixed_string_t hwsw;
4024 csum_show(int port_id)
4026 struct rte_eth_dev_info dev_info;
4027 uint64_t tx_offloads;
4029 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4030 printf("Parse tunnel is %s\n",
4031 (ports[port_id].parse_tunnel) ? "on" : "off");
4032 printf("IP checksum offload is %s\n",
4033 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4034 printf("UDP checksum offload is %s\n",
4035 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4036 printf("TCP checksum offload is %s\n",
4037 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4038 printf("SCTP checksum offload is %s\n",
4039 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4040 printf("Outer-Ip checksum offload is %s\n",
4041 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4043 /* display warnings if configuration is not supported by the NIC */
4044 rte_eth_dev_info_get(port_id, &dev_info);
4045 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4046 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4047 printf("Warning: hardware IP checksum enabled but not "
4048 "supported by port %d\n", port_id);
4050 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4051 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4052 printf("Warning: hardware UDP checksum enabled but not "
4053 "supported by port %d\n", port_id);
4055 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4056 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4057 printf("Warning: hardware TCP checksum enabled but not "
4058 "supported by port %d\n", port_id);
4060 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4061 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4062 printf("Warning: hardware SCTP checksum enabled but not "
4063 "supported by port %d\n", port_id);
4065 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4066 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4067 printf("Warning: hardware outer IP checksum enabled but not "
4068 "supported by port %d\n", port_id);
4073 cmd_csum_parsed(void *parsed_result,
4074 __attribute__((unused)) struct cmdline *cl,
4075 __attribute__((unused)) void *data)
4077 struct cmd_csum_result *res = parsed_result;
4079 uint64_t csum_offloads = 0;
4080 struct rte_eth_dev_info dev_info;
4082 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4083 printf("invalid port %d\n", res->port_id);
4086 if (!port_is_stopped(res->port_id)) {
4087 printf("Please stop port %d first\n", res->port_id);
4091 rte_eth_dev_info_get(res->port_id, &dev_info);
4092 if (!strcmp(res->mode, "set")) {
4094 if (!strcmp(res->hwsw, "hw"))
4097 if (!strcmp(res->proto, "ip")) {
4098 if (hw == 0 || (dev_info.tx_offload_capa &
4099 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4100 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4102 printf("IP checksum offload is not supported "
4103 "by port %u\n", res->port_id);
4105 } else if (!strcmp(res->proto, "udp")) {
4106 if (hw == 0 || (dev_info.tx_offload_capa &
4107 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4108 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4110 printf("UDP checksum offload is not supported "
4111 "by port %u\n", res->port_id);
4113 } else if (!strcmp(res->proto, "tcp")) {
4114 if (hw == 0 || (dev_info.tx_offload_capa &
4115 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4116 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4118 printf("TCP checksum offload is not supported "
4119 "by port %u\n", res->port_id);
4121 } else if (!strcmp(res->proto, "sctp")) {
4122 if (hw == 0 || (dev_info.tx_offload_capa &
4123 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4124 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4126 printf("SCTP checksum offload is not supported "
4127 "by port %u\n", res->port_id);
4129 } else if (!strcmp(res->proto, "outer-ip")) {
4130 if (hw == 0 || (dev_info.tx_offload_capa &
4131 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4133 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4135 printf("Outer IP checksum offload is not "
4136 "supported by port %u\n", res->port_id);
4141 ports[res->port_id].dev_conf.txmode.offloads |=
4144 ports[res->port_id].dev_conf.txmode.offloads &=
4148 csum_show(res->port_id);
4150 cmd_reconfig_device_queue(res->port_id, 1, 1);
4153 cmdline_parse_token_string_t cmd_csum_csum =
4154 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4156 cmdline_parse_token_string_t cmd_csum_mode =
4157 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4159 cmdline_parse_token_string_t cmd_csum_proto =
4160 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4161 proto, "ip#tcp#udp#sctp#outer-ip");
4162 cmdline_parse_token_string_t cmd_csum_hwsw =
4163 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4165 cmdline_parse_token_num_t cmd_csum_portid =
4166 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4169 cmdline_parse_inst_t cmd_csum_set = {
4170 .f = cmd_csum_parsed,
4172 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
4173 "Enable/Disable hardware calculation of L3/L4 checksum when "
4174 "using csum forward engine",
4176 (void *)&cmd_csum_csum,
4177 (void *)&cmd_csum_mode,
4178 (void *)&cmd_csum_proto,
4179 (void *)&cmd_csum_hwsw,
4180 (void *)&cmd_csum_portid,
4185 cmdline_parse_token_string_t cmd_csum_mode_show =
4186 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4189 cmdline_parse_inst_t cmd_csum_show = {
4190 .f = cmd_csum_parsed,
4192 .help_str = "csum show <port_id>: Show checksum offload configuration",
4194 (void *)&cmd_csum_csum,
4195 (void *)&cmd_csum_mode_show,
4196 (void *)&cmd_csum_portid,
4201 /* Enable/disable tunnel parsing */
4202 struct cmd_csum_tunnel_result {
4203 cmdline_fixed_string_t csum;
4204 cmdline_fixed_string_t parse;
4205 cmdline_fixed_string_t onoff;
4210 cmd_csum_tunnel_parsed(void *parsed_result,
4211 __attribute__((unused)) struct cmdline *cl,
4212 __attribute__((unused)) void *data)
4214 struct cmd_csum_tunnel_result *res = parsed_result;
4216 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4219 if (!strcmp(res->onoff, "on"))
4220 ports[res->port_id].parse_tunnel = 1;
4222 ports[res->port_id].parse_tunnel = 0;
4224 csum_show(res->port_id);
4227 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4228 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4230 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4231 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4232 parse, "parse_tunnel");
4233 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4234 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4236 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4237 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4240 cmdline_parse_inst_t cmd_csum_tunnel = {
4241 .f = cmd_csum_tunnel_parsed,
4243 .help_str = "csum parse_tunnel on|off <port_id>: "
4244 "Enable/Disable parsing of tunnels for csum engine",
4246 (void *)&cmd_csum_tunnel_csum,
4247 (void *)&cmd_csum_tunnel_parse,
4248 (void *)&cmd_csum_tunnel_onoff,
4249 (void *)&cmd_csum_tunnel_portid,
4254 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4255 struct cmd_tso_set_result {
4256 cmdline_fixed_string_t tso;
4257 cmdline_fixed_string_t mode;
4263 cmd_tso_set_parsed(void *parsed_result,
4264 __attribute__((unused)) struct cmdline *cl,
4265 __attribute__((unused)) void *data)
4267 struct cmd_tso_set_result *res = parsed_result;
4268 struct rte_eth_dev_info dev_info;
4270 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4272 if (!port_is_stopped(res->port_id)) {
4273 printf("Please stop port %d first\n", res->port_id);
4277 if (!strcmp(res->mode, "set"))
4278 ports[res->port_id].tso_segsz = res->tso_segsz;
4280 rte_eth_dev_info_get(res->port_id, &dev_info);
4281 if ((ports[res->port_id].tso_segsz != 0) &&
4282 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4283 printf("Error: TSO is not supported by port %d\n",
4288 if (ports[res->port_id].tso_segsz == 0) {
4289 ports[res->port_id].dev_conf.txmode.offloads &=
4290 ~DEV_TX_OFFLOAD_TCP_TSO;
4291 printf("TSO for non-tunneled packets is disabled\n");
4293 ports[res->port_id].dev_conf.txmode.offloads |=
4294 DEV_TX_OFFLOAD_TCP_TSO;
4295 printf("TSO segment size for non-tunneled packets is %d\n",
4296 ports[res->port_id].tso_segsz);
4299 /* display warnings if configuration is not supported by the NIC */
4300 rte_eth_dev_info_get(res->port_id, &dev_info);
4301 if ((ports[res->port_id].tso_segsz != 0) &&
4302 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4303 printf("Warning: TSO enabled but not "
4304 "supported by port %d\n", res->port_id);
4307 cmd_reconfig_device_queue(res->port_id, 1, 1);
4310 cmdline_parse_token_string_t cmd_tso_set_tso =
4311 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4313 cmdline_parse_token_string_t cmd_tso_set_mode =
4314 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4316 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4317 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4319 cmdline_parse_token_num_t cmd_tso_set_portid =
4320 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4323 cmdline_parse_inst_t cmd_tso_set = {
4324 .f = cmd_tso_set_parsed,
4326 .help_str = "tso set <tso_segsz> <port_id>: "
4327 "Set TSO segment size of non-tunneled packets for csum engine "
4330 (void *)&cmd_tso_set_tso,
4331 (void *)&cmd_tso_set_mode,
4332 (void *)&cmd_tso_set_tso_segsz,
4333 (void *)&cmd_tso_set_portid,
4338 cmdline_parse_token_string_t cmd_tso_show_mode =
4339 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4343 cmdline_parse_inst_t cmd_tso_show = {
4344 .f = cmd_tso_set_parsed,
4346 .help_str = "tso show <port_id>: "
4347 "Show TSO segment size of non-tunneled packets for csum engine",
4349 (void *)&cmd_tso_set_tso,
4350 (void *)&cmd_tso_show_mode,
4351 (void *)&cmd_tso_set_portid,
4356 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4357 struct cmd_tunnel_tso_set_result {
4358 cmdline_fixed_string_t tso;
4359 cmdline_fixed_string_t mode;
4364 static struct rte_eth_dev_info
4365 check_tunnel_tso_nic_support(portid_t port_id)
4367 struct rte_eth_dev_info dev_info;
4369 rte_eth_dev_info_get(port_id, &dev_info);
4370 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4371 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4372 "not enabled for port %d\n", port_id);
4373 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4374 printf("Warning: GRE TUNNEL TSO not supported therefore "
4375 "not enabled for port %d\n", port_id);
4376 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4377 printf("Warning: IPIP TUNNEL TSO not supported therefore "
4378 "not enabled for port %d\n", port_id);
4379 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4380 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4381 "not enabled for port %d\n", port_id);
4382 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
4383 printf("Warning: IP TUNNEL TSO not supported therefore "
4384 "not enabled for port %d\n", port_id);
4385 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
4386 printf("Warning: UDP TUNNEL TSO not supported therefore "
4387 "not enabled for port %d\n", port_id);
4392 cmd_tunnel_tso_set_parsed(void *parsed_result,
4393 __attribute__((unused)) struct cmdline *cl,
4394 __attribute__((unused)) void *data)
4396 struct cmd_tunnel_tso_set_result *res = parsed_result;
4397 struct rte_eth_dev_info dev_info;
4399 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4401 if (!port_is_stopped(res->port_id)) {
4402 printf("Please stop port %d first\n", res->port_id);
4406 if (!strcmp(res->mode, "set"))
4407 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4409 dev_info = check_tunnel_tso_nic_support(res->port_id);
4410 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4411 ports[res->port_id].dev_conf.txmode.offloads &=
4412 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4413 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4414 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4415 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4416 DEV_TX_OFFLOAD_IP_TNL_TSO |
4417 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4418 printf("TSO for tunneled packets is disabled\n");
4420 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4421 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4422 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4423 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4424 DEV_TX_OFFLOAD_IP_TNL_TSO |
4425 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4427 ports[res->port_id].dev_conf.txmode.offloads |=
4428 (tso_offloads & dev_info.tx_offload_capa);
4429 printf("TSO segment size for tunneled packets is %d\n",
4430 ports[res->port_id].tunnel_tso_segsz);
4432 /* Below conditions are needed to make it work:
4433 * (1) tunnel TSO is supported by the NIC;
4434 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4436 * (3) for tunneled pkts with outer L3 of IPv4,
4437 * "csum set outer-ip" must be set to hw, because after tso,
4438 * total_len of outer IP header is changed, and the checksum
4439 * of outer IP header calculated by sw should be wrong; that
4440 * is not necessary for IPv6 tunneled pkts because there's no
4441 * checksum in IP header anymore.
4444 if (!ports[res->port_id].parse_tunnel)
4445 printf("Warning: csum parse_tunnel must be set "
4446 "so that tunneled packets are recognized\n");
4447 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4448 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4449 printf("Warning: csum set outer-ip must be set to hw "
4450 "if outer L3 is IPv4; not necessary for IPv6\n");
4453 cmd_reconfig_device_queue(res->port_id, 1, 1);
4456 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4457 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4459 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4460 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4462 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4463 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4465 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4466 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4469 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4470 .f = cmd_tunnel_tso_set_parsed,
4472 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4473 "Set TSO segment size of tunneled packets for csum engine "
4476 (void *)&cmd_tunnel_tso_set_tso,
4477 (void *)&cmd_tunnel_tso_set_mode,
4478 (void *)&cmd_tunnel_tso_set_tso_segsz,
4479 (void *)&cmd_tunnel_tso_set_portid,
4484 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4485 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4489 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4490 .f = cmd_tunnel_tso_set_parsed,
4492 .help_str = "tunnel_tso show <port_id> "
4493 "Show TSO segment size of tunneled packets for csum engine",
4495 (void *)&cmd_tunnel_tso_set_tso,
4496 (void *)&cmd_tunnel_tso_show_mode,
4497 (void *)&cmd_tunnel_tso_set_portid,
4502 /* *** SET GRO FOR A PORT *** */
4503 struct cmd_gro_enable_result {
4504 cmdline_fixed_string_t cmd_set;
4505 cmdline_fixed_string_t cmd_port;
4506 cmdline_fixed_string_t cmd_keyword;
4507 cmdline_fixed_string_t cmd_onoff;
4512 cmd_gro_enable_parsed(void *parsed_result,
4513 __attribute__((unused)) struct cmdline *cl,
4514 __attribute__((unused)) void *data)
4516 struct cmd_gro_enable_result *res;
4518 res = parsed_result;
4519 if (!strcmp(res->cmd_keyword, "gro"))
4520 setup_gro(res->cmd_onoff, res->cmd_pid);
4523 cmdline_parse_token_string_t cmd_gro_enable_set =
4524 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4526 cmdline_parse_token_string_t cmd_gro_enable_port =
4527 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4528 cmd_keyword, "port");
4529 cmdline_parse_token_num_t cmd_gro_enable_pid =
4530 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4532 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4533 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4534 cmd_keyword, "gro");
4535 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4536 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4537 cmd_onoff, "on#off");
4539 cmdline_parse_inst_t cmd_gro_enable = {
4540 .f = cmd_gro_enable_parsed,
4542 .help_str = "set port <port_id> gro on|off",
4544 (void *)&cmd_gro_enable_set,
4545 (void *)&cmd_gro_enable_port,
4546 (void *)&cmd_gro_enable_pid,
4547 (void *)&cmd_gro_enable_keyword,
4548 (void *)&cmd_gro_enable_onoff,
4553 /* *** DISPLAY GRO CONFIGURATION *** */
4554 struct cmd_gro_show_result {
4555 cmdline_fixed_string_t cmd_show;
4556 cmdline_fixed_string_t cmd_port;
4557 cmdline_fixed_string_t cmd_keyword;
4562 cmd_gro_show_parsed(void *parsed_result,
4563 __attribute__((unused)) struct cmdline *cl,
4564 __attribute__((unused)) void *data)
4566 struct cmd_gro_show_result *res;
4568 res = parsed_result;
4569 if (!strcmp(res->cmd_keyword, "gro"))
4570 show_gro(res->cmd_pid);
4573 cmdline_parse_token_string_t cmd_gro_show_show =
4574 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4576 cmdline_parse_token_string_t cmd_gro_show_port =
4577 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4579 cmdline_parse_token_num_t cmd_gro_show_pid =
4580 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
4582 cmdline_parse_token_string_t cmd_gro_show_keyword =
4583 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4584 cmd_keyword, "gro");
4586 cmdline_parse_inst_t cmd_gro_show = {
4587 .f = cmd_gro_show_parsed,
4589 .help_str = "show port <port_id> gro",
4591 (void *)&cmd_gro_show_show,
4592 (void *)&cmd_gro_show_port,
4593 (void *)&cmd_gro_show_pid,
4594 (void *)&cmd_gro_show_keyword,
4599 /* *** SET FLUSH CYCLES FOR GRO *** */
4600 struct cmd_gro_flush_result {
4601 cmdline_fixed_string_t cmd_set;
4602 cmdline_fixed_string_t cmd_keyword;
4603 cmdline_fixed_string_t cmd_flush;
4608 cmd_gro_flush_parsed(void *parsed_result,
4609 __attribute__((unused)) struct cmdline *cl,
4610 __attribute__((unused)) void *data)
4612 struct cmd_gro_flush_result *res;
4614 res = parsed_result;
4615 if ((!strcmp(res->cmd_keyword, "gro")) &&
4616 (!strcmp(res->cmd_flush, "flush")))
4617 setup_gro_flush_cycles(res->cmd_cycles);
4620 cmdline_parse_token_string_t cmd_gro_flush_set =
4621 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4623 cmdline_parse_token_string_t cmd_gro_flush_keyword =
4624 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4625 cmd_keyword, "gro");
4626 cmdline_parse_token_string_t cmd_gro_flush_flush =
4627 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4628 cmd_flush, "flush");
4629 cmdline_parse_token_num_t cmd_gro_flush_cycles =
4630 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
4633 cmdline_parse_inst_t cmd_gro_flush = {
4634 .f = cmd_gro_flush_parsed,
4636 .help_str = "set gro flush <cycles>",
4638 (void *)&cmd_gro_flush_set,
4639 (void *)&cmd_gro_flush_keyword,
4640 (void *)&cmd_gro_flush_flush,
4641 (void *)&cmd_gro_flush_cycles,
4646 /* *** ENABLE/DISABLE GSO *** */
4647 struct cmd_gso_enable_result {
4648 cmdline_fixed_string_t cmd_set;
4649 cmdline_fixed_string_t cmd_port;
4650 cmdline_fixed_string_t cmd_keyword;
4651 cmdline_fixed_string_t cmd_mode;
4656 cmd_gso_enable_parsed(void *parsed_result,
4657 __attribute__((unused)) struct cmdline *cl,
4658 __attribute__((unused)) void *data)
4660 struct cmd_gso_enable_result *res;
4662 res = parsed_result;
4663 if (!strcmp(res->cmd_keyword, "gso"))
4664 setup_gso(res->cmd_mode, res->cmd_pid);
4667 cmdline_parse_token_string_t cmd_gso_enable_set =
4668 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4670 cmdline_parse_token_string_t cmd_gso_enable_port =
4671 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4673 cmdline_parse_token_string_t cmd_gso_enable_keyword =
4674 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4675 cmd_keyword, "gso");
4676 cmdline_parse_token_string_t cmd_gso_enable_mode =
4677 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4678 cmd_mode, "on#off");
4679 cmdline_parse_token_num_t cmd_gso_enable_pid =
4680 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
4683 cmdline_parse_inst_t cmd_gso_enable = {
4684 .f = cmd_gso_enable_parsed,
4686 .help_str = "set port <port_id> gso on|off",
4688 (void *)&cmd_gso_enable_set,
4689 (void *)&cmd_gso_enable_port,
4690 (void *)&cmd_gso_enable_pid,
4691 (void *)&cmd_gso_enable_keyword,
4692 (void *)&cmd_gso_enable_mode,
4697 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
4698 struct cmd_gso_size_result {
4699 cmdline_fixed_string_t cmd_set;
4700 cmdline_fixed_string_t cmd_keyword;
4701 cmdline_fixed_string_t cmd_segsz;
4706 cmd_gso_size_parsed(void *parsed_result,
4707 __attribute__((unused)) struct cmdline *cl,
4708 __attribute__((unused)) void *data)
4710 struct cmd_gso_size_result *res = parsed_result;
4712 if (test_done == 0) {
4713 printf("Before setting GSO segsz, please first"
4714 " stop fowarding\n");
4718 if (!strcmp(res->cmd_keyword, "gso") &&
4719 !strcmp(res->cmd_segsz, "segsz")) {
4720 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
4721 printf("gso_size should be larger than %zu."
4722 " Please input a legal value\n",
4723 RTE_GSO_SEG_SIZE_MIN);
4725 gso_max_segment_size = res->cmd_size;
4729 cmdline_parse_token_string_t cmd_gso_size_set =
4730 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4732 cmdline_parse_token_string_t cmd_gso_size_keyword =
4733 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4734 cmd_keyword, "gso");
4735 cmdline_parse_token_string_t cmd_gso_size_segsz =
4736 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4737 cmd_segsz, "segsz");
4738 cmdline_parse_token_num_t cmd_gso_size_size =
4739 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
4742 cmdline_parse_inst_t cmd_gso_size = {
4743 .f = cmd_gso_size_parsed,
4745 .help_str = "set gso segsz <length>",
4747 (void *)&cmd_gso_size_set,
4748 (void *)&cmd_gso_size_keyword,
4749 (void *)&cmd_gso_size_segsz,
4750 (void *)&cmd_gso_size_size,
4755 /* *** SHOW GSO CONFIGURATION *** */
4756 struct cmd_gso_show_result {
4757 cmdline_fixed_string_t cmd_show;
4758 cmdline_fixed_string_t cmd_port;
4759 cmdline_fixed_string_t cmd_keyword;
4764 cmd_gso_show_parsed(void *parsed_result,
4765 __attribute__((unused)) struct cmdline *cl,
4766 __attribute__((unused)) void *data)
4768 struct cmd_gso_show_result *res = parsed_result;
4770 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
4771 printf("invalid port id %u\n", res->cmd_pid);
4774 if (!strcmp(res->cmd_keyword, "gso")) {
4775 if (gso_ports[res->cmd_pid].enable) {
4776 printf("Max GSO'd packet size: %uB\n"
4777 "Supported GSO types: TCP/IPv4, "
4778 "VxLAN with inner TCP/IPv4 packet, "
4779 "GRE with inner TCP/IPv4 packet\n",
4780 gso_max_segment_size);
4782 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
4786 cmdline_parse_token_string_t cmd_gso_show_show =
4787 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4789 cmdline_parse_token_string_t cmd_gso_show_port =
4790 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4792 cmdline_parse_token_string_t cmd_gso_show_keyword =
4793 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4794 cmd_keyword, "gso");
4795 cmdline_parse_token_num_t cmd_gso_show_pid =
4796 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
4799 cmdline_parse_inst_t cmd_gso_show = {
4800 .f = cmd_gso_show_parsed,
4802 .help_str = "show port <port_id> gso",
4804 (void *)&cmd_gso_show_show,
4805 (void *)&cmd_gso_show_port,
4806 (void *)&cmd_gso_show_pid,
4807 (void *)&cmd_gso_show_keyword,
4812 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
4813 struct cmd_set_flush_rx {
4814 cmdline_fixed_string_t set;
4815 cmdline_fixed_string_t flush_rx;
4816 cmdline_fixed_string_t mode;
4820 cmd_set_flush_rx_parsed(void *parsed_result,
4821 __attribute__((unused)) struct cmdline *cl,
4822 __attribute__((unused)) void *data)
4824 struct cmd_set_flush_rx *res = parsed_result;
4825 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4828 cmdline_parse_token_string_t cmd_setflushrx_set =
4829 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4831 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
4832 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4833 flush_rx, "flush_rx");
4834 cmdline_parse_token_string_t cmd_setflushrx_mode =
4835 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4839 cmdline_parse_inst_t cmd_set_flush_rx = {
4840 .f = cmd_set_flush_rx_parsed,
4841 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
4844 (void *)&cmd_setflushrx_set,
4845 (void *)&cmd_setflushrx_flush_rx,
4846 (void *)&cmd_setflushrx_mode,
4851 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
4852 struct cmd_set_link_check {
4853 cmdline_fixed_string_t set;
4854 cmdline_fixed_string_t link_check;
4855 cmdline_fixed_string_t mode;
4859 cmd_set_link_check_parsed(void *parsed_result,
4860 __attribute__((unused)) struct cmdline *cl,
4861 __attribute__((unused)) void *data)
4863 struct cmd_set_link_check *res = parsed_result;
4864 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4867 cmdline_parse_token_string_t cmd_setlinkcheck_set =
4868 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4870 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
4871 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4872 link_check, "link_check");
4873 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
4874 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4878 cmdline_parse_inst_t cmd_set_link_check = {
4879 .f = cmd_set_link_check_parsed,
4880 .help_str = "set link_check on|off: Enable/Disable link status check "
4881 "when starting/stopping a port",
4884 (void *)&cmd_setlinkcheck_set,
4885 (void *)&cmd_setlinkcheck_link_check,
4886 (void *)&cmd_setlinkcheck_mode,
4891 /* *** SET NIC BYPASS MODE *** */
4892 struct cmd_set_bypass_mode_result {
4893 cmdline_fixed_string_t set;
4894 cmdline_fixed_string_t bypass;
4895 cmdline_fixed_string_t mode;
4896 cmdline_fixed_string_t value;
4901 cmd_set_bypass_mode_parsed(void *parsed_result,
4902 __attribute__((unused)) struct cmdline *cl,
4903 __attribute__((unused)) void *data)
4905 struct cmd_set_bypass_mode_result *res = parsed_result;
4906 portid_t port_id = res->port_id;
4907 int32_t rc = -EINVAL;
4909 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4910 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4912 if (!strcmp(res->value, "bypass"))
4913 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4914 else if (!strcmp(res->value, "isolate"))
4915 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4917 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4919 /* Set the bypass mode for the relevant port. */
4920 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
4923 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
4926 cmdline_parse_token_string_t cmd_setbypass_mode_set =
4927 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4929 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
4930 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4932 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
4933 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4935 cmdline_parse_token_string_t cmd_setbypass_mode_value =
4936 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4937 value, "normal#bypass#isolate");
4938 cmdline_parse_token_num_t cmd_setbypass_mode_port =
4939 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
4942 cmdline_parse_inst_t cmd_set_bypass_mode = {
4943 .f = cmd_set_bypass_mode_parsed,
4944 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
4945 "Set the NIC bypass mode for port_id",
4948 (void *)&cmd_setbypass_mode_set,
4949 (void *)&cmd_setbypass_mode_bypass,
4950 (void *)&cmd_setbypass_mode_mode,
4951 (void *)&cmd_setbypass_mode_value,
4952 (void *)&cmd_setbypass_mode_port,
4957 /* *** SET NIC BYPASS EVENT *** */
4958 struct cmd_set_bypass_event_result {
4959 cmdline_fixed_string_t set;
4960 cmdline_fixed_string_t bypass;
4961 cmdline_fixed_string_t event;
4962 cmdline_fixed_string_t event_value;
4963 cmdline_fixed_string_t mode;
4964 cmdline_fixed_string_t mode_value;
4969 cmd_set_bypass_event_parsed(void *parsed_result,
4970 __attribute__((unused)) struct cmdline *cl,
4971 __attribute__((unused)) void *data)
4973 int32_t rc = -EINVAL;
4974 struct cmd_set_bypass_event_result *res = parsed_result;
4975 portid_t port_id = res->port_id;
4977 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4978 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4979 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4981 if (!strcmp(res->event_value, "timeout"))
4982 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
4983 else if (!strcmp(res->event_value, "os_on"))
4984 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
4985 else if (!strcmp(res->event_value, "os_off"))
4986 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
4987 else if (!strcmp(res->event_value, "power_on"))
4988 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
4989 else if (!strcmp(res->event_value, "power_off"))
4990 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
4992 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4994 if (!strcmp(res->mode_value, "bypass"))
4995 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4996 else if (!strcmp(res->mode_value, "isolate"))
4997 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4999 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5001 /* Set the watchdog timeout. */
5002 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5005 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5006 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5010 printf("Failed to set timeout value %u "
5011 "for port %d, errto code: %d.\n",
5012 bypass_timeout, port_id, rc);
5016 /* Set the bypass event to transition to bypass mode. */
5017 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5022 printf("\t Failed to set bypass event for port = %d.\n",
5026 cmdline_parse_token_string_t cmd_setbypass_event_set =
5027 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5029 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5030 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5032 cmdline_parse_token_string_t cmd_setbypass_event_event =
5033 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5035 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5036 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5037 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5038 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5039 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5041 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5042 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5043 mode_value, "normal#bypass#isolate");
5044 cmdline_parse_token_num_t cmd_setbypass_event_port =
5045 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5048 cmdline_parse_inst_t cmd_set_bypass_event = {
5049 .f = cmd_set_bypass_event_parsed,
5050 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5051 "power_off mode normal|bypass|isolate <port_id>: "
5052 "Set the NIC bypass event mode for port_id",
5055 (void *)&cmd_setbypass_event_set,
5056 (void *)&cmd_setbypass_event_bypass,
5057 (void *)&cmd_setbypass_event_event,
5058 (void *)&cmd_setbypass_event_event_value,
5059 (void *)&cmd_setbypass_event_mode,
5060 (void *)&cmd_setbypass_event_mode_value,
5061 (void *)&cmd_setbypass_event_port,
5067 /* *** SET NIC BYPASS TIMEOUT *** */
5068 struct cmd_set_bypass_timeout_result {
5069 cmdline_fixed_string_t set;
5070 cmdline_fixed_string_t bypass;
5071 cmdline_fixed_string_t timeout;
5072 cmdline_fixed_string_t value;
5076 cmd_set_bypass_timeout_parsed(void *parsed_result,
5077 __attribute__((unused)) struct cmdline *cl,
5078 __attribute__((unused)) void *data)
5080 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5082 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5083 if (!strcmp(res->value, "1.5"))
5084 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5085 else if (!strcmp(res->value, "2"))
5086 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5087 else if (!strcmp(res->value, "3"))
5088 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5089 else if (!strcmp(res->value, "4"))
5090 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5091 else if (!strcmp(res->value, "8"))
5092 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5093 else if (!strcmp(res->value, "16"))
5094 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5095 else if (!strcmp(res->value, "32"))
5096 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5098 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5102 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5103 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5105 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5106 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5108 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5109 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5110 timeout, "timeout");
5111 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5112 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5113 value, "0#1.5#2#3#4#8#16#32");
5115 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5116 .f = cmd_set_bypass_timeout_parsed,
5117 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5118 "Set the NIC bypass watchdog timeout in seconds",
5121 (void *)&cmd_setbypass_timeout_set,
5122 (void *)&cmd_setbypass_timeout_bypass,
5123 (void *)&cmd_setbypass_timeout_timeout,
5124 (void *)&cmd_setbypass_timeout_value,
5129 /* *** SHOW NIC BYPASS MODE *** */
5130 struct cmd_show_bypass_config_result {
5131 cmdline_fixed_string_t show;
5132 cmdline_fixed_string_t bypass;
5133 cmdline_fixed_string_t config;
5138 cmd_show_bypass_config_parsed(void *parsed_result,
5139 __attribute__((unused)) struct cmdline *cl,
5140 __attribute__((unused)) void *data)
5142 struct cmd_show_bypass_config_result *res = parsed_result;
5143 portid_t port_id = res->port_id;
5145 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5146 uint32_t event_mode;
5147 uint32_t bypass_mode;
5148 uint32_t timeout = bypass_timeout;
5151 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5152 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5153 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5154 {"UNKNOWN", "normal", "bypass", "isolate"};
5155 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5162 int num_events = (sizeof events) / (sizeof events[0]);
5164 /* Display the bypass mode.*/
5165 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5166 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5170 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5171 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5173 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5176 /* Display the bypass timeout.*/
5177 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5178 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5180 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5182 /* Display the bypass events and associated modes. */
5183 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
5185 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5186 printf("\tFailed to get bypass mode for event = %s\n",
5189 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5190 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5192 printf("\tbypass event: %-16s = %s\n", events[i],
5198 printf("\tFailed to get bypass configuration for port = %d\n",
5202 cmdline_parse_token_string_t cmd_showbypass_config_show =
5203 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5205 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5206 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5208 cmdline_parse_token_string_t cmd_showbypass_config_config =
5209 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5211 cmdline_parse_token_num_t cmd_showbypass_config_port =
5212 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5215 cmdline_parse_inst_t cmd_show_bypass_config = {
5216 .f = cmd_show_bypass_config_parsed,
5217 .help_str = "show bypass config <port_id>: "
5218 "Show the NIC bypass config for port_id",
5221 (void *)&cmd_showbypass_config_show,
5222 (void *)&cmd_showbypass_config_bypass,
5223 (void *)&cmd_showbypass_config_config,
5224 (void *)&cmd_showbypass_config_port,
5229 #ifdef RTE_LIBRTE_PMD_BOND
5230 /* *** SET BONDING MODE *** */
5231 struct cmd_set_bonding_mode_result {
5232 cmdline_fixed_string_t set;
5233 cmdline_fixed_string_t bonding;
5234 cmdline_fixed_string_t mode;
5239 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5240 __attribute__((unused)) struct cmdline *cl,
5241 __attribute__((unused)) void *data)
5243 struct cmd_set_bonding_mode_result *res = parsed_result;
5244 portid_t port_id = res->port_id;
5246 /* Set the bonding mode for the relevant port. */
5247 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5248 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5251 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5252 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5254 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5255 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5256 bonding, "bonding");
5257 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5258 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5260 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5261 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5263 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5264 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5267 cmdline_parse_inst_t cmd_set_bonding_mode = {
5268 .f = cmd_set_bonding_mode_parsed,
5269 .help_str = "set bonding mode <mode_value> <port_id>: "
5270 "Set the bonding mode for port_id",
5273 (void *) &cmd_setbonding_mode_set,
5274 (void *) &cmd_setbonding_mode_bonding,
5275 (void *) &cmd_setbonding_mode_mode,
5276 (void *) &cmd_setbonding_mode_value,
5277 (void *) &cmd_setbonding_mode_port,
5282 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5283 struct cmd_set_bonding_lacp_dedicated_queues_result {
5284 cmdline_fixed_string_t set;
5285 cmdline_fixed_string_t bonding;
5286 cmdline_fixed_string_t lacp;
5287 cmdline_fixed_string_t dedicated_queues;
5289 cmdline_fixed_string_t mode;
5292 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5293 __attribute__((unused)) struct cmdline *cl,
5294 __attribute__((unused)) void *data)
5296 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5297 portid_t port_id = res->port_id;
5298 struct rte_port *port;
5300 port = &ports[port_id];
5302 /** Check if the port is not started **/
5303 if (port->port_status != RTE_PORT_STOPPED) {
5304 printf("Please stop port %d first\n", port_id);
5308 if (!strcmp(res->mode, "enable")) {
5309 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5310 printf("Dedicate queues for LACP control packets"
5313 printf("Enabling dedicate queues for LACP control "
5314 "packets on port %d failed\n", port_id);
5315 } else if (!strcmp(res->mode, "disable")) {
5316 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5317 printf("Dedicated queues for LACP control packets "
5320 printf("Disabling dedicated queues for LACP control "
5321 "traffic on port %d failed\n", port_id);
5325 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5326 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5328 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5329 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5330 bonding, "bonding");
5331 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5332 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5334 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5335 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5336 dedicated_queues, "dedicated_queues");
5337 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5338 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5340 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5341 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5342 mode, "enable#disable");
5344 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5345 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5346 .help_str = "set bonding lacp dedicated_queues <port_id> "
5348 "Enable/disable dedicated queues for LACP control traffic for port_id",
5351 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5352 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5353 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5354 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5355 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5356 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5361 /* *** SET BALANCE XMIT POLICY *** */
5362 struct cmd_set_bonding_balance_xmit_policy_result {
5363 cmdline_fixed_string_t set;
5364 cmdline_fixed_string_t bonding;
5365 cmdline_fixed_string_t balance_xmit_policy;
5367 cmdline_fixed_string_t policy;
5370 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5371 __attribute__((unused)) struct cmdline *cl,
5372 __attribute__((unused)) void *data)
5374 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5375 portid_t port_id = res->port_id;
5378 if (!strcmp(res->policy, "l2")) {
5379 policy = BALANCE_XMIT_POLICY_LAYER2;
5380 } else if (!strcmp(res->policy, "l23")) {
5381 policy = BALANCE_XMIT_POLICY_LAYER23;
5382 } else if (!strcmp(res->policy, "l34")) {
5383 policy = BALANCE_XMIT_POLICY_LAYER34;
5385 printf("\t Invalid xmit policy selection");
5389 /* Set the bonding mode for the relevant port. */
5390 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5391 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5396 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5397 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5399 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5400 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5401 bonding, "bonding");
5402 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5403 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5404 balance_xmit_policy, "balance_xmit_policy");
5405 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5406 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5408 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5409 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5410 policy, "l2#l23#l34");
5412 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5413 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5414 .help_str = "set bonding balance_xmit_policy <port_id> "
5416 "Set the bonding balance_xmit_policy for port_id",
5419 (void *)&cmd_setbonding_balance_xmit_policy_set,
5420 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5421 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5422 (void *)&cmd_setbonding_balance_xmit_policy_port,
5423 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5428 /* *** SHOW NIC BONDING CONFIGURATION *** */
5429 struct cmd_show_bonding_config_result {
5430 cmdline_fixed_string_t show;
5431 cmdline_fixed_string_t bonding;
5432 cmdline_fixed_string_t config;
5436 static void cmd_show_bonding_config_parsed(void *parsed_result,
5437 __attribute__((unused)) struct cmdline *cl,
5438 __attribute__((unused)) void *data)
5440 struct cmd_show_bonding_config_result *res = parsed_result;
5441 int bonding_mode, agg_mode;
5442 portid_t slaves[RTE_MAX_ETHPORTS];
5443 int num_slaves, num_active_slaves;
5446 portid_t port_id = res->port_id;
5448 /* Display the bonding mode.*/
5449 bonding_mode = rte_eth_bond_mode_get(port_id);
5450 if (bonding_mode < 0) {
5451 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5454 printf("\tBonding mode: %d\n", bonding_mode);
5456 if (bonding_mode == BONDING_MODE_BALANCE) {
5457 int balance_xmit_policy;
5459 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5460 if (balance_xmit_policy < 0) {
5461 printf("\tFailed to get balance xmit policy for port = %d\n",
5465 printf("\tBalance Xmit Policy: ");
5467 switch (balance_xmit_policy) {
5468 case BALANCE_XMIT_POLICY_LAYER2:
5469 printf("BALANCE_XMIT_POLICY_LAYER2");
5471 case BALANCE_XMIT_POLICY_LAYER23:
5472 printf("BALANCE_XMIT_POLICY_LAYER23");
5474 case BALANCE_XMIT_POLICY_LAYER34:
5475 printf("BALANCE_XMIT_POLICY_LAYER34");
5482 if (bonding_mode == BONDING_MODE_8023AD) {
5483 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5484 printf("\tIEEE802.3AD Aggregator Mode: ");
5487 printf("bandwidth");
5499 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5501 if (num_slaves < 0) {
5502 printf("\tFailed to get slave list for port = %d\n", port_id);
5505 if (num_slaves > 0) {
5506 printf("\tSlaves (%d): [", num_slaves);
5507 for (i = 0; i < num_slaves - 1; i++)
5508 printf("%d ", slaves[i]);
5510 printf("%d]\n", slaves[num_slaves - 1]);
5512 printf("\tSlaves: []\n");
5516 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5519 if (num_active_slaves < 0) {
5520 printf("\tFailed to get active slave list for port = %d\n", port_id);
5523 if (num_active_slaves > 0) {
5524 printf("\tActive Slaves (%d): [", num_active_slaves);
5525 for (i = 0; i < num_active_slaves - 1; i++)
5526 printf("%d ", slaves[i]);
5528 printf("%d]\n", slaves[num_active_slaves - 1]);
5531 printf("\tActive Slaves: []\n");
5535 primary_id = rte_eth_bond_primary_get(port_id);
5536 if (primary_id < 0) {
5537 printf("\tFailed to get primary slave for port = %d\n", port_id);
5540 printf("\tPrimary: [%d]\n", primary_id);
5544 cmdline_parse_token_string_t cmd_showbonding_config_show =
5545 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5547 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5548 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5549 bonding, "bonding");
5550 cmdline_parse_token_string_t cmd_showbonding_config_config =
5551 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5553 cmdline_parse_token_num_t cmd_showbonding_config_port =
5554 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
5557 cmdline_parse_inst_t cmd_show_bonding_config = {
5558 .f = cmd_show_bonding_config_parsed,
5559 .help_str = "show bonding config <port_id>: "
5560 "Show the bonding config for port_id",
5563 (void *)&cmd_showbonding_config_show,
5564 (void *)&cmd_showbonding_config_bonding,
5565 (void *)&cmd_showbonding_config_config,
5566 (void *)&cmd_showbonding_config_port,
5571 /* *** SET BONDING PRIMARY *** */
5572 struct cmd_set_bonding_primary_result {
5573 cmdline_fixed_string_t set;
5574 cmdline_fixed_string_t bonding;
5575 cmdline_fixed_string_t primary;
5580 static void cmd_set_bonding_primary_parsed(void *parsed_result,
5581 __attribute__((unused)) struct cmdline *cl,
5582 __attribute__((unused)) void *data)
5584 struct cmd_set_bonding_primary_result *res = parsed_result;
5585 portid_t master_port_id = res->port_id;
5586 portid_t slave_port_id = res->slave_id;
5588 /* Set the primary slave for a bonded device. */
5589 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
5590 printf("\t Failed to set primary slave for port = %d.\n",
5597 cmdline_parse_token_string_t cmd_setbonding_primary_set =
5598 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5600 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
5601 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5602 bonding, "bonding");
5603 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
5604 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5605 primary, "primary");
5606 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
5607 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5609 cmdline_parse_token_num_t cmd_setbonding_primary_port =
5610 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5613 cmdline_parse_inst_t cmd_set_bonding_primary = {
5614 .f = cmd_set_bonding_primary_parsed,
5615 .help_str = "set bonding primary <slave_id> <port_id>: "
5616 "Set the primary slave for port_id",
5619 (void *)&cmd_setbonding_primary_set,
5620 (void *)&cmd_setbonding_primary_bonding,
5621 (void *)&cmd_setbonding_primary_primary,
5622 (void *)&cmd_setbonding_primary_slave,
5623 (void *)&cmd_setbonding_primary_port,
5628 /* *** ADD SLAVE *** */
5629 struct cmd_add_bonding_slave_result {
5630 cmdline_fixed_string_t add;
5631 cmdline_fixed_string_t bonding;
5632 cmdline_fixed_string_t slave;
5637 static void cmd_add_bonding_slave_parsed(void *parsed_result,
5638 __attribute__((unused)) struct cmdline *cl,
5639 __attribute__((unused)) void *data)
5641 struct cmd_add_bonding_slave_result *res = parsed_result;
5642 portid_t master_port_id = res->port_id;
5643 portid_t slave_port_id = res->slave_id;
5645 /* add the slave for a bonded device. */
5646 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
5647 printf("\t Failed to add slave %d to master port = %d.\n",
5648 slave_port_id, master_port_id);
5652 set_port_slave_flag(slave_port_id);
5655 cmdline_parse_token_string_t cmd_addbonding_slave_add =
5656 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5658 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
5659 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5660 bonding, "bonding");
5661 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
5662 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5664 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
5665 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5667 cmdline_parse_token_num_t cmd_addbonding_slave_port =
5668 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5671 cmdline_parse_inst_t cmd_add_bonding_slave = {
5672 .f = cmd_add_bonding_slave_parsed,
5673 .help_str = "add bonding slave <slave_id> <port_id>: "
5674 "Add a slave device to a bonded device",
5677 (void *)&cmd_addbonding_slave_add,
5678 (void *)&cmd_addbonding_slave_bonding,
5679 (void *)&cmd_addbonding_slave_slave,
5680 (void *)&cmd_addbonding_slave_slaveid,
5681 (void *)&cmd_addbonding_slave_port,
5686 /* *** REMOVE SLAVE *** */
5687 struct cmd_remove_bonding_slave_result {
5688 cmdline_fixed_string_t remove;
5689 cmdline_fixed_string_t bonding;
5690 cmdline_fixed_string_t slave;
5695 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
5696 __attribute__((unused)) struct cmdline *cl,
5697 __attribute__((unused)) void *data)
5699 struct cmd_remove_bonding_slave_result *res = parsed_result;
5700 portid_t master_port_id = res->port_id;
5701 portid_t slave_port_id = res->slave_id;
5703 /* remove the slave from a bonded device. */
5704 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
5705 printf("\t Failed to remove slave %d from master port = %d.\n",
5706 slave_port_id, master_port_id);
5710 clear_port_slave_flag(slave_port_id);
5713 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
5714 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5716 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
5717 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5718 bonding, "bonding");
5719 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
5720 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5722 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
5723 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5725 cmdline_parse_token_num_t cmd_removebonding_slave_port =
5726 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5729 cmdline_parse_inst_t cmd_remove_bonding_slave = {
5730 .f = cmd_remove_bonding_slave_parsed,
5731 .help_str = "remove bonding slave <slave_id> <port_id>: "
5732 "Remove a slave device from a bonded device",
5735 (void *)&cmd_removebonding_slave_remove,
5736 (void *)&cmd_removebonding_slave_bonding,
5737 (void *)&cmd_removebonding_slave_slave,
5738 (void *)&cmd_removebonding_slave_slaveid,
5739 (void *)&cmd_removebonding_slave_port,
5744 /* *** CREATE BONDED DEVICE *** */
5745 struct cmd_create_bonded_device_result {
5746 cmdline_fixed_string_t create;
5747 cmdline_fixed_string_t bonded;
5748 cmdline_fixed_string_t device;
5753 static int bond_dev_num = 0;
5755 static void cmd_create_bonded_device_parsed(void *parsed_result,
5756 __attribute__((unused)) struct cmdline *cl,
5757 __attribute__((unused)) void *data)
5759 struct cmd_create_bonded_device_result *res = parsed_result;
5760 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
5763 if (test_done == 0) {
5764 printf("Please stop forwarding first\n");
5768 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
5771 /* Create a new bonded device. */
5772 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
5774 printf("\t Failed to create bonded device.\n");
5777 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
5780 /* Update number of ports */
5781 nb_ports = rte_eth_dev_count_avail();
5782 reconfig(port_id, res->socket);
5783 rte_eth_promiscuous_enable(port_id);
5788 cmdline_parse_token_string_t cmd_createbonded_device_create =
5789 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5791 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
5792 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5794 cmdline_parse_token_string_t cmd_createbonded_device_device =
5795 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5797 cmdline_parse_token_num_t cmd_createbonded_device_mode =
5798 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5800 cmdline_parse_token_num_t cmd_createbonded_device_socket =
5801 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5804 cmdline_parse_inst_t cmd_create_bonded_device = {
5805 .f = cmd_create_bonded_device_parsed,
5806 .help_str = "create bonded device <mode> <socket>: "
5807 "Create a new bonded device with specific bonding mode and socket",
5810 (void *)&cmd_createbonded_device_create,
5811 (void *)&cmd_createbonded_device_bonded,
5812 (void *)&cmd_createbonded_device_device,
5813 (void *)&cmd_createbonded_device_mode,
5814 (void *)&cmd_createbonded_device_socket,
5819 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
5820 struct cmd_set_bond_mac_addr_result {
5821 cmdline_fixed_string_t set;
5822 cmdline_fixed_string_t bonding;
5823 cmdline_fixed_string_t mac_addr;
5825 struct ether_addr address;
5828 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
5829 __attribute__((unused)) struct cmdline *cl,
5830 __attribute__((unused)) void *data)
5832 struct cmd_set_bond_mac_addr_result *res = parsed_result;
5835 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
5838 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
5840 /* check the return value and print it if is < 0 */
5842 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5845 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
5846 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
5847 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
5848 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
5850 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
5851 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
5853 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
5854 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
5856 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
5857 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
5859 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
5860 .f = cmd_set_bond_mac_addr_parsed,
5862 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
5864 (void *)&cmd_set_bond_mac_addr_set,
5865 (void *)&cmd_set_bond_mac_addr_bonding,
5866 (void *)&cmd_set_bond_mac_addr_mac,
5867 (void *)&cmd_set_bond_mac_addr_portnum,
5868 (void *)&cmd_set_bond_mac_addr_addr,
5874 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
5875 struct cmd_set_bond_mon_period_result {
5876 cmdline_fixed_string_t set;
5877 cmdline_fixed_string_t bonding;
5878 cmdline_fixed_string_t mon_period;
5883 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
5884 __attribute__((unused)) struct cmdline *cl,
5885 __attribute__((unused)) void *data)
5887 struct cmd_set_bond_mon_period_result *res = parsed_result;
5890 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
5892 /* check the return value and print it if is < 0 */
5894 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5897 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
5898 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5900 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
5901 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5902 bonding, "bonding");
5903 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
5904 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5905 mon_period, "mon_period");
5906 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
5907 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5909 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
5910 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5913 cmdline_parse_inst_t cmd_set_bond_mon_period = {
5914 .f = cmd_set_bond_mon_period_parsed,
5916 .help_str = "set bonding mon_period <port_id> <period_ms>",
5918 (void *)&cmd_set_bond_mon_period_set,
5919 (void *)&cmd_set_bond_mon_period_bonding,
5920 (void *)&cmd_set_bond_mon_period_mon_period,
5921 (void *)&cmd_set_bond_mon_period_portnum,
5922 (void *)&cmd_set_bond_mon_period_period_ms,
5929 struct cmd_set_bonding_agg_mode_policy_result {
5930 cmdline_fixed_string_t set;
5931 cmdline_fixed_string_t bonding;
5932 cmdline_fixed_string_t agg_mode;
5934 cmdline_fixed_string_t policy;
5939 cmd_set_bonding_agg_mode(void *parsed_result,
5940 __attribute__((unused)) struct cmdline *cl,
5941 __attribute__((unused)) void *data)
5943 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
5944 uint8_t policy = AGG_BANDWIDTH;
5946 if (!strcmp(res->policy, "bandwidth"))
5947 policy = AGG_BANDWIDTH;
5948 else if (!strcmp(res->policy, "stable"))
5949 policy = AGG_STABLE;
5950 else if (!strcmp(res->policy, "count"))
5953 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
5957 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
5958 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5960 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
5961 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5962 bonding, "bonding");
5964 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
5965 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5966 agg_mode, "agg_mode");
5968 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
5969 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5972 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
5973 TOKEN_STRING_INITIALIZER(
5974 struct cmd_set_bonding_balance_xmit_policy_result,
5975 policy, "stable#bandwidth#count");
5977 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
5978 .f = cmd_set_bonding_agg_mode,
5980 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
5982 (void *)&cmd_set_bonding_agg_mode_set,
5983 (void *)&cmd_set_bonding_agg_mode_bonding,
5984 (void *)&cmd_set_bonding_agg_mode_agg_mode,
5985 (void *)&cmd_set_bonding_agg_mode_portnum,
5986 (void *)&cmd_set_bonding_agg_mode_policy_string,
5992 #endif /* RTE_LIBRTE_PMD_BOND */
5994 /* *** SET FORWARDING MODE *** */
5995 struct cmd_set_fwd_mode_result {
5996 cmdline_fixed_string_t set;
5997 cmdline_fixed_string_t fwd;
5998 cmdline_fixed_string_t mode;
6001 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6002 __attribute__((unused)) struct cmdline *cl,
6003 __attribute__((unused)) void *data)
6005 struct cmd_set_fwd_mode_result *res = parsed_result;
6008 set_pkt_forwarding_mode(res->mode);
6011 cmdline_parse_token_string_t cmd_setfwd_set =
6012 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6013 cmdline_parse_token_string_t cmd_setfwd_fwd =
6014 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6015 cmdline_parse_token_string_t cmd_setfwd_mode =
6016 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6017 "" /* defined at init */);
6019 cmdline_parse_inst_t cmd_set_fwd_mode = {
6020 .f = cmd_set_fwd_mode_parsed,
6022 .help_str = NULL, /* defined at init */
6024 (void *)&cmd_setfwd_set,
6025 (void *)&cmd_setfwd_fwd,
6026 (void *)&cmd_setfwd_mode,
6031 static void cmd_set_fwd_mode_init(void)
6034 static char token[128];
6035 static char help[256];
6036 cmdline_parse_token_string_t *token_struct;
6038 modes = list_pkt_forwarding_modes();
6039 snprintf(help, sizeof(help), "set fwd %s: "
6040 "Set packet forwarding mode", modes);
6041 cmd_set_fwd_mode.help_str = help;
6043 /* string token separator is # */
6044 for (c = token; *modes != '\0'; modes++)
6049 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6050 token_struct->string_data.str = token;
6053 /* *** SET RETRY FORWARDING MODE *** */
6054 struct cmd_set_fwd_retry_mode_result {
6055 cmdline_fixed_string_t set;
6056 cmdline_fixed_string_t fwd;
6057 cmdline_fixed_string_t mode;
6058 cmdline_fixed_string_t retry;
6061 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6062 __attribute__((unused)) struct cmdline *cl,
6063 __attribute__((unused)) void *data)
6065 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6068 set_pkt_forwarding_mode(res->mode);
6071 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6072 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6074 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6075 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6077 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6078 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6080 "" /* defined at init */);
6081 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6082 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6085 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6086 .f = cmd_set_fwd_retry_mode_parsed,
6088 .help_str = NULL, /* defined at init */
6090 (void *)&cmd_setfwd_retry_set,
6091 (void *)&cmd_setfwd_retry_fwd,
6092 (void *)&cmd_setfwd_retry_mode,
6093 (void *)&cmd_setfwd_retry_retry,
6098 static void cmd_set_fwd_retry_mode_init(void)
6101 static char token[128];
6102 static char help[256];
6103 cmdline_parse_token_string_t *token_struct;
6105 modes = list_pkt_forwarding_retry_modes();
6106 snprintf(help, sizeof(help), "set fwd %s retry: "
6107 "Set packet forwarding mode with retry", modes);
6108 cmd_set_fwd_retry_mode.help_str = help;
6110 /* string token separator is # */
6111 for (c = token; *modes != '\0'; modes++)
6116 token_struct = (cmdline_parse_token_string_t *)
6117 cmd_set_fwd_retry_mode.tokens[2];
6118 token_struct->string_data.str = token;
6121 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6122 struct cmd_set_burst_tx_retry_result {
6123 cmdline_fixed_string_t set;
6124 cmdline_fixed_string_t burst;
6125 cmdline_fixed_string_t tx;
6126 cmdline_fixed_string_t delay;
6128 cmdline_fixed_string_t retry;
6132 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6133 __attribute__((unused)) struct cmdline *cl,
6134 __attribute__((unused)) void *data)
6136 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6138 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6139 && !strcmp(res->tx, "tx")) {
6140 if (!strcmp(res->delay, "delay"))
6141 burst_tx_delay_time = res->time;
6142 if (!strcmp(res->retry, "retry"))
6143 burst_tx_retry_num = res->retry_num;
6148 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6149 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6150 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6151 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6153 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6154 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6155 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6156 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6157 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6158 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
6159 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6160 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6161 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6162 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
6164 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6165 .f = cmd_set_burst_tx_retry_parsed,
6166 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6168 (void *)&cmd_set_burst_tx_retry_set,
6169 (void *)&cmd_set_burst_tx_retry_burst,
6170 (void *)&cmd_set_burst_tx_retry_tx,
6171 (void *)&cmd_set_burst_tx_retry_delay,
6172 (void *)&cmd_set_burst_tx_retry_time,
6173 (void *)&cmd_set_burst_tx_retry_retry,
6174 (void *)&cmd_set_burst_tx_retry_retry_num,
6179 /* *** SET PROMISC MODE *** */
6180 struct cmd_set_promisc_mode_result {
6181 cmdline_fixed_string_t set;
6182 cmdline_fixed_string_t promisc;
6183 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6184 uint16_t port_num; /* valid if "allports" argument == 0 */
6185 cmdline_fixed_string_t mode;
6188 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6189 __attribute__((unused)) struct cmdline *cl,
6192 struct cmd_set_promisc_mode_result *res = parsed_result;
6196 if (!strcmp(res->mode, "on"))
6203 RTE_ETH_FOREACH_DEV(i) {
6205 rte_eth_promiscuous_enable(i);
6207 rte_eth_promiscuous_disable(i);
6212 rte_eth_promiscuous_enable(res->port_num);
6214 rte_eth_promiscuous_disable(res->port_num);
6218 cmdline_parse_token_string_t cmd_setpromisc_set =
6219 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6220 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6221 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6223 cmdline_parse_token_string_t cmd_setpromisc_portall =
6224 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6226 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6227 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6229 cmdline_parse_token_string_t cmd_setpromisc_mode =
6230 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6233 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6234 .f = cmd_set_promisc_mode_parsed,
6236 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6238 (void *)&cmd_setpromisc_set,
6239 (void *)&cmd_setpromisc_promisc,
6240 (void *)&cmd_setpromisc_portall,
6241 (void *)&cmd_setpromisc_mode,
6246 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6247 .f = cmd_set_promisc_mode_parsed,
6249 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6251 (void *)&cmd_setpromisc_set,
6252 (void *)&cmd_setpromisc_promisc,
6253 (void *)&cmd_setpromisc_portnum,
6254 (void *)&cmd_setpromisc_mode,
6259 /* *** SET ALLMULTI MODE *** */
6260 struct cmd_set_allmulti_mode_result {
6261 cmdline_fixed_string_t set;
6262 cmdline_fixed_string_t allmulti;
6263 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6264 uint16_t port_num; /* valid if "allports" argument == 0 */
6265 cmdline_fixed_string_t mode;
6268 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6269 __attribute__((unused)) struct cmdline *cl,
6272 struct cmd_set_allmulti_mode_result *res = parsed_result;
6276 if (!strcmp(res->mode, "on"))
6283 RTE_ETH_FOREACH_DEV(i) {
6285 rte_eth_allmulticast_enable(i);
6287 rte_eth_allmulticast_disable(i);
6292 rte_eth_allmulticast_enable(res->port_num);
6294 rte_eth_allmulticast_disable(res->port_num);
6298 cmdline_parse_token_string_t cmd_setallmulti_set =
6299 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6300 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6301 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6303 cmdline_parse_token_string_t cmd_setallmulti_portall =
6304 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6306 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6307 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6309 cmdline_parse_token_string_t cmd_setallmulti_mode =
6310 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6313 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6314 .f = cmd_set_allmulti_mode_parsed,
6316 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6318 (void *)&cmd_setallmulti_set,
6319 (void *)&cmd_setallmulti_allmulti,
6320 (void *)&cmd_setallmulti_portall,
6321 (void *)&cmd_setallmulti_mode,
6326 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6327 .f = cmd_set_allmulti_mode_parsed,
6329 .help_str = "set allmulti <port_id> on|off: "
6330 "Set allmulti mode on port_id",
6332 (void *)&cmd_setallmulti_set,
6333 (void *)&cmd_setallmulti_allmulti,
6334 (void *)&cmd_setallmulti_portnum,
6335 (void *)&cmd_setallmulti_mode,
6340 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6341 struct cmd_link_flow_ctrl_set_result {
6342 cmdline_fixed_string_t set;
6343 cmdline_fixed_string_t flow_ctrl;
6344 cmdline_fixed_string_t rx;
6345 cmdline_fixed_string_t rx_lfc_mode;
6346 cmdline_fixed_string_t tx;
6347 cmdline_fixed_string_t tx_lfc_mode;
6348 cmdline_fixed_string_t mac_ctrl_frame_fwd;
6349 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6350 cmdline_fixed_string_t autoneg_str;
6351 cmdline_fixed_string_t autoneg;
6352 cmdline_fixed_string_t hw_str;
6353 uint32_t high_water;
6354 cmdline_fixed_string_t lw_str;
6356 cmdline_fixed_string_t pt_str;
6357 uint16_t pause_time;
6358 cmdline_fixed_string_t xon_str;
6363 cmdline_parse_token_string_t cmd_lfc_set_set =
6364 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6366 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6367 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6368 flow_ctrl, "flow_ctrl");
6369 cmdline_parse_token_string_t cmd_lfc_set_rx =
6370 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6372 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6373 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6374 rx_lfc_mode, "on#off");
6375 cmdline_parse_token_string_t cmd_lfc_set_tx =
6376 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6378 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6379 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6380 tx_lfc_mode, "on#off");
6381 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6382 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6383 hw_str, "high_water");
6384 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6385 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6386 high_water, UINT32);
6387 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6388 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6389 lw_str, "low_water");
6390 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6391 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6393 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6394 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6395 pt_str, "pause_time");
6396 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6397 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6398 pause_time, UINT16);
6399 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6400 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6401 xon_str, "send_xon");
6402 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6403 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6405 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6406 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6407 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6408 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6409 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6410 mac_ctrl_frame_fwd_mode, "on#off");
6411 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6412 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6413 autoneg_str, "autoneg");
6414 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6415 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6417 cmdline_parse_token_num_t cmd_lfc_set_portid =
6418 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6421 /* forward declaration */
6423 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6426 cmdline_parse_inst_t cmd_link_flow_control_set = {
6427 .f = cmd_link_flow_ctrl_set_parsed,
6429 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6430 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6431 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6433 (void *)&cmd_lfc_set_set,
6434 (void *)&cmd_lfc_set_flow_ctrl,
6435 (void *)&cmd_lfc_set_rx,
6436 (void *)&cmd_lfc_set_rx_mode,
6437 (void *)&cmd_lfc_set_tx,
6438 (void *)&cmd_lfc_set_tx_mode,
6439 (void *)&cmd_lfc_set_high_water,
6440 (void *)&cmd_lfc_set_low_water,
6441 (void *)&cmd_lfc_set_pause_time,
6442 (void *)&cmd_lfc_set_send_xon,
6443 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6444 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6445 (void *)&cmd_lfc_set_autoneg_str,
6446 (void *)&cmd_lfc_set_autoneg,
6447 (void *)&cmd_lfc_set_portid,
6452 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6453 .f = cmd_link_flow_ctrl_set_parsed,
6454 .data = (void *)&cmd_link_flow_control_set_rx,
6455 .help_str = "set flow_ctrl rx on|off <port_id>: "
6456 "Change rx flow control parameter",
6458 (void *)&cmd_lfc_set_set,
6459 (void *)&cmd_lfc_set_flow_ctrl,
6460 (void *)&cmd_lfc_set_rx,
6461 (void *)&cmd_lfc_set_rx_mode,
6462 (void *)&cmd_lfc_set_portid,
6467 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6468 .f = cmd_link_flow_ctrl_set_parsed,
6469 .data = (void *)&cmd_link_flow_control_set_tx,
6470 .help_str = "set flow_ctrl tx on|off <port_id>: "
6471 "Change tx flow control parameter",
6473 (void *)&cmd_lfc_set_set,
6474 (void *)&cmd_lfc_set_flow_ctrl,
6475 (void *)&cmd_lfc_set_tx,
6476 (void *)&cmd_lfc_set_tx_mode,
6477 (void *)&cmd_lfc_set_portid,
6482 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6483 .f = cmd_link_flow_ctrl_set_parsed,
6484 .data = (void *)&cmd_link_flow_control_set_hw,
6485 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6486 "Change high water flow control parameter",
6488 (void *)&cmd_lfc_set_set,
6489 (void *)&cmd_lfc_set_flow_ctrl,
6490 (void *)&cmd_lfc_set_high_water_str,
6491 (void *)&cmd_lfc_set_high_water,
6492 (void *)&cmd_lfc_set_portid,
6497 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6498 .f = cmd_link_flow_ctrl_set_parsed,
6499 .data = (void *)&cmd_link_flow_control_set_lw,
6500 .help_str = "set flow_ctrl low_water <value> <port_id>: "
6501 "Change low water flow control parameter",
6503 (void *)&cmd_lfc_set_set,
6504 (void *)&cmd_lfc_set_flow_ctrl,
6505 (void *)&cmd_lfc_set_low_water_str,
6506 (void *)&cmd_lfc_set_low_water,
6507 (void *)&cmd_lfc_set_portid,
6512 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6513 .f = cmd_link_flow_ctrl_set_parsed,
6514 .data = (void *)&cmd_link_flow_control_set_pt,
6515 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6516 "Change pause time flow control parameter",
6518 (void *)&cmd_lfc_set_set,
6519 (void *)&cmd_lfc_set_flow_ctrl,
6520 (void *)&cmd_lfc_set_pause_time_str,
6521 (void *)&cmd_lfc_set_pause_time,
6522 (void *)&cmd_lfc_set_portid,
6527 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6528 .f = cmd_link_flow_ctrl_set_parsed,
6529 .data = (void *)&cmd_link_flow_control_set_xon,
6530 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6531 "Change send_xon flow control parameter",
6533 (void *)&cmd_lfc_set_set,
6534 (void *)&cmd_lfc_set_flow_ctrl,
6535 (void *)&cmd_lfc_set_send_xon_str,
6536 (void *)&cmd_lfc_set_send_xon,
6537 (void *)&cmd_lfc_set_portid,
6542 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6543 .f = cmd_link_flow_ctrl_set_parsed,
6544 .data = (void *)&cmd_link_flow_control_set_macfwd,
6545 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6546 "Change mac ctrl fwd flow control parameter",
6548 (void *)&cmd_lfc_set_set,
6549 (void *)&cmd_lfc_set_flow_ctrl,
6550 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6551 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6552 (void *)&cmd_lfc_set_portid,
6557 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6558 .f = cmd_link_flow_ctrl_set_parsed,
6559 .data = (void *)&cmd_link_flow_control_set_autoneg,
6560 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6561 "Change autoneg flow control parameter",
6563 (void *)&cmd_lfc_set_set,
6564 (void *)&cmd_lfc_set_flow_ctrl,
6565 (void *)&cmd_lfc_set_autoneg_str,
6566 (void *)&cmd_lfc_set_autoneg,
6567 (void *)&cmd_lfc_set_portid,
6573 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6574 __attribute__((unused)) struct cmdline *cl,
6577 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6578 cmdline_parse_inst_t *cmd = data;
6579 struct rte_eth_fc_conf fc_conf;
6585 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6586 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6587 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6588 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6590 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6591 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
6594 /* Partial command line, retrieve current configuration */
6596 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6598 printf("cannot get current flow ctrl parameters, return"
6599 "code = %d\n", ret);
6603 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
6604 (fc_conf.mode == RTE_FC_FULL))
6606 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
6607 (fc_conf.mode == RTE_FC_FULL))
6611 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6612 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6614 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6615 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6617 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6619 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6620 fc_conf.high_water = res->high_water;
6622 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6623 fc_conf.low_water = res->low_water;
6625 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6626 fc_conf.pause_time = res->pause_time;
6628 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6629 fc_conf.send_xon = res->send_xon;
6631 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6632 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6633 fc_conf.mac_ctrl_frame_fwd = 1;
6635 fc_conf.mac_ctrl_frame_fwd = 0;
6638 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6639 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6641 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6643 printf("bad flow contrl parameter, return code = %d \n", ret);
6646 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6647 struct cmd_priority_flow_ctrl_set_result {
6648 cmdline_fixed_string_t set;
6649 cmdline_fixed_string_t pfc_ctrl;
6650 cmdline_fixed_string_t rx;
6651 cmdline_fixed_string_t rx_pfc_mode;
6652 cmdline_fixed_string_t tx;
6653 cmdline_fixed_string_t tx_pfc_mode;
6654 uint32_t high_water;
6656 uint16_t pause_time;
6662 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6663 __attribute__((unused)) struct cmdline *cl,
6664 __attribute__((unused)) void *data)
6666 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
6667 struct rte_eth_pfc_conf pfc_conf;
6668 int rx_fc_enable, tx_fc_enable;
6672 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6673 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6674 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6675 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6677 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
6678 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
6681 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
6682 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
6683 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
6684 pfc_conf.fc.high_water = res->high_water;
6685 pfc_conf.fc.low_water = res->low_water;
6686 pfc_conf.fc.pause_time = res->pause_time;
6687 pfc_conf.priority = res->priority;
6689 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
6691 printf("bad priority flow contrl parameter, return code = %d \n", ret);
6694 cmdline_parse_token_string_t cmd_pfc_set_set =
6695 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6697 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
6698 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6699 pfc_ctrl, "pfc_ctrl");
6700 cmdline_parse_token_string_t cmd_pfc_set_rx =
6701 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6703 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
6704 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6705 rx_pfc_mode, "on#off");
6706 cmdline_parse_token_string_t cmd_pfc_set_tx =
6707 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6709 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
6710 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6711 tx_pfc_mode, "on#off");
6712 cmdline_parse_token_num_t cmd_pfc_set_high_water =
6713 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6714 high_water, UINT32);
6715 cmdline_parse_token_num_t cmd_pfc_set_low_water =
6716 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6718 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
6719 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6720 pause_time, UINT16);
6721 cmdline_parse_token_num_t cmd_pfc_set_priority =
6722 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6724 cmdline_parse_token_num_t cmd_pfc_set_portid =
6725 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6728 cmdline_parse_inst_t cmd_priority_flow_control_set = {
6729 .f = cmd_priority_flow_ctrl_set_parsed,
6731 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
6732 "<pause_time> <priority> <port_id>: "
6733 "Configure the Ethernet priority flow control",
6735 (void *)&cmd_pfc_set_set,
6736 (void *)&cmd_pfc_set_flow_ctrl,
6737 (void *)&cmd_pfc_set_rx,
6738 (void *)&cmd_pfc_set_rx_mode,
6739 (void *)&cmd_pfc_set_tx,
6740 (void *)&cmd_pfc_set_tx_mode,
6741 (void *)&cmd_pfc_set_high_water,
6742 (void *)&cmd_pfc_set_low_water,
6743 (void *)&cmd_pfc_set_pause_time,
6744 (void *)&cmd_pfc_set_priority,
6745 (void *)&cmd_pfc_set_portid,
6750 /* *** RESET CONFIGURATION *** */
6751 struct cmd_reset_result {
6752 cmdline_fixed_string_t reset;
6753 cmdline_fixed_string_t def;
6756 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
6758 __attribute__((unused)) void *data)
6760 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
6761 set_def_fwd_config();
6764 cmdline_parse_token_string_t cmd_reset_set =
6765 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
6766 cmdline_parse_token_string_t cmd_reset_def =
6767 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
6770 cmdline_parse_inst_t cmd_reset = {
6771 .f = cmd_reset_parsed,
6773 .help_str = "set default: Reset default forwarding configuration",
6775 (void *)&cmd_reset_set,
6776 (void *)&cmd_reset_def,
6781 /* *** START FORWARDING *** */
6782 struct cmd_start_result {
6783 cmdline_fixed_string_t start;
6786 cmdline_parse_token_string_t cmd_start_start =
6787 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
6789 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
6790 __attribute__((unused)) struct cmdline *cl,
6791 __attribute__((unused)) void *data)
6793 start_packet_forwarding(0);
6796 cmdline_parse_inst_t cmd_start = {
6797 .f = cmd_start_parsed,
6799 .help_str = "start: Start packet forwarding",
6801 (void *)&cmd_start_start,
6806 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
6807 struct cmd_start_tx_first_result {
6808 cmdline_fixed_string_t start;
6809 cmdline_fixed_string_t tx_first;
6813 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
6814 __attribute__((unused)) struct cmdline *cl,
6815 __attribute__((unused)) void *data)
6817 start_packet_forwarding(1);
6820 cmdline_parse_token_string_t cmd_start_tx_first_start =
6821 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
6823 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
6824 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
6825 tx_first, "tx_first");
6827 cmdline_parse_inst_t cmd_start_tx_first = {
6828 .f = cmd_start_tx_first_parsed,
6830 .help_str = "start tx_first: Start packet forwarding, "
6831 "after sending 1 burst of packets",
6833 (void *)&cmd_start_tx_first_start,
6834 (void *)&cmd_start_tx_first_tx_first,
6839 /* *** START FORWARDING WITH N TX BURST FIRST *** */
6840 struct cmd_start_tx_first_n_result {
6841 cmdline_fixed_string_t start;
6842 cmdline_fixed_string_t tx_first;
6847 cmd_start_tx_first_n_parsed(void *parsed_result,
6848 __attribute__((unused)) struct cmdline *cl,
6849 __attribute__((unused)) void *data)
6851 struct cmd_start_tx_first_n_result *res = parsed_result;
6853 start_packet_forwarding(res->tx_num);
6856 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
6857 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6859 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
6860 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6861 tx_first, "tx_first");
6862 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
6863 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
6866 cmdline_parse_inst_t cmd_start_tx_first_n = {
6867 .f = cmd_start_tx_first_n_parsed,
6869 .help_str = "start tx_first <num>: "
6870 "packet forwarding, after sending <num> bursts of packets",
6872 (void *)&cmd_start_tx_first_n_start,
6873 (void *)&cmd_start_tx_first_n_tx_first,
6874 (void *)&cmd_start_tx_first_n_tx_num,
6879 /* *** SET LINK UP *** */
6880 struct cmd_set_link_up_result {
6881 cmdline_fixed_string_t set;
6882 cmdline_fixed_string_t link_up;
6883 cmdline_fixed_string_t port;
6887 cmdline_parse_token_string_t cmd_set_link_up_set =
6888 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
6889 cmdline_parse_token_string_t cmd_set_link_up_link_up =
6890 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
6892 cmdline_parse_token_string_t cmd_set_link_up_port =
6893 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
6894 cmdline_parse_token_num_t cmd_set_link_up_port_id =
6895 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
6897 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
6898 __attribute__((unused)) struct cmdline *cl,
6899 __attribute__((unused)) void *data)
6901 struct cmd_set_link_up_result *res = parsed_result;
6902 dev_set_link_up(res->port_id);
6905 cmdline_parse_inst_t cmd_set_link_up = {
6906 .f = cmd_set_link_up_parsed,
6908 .help_str = "set link-up port <port id>",
6910 (void *)&cmd_set_link_up_set,
6911 (void *)&cmd_set_link_up_link_up,
6912 (void *)&cmd_set_link_up_port,
6913 (void *)&cmd_set_link_up_port_id,
6918 /* *** SET LINK DOWN *** */
6919 struct cmd_set_link_down_result {
6920 cmdline_fixed_string_t set;
6921 cmdline_fixed_string_t link_down;
6922 cmdline_fixed_string_t port;
6926 cmdline_parse_token_string_t cmd_set_link_down_set =
6927 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
6928 cmdline_parse_token_string_t cmd_set_link_down_link_down =
6929 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
6931 cmdline_parse_token_string_t cmd_set_link_down_port =
6932 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
6933 cmdline_parse_token_num_t cmd_set_link_down_port_id =
6934 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
6936 static void cmd_set_link_down_parsed(
6937 __attribute__((unused)) void *parsed_result,
6938 __attribute__((unused)) struct cmdline *cl,
6939 __attribute__((unused)) void *data)
6941 struct cmd_set_link_down_result *res = parsed_result;
6942 dev_set_link_down(res->port_id);
6945 cmdline_parse_inst_t cmd_set_link_down = {
6946 .f = cmd_set_link_down_parsed,
6948 .help_str = "set link-down port <port id>",
6950 (void *)&cmd_set_link_down_set,
6951 (void *)&cmd_set_link_down_link_down,
6952 (void *)&cmd_set_link_down_port,
6953 (void *)&cmd_set_link_down_port_id,
6958 /* *** SHOW CFG *** */
6959 struct cmd_showcfg_result {
6960 cmdline_fixed_string_t show;
6961 cmdline_fixed_string_t cfg;
6962 cmdline_fixed_string_t what;
6965 static void cmd_showcfg_parsed(void *parsed_result,
6966 __attribute__((unused)) struct cmdline *cl,
6967 __attribute__((unused)) void *data)
6969 struct cmd_showcfg_result *res = parsed_result;
6970 if (!strcmp(res->what, "rxtx"))
6971 rxtx_config_display();
6972 else if (!strcmp(res->what, "cores"))
6973 fwd_lcores_config_display();
6974 else if (!strcmp(res->what, "fwd"))
6975 pkt_fwd_config_display(&cur_fwd_config);
6976 else if (!strcmp(res->what, "txpkts"))
6977 show_tx_pkt_segments();
6980 cmdline_parse_token_string_t cmd_showcfg_show =
6981 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
6982 cmdline_parse_token_string_t cmd_showcfg_port =
6983 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
6984 cmdline_parse_token_string_t cmd_showcfg_what =
6985 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
6986 "rxtx#cores#fwd#txpkts");
6988 cmdline_parse_inst_t cmd_showcfg = {
6989 .f = cmd_showcfg_parsed,
6991 .help_str = "show config rxtx|cores|fwd|txpkts",
6993 (void *)&cmd_showcfg_show,
6994 (void *)&cmd_showcfg_port,
6995 (void *)&cmd_showcfg_what,
7000 /* *** SHOW ALL PORT INFO *** */
7001 struct cmd_showportall_result {
7002 cmdline_fixed_string_t show;
7003 cmdline_fixed_string_t port;
7004 cmdline_fixed_string_t what;
7005 cmdline_fixed_string_t all;
7008 static void cmd_showportall_parsed(void *parsed_result,
7009 __attribute__((unused)) struct cmdline *cl,
7010 __attribute__((unused)) void *data)
7014 struct cmd_showportall_result *res = parsed_result;
7015 if (!strcmp(res->show, "clear")) {
7016 if (!strcmp(res->what, "stats"))
7017 RTE_ETH_FOREACH_DEV(i)
7019 else if (!strcmp(res->what, "xstats"))
7020 RTE_ETH_FOREACH_DEV(i)
7021 nic_xstats_clear(i);
7022 } else if (!strcmp(res->what, "info"))
7023 RTE_ETH_FOREACH_DEV(i)
7024 port_infos_display(i);
7025 else if (!strcmp(res->what, "stats"))
7026 RTE_ETH_FOREACH_DEV(i)
7027 nic_stats_display(i);
7028 else if (!strcmp(res->what, "xstats"))
7029 RTE_ETH_FOREACH_DEV(i)
7030 nic_xstats_display(i);
7031 else if (!strcmp(res->what, "fdir"))
7032 RTE_ETH_FOREACH_DEV(i)
7034 else if (!strcmp(res->what, "stat_qmap"))
7035 RTE_ETH_FOREACH_DEV(i)
7036 nic_stats_mapping_display(i);
7037 else if (!strcmp(res->what, "dcb_tc"))
7038 RTE_ETH_FOREACH_DEV(i)
7039 port_dcb_info_display(i);
7040 else if (!strcmp(res->what, "cap"))
7041 RTE_ETH_FOREACH_DEV(i)
7042 port_offload_cap_display(i);
7045 cmdline_parse_token_string_t cmd_showportall_show =
7046 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7048 cmdline_parse_token_string_t cmd_showportall_port =
7049 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7050 cmdline_parse_token_string_t cmd_showportall_what =
7051 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7052 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7053 cmdline_parse_token_string_t cmd_showportall_all =
7054 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7055 cmdline_parse_inst_t cmd_showportall = {
7056 .f = cmd_showportall_parsed,
7058 .help_str = "show|clear port "
7059 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
7061 (void *)&cmd_showportall_show,
7062 (void *)&cmd_showportall_port,
7063 (void *)&cmd_showportall_what,
7064 (void *)&cmd_showportall_all,
7069 /* *** SHOW PORT INFO *** */
7070 struct cmd_showport_result {
7071 cmdline_fixed_string_t show;
7072 cmdline_fixed_string_t port;
7073 cmdline_fixed_string_t what;
7077 static void cmd_showport_parsed(void *parsed_result,
7078 __attribute__((unused)) struct cmdline *cl,
7079 __attribute__((unused)) void *data)
7081 struct cmd_showport_result *res = parsed_result;
7082 if (!strcmp(res->show, "clear")) {
7083 if (!strcmp(res->what, "stats"))
7084 nic_stats_clear(res->portnum);
7085 else if (!strcmp(res->what, "xstats"))
7086 nic_xstats_clear(res->portnum);
7087 } else if (!strcmp(res->what, "info"))
7088 port_infos_display(res->portnum);
7089 else if (!strcmp(res->what, "stats"))
7090 nic_stats_display(res->portnum);
7091 else if (!strcmp(res->what, "xstats"))
7092 nic_xstats_display(res->portnum);
7093 else if (!strcmp(res->what, "fdir"))
7094 fdir_get_infos(res->portnum);
7095 else if (!strcmp(res->what, "stat_qmap"))
7096 nic_stats_mapping_display(res->portnum);
7097 else if (!strcmp(res->what, "dcb_tc"))
7098 port_dcb_info_display(res->portnum);
7099 else if (!strcmp(res->what, "cap"))
7100 port_offload_cap_display(res->portnum);
7103 cmdline_parse_token_string_t cmd_showport_show =
7104 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7106 cmdline_parse_token_string_t cmd_showport_port =
7107 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7108 cmdline_parse_token_string_t cmd_showport_what =
7109 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7110 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7111 cmdline_parse_token_num_t cmd_showport_portnum =
7112 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
7114 cmdline_parse_inst_t cmd_showport = {
7115 .f = cmd_showport_parsed,
7117 .help_str = "show|clear port "
7118 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
7121 (void *)&cmd_showport_show,
7122 (void *)&cmd_showport_port,
7123 (void *)&cmd_showport_what,
7124 (void *)&cmd_showport_portnum,
7129 /* *** SHOW QUEUE INFO *** */
7130 struct cmd_showqueue_result {
7131 cmdline_fixed_string_t show;
7132 cmdline_fixed_string_t type;
7133 cmdline_fixed_string_t what;
7139 cmd_showqueue_parsed(void *parsed_result,
7140 __attribute__((unused)) struct cmdline *cl,
7141 __attribute__((unused)) void *data)
7143 struct cmd_showqueue_result *res = parsed_result;
7145 if (!strcmp(res->type, "rxq"))
7146 rx_queue_infos_display(res->portnum, res->queuenum);
7147 else if (!strcmp(res->type, "txq"))
7148 tx_queue_infos_display(res->portnum, res->queuenum);
7151 cmdline_parse_token_string_t cmd_showqueue_show =
7152 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7153 cmdline_parse_token_string_t cmd_showqueue_type =
7154 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7155 cmdline_parse_token_string_t cmd_showqueue_what =
7156 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7157 cmdline_parse_token_num_t cmd_showqueue_portnum =
7158 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
7159 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7160 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
7162 cmdline_parse_inst_t cmd_showqueue = {
7163 .f = cmd_showqueue_parsed,
7165 .help_str = "show rxq|txq info <port_id> <queue_id>",
7167 (void *)&cmd_showqueue_show,
7168 (void *)&cmd_showqueue_type,
7169 (void *)&cmd_showqueue_what,
7170 (void *)&cmd_showqueue_portnum,
7171 (void *)&cmd_showqueue_queuenum,
7176 /* *** READ PORT REGISTER *** */
7177 struct cmd_read_reg_result {
7178 cmdline_fixed_string_t read;
7179 cmdline_fixed_string_t reg;
7185 cmd_read_reg_parsed(void *parsed_result,
7186 __attribute__((unused)) struct cmdline *cl,
7187 __attribute__((unused)) void *data)
7189 struct cmd_read_reg_result *res = parsed_result;
7190 port_reg_display(res->port_id, res->reg_off);
7193 cmdline_parse_token_string_t cmd_read_reg_read =
7194 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7195 cmdline_parse_token_string_t cmd_read_reg_reg =
7196 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7197 cmdline_parse_token_num_t cmd_read_reg_port_id =
7198 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
7199 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7200 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
7202 cmdline_parse_inst_t cmd_read_reg = {
7203 .f = cmd_read_reg_parsed,
7205 .help_str = "read reg <port_id> <reg_off>",
7207 (void *)&cmd_read_reg_read,
7208 (void *)&cmd_read_reg_reg,
7209 (void *)&cmd_read_reg_port_id,
7210 (void *)&cmd_read_reg_reg_off,
7215 /* *** READ PORT REGISTER BIT FIELD *** */
7216 struct cmd_read_reg_bit_field_result {
7217 cmdline_fixed_string_t read;
7218 cmdline_fixed_string_t regfield;
7226 cmd_read_reg_bit_field_parsed(void *parsed_result,
7227 __attribute__((unused)) struct cmdline *cl,
7228 __attribute__((unused)) void *data)
7230 struct cmd_read_reg_bit_field_result *res = parsed_result;
7231 port_reg_bit_field_display(res->port_id, res->reg_off,
7232 res->bit1_pos, res->bit2_pos);
7235 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7236 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7238 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7239 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7240 regfield, "regfield");
7241 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7242 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7244 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7245 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7247 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7248 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7250 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7251 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7254 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7255 .f = cmd_read_reg_bit_field_parsed,
7257 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7258 "Read register bit field between bit_x and bit_y included",
7260 (void *)&cmd_read_reg_bit_field_read,
7261 (void *)&cmd_read_reg_bit_field_regfield,
7262 (void *)&cmd_read_reg_bit_field_port_id,
7263 (void *)&cmd_read_reg_bit_field_reg_off,
7264 (void *)&cmd_read_reg_bit_field_bit1_pos,
7265 (void *)&cmd_read_reg_bit_field_bit2_pos,
7270 /* *** READ PORT REGISTER BIT *** */
7271 struct cmd_read_reg_bit_result {
7272 cmdline_fixed_string_t read;
7273 cmdline_fixed_string_t regbit;
7280 cmd_read_reg_bit_parsed(void *parsed_result,
7281 __attribute__((unused)) struct cmdline *cl,
7282 __attribute__((unused)) void *data)
7284 struct cmd_read_reg_bit_result *res = parsed_result;
7285 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7288 cmdline_parse_token_string_t cmd_read_reg_bit_read =
7289 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
7290 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
7291 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
7293 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
7294 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
7295 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
7296 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
7297 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
7298 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
7300 cmdline_parse_inst_t cmd_read_reg_bit = {
7301 .f = cmd_read_reg_bit_parsed,
7303 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7305 (void *)&cmd_read_reg_bit_read,
7306 (void *)&cmd_read_reg_bit_regbit,
7307 (void *)&cmd_read_reg_bit_port_id,
7308 (void *)&cmd_read_reg_bit_reg_off,
7309 (void *)&cmd_read_reg_bit_bit_pos,
7314 /* *** WRITE PORT REGISTER *** */
7315 struct cmd_write_reg_result {
7316 cmdline_fixed_string_t write;
7317 cmdline_fixed_string_t reg;
7324 cmd_write_reg_parsed(void *parsed_result,
7325 __attribute__((unused)) struct cmdline *cl,
7326 __attribute__((unused)) void *data)
7328 struct cmd_write_reg_result *res = parsed_result;
7329 port_reg_set(res->port_id, res->reg_off, res->value);
7332 cmdline_parse_token_string_t cmd_write_reg_write =
7333 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
7334 cmdline_parse_token_string_t cmd_write_reg_reg =
7335 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
7336 cmdline_parse_token_num_t cmd_write_reg_port_id =
7337 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
7338 cmdline_parse_token_num_t cmd_write_reg_reg_off =
7339 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
7340 cmdline_parse_token_num_t cmd_write_reg_value =
7341 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
7343 cmdline_parse_inst_t cmd_write_reg = {
7344 .f = cmd_write_reg_parsed,
7346 .help_str = "write reg <port_id> <reg_off> <reg_value>",
7348 (void *)&cmd_write_reg_write,
7349 (void *)&cmd_write_reg_reg,
7350 (void *)&cmd_write_reg_port_id,
7351 (void *)&cmd_write_reg_reg_off,
7352 (void *)&cmd_write_reg_value,
7357 /* *** WRITE PORT REGISTER BIT FIELD *** */
7358 struct cmd_write_reg_bit_field_result {
7359 cmdline_fixed_string_t write;
7360 cmdline_fixed_string_t regfield;
7369 cmd_write_reg_bit_field_parsed(void *parsed_result,
7370 __attribute__((unused)) struct cmdline *cl,
7371 __attribute__((unused)) void *data)
7373 struct cmd_write_reg_bit_field_result *res = parsed_result;
7374 port_reg_bit_field_set(res->port_id, res->reg_off,
7375 res->bit1_pos, res->bit2_pos, res->value);
7378 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
7379 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
7381 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
7382 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
7383 regfield, "regfield");
7384 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
7385 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
7387 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
7388 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
7390 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
7391 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
7393 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
7394 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
7396 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
7397 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
7400 cmdline_parse_inst_t cmd_write_reg_bit_field = {
7401 .f = cmd_write_reg_bit_field_parsed,
7403 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
7405 "Set register bit field between bit_x and bit_y included",
7407 (void *)&cmd_write_reg_bit_field_write,
7408 (void *)&cmd_write_reg_bit_field_regfield,
7409 (void *)&cmd_write_reg_bit_field_port_id,
7410 (void *)&cmd_write_reg_bit_field_reg_off,
7411 (void *)&cmd_write_reg_bit_field_bit1_pos,
7412 (void *)&cmd_write_reg_bit_field_bit2_pos,
7413 (void *)&cmd_write_reg_bit_field_value,
7418 /* *** WRITE PORT REGISTER BIT *** */
7419 struct cmd_write_reg_bit_result {
7420 cmdline_fixed_string_t write;
7421 cmdline_fixed_string_t regbit;
7429 cmd_write_reg_bit_parsed(void *parsed_result,
7430 __attribute__((unused)) struct cmdline *cl,
7431 __attribute__((unused)) void *data)
7433 struct cmd_write_reg_bit_result *res = parsed_result;
7434 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
7437 cmdline_parse_token_string_t cmd_write_reg_bit_write =
7438 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
7440 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
7441 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
7443 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
7444 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
7445 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
7446 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
7447 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
7448 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
7449 cmdline_parse_token_num_t cmd_write_reg_bit_value =
7450 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
7452 cmdline_parse_inst_t cmd_write_reg_bit = {
7453 .f = cmd_write_reg_bit_parsed,
7455 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
7458 (void *)&cmd_write_reg_bit_write,
7459 (void *)&cmd_write_reg_bit_regbit,
7460 (void *)&cmd_write_reg_bit_port_id,
7461 (void *)&cmd_write_reg_bit_reg_off,
7462 (void *)&cmd_write_reg_bit_bit_pos,
7463 (void *)&cmd_write_reg_bit_value,
7468 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7469 struct cmd_read_rxd_txd_result {
7470 cmdline_fixed_string_t read;
7471 cmdline_fixed_string_t rxd_txd;
7478 cmd_read_rxd_txd_parsed(void *parsed_result,
7479 __attribute__((unused)) struct cmdline *cl,
7480 __attribute__((unused)) void *data)
7482 struct cmd_read_rxd_txd_result *res = parsed_result;
7484 if (!strcmp(res->rxd_txd, "rxd"))
7485 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7486 else if (!strcmp(res->rxd_txd, "txd"))
7487 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7490 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
7491 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
7492 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
7493 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
7495 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
7496 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
7497 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
7498 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
7499 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
7500 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
7502 cmdline_parse_inst_t cmd_read_rxd_txd = {
7503 .f = cmd_read_rxd_txd_parsed,
7505 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
7507 (void *)&cmd_read_rxd_txd_read,
7508 (void *)&cmd_read_rxd_txd_rxd_txd,
7509 (void *)&cmd_read_rxd_txd_port_id,
7510 (void *)&cmd_read_rxd_txd_queue_id,
7511 (void *)&cmd_read_rxd_txd_desc_id,
7517 struct cmd_quit_result {
7518 cmdline_fixed_string_t quit;
7521 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
7523 __attribute__((unused)) void *data)
7529 cmdline_parse_token_string_t cmd_quit_quit =
7530 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
7532 cmdline_parse_inst_t cmd_quit = {
7533 .f = cmd_quit_parsed,
7535 .help_str = "quit: Exit application",
7537 (void *)&cmd_quit_quit,
7542 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
7543 struct cmd_mac_addr_result {
7544 cmdline_fixed_string_t mac_addr_cmd;
7545 cmdline_fixed_string_t what;
7547 struct ether_addr address;
7550 static void cmd_mac_addr_parsed(void *parsed_result,
7551 __attribute__((unused)) struct cmdline *cl,
7552 __attribute__((unused)) void *data)
7554 struct cmd_mac_addr_result *res = parsed_result;
7557 if (strcmp(res->what, "add") == 0)
7558 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
7559 else if (strcmp(res->what, "set") == 0)
7560 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
7563 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
7565 /* check the return value and print it if is < 0 */
7567 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
7571 cmdline_parse_token_string_t cmd_mac_addr_cmd =
7572 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
7574 cmdline_parse_token_string_t cmd_mac_addr_what =
7575 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
7577 cmdline_parse_token_num_t cmd_mac_addr_portnum =
7578 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
7580 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
7581 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
7583 cmdline_parse_inst_t cmd_mac_addr = {
7584 .f = cmd_mac_addr_parsed,
7586 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
7587 "Add/Remove/Set MAC address on port_id",
7589 (void *)&cmd_mac_addr_cmd,
7590 (void *)&cmd_mac_addr_what,
7591 (void *)&cmd_mac_addr_portnum,
7592 (void *)&cmd_mac_addr_addr,
7597 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
7598 struct cmd_eth_peer_result {
7599 cmdline_fixed_string_t set;
7600 cmdline_fixed_string_t eth_peer;
7602 cmdline_fixed_string_t peer_addr;
7605 static void cmd_set_eth_peer_parsed(void *parsed_result,
7606 __attribute__((unused)) struct cmdline *cl,
7607 __attribute__((unused)) void *data)
7609 struct cmd_eth_peer_result *res = parsed_result;
7611 if (test_done == 0) {
7612 printf("Please stop forwarding first\n");
7615 if (!strcmp(res->eth_peer, "eth-peer")) {
7616 set_fwd_eth_peer(res->port_id, res->peer_addr);
7620 cmdline_parse_token_string_t cmd_eth_peer_set =
7621 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
7622 cmdline_parse_token_string_t cmd_eth_peer =
7623 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
7624 cmdline_parse_token_num_t cmd_eth_peer_port_id =
7625 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
7626 cmdline_parse_token_string_t cmd_eth_peer_addr =
7627 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
7629 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
7630 .f = cmd_set_eth_peer_parsed,
7632 .help_str = "set eth-peer <port_id> <peer_mac>",
7634 (void *)&cmd_eth_peer_set,
7635 (void *)&cmd_eth_peer,
7636 (void *)&cmd_eth_peer_port_id,
7637 (void *)&cmd_eth_peer_addr,
7642 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
7643 struct cmd_set_qmap_result {
7644 cmdline_fixed_string_t set;
7645 cmdline_fixed_string_t qmap;
7646 cmdline_fixed_string_t what;
7653 cmd_set_qmap_parsed(void *parsed_result,
7654 __attribute__((unused)) struct cmdline *cl,
7655 __attribute__((unused)) void *data)
7657 struct cmd_set_qmap_result *res = parsed_result;
7658 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
7660 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
7663 cmdline_parse_token_string_t cmd_setqmap_set =
7664 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7666 cmdline_parse_token_string_t cmd_setqmap_qmap =
7667 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7669 cmdline_parse_token_string_t cmd_setqmap_what =
7670 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7672 cmdline_parse_token_num_t cmd_setqmap_portid =
7673 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7675 cmdline_parse_token_num_t cmd_setqmap_queueid =
7676 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7678 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
7679 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7682 cmdline_parse_inst_t cmd_set_qmap = {
7683 .f = cmd_set_qmap_parsed,
7685 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
7686 "Set statistics mapping value on tx|rx queue_id of port_id",
7688 (void *)&cmd_setqmap_set,
7689 (void *)&cmd_setqmap_qmap,
7690 (void *)&cmd_setqmap_what,
7691 (void *)&cmd_setqmap_portid,
7692 (void *)&cmd_setqmap_queueid,
7693 (void *)&cmd_setqmap_mapvalue,
7698 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
7699 struct cmd_set_xstats_hide_zero_result {
7700 cmdline_fixed_string_t keyword;
7701 cmdline_fixed_string_t name;
7702 cmdline_fixed_string_t on_off;
7706 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
7707 __attribute__((unused)) struct cmdline *cl,
7708 __attribute__((unused)) void *data)
7710 struct cmd_set_xstats_hide_zero_result *res;
7711 uint16_t on_off = 0;
7713 res = parsed_result;
7714 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
7715 set_xstats_hide_zero(on_off);
7718 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
7719 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7721 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
7722 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7723 name, "xstats-hide-zero");
7724 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
7725 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7728 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
7729 .f = cmd_set_xstats_hide_zero_parsed,
7731 .help_str = "set xstats-hide-zero on|off",
7733 (void *)&cmd_set_xstats_hide_zero_keyword,
7734 (void *)&cmd_set_xstats_hide_zero_name,
7735 (void *)&cmd_set_xstats_hide_zero_on_off,
7740 /* *** CONFIGURE UNICAST HASH TABLE *** */
7741 struct cmd_set_uc_hash_table {
7742 cmdline_fixed_string_t set;
7743 cmdline_fixed_string_t port;
7745 cmdline_fixed_string_t what;
7746 struct ether_addr address;
7747 cmdline_fixed_string_t mode;
7751 cmd_set_uc_hash_parsed(void *parsed_result,
7752 __attribute__((unused)) struct cmdline *cl,
7753 __attribute__((unused)) void *data)
7756 struct cmd_set_uc_hash_table *res = parsed_result;
7758 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7760 if (strcmp(res->what, "uta") == 0)
7761 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
7762 &res->address,(uint8_t)is_on);
7764 printf("bad unicast hash table parameter, return code = %d \n", ret);
7768 cmdline_parse_token_string_t cmd_set_uc_hash_set =
7769 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7771 cmdline_parse_token_string_t cmd_set_uc_hash_port =
7772 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7774 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
7775 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
7777 cmdline_parse_token_string_t cmd_set_uc_hash_what =
7778 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7780 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
7781 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
7783 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
7784 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7787 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
7788 .f = cmd_set_uc_hash_parsed,
7790 .help_str = "set port <port_id> uta <mac_addr> on|off)",
7792 (void *)&cmd_set_uc_hash_set,
7793 (void *)&cmd_set_uc_hash_port,
7794 (void *)&cmd_set_uc_hash_portid,
7795 (void *)&cmd_set_uc_hash_what,
7796 (void *)&cmd_set_uc_hash_mac,
7797 (void *)&cmd_set_uc_hash_mode,
7802 struct cmd_set_uc_all_hash_table {
7803 cmdline_fixed_string_t set;
7804 cmdline_fixed_string_t port;
7806 cmdline_fixed_string_t what;
7807 cmdline_fixed_string_t value;
7808 cmdline_fixed_string_t mode;
7812 cmd_set_uc_all_hash_parsed(void *parsed_result,
7813 __attribute__((unused)) struct cmdline *cl,
7814 __attribute__((unused)) void *data)
7817 struct cmd_set_uc_all_hash_table *res = parsed_result;
7819 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7821 if ((strcmp(res->what, "uta") == 0) &&
7822 (strcmp(res->value, "all") == 0))
7823 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
7825 printf("bad unicast hash table parameter,"
7826 "return code = %d \n", ret);
7829 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
7830 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7832 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
7833 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7835 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
7836 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
7838 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
7839 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7841 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
7842 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7844 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
7845 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7848 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
7849 .f = cmd_set_uc_all_hash_parsed,
7851 .help_str = "set port <port_id> uta all on|off",
7853 (void *)&cmd_set_uc_all_hash_set,
7854 (void *)&cmd_set_uc_all_hash_port,
7855 (void *)&cmd_set_uc_all_hash_portid,
7856 (void *)&cmd_set_uc_all_hash_what,
7857 (void *)&cmd_set_uc_all_hash_value,
7858 (void *)&cmd_set_uc_all_hash_mode,
7863 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
7864 struct cmd_set_vf_macvlan_filter {
7865 cmdline_fixed_string_t set;
7866 cmdline_fixed_string_t port;
7868 cmdline_fixed_string_t vf;
7870 struct ether_addr address;
7871 cmdline_fixed_string_t filter_type;
7872 cmdline_fixed_string_t mode;
7876 cmd_set_vf_macvlan_parsed(void *parsed_result,
7877 __attribute__((unused)) struct cmdline *cl,
7878 __attribute__((unused)) void *data)
7881 struct cmd_set_vf_macvlan_filter *res = parsed_result;
7882 struct rte_eth_mac_filter filter;
7884 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
7886 rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
7888 /* set VF MAC filter */
7892 filter.dst_id = res->vf_id;
7894 if (!strcmp(res->filter_type, "exact-mac"))
7895 filter.filter_type = RTE_MAC_PERFECT_MATCH;
7896 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
7897 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
7898 else if (!strcmp(res->filter_type, "hashmac"))
7899 filter.filter_type = RTE_MAC_HASH_MATCH;
7900 else if (!strcmp(res->filter_type, "hashmac-vlan"))
7901 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
7903 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7906 ret = rte_eth_dev_filter_ctrl(res->port_id,
7907 RTE_ETH_FILTER_MACVLAN,
7911 ret = rte_eth_dev_filter_ctrl(res->port_id,
7912 RTE_ETH_FILTER_MACVLAN,
7913 RTE_ETH_FILTER_DELETE,
7917 printf("bad set MAC hash parameter, return code = %d\n", ret);
7921 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
7922 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7924 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
7925 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7927 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
7928 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7930 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
7931 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7933 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
7934 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7936 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
7937 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7939 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
7940 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7941 filter_type, "exact-mac#exact-mac-vlan"
7942 "#hashmac#hashmac-vlan");
7943 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
7944 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7947 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
7948 .f = cmd_set_vf_macvlan_parsed,
7950 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
7951 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
7952 "Exact match rule: exact match of MAC or MAC and VLAN; "
7953 "hash match rule: hash match of MAC and exact match of VLAN",
7955 (void *)&cmd_set_vf_macvlan_set,
7956 (void *)&cmd_set_vf_macvlan_port,
7957 (void *)&cmd_set_vf_macvlan_portid,
7958 (void *)&cmd_set_vf_macvlan_vf,
7959 (void *)&cmd_set_vf_macvlan_vf_id,
7960 (void *)&cmd_set_vf_macvlan_mac,
7961 (void *)&cmd_set_vf_macvlan_filter_type,
7962 (void *)&cmd_set_vf_macvlan_mode,
7967 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
7968 struct cmd_set_vf_traffic {
7969 cmdline_fixed_string_t set;
7970 cmdline_fixed_string_t port;
7972 cmdline_fixed_string_t vf;
7974 cmdline_fixed_string_t what;
7975 cmdline_fixed_string_t mode;
7979 cmd_set_vf_traffic_parsed(void *parsed_result,
7980 __attribute__((unused)) struct cmdline *cl,
7981 __attribute__((unused)) void *data)
7983 struct cmd_set_vf_traffic *res = parsed_result;
7984 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
7985 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7987 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
7990 cmdline_parse_token_string_t cmd_setvf_traffic_set =
7991 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7993 cmdline_parse_token_string_t cmd_setvf_traffic_port =
7994 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7996 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
7997 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7999 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8000 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8002 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8003 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8005 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8006 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8008 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8009 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8012 cmdline_parse_inst_t cmd_set_vf_traffic = {
8013 .f = cmd_set_vf_traffic_parsed,
8015 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8017 (void *)&cmd_setvf_traffic_set,
8018 (void *)&cmd_setvf_traffic_port,
8019 (void *)&cmd_setvf_traffic_portid,
8020 (void *)&cmd_setvf_traffic_vf,
8021 (void *)&cmd_setvf_traffic_vfid,
8022 (void *)&cmd_setvf_traffic_what,
8023 (void *)&cmd_setvf_traffic_mode,
8028 /* *** CONFIGURE VF RECEIVE MODE *** */
8029 struct cmd_set_vf_rxmode {
8030 cmdline_fixed_string_t set;
8031 cmdline_fixed_string_t port;
8033 cmdline_fixed_string_t vf;
8035 cmdline_fixed_string_t what;
8036 cmdline_fixed_string_t mode;
8037 cmdline_fixed_string_t on;
8041 cmd_set_vf_rxmode_parsed(void *parsed_result,
8042 __attribute__((unused)) struct cmdline *cl,
8043 __attribute__((unused)) void *data)
8046 uint16_t rx_mode = 0;
8047 struct cmd_set_vf_rxmode *res = parsed_result;
8049 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8050 if (!strcmp(res->what,"rxmode")) {
8051 if (!strcmp(res->mode, "AUPE"))
8052 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
8053 else if (!strcmp(res->mode, "ROPE"))
8054 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
8055 else if (!strcmp(res->mode, "BAM"))
8056 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
8057 else if (!strncmp(res->mode, "MPE",3))
8058 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
8061 RTE_SET_USED(is_on);
8063 #ifdef RTE_LIBRTE_IXGBE_PMD
8064 if (ret == -ENOTSUP)
8065 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8066 rx_mode, (uint8_t)is_on);
8068 #ifdef RTE_LIBRTE_BNXT_PMD
8069 if (ret == -ENOTSUP)
8070 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8071 rx_mode, (uint8_t)is_on);
8074 printf("bad VF receive mode parameter, return code = %d \n",
8078 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8079 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8081 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8082 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8084 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8085 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8087 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8088 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8090 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8091 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8093 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8094 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8096 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8097 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8098 mode, "AUPE#ROPE#BAM#MPE");
8099 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8100 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8103 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8104 .f = cmd_set_vf_rxmode_parsed,
8106 .help_str = "set port <port_id> vf <vf_id> rxmode "
8107 "AUPE|ROPE|BAM|MPE on|off",
8109 (void *)&cmd_set_vf_rxmode_set,
8110 (void *)&cmd_set_vf_rxmode_port,
8111 (void *)&cmd_set_vf_rxmode_portid,
8112 (void *)&cmd_set_vf_rxmode_vf,
8113 (void *)&cmd_set_vf_rxmode_vfid,
8114 (void *)&cmd_set_vf_rxmode_what,
8115 (void *)&cmd_set_vf_rxmode_mode,
8116 (void *)&cmd_set_vf_rxmode_on,
8121 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8122 struct cmd_vf_mac_addr_result {
8123 cmdline_fixed_string_t mac_addr_cmd;
8124 cmdline_fixed_string_t what;
8125 cmdline_fixed_string_t port;
8127 cmdline_fixed_string_t vf;
8129 struct ether_addr address;
8132 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8133 __attribute__((unused)) struct cmdline *cl,
8134 __attribute__((unused)) void *data)
8136 struct cmd_vf_mac_addr_result *res = parsed_result;
8139 if (strcmp(res->what, "add") != 0)
8142 #ifdef RTE_LIBRTE_I40E_PMD
8143 if (ret == -ENOTSUP)
8144 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8147 #ifdef RTE_LIBRTE_BNXT_PMD
8148 if (ret == -ENOTSUP)
8149 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8154 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8158 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8159 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8160 mac_addr_cmd,"mac_addr");
8161 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8162 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8164 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8165 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8167 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8168 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8170 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8171 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8173 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8174 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8176 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8177 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8180 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8181 .f = cmd_vf_mac_addr_parsed,
8183 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8184 "Add MAC address filtering for a VF on port_id",
8186 (void *)&cmd_vf_mac_addr_cmd,
8187 (void *)&cmd_vf_mac_addr_what,
8188 (void *)&cmd_vf_mac_addr_port,
8189 (void *)&cmd_vf_mac_addr_portnum,
8190 (void *)&cmd_vf_mac_addr_vf,
8191 (void *)&cmd_vf_mac_addr_vfnum,
8192 (void *)&cmd_vf_mac_addr_addr,
8197 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8198 struct cmd_vf_rx_vlan_filter {
8199 cmdline_fixed_string_t rx_vlan;
8200 cmdline_fixed_string_t what;
8202 cmdline_fixed_string_t port;
8204 cmdline_fixed_string_t vf;
8209 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8210 __attribute__((unused)) struct cmdline *cl,
8211 __attribute__((unused)) void *data)
8213 struct cmd_vf_rx_vlan_filter *res = parsed_result;
8216 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8218 #ifdef RTE_LIBRTE_IXGBE_PMD
8219 if (ret == -ENOTSUP)
8220 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8221 res->vlan_id, res->vf_mask, is_add);
8223 #ifdef RTE_LIBRTE_I40E_PMD
8224 if (ret == -ENOTSUP)
8225 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8226 res->vlan_id, res->vf_mask, is_add);
8228 #ifdef RTE_LIBRTE_BNXT_PMD
8229 if (ret == -ENOTSUP)
8230 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8231 res->vlan_id, res->vf_mask, is_add);
8238 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8239 res->vlan_id, res->vf_mask);
8242 printf("invalid port_id %d\n", res->port_id);
8245 printf("function not implemented or supported\n");
8248 printf("programming error: (%s)\n", strerror(-ret));
8252 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8253 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8254 rx_vlan, "rx_vlan");
8255 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8256 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8258 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8259 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8261 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8262 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8264 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8265 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8267 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8268 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8270 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8271 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8274 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8275 .f = cmd_vf_rx_vlan_filter_parsed,
8277 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8278 "(vf_mask = hexadecimal VF mask)",
8280 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8281 (void *)&cmd_vf_rx_vlan_filter_what,
8282 (void *)&cmd_vf_rx_vlan_filter_vlanid,
8283 (void *)&cmd_vf_rx_vlan_filter_port,
8284 (void *)&cmd_vf_rx_vlan_filter_portid,
8285 (void *)&cmd_vf_rx_vlan_filter_vf,
8286 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8291 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8292 struct cmd_queue_rate_limit_result {
8293 cmdline_fixed_string_t set;
8294 cmdline_fixed_string_t port;
8296 cmdline_fixed_string_t queue;
8298 cmdline_fixed_string_t rate;
8302 static void cmd_queue_rate_limit_parsed(void *parsed_result,
8303 __attribute__((unused)) struct cmdline *cl,
8304 __attribute__((unused)) void *data)
8306 struct cmd_queue_rate_limit_result *res = parsed_result;
8309 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8310 && (strcmp(res->queue, "queue") == 0)
8311 && (strcmp(res->rate, "rate") == 0))
8312 ret = set_queue_rate_limit(res->port_num, res->queue_num,
8315 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
8319 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8320 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8322 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8323 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8325 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8326 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8328 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8329 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8331 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8332 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8334 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8335 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8337 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8338 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8341 cmdline_parse_inst_t cmd_queue_rate_limit = {
8342 .f = cmd_queue_rate_limit_parsed,
8344 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8345 "Set rate limit for a queue on port_id",
8347 (void *)&cmd_queue_rate_limit_set,
8348 (void *)&cmd_queue_rate_limit_port,
8349 (void *)&cmd_queue_rate_limit_portnum,
8350 (void *)&cmd_queue_rate_limit_queue,
8351 (void *)&cmd_queue_rate_limit_queuenum,
8352 (void *)&cmd_queue_rate_limit_rate,
8353 (void *)&cmd_queue_rate_limit_ratenum,
8358 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
8359 struct cmd_vf_rate_limit_result {
8360 cmdline_fixed_string_t set;
8361 cmdline_fixed_string_t port;
8363 cmdline_fixed_string_t vf;
8365 cmdline_fixed_string_t rate;
8367 cmdline_fixed_string_t q_msk;
8371 static void cmd_vf_rate_limit_parsed(void *parsed_result,
8372 __attribute__((unused)) struct cmdline *cl,
8373 __attribute__((unused)) void *data)
8375 struct cmd_vf_rate_limit_result *res = parsed_result;
8378 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8379 && (strcmp(res->vf, "vf") == 0)
8380 && (strcmp(res->rate, "rate") == 0)
8381 && (strcmp(res->q_msk, "queue_mask") == 0))
8382 ret = set_vf_rate_limit(res->port_num, res->vf_num,
8383 res->rate_num, res->q_msk_val);
8385 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
8389 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
8390 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8392 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
8393 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8395 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
8396 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8398 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
8399 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8401 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
8402 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8404 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
8405 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8407 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
8408 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8410 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
8411 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8412 q_msk, "queue_mask");
8413 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
8414 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8417 cmdline_parse_inst_t cmd_vf_rate_limit = {
8418 .f = cmd_vf_rate_limit_parsed,
8420 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
8421 "queue_mask <queue_mask_value>: "
8422 "Set rate limit for queues of VF on port_id",
8424 (void *)&cmd_vf_rate_limit_set,
8425 (void *)&cmd_vf_rate_limit_port,
8426 (void *)&cmd_vf_rate_limit_portnum,
8427 (void *)&cmd_vf_rate_limit_vf,
8428 (void *)&cmd_vf_rate_limit_vfnum,
8429 (void *)&cmd_vf_rate_limit_rate,
8430 (void *)&cmd_vf_rate_limit_ratenum,
8431 (void *)&cmd_vf_rate_limit_q_msk,
8432 (void *)&cmd_vf_rate_limit_q_msk_val,
8437 /* *** ADD TUNNEL FILTER OF A PORT *** */
8438 struct cmd_tunnel_filter_result {
8439 cmdline_fixed_string_t cmd;
8440 cmdline_fixed_string_t what;
8442 struct ether_addr outer_mac;
8443 struct ether_addr inner_mac;
8444 cmdline_ipaddr_t ip_value;
8445 uint16_t inner_vlan;
8446 cmdline_fixed_string_t tunnel_type;
8447 cmdline_fixed_string_t filter_type;
8453 cmd_tunnel_filter_parsed(void *parsed_result,
8454 __attribute__((unused)) struct cmdline *cl,
8455 __attribute__((unused)) void *data)
8457 struct cmd_tunnel_filter_result *res = parsed_result;
8458 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
8461 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
8463 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
8464 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
8465 tunnel_filter_conf.inner_vlan = res->inner_vlan;
8467 if (res->ip_value.family == AF_INET) {
8468 tunnel_filter_conf.ip_addr.ipv4_addr =
8469 res->ip_value.addr.ipv4.s_addr;
8470 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
8472 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
8473 &(res->ip_value.addr.ipv6),
8474 sizeof(struct in6_addr));
8475 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
8478 if (!strcmp(res->filter_type, "imac-ivlan"))
8479 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
8480 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
8481 tunnel_filter_conf.filter_type =
8482 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
8483 else if (!strcmp(res->filter_type, "imac-tenid"))
8484 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
8485 else if (!strcmp(res->filter_type, "imac"))
8486 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
8487 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
8488 tunnel_filter_conf.filter_type =
8489 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
8490 else if (!strcmp(res->filter_type, "oip"))
8491 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
8492 else if (!strcmp(res->filter_type, "iip"))
8493 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
8495 printf("The filter type is not supported");
8499 if (!strcmp(res->tunnel_type, "vxlan"))
8500 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
8501 else if (!strcmp(res->tunnel_type, "nvgre"))
8502 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
8503 else if (!strcmp(res->tunnel_type, "ipingre"))
8504 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
8506 printf("The tunnel type %s not supported.\n", res->tunnel_type);
8510 tunnel_filter_conf.tenant_id = res->tenant_id;
8511 tunnel_filter_conf.queue_id = res->queue_num;
8512 if (!strcmp(res->what, "add"))
8513 ret = rte_eth_dev_filter_ctrl(res->port_id,
8514 RTE_ETH_FILTER_TUNNEL,
8516 &tunnel_filter_conf);
8518 ret = rte_eth_dev_filter_ctrl(res->port_id,
8519 RTE_ETH_FILTER_TUNNEL,
8520 RTE_ETH_FILTER_DELETE,
8521 &tunnel_filter_conf);
8523 printf("cmd_tunnel_filter_parsed error: (%s)\n",
8527 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
8528 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8529 cmd, "tunnel_filter");
8530 cmdline_parse_token_string_t cmd_tunnel_filter_what =
8531 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8533 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
8534 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8536 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
8537 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8539 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
8540 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8542 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
8543 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8544 inner_vlan, UINT16);
8545 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
8546 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8548 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
8549 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8550 tunnel_type, "vxlan#nvgre#ipingre");
8552 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
8553 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8554 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
8555 "imac#omac-imac-tenid");
8556 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
8557 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8559 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
8560 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8563 cmdline_parse_inst_t cmd_tunnel_filter = {
8564 .f = cmd_tunnel_filter_parsed,
8566 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
8567 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
8568 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
8569 "<queue_id>: Add/Rm tunnel filter of a port",
8571 (void *)&cmd_tunnel_filter_cmd,
8572 (void *)&cmd_tunnel_filter_what,
8573 (void *)&cmd_tunnel_filter_port_id,
8574 (void *)&cmd_tunnel_filter_outer_mac,
8575 (void *)&cmd_tunnel_filter_inner_mac,
8576 (void *)&cmd_tunnel_filter_ip_value,
8577 (void *)&cmd_tunnel_filter_innner_vlan,
8578 (void *)&cmd_tunnel_filter_tunnel_type,
8579 (void *)&cmd_tunnel_filter_filter_type,
8580 (void *)&cmd_tunnel_filter_tenant_id,
8581 (void *)&cmd_tunnel_filter_queue_num,
8586 /* *** CONFIGURE TUNNEL UDP PORT *** */
8587 struct cmd_tunnel_udp_config {
8588 cmdline_fixed_string_t cmd;
8589 cmdline_fixed_string_t what;
8595 cmd_tunnel_udp_config_parsed(void *parsed_result,
8596 __attribute__((unused)) struct cmdline *cl,
8597 __attribute__((unused)) void *data)
8599 struct cmd_tunnel_udp_config *res = parsed_result;
8600 struct rte_eth_udp_tunnel tunnel_udp;
8603 tunnel_udp.udp_port = res->udp_port;
8605 if (!strcmp(res->cmd, "rx_vxlan_port"))
8606 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8608 if (!strcmp(res->what, "add"))
8609 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8612 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8616 printf("udp tunneling add error: (%s)\n", strerror(-ret));
8619 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
8620 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8621 cmd, "rx_vxlan_port");
8622 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
8623 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8625 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
8626 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8628 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
8629 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8632 cmdline_parse_inst_t cmd_tunnel_udp_config = {
8633 .f = cmd_tunnel_udp_config_parsed,
8635 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
8636 "Add/Remove a tunneling UDP port filter",
8638 (void *)&cmd_tunnel_udp_config_cmd,
8639 (void *)&cmd_tunnel_udp_config_what,
8640 (void *)&cmd_tunnel_udp_config_udp_port,
8641 (void *)&cmd_tunnel_udp_config_port_id,
8646 /* *** GLOBAL CONFIG *** */
8647 struct cmd_global_config_result {
8648 cmdline_fixed_string_t cmd;
8650 cmdline_fixed_string_t cfg_type;
8655 cmd_global_config_parsed(void *parsed_result,
8656 __attribute__((unused)) struct cmdline *cl,
8657 __attribute__((unused)) void *data)
8659 struct cmd_global_config_result *res = parsed_result;
8660 struct rte_eth_global_cfg conf;
8663 memset(&conf, 0, sizeof(conf));
8664 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
8665 conf.cfg.gre_key_len = res->len;
8666 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
8667 RTE_ETH_FILTER_SET, &conf);
8669 printf("Global config error\n");
8672 cmdline_parse_token_string_t cmd_global_config_cmd =
8673 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
8675 cmdline_parse_token_num_t cmd_global_config_port_id =
8676 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
8678 cmdline_parse_token_string_t cmd_global_config_type =
8679 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
8680 cfg_type, "gre-key-len");
8681 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
8682 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
8685 cmdline_parse_inst_t cmd_global_config = {
8686 .f = cmd_global_config_parsed,
8687 .data = (void *)NULL,
8688 .help_str = "global_config <port_id> gre-key-len <key_len>",
8690 (void *)&cmd_global_config_cmd,
8691 (void *)&cmd_global_config_port_id,
8692 (void *)&cmd_global_config_type,
8693 (void *)&cmd_global_config_gre_key_len,
8698 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
8699 struct cmd_set_mirror_mask_result {
8700 cmdline_fixed_string_t set;
8701 cmdline_fixed_string_t port;
8703 cmdline_fixed_string_t mirror;
8705 cmdline_fixed_string_t what;
8706 cmdline_fixed_string_t value;
8707 cmdline_fixed_string_t dstpool;
8709 cmdline_fixed_string_t on;
8712 cmdline_parse_token_string_t cmd_mirror_mask_set =
8713 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8715 cmdline_parse_token_string_t cmd_mirror_mask_port =
8716 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8718 cmdline_parse_token_num_t cmd_mirror_mask_portid =
8719 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8721 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
8722 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8723 mirror, "mirror-rule");
8724 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
8725 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8727 cmdline_parse_token_string_t cmd_mirror_mask_what =
8728 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8729 what, "pool-mirror-up#pool-mirror-down"
8731 cmdline_parse_token_string_t cmd_mirror_mask_value =
8732 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8734 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
8735 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8736 dstpool, "dst-pool");
8737 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
8738 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8740 cmdline_parse_token_string_t cmd_mirror_mask_on =
8741 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8745 cmd_set_mirror_mask_parsed(void *parsed_result,
8746 __attribute__((unused)) struct cmdline *cl,
8747 __attribute__((unused)) void *data)
8750 struct cmd_set_mirror_mask_result *res = parsed_result;
8751 struct rte_eth_mirror_conf mr_conf;
8753 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8755 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
8757 mr_conf.dst_pool = res->dstpool_id;
8759 if (!strcmp(res->what, "pool-mirror-up")) {
8760 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8761 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
8762 } else if (!strcmp(res->what, "pool-mirror-down")) {
8763 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8764 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
8765 } else if (!strcmp(res->what, "vlan-mirror")) {
8766 mr_conf.rule_type = ETH_MIRROR_VLAN;
8767 nb_item = parse_item_list(res->value, "vlan",
8768 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
8772 for (i = 0; i < nb_item; i++) {
8773 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
8774 printf("Invalid vlan_id: must be < 4096\n");
8778 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
8779 mr_conf.vlan.vlan_mask |= 1ULL << i;
8783 if (!strcmp(res->on, "on"))
8784 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8787 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8790 printf("mirror rule add error: (%s)\n", strerror(-ret));
8793 cmdline_parse_inst_t cmd_set_mirror_mask = {
8794 .f = cmd_set_mirror_mask_parsed,
8796 .help_str = "set port <port_id> mirror-rule <rule_id> "
8797 "pool-mirror-up|pool-mirror-down|vlan-mirror "
8798 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
8800 (void *)&cmd_mirror_mask_set,
8801 (void *)&cmd_mirror_mask_port,
8802 (void *)&cmd_mirror_mask_portid,
8803 (void *)&cmd_mirror_mask_mirror,
8804 (void *)&cmd_mirror_mask_ruleid,
8805 (void *)&cmd_mirror_mask_what,
8806 (void *)&cmd_mirror_mask_value,
8807 (void *)&cmd_mirror_mask_dstpool,
8808 (void *)&cmd_mirror_mask_poolid,
8809 (void *)&cmd_mirror_mask_on,
8814 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
8815 struct cmd_set_mirror_link_result {
8816 cmdline_fixed_string_t set;
8817 cmdline_fixed_string_t port;
8819 cmdline_fixed_string_t mirror;
8821 cmdline_fixed_string_t what;
8822 cmdline_fixed_string_t dstpool;
8824 cmdline_fixed_string_t on;
8827 cmdline_parse_token_string_t cmd_mirror_link_set =
8828 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8830 cmdline_parse_token_string_t cmd_mirror_link_port =
8831 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8833 cmdline_parse_token_num_t cmd_mirror_link_portid =
8834 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8836 cmdline_parse_token_string_t cmd_mirror_link_mirror =
8837 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8838 mirror, "mirror-rule");
8839 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
8840 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8842 cmdline_parse_token_string_t cmd_mirror_link_what =
8843 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8844 what, "uplink-mirror#downlink-mirror");
8845 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
8846 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8847 dstpool, "dst-pool");
8848 cmdline_parse_token_num_t cmd_mirror_link_poolid =
8849 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8851 cmdline_parse_token_string_t cmd_mirror_link_on =
8852 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8856 cmd_set_mirror_link_parsed(void *parsed_result,
8857 __attribute__((unused)) struct cmdline *cl,
8858 __attribute__((unused)) void *data)
8861 struct cmd_set_mirror_link_result *res = parsed_result;
8862 struct rte_eth_mirror_conf mr_conf;
8864 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8865 if (!strcmp(res->what, "uplink-mirror"))
8866 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
8868 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
8870 mr_conf.dst_pool = res->dstpool_id;
8872 if (!strcmp(res->on, "on"))
8873 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8876 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8879 /* check the return value and print it if is < 0 */
8881 printf("mirror rule add error: (%s)\n", strerror(-ret));
8885 cmdline_parse_inst_t cmd_set_mirror_link = {
8886 .f = cmd_set_mirror_link_parsed,
8888 .help_str = "set port <port_id> mirror-rule <rule_id> "
8889 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
8891 (void *)&cmd_mirror_link_set,
8892 (void *)&cmd_mirror_link_port,
8893 (void *)&cmd_mirror_link_portid,
8894 (void *)&cmd_mirror_link_mirror,
8895 (void *)&cmd_mirror_link_ruleid,
8896 (void *)&cmd_mirror_link_what,
8897 (void *)&cmd_mirror_link_dstpool,
8898 (void *)&cmd_mirror_link_poolid,
8899 (void *)&cmd_mirror_link_on,
8904 /* *** RESET VM MIRROR RULE *** */
8905 struct cmd_rm_mirror_rule_result {
8906 cmdline_fixed_string_t reset;
8907 cmdline_fixed_string_t port;
8909 cmdline_fixed_string_t mirror;
8913 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
8914 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8916 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
8917 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8919 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
8920 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
8922 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
8923 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8924 mirror, "mirror-rule");
8925 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
8926 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
8930 cmd_reset_mirror_rule_parsed(void *parsed_result,
8931 __attribute__((unused)) struct cmdline *cl,
8932 __attribute__((unused)) void *data)
8935 struct cmd_set_mirror_link_result *res = parsed_result;
8937 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
8939 printf("mirror rule remove error: (%s)\n", strerror(-ret));
8942 cmdline_parse_inst_t cmd_reset_mirror_rule = {
8943 .f = cmd_reset_mirror_rule_parsed,
8945 .help_str = "reset port <port_id> mirror-rule <rule_id>",
8947 (void *)&cmd_rm_mirror_rule_reset,
8948 (void *)&cmd_rm_mirror_rule_port,
8949 (void *)&cmd_rm_mirror_rule_portid,
8950 (void *)&cmd_rm_mirror_rule_mirror,
8951 (void *)&cmd_rm_mirror_rule_ruleid,
8956 /* ******************************************************************************** */
8958 struct cmd_dump_result {
8959 cmdline_fixed_string_t dump;
8963 dump_struct_sizes(void)
8965 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
8966 DUMP_SIZE(struct rte_mbuf);
8967 DUMP_SIZE(struct rte_mempool);
8968 DUMP_SIZE(struct rte_ring);
8972 static void cmd_dump_parsed(void *parsed_result,
8973 __attribute__((unused)) struct cmdline *cl,
8974 __attribute__((unused)) void *data)
8976 struct cmd_dump_result *res = parsed_result;
8978 if (!strcmp(res->dump, "dump_physmem"))
8979 rte_dump_physmem_layout(stdout);
8980 else if (!strcmp(res->dump, "dump_memzone"))
8981 rte_memzone_dump(stdout);
8982 else if (!strcmp(res->dump, "dump_struct_sizes"))
8983 dump_struct_sizes();
8984 else if (!strcmp(res->dump, "dump_ring"))
8985 rte_ring_list_dump(stdout);
8986 else if (!strcmp(res->dump, "dump_mempool"))
8987 rte_mempool_list_dump(stdout);
8988 else if (!strcmp(res->dump, "dump_devargs"))
8989 rte_devargs_dump(stdout);
8990 else if (!strcmp(res->dump, "dump_log_types"))
8991 rte_log_dump(stdout);
8994 cmdline_parse_token_string_t cmd_dump_dump =
8995 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
8998 "dump_struct_sizes#"
9004 cmdline_parse_inst_t cmd_dump = {
9005 .f = cmd_dump_parsed, /* function to call */
9006 .data = NULL, /* 2nd arg of func */
9007 .help_str = "Dump status",
9008 .tokens = { /* token list, NULL terminated */
9009 (void *)&cmd_dump_dump,
9014 /* ******************************************************************************** */
9016 struct cmd_dump_one_result {
9017 cmdline_fixed_string_t dump;
9018 cmdline_fixed_string_t name;
9021 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9022 __attribute__((unused)) void *data)
9024 struct cmd_dump_one_result *res = parsed_result;
9026 if (!strcmp(res->dump, "dump_ring")) {
9028 r = rte_ring_lookup(res->name);
9030 cmdline_printf(cl, "Cannot find ring\n");
9033 rte_ring_dump(stdout, r);
9034 } else if (!strcmp(res->dump, "dump_mempool")) {
9035 struct rte_mempool *mp;
9036 mp = rte_mempool_lookup(res->name);
9038 cmdline_printf(cl, "Cannot find mempool\n");
9041 rte_mempool_dump(stdout, mp);
9045 cmdline_parse_token_string_t cmd_dump_one_dump =
9046 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9047 "dump_ring#dump_mempool");
9049 cmdline_parse_token_string_t cmd_dump_one_name =
9050 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9052 cmdline_parse_inst_t cmd_dump_one = {
9053 .f = cmd_dump_one_parsed, /* function to call */
9054 .data = NULL, /* 2nd arg of func */
9055 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9056 .tokens = { /* token list, NULL terminated */
9057 (void *)&cmd_dump_one_dump,
9058 (void *)&cmd_dump_one_name,
9063 /* *** Add/Del syn filter *** */
9064 struct cmd_syn_filter_result {
9065 cmdline_fixed_string_t filter;
9067 cmdline_fixed_string_t ops;
9068 cmdline_fixed_string_t priority;
9069 cmdline_fixed_string_t high;
9070 cmdline_fixed_string_t queue;
9075 cmd_syn_filter_parsed(void *parsed_result,
9076 __attribute__((unused)) struct cmdline *cl,
9077 __attribute__((unused)) void *data)
9079 struct cmd_syn_filter_result *res = parsed_result;
9080 struct rte_eth_syn_filter syn_filter;
9083 ret = rte_eth_dev_filter_supported(res->port_id,
9084 RTE_ETH_FILTER_SYN);
9086 printf("syn filter is not supported on port %u.\n",
9091 memset(&syn_filter, 0, sizeof(syn_filter));
9093 if (!strcmp(res->ops, "add")) {
9094 if (!strcmp(res->high, "high"))
9095 syn_filter.hig_pri = 1;
9097 syn_filter.hig_pri = 0;
9099 syn_filter.queue = res->queue_id;
9100 ret = rte_eth_dev_filter_ctrl(res->port_id,
9105 ret = rte_eth_dev_filter_ctrl(res->port_id,
9107 RTE_ETH_FILTER_DELETE,
9111 printf("syn filter programming error: (%s)\n",
9115 cmdline_parse_token_string_t cmd_syn_filter_filter =
9116 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9117 filter, "syn_filter");
9118 cmdline_parse_token_num_t cmd_syn_filter_port_id =
9119 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9121 cmdline_parse_token_string_t cmd_syn_filter_ops =
9122 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9124 cmdline_parse_token_string_t cmd_syn_filter_priority =
9125 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9126 priority, "priority");
9127 cmdline_parse_token_string_t cmd_syn_filter_high =
9128 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9130 cmdline_parse_token_string_t cmd_syn_filter_queue =
9131 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9133 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
9134 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9137 cmdline_parse_inst_t cmd_syn_filter = {
9138 .f = cmd_syn_filter_parsed,
9140 .help_str = "syn_filter <port_id> add|del priority high|low queue "
9141 "<queue_id>: Add/Delete syn filter",
9143 (void *)&cmd_syn_filter_filter,
9144 (void *)&cmd_syn_filter_port_id,
9145 (void *)&cmd_syn_filter_ops,
9146 (void *)&cmd_syn_filter_priority,
9147 (void *)&cmd_syn_filter_high,
9148 (void *)&cmd_syn_filter_queue,
9149 (void *)&cmd_syn_filter_queue_id,
9154 /* *** queue region set *** */
9155 struct cmd_queue_region_result {
9156 cmdline_fixed_string_t set;
9157 cmdline_fixed_string_t port;
9159 cmdline_fixed_string_t cmd;
9160 cmdline_fixed_string_t region;
9162 cmdline_fixed_string_t queue_start_index;
9164 cmdline_fixed_string_t queue_num;
9165 uint8_t queue_num_value;
9169 cmd_queue_region_parsed(void *parsed_result,
9170 __attribute__((unused)) struct cmdline *cl,
9171 __attribute__((unused)) void *data)
9173 struct cmd_queue_region_result *res = parsed_result;
9175 #ifdef RTE_LIBRTE_I40E_PMD
9176 struct rte_pmd_i40e_queue_region_conf region_conf;
9177 enum rte_pmd_i40e_queue_region_op op_type;
9180 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9183 #ifdef RTE_LIBRTE_I40E_PMD
9184 memset(®ion_conf, 0, sizeof(region_conf));
9185 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9186 region_conf.region_id = res->region_id;
9187 region_conf.queue_num = res->queue_num_value;
9188 region_conf.queue_start_index = res->queue_id;
9190 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9191 op_type, ®ion_conf);
9198 printf("function not implemented or supported\n");
9201 printf("queue region config error: (%s)\n", strerror(-ret));
9205 cmdline_parse_token_string_t cmd_queue_region_set =
9206 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9208 cmdline_parse_token_string_t cmd_queue_region_port =
9209 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9210 cmdline_parse_token_num_t cmd_queue_region_port_id =
9211 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9213 cmdline_parse_token_string_t cmd_queue_region_cmd =
9214 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9215 cmd, "queue-region");
9216 cmdline_parse_token_string_t cmd_queue_region_id =
9217 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9218 region, "region_id");
9219 cmdline_parse_token_num_t cmd_queue_region_index =
9220 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9222 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9223 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9224 queue_start_index, "queue_start_index");
9225 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9226 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9228 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9229 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9230 queue_num, "queue_num");
9231 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9232 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9233 queue_num_value, UINT8);
9235 cmdline_parse_inst_t cmd_queue_region = {
9236 .f = cmd_queue_region_parsed,
9238 .help_str = "set port <port_id> queue-region region_id <value> "
9239 "queue_start_index <value> queue_num <value>: Set a queue region",
9241 (void *)&cmd_queue_region_set,
9242 (void *)&cmd_queue_region_port,
9243 (void *)&cmd_queue_region_port_id,
9244 (void *)&cmd_queue_region_cmd,
9245 (void *)&cmd_queue_region_id,
9246 (void *)&cmd_queue_region_index,
9247 (void *)&cmd_queue_region_queue_start_index,
9248 (void *)&cmd_queue_region_queue_id,
9249 (void *)&cmd_queue_region_queue_num,
9250 (void *)&cmd_queue_region_queue_num_value,
9255 /* *** queue region and flowtype set *** */
9256 struct cmd_region_flowtype_result {
9257 cmdline_fixed_string_t set;
9258 cmdline_fixed_string_t port;
9260 cmdline_fixed_string_t cmd;
9261 cmdline_fixed_string_t region;
9263 cmdline_fixed_string_t flowtype;
9264 uint8_t flowtype_id;
9268 cmd_region_flowtype_parsed(void *parsed_result,
9269 __attribute__((unused)) struct cmdline *cl,
9270 __attribute__((unused)) void *data)
9272 struct cmd_region_flowtype_result *res = parsed_result;
9274 #ifdef RTE_LIBRTE_I40E_PMD
9275 struct rte_pmd_i40e_queue_region_conf region_conf;
9276 enum rte_pmd_i40e_queue_region_op op_type;
9279 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9282 #ifdef RTE_LIBRTE_I40E_PMD
9283 memset(®ion_conf, 0, sizeof(region_conf));
9285 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9286 region_conf.region_id = res->region_id;
9287 region_conf.hw_flowtype = res->flowtype_id;
9289 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9290 op_type, ®ion_conf);
9297 printf("function not implemented or supported\n");
9300 printf("region flowtype config error: (%s)\n", strerror(-ret));
9304 cmdline_parse_token_string_t cmd_region_flowtype_set =
9305 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9307 cmdline_parse_token_string_t cmd_region_flowtype_port =
9308 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9310 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9311 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9313 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9314 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9315 cmd, "queue-region");
9316 cmdline_parse_token_string_t cmd_region_flowtype_index =
9317 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9318 region, "region_id");
9319 cmdline_parse_token_num_t cmd_region_flowtype_id =
9320 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9322 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
9323 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9324 flowtype, "flowtype");
9325 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
9326 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9327 flowtype_id, UINT8);
9328 cmdline_parse_inst_t cmd_region_flowtype = {
9329 .f = cmd_region_flowtype_parsed,
9331 .help_str = "set port <port_id> queue-region region_id <value> "
9332 "flowtype <value>: Set a flowtype region index",
9334 (void *)&cmd_region_flowtype_set,
9335 (void *)&cmd_region_flowtype_port,
9336 (void *)&cmd_region_flowtype_port_index,
9337 (void *)&cmd_region_flowtype_cmd,
9338 (void *)&cmd_region_flowtype_index,
9339 (void *)&cmd_region_flowtype_id,
9340 (void *)&cmd_region_flowtype_flow_index,
9341 (void *)&cmd_region_flowtype_flow_id,
9346 /* *** User Priority (UP) to queue region (region_id) set *** */
9347 struct cmd_user_priority_region_result {
9348 cmdline_fixed_string_t set;
9349 cmdline_fixed_string_t port;
9351 cmdline_fixed_string_t cmd;
9352 cmdline_fixed_string_t user_priority;
9353 uint8_t user_priority_id;
9354 cmdline_fixed_string_t region;
9359 cmd_user_priority_region_parsed(void *parsed_result,
9360 __attribute__((unused)) struct cmdline *cl,
9361 __attribute__((unused)) void *data)
9363 struct cmd_user_priority_region_result *res = parsed_result;
9365 #ifdef RTE_LIBRTE_I40E_PMD
9366 struct rte_pmd_i40e_queue_region_conf region_conf;
9367 enum rte_pmd_i40e_queue_region_op op_type;
9370 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9373 #ifdef RTE_LIBRTE_I40E_PMD
9374 memset(®ion_conf, 0, sizeof(region_conf));
9375 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
9376 region_conf.user_priority = res->user_priority_id;
9377 region_conf.region_id = res->region_id;
9379 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9380 op_type, ®ion_conf);
9387 printf("function not implemented or supported\n");
9390 printf("user_priority region config error: (%s)\n",
9395 cmdline_parse_token_string_t cmd_user_priority_region_set =
9396 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9398 cmdline_parse_token_string_t cmd_user_priority_region_port =
9399 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9401 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
9402 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9404 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
9405 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9406 cmd, "queue-region");
9407 cmdline_parse_token_string_t cmd_user_priority_region_UP =
9408 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9409 user_priority, "UP");
9410 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
9411 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9412 user_priority_id, UINT8);
9413 cmdline_parse_token_string_t cmd_user_priority_region_region =
9414 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9415 region, "region_id");
9416 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
9417 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9420 cmdline_parse_inst_t cmd_user_priority_region = {
9421 .f = cmd_user_priority_region_parsed,
9423 .help_str = "set port <port_id> queue-region UP <value> "
9424 "region_id <value>: Set the mapping of User Priority (UP) "
9425 "to queue region (region_id) ",
9427 (void *)&cmd_user_priority_region_set,
9428 (void *)&cmd_user_priority_region_port,
9429 (void *)&cmd_user_priority_region_port_index,
9430 (void *)&cmd_user_priority_region_cmd,
9431 (void *)&cmd_user_priority_region_UP,
9432 (void *)&cmd_user_priority_region_UP_id,
9433 (void *)&cmd_user_priority_region_region,
9434 (void *)&cmd_user_priority_region_region_id,
9439 /* *** flush all queue region related configuration *** */
9440 struct cmd_flush_queue_region_result {
9441 cmdline_fixed_string_t set;
9442 cmdline_fixed_string_t port;
9444 cmdline_fixed_string_t cmd;
9445 cmdline_fixed_string_t flush;
9446 cmdline_fixed_string_t what;
9450 cmd_flush_queue_region_parsed(void *parsed_result,
9451 __attribute__((unused)) struct cmdline *cl,
9452 __attribute__((unused)) void *data)
9454 struct cmd_flush_queue_region_result *res = parsed_result;
9456 #ifdef RTE_LIBRTE_I40E_PMD
9457 struct rte_pmd_i40e_queue_region_conf region_conf;
9458 enum rte_pmd_i40e_queue_region_op op_type;
9461 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9464 #ifdef RTE_LIBRTE_I40E_PMD
9465 memset(®ion_conf, 0, sizeof(region_conf));
9467 if (strcmp(res->what, "on") == 0)
9468 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
9470 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
9472 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9473 op_type, ®ion_conf);
9480 printf("function not implemented or supported\n");
9483 printf("queue region config flush error: (%s)\n",
9488 cmdline_parse_token_string_t cmd_flush_queue_region_set =
9489 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9491 cmdline_parse_token_string_t cmd_flush_queue_region_port =
9492 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9494 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
9495 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
9497 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
9498 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9499 cmd, "queue-region");
9500 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
9501 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9503 cmdline_parse_token_string_t cmd_flush_queue_region_what =
9504 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9507 cmdline_parse_inst_t cmd_flush_queue_region = {
9508 .f = cmd_flush_queue_region_parsed,
9510 .help_str = "set port <port_id> queue-region flush on|off"
9511 ": flush all queue region related configuration",
9513 (void *)&cmd_flush_queue_region_set,
9514 (void *)&cmd_flush_queue_region_port,
9515 (void *)&cmd_flush_queue_region_port_index,
9516 (void *)&cmd_flush_queue_region_cmd,
9517 (void *)&cmd_flush_queue_region_flush,
9518 (void *)&cmd_flush_queue_region_what,
9523 /* *** get all queue region related configuration info *** */
9524 struct cmd_show_queue_region_info {
9525 cmdline_fixed_string_t show;
9526 cmdline_fixed_string_t port;
9528 cmdline_fixed_string_t cmd;
9532 cmd_show_queue_region_info_parsed(void *parsed_result,
9533 __attribute__((unused)) struct cmdline *cl,
9534 __attribute__((unused)) void *data)
9536 struct cmd_show_queue_region_info *res = parsed_result;
9538 #ifdef RTE_LIBRTE_I40E_PMD
9539 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
9540 enum rte_pmd_i40e_queue_region_op op_type;
9543 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9546 #ifdef RTE_LIBRTE_I40E_PMD
9547 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
9549 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
9551 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9552 op_type, &rte_pmd_regions);
9554 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
9561 printf("function not implemented or supported\n");
9564 printf("queue region config info show error: (%s)\n",
9569 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
9570 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9572 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
9573 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9575 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
9576 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
9578 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
9579 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9580 cmd, "queue-region");
9582 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
9583 .f = cmd_show_queue_region_info_parsed,
9585 .help_str = "show port <port_id> queue-region"
9586 ": show all queue region related configuration info",
9588 (void *)&cmd_show_queue_region_info_get,
9589 (void *)&cmd_show_queue_region_info_port,
9590 (void *)&cmd_show_queue_region_info_port_index,
9591 (void *)&cmd_show_queue_region_info_cmd,
9596 /* *** ADD/REMOVE A 2tuple FILTER *** */
9597 struct cmd_2tuple_filter_result {
9598 cmdline_fixed_string_t filter;
9600 cmdline_fixed_string_t ops;
9601 cmdline_fixed_string_t dst_port;
9602 uint16_t dst_port_value;
9603 cmdline_fixed_string_t protocol;
9604 uint8_t protocol_value;
9605 cmdline_fixed_string_t mask;
9607 cmdline_fixed_string_t tcp_flags;
9608 uint8_t tcp_flags_value;
9609 cmdline_fixed_string_t priority;
9610 uint8_t priority_value;
9611 cmdline_fixed_string_t queue;
9616 cmd_2tuple_filter_parsed(void *parsed_result,
9617 __attribute__((unused)) struct cmdline *cl,
9618 __attribute__((unused)) void *data)
9620 struct rte_eth_ntuple_filter filter;
9621 struct cmd_2tuple_filter_result *res = parsed_result;
9624 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9626 printf("ntuple filter is not supported on port %u.\n",
9631 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9633 filter.flags = RTE_2TUPLE_FLAGS;
9634 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9635 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9636 filter.proto = res->protocol_value;
9637 filter.priority = res->priority_value;
9638 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9639 printf("nonzero tcp_flags is only meaningful"
9640 " when protocol is TCP.\n");
9643 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9644 printf("invalid TCP flags.\n");
9648 if (res->tcp_flags_value != 0) {
9649 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9650 filter.tcp_flags = res->tcp_flags_value;
9653 /* need convert to big endian. */
9654 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9655 filter.queue = res->queue_id;
9657 if (!strcmp(res->ops, "add"))
9658 ret = rte_eth_dev_filter_ctrl(res->port_id,
9659 RTE_ETH_FILTER_NTUPLE,
9663 ret = rte_eth_dev_filter_ctrl(res->port_id,
9664 RTE_ETH_FILTER_NTUPLE,
9665 RTE_ETH_FILTER_DELETE,
9668 printf("2tuple filter programming error: (%s)\n",
9673 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
9674 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9675 filter, "2tuple_filter");
9676 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
9677 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9679 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
9680 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9682 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
9683 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9684 dst_port, "dst_port");
9685 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
9686 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9687 dst_port_value, UINT16);
9688 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
9689 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9690 protocol, "protocol");
9691 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
9692 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9693 protocol_value, UINT8);
9694 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
9695 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9697 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
9698 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9700 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
9701 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9702 tcp_flags, "tcp_flags");
9703 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
9704 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9705 tcp_flags_value, UINT8);
9706 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
9707 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9708 priority, "priority");
9709 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
9710 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9711 priority_value, UINT8);
9712 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
9713 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9715 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
9716 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9719 cmdline_parse_inst_t cmd_2tuple_filter = {
9720 .f = cmd_2tuple_filter_parsed,
9722 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
9723 "<value> mask <value> tcp_flags <value> priority <value> queue "
9724 "<queue_id>: Add a 2tuple filter",
9726 (void *)&cmd_2tuple_filter_filter,
9727 (void *)&cmd_2tuple_filter_port_id,
9728 (void *)&cmd_2tuple_filter_ops,
9729 (void *)&cmd_2tuple_filter_dst_port,
9730 (void *)&cmd_2tuple_filter_dst_port_value,
9731 (void *)&cmd_2tuple_filter_protocol,
9732 (void *)&cmd_2tuple_filter_protocol_value,
9733 (void *)&cmd_2tuple_filter_mask,
9734 (void *)&cmd_2tuple_filter_mask_value,
9735 (void *)&cmd_2tuple_filter_tcp_flags,
9736 (void *)&cmd_2tuple_filter_tcp_flags_value,
9737 (void *)&cmd_2tuple_filter_priority,
9738 (void *)&cmd_2tuple_filter_priority_value,
9739 (void *)&cmd_2tuple_filter_queue,
9740 (void *)&cmd_2tuple_filter_queue_id,
9745 /* *** ADD/REMOVE A 5tuple FILTER *** */
9746 struct cmd_5tuple_filter_result {
9747 cmdline_fixed_string_t filter;
9749 cmdline_fixed_string_t ops;
9750 cmdline_fixed_string_t dst_ip;
9751 cmdline_ipaddr_t dst_ip_value;
9752 cmdline_fixed_string_t src_ip;
9753 cmdline_ipaddr_t src_ip_value;
9754 cmdline_fixed_string_t dst_port;
9755 uint16_t dst_port_value;
9756 cmdline_fixed_string_t src_port;
9757 uint16_t src_port_value;
9758 cmdline_fixed_string_t protocol;
9759 uint8_t protocol_value;
9760 cmdline_fixed_string_t mask;
9762 cmdline_fixed_string_t tcp_flags;
9763 uint8_t tcp_flags_value;
9764 cmdline_fixed_string_t priority;
9765 uint8_t priority_value;
9766 cmdline_fixed_string_t queue;
9771 cmd_5tuple_filter_parsed(void *parsed_result,
9772 __attribute__((unused)) struct cmdline *cl,
9773 __attribute__((unused)) void *data)
9775 struct rte_eth_ntuple_filter filter;
9776 struct cmd_5tuple_filter_result *res = parsed_result;
9779 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9781 printf("ntuple filter is not supported on port %u.\n",
9786 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9788 filter.flags = RTE_5TUPLE_FLAGS;
9789 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
9790 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
9791 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
9792 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9793 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9794 filter.proto = res->protocol_value;
9795 filter.priority = res->priority_value;
9796 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9797 printf("nonzero tcp_flags is only meaningful"
9798 " when protocol is TCP.\n");
9801 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9802 printf("invalid TCP flags.\n");
9806 if (res->tcp_flags_value != 0) {
9807 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9808 filter.tcp_flags = res->tcp_flags_value;
9811 if (res->dst_ip_value.family == AF_INET)
9812 /* no need to convert, already big endian. */
9813 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
9815 if (filter.dst_ip_mask == 0) {
9816 printf("can not support ipv6 involved compare.\n");
9822 if (res->src_ip_value.family == AF_INET)
9823 /* no need to convert, already big endian. */
9824 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
9826 if (filter.src_ip_mask == 0) {
9827 printf("can not support ipv6 involved compare.\n");
9832 /* need convert to big endian. */
9833 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9834 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
9835 filter.queue = res->queue_id;
9837 if (!strcmp(res->ops, "add"))
9838 ret = rte_eth_dev_filter_ctrl(res->port_id,
9839 RTE_ETH_FILTER_NTUPLE,
9843 ret = rte_eth_dev_filter_ctrl(res->port_id,
9844 RTE_ETH_FILTER_NTUPLE,
9845 RTE_ETH_FILTER_DELETE,
9848 printf("5tuple filter programming error: (%s)\n",
9852 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
9853 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9854 filter, "5tuple_filter");
9855 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
9856 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9858 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
9859 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9861 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
9862 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9864 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
9865 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9867 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
9868 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9870 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
9871 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9873 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
9874 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9875 dst_port, "dst_port");
9876 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
9877 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9878 dst_port_value, UINT16);
9879 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
9880 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9881 src_port, "src_port");
9882 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
9883 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9884 src_port_value, UINT16);
9885 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
9886 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9887 protocol, "protocol");
9888 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
9889 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9890 protocol_value, UINT8);
9891 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
9892 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9894 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
9895 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9897 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
9898 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9899 tcp_flags, "tcp_flags");
9900 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
9901 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9902 tcp_flags_value, UINT8);
9903 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
9904 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9905 priority, "priority");
9906 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
9907 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9908 priority_value, UINT8);
9909 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
9910 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9912 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
9913 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9916 cmdline_parse_inst_t cmd_5tuple_filter = {
9917 .f = cmd_5tuple_filter_parsed,
9919 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
9920 "src_ip <value> dst_port <value> src_port <value> "
9921 "protocol <value> mask <value> tcp_flags <value> "
9922 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
9924 (void *)&cmd_5tuple_filter_filter,
9925 (void *)&cmd_5tuple_filter_port_id,
9926 (void *)&cmd_5tuple_filter_ops,
9927 (void *)&cmd_5tuple_filter_dst_ip,
9928 (void *)&cmd_5tuple_filter_dst_ip_value,
9929 (void *)&cmd_5tuple_filter_src_ip,
9930 (void *)&cmd_5tuple_filter_src_ip_value,
9931 (void *)&cmd_5tuple_filter_dst_port,
9932 (void *)&cmd_5tuple_filter_dst_port_value,
9933 (void *)&cmd_5tuple_filter_src_port,
9934 (void *)&cmd_5tuple_filter_src_port_value,
9935 (void *)&cmd_5tuple_filter_protocol,
9936 (void *)&cmd_5tuple_filter_protocol_value,
9937 (void *)&cmd_5tuple_filter_mask,
9938 (void *)&cmd_5tuple_filter_mask_value,
9939 (void *)&cmd_5tuple_filter_tcp_flags,
9940 (void *)&cmd_5tuple_filter_tcp_flags_value,
9941 (void *)&cmd_5tuple_filter_priority,
9942 (void *)&cmd_5tuple_filter_priority_value,
9943 (void *)&cmd_5tuple_filter_queue,
9944 (void *)&cmd_5tuple_filter_queue_id,
9949 /* *** ADD/REMOVE A flex FILTER *** */
9950 struct cmd_flex_filter_result {
9951 cmdline_fixed_string_t filter;
9952 cmdline_fixed_string_t ops;
9954 cmdline_fixed_string_t len;
9956 cmdline_fixed_string_t bytes;
9957 cmdline_fixed_string_t bytes_value;
9958 cmdline_fixed_string_t mask;
9959 cmdline_fixed_string_t mask_value;
9960 cmdline_fixed_string_t priority;
9961 uint8_t priority_value;
9962 cmdline_fixed_string_t queue;
9966 static int xdigit2val(unsigned char c)
9971 else if (isupper(c))
9979 cmd_flex_filter_parsed(void *parsed_result,
9980 __attribute__((unused)) struct cmdline *cl,
9981 __attribute__((unused)) void *data)
9984 struct rte_eth_flex_filter filter;
9985 struct cmd_flex_filter_result *res = parsed_result;
9986 char *bytes_ptr, *mask_ptr;
9987 uint16_t len, i, j = 0;
9992 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
9993 printf("the len exceed the max length 128\n");
9996 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
9997 filter.len = res->len_value;
9998 filter.priority = res->priority_value;
9999 filter.queue = res->queue_id;
10000 bytes_ptr = res->bytes_value;
10001 mask_ptr = res->mask_value;
10003 /* translate bytes string to array. */
10004 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
10005 (bytes_ptr[1] == 'X')))
10007 len = strnlen(bytes_ptr, res->len_value * 2);
10008 if (len == 0 || (len % 8 != 0)) {
10009 printf("please check len and bytes input\n");
10012 for (i = 0; i < len; i++) {
10014 if (isxdigit(c) == 0) {
10015 /* invalid characters. */
10016 printf("invalid input\n");
10019 val = xdigit2val(c);
10022 filter.bytes[j] = byte;
10023 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
10030 /* translate mask string to uint8_t array. */
10031 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
10032 (mask_ptr[1] == 'X')))
10034 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
10036 printf("invalid input\n");
10041 for (i = 0; i < len; i++) {
10043 if (isxdigit(c) == 0) {
10044 /* invalid characters. */
10045 printf("invalid input\n");
10048 val = xdigit2val(c);
10051 filter.mask[j] = byte;
10052 printf("mask[%d]:%02x ", j, filter.mask[j]);
10060 if (!strcmp(res->ops, "add"))
10061 ret = rte_eth_dev_filter_ctrl(res->port_id,
10062 RTE_ETH_FILTER_FLEXIBLE,
10063 RTE_ETH_FILTER_ADD,
10066 ret = rte_eth_dev_filter_ctrl(res->port_id,
10067 RTE_ETH_FILTER_FLEXIBLE,
10068 RTE_ETH_FILTER_DELETE,
10072 printf("flex filter setting error: (%s)\n", strerror(-ret));
10075 cmdline_parse_token_string_t cmd_flex_filter_filter =
10076 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10077 filter, "flex_filter");
10078 cmdline_parse_token_num_t cmd_flex_filter_port_id =
10079 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10081 cmdline_parse_token_string_t cmd_flex_filter_ops =
10082 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10084 cmdline_parse_token_string_t cmd_flex_filter_len =
10085 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10087 cmdline_parse_token_num_t cmd_flex_filter_len_value =
10088 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10090 cmdline_parse_token_string_t cmd_flex_filter_bytes =
10091 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10093 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
10094 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10095 bytes_value, NULL);
10096 cmdline_parse_token_string_t cmd_flex_filter_mask =
10097 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10099 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
10100 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10102 cmdline_parse_token_string_t cmd_flex_filter_priority =
10103 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10104 priority, "priority");
10105 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
10106 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10107 priority_value, UINT8);
10108 cmdline_parse_token_string_t cmd_flex_filter_queue =
10109 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10111 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
10112 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10114 cmdline_parse_inst_t cmd_flex_filter = {
10115 .f = cmd_flex_filter_parsed,
10117 .help_str = "flex_filter <port_id> add|del len <value> bytes "
10118 "<value> mask <value> priority <value> queue <queue_id>: "
10119 "Add/Del a flex filter",
10121 (void *)&cmd_flex_filter_filter,
10122 (void *)&cmd_flex_filter_port_id,
10123 (void *)&cmd_flex_filter_ops,
10124 (void *)&cmd_flex_filter_len,
10125 (void *)&cmd_flex_filter_len_value,
10126 (void *)&cmd_flex_filter_bytes,
10127 (void *)&cmd_flex_filter_bytes_value,
10128 (void *)&cmd_flex_filter_mask,
10129 (void *)&cmd_flex_filter_mask_value,
10130 (void *)&cmd_flex_filter_priority,
10131 (void *)&cmd_flex_filter_priority_value,
10132 (void *)&cmd_flex_filter_queue,
10133 (void *)&cmd_flex_filter_queue_id,
10138 /* *** Filters Control *** */
10140 /* *** deal with ethertype filter *** */
10141 struct cmd_ethertype_filter_result {
10142 cmdline_fixed_string_t filter;
10144 cmdline_fixed_string_t ops;
10145 cmdline_fixed_string_t mac;
10146 struct ether_addr mac_addr;
10147 cmdline_fixed_string_t ethertype;
10148 uint16_t ethertype_value;
10149 cmdline_fixed_string_t drop;
10150 cmdline_fixed_string_t queue;
10154 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
10155 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10156 filter, "ethertype_filter");
10157 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
10158 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10160 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
10161 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10163 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
10164 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10165 mac, "mac_addr#mac_ignr");
10166 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
10167 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
10169 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
10170 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10171 ethertype, "ethertype");
10172 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
10173 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10174 ethertype_value, UINT16);
10175 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
10176 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10178 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
10179 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10181 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
10182 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10186 cmd_ethertype_filter_parsed(void *parsed_result,
10187 __attribute__((unused)) struct cmdline *cl,
10188 __attribute__((unused)) void *data)
10190 struct cmd_ethertype_filter_result *res = parsed_result;
10191 struct rte_eth_ethertype_filter filter;
10194 ret = rte_eth_dev_filter_supported(res->port_id,
10195 RTE_ETH_FILTER_ETHERTYPE);
10197 printf("ethertype filter is not supported on port %u.\n",
10202 memset(&filter, 0, sizeof(filter));
10203 if (!strcmp(res->mac, "mac_addr")) {
10204 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
10205 rte_memcpy(&filter.mac_addr, &res->mac_addr,
10206 sizeof(struct ether_addr));
10208 if (!strcmp(res->drop, "drop"))
10209 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
10210 filter.ether_type = res->ethertype_value;
10211 filter.queue = res->queue_id;
10213 if (!strcmp(res->ops, "add"))
10214 ret = rte_eth_dev_filter_ctrl(res->port_id,
10215 RTE_ETH_FILTER_ETHERTYPE,
10216 RTE_ETH_FILTER_ADD,
10219 ret = rte_eth_dev_filter_ctrl(res->port_id,
10220 RTE_ETH_FILTER_ETHERTYPE,
10221 RTE_ETH_FILTER_DELETE,
10224 printf("ethertype filter programming error: (%s)\n",
10228 cmdline_parse_inst_t cmd_ethertype_filter = {
10229 .f = cmd_ethertype_filter_parsed,
10231 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
10232 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
10233 "Add or delete an ethertype filter entry",
10235 (void *)&cmd_ethertype_filter_filter,
10236 (void *)&cmd_ethertype_filter_port_id,
10237 (void *)&cmd_ethertype_filter_ops,
10238 (void *)&cmd_ethertype_filter_mac,
10239 (void *)&cmd_ethertype_filter_mac_addr,
10240 (void *)&cmd_ethertype_filter_ethertype,
10241 (void *)&cmd_ethertype_filter_ethertype_value,
10242 (void *)&cmd_ethertype_filter_drop,
10243 (void *)&cmd_ethertype_filter_queue,
10244 (void *)&cmd_ethertype_filter_queue_id,
10249 /* *** deal with flow director filter *** */
10250 struct cmd_flow_director_result {
10251 cmdline_fixed_string_t flow_director_filter;
10253 cmdline_fixed_string_t mode;
10254 cmdline_fixed_string_t mode_value;
10255 cmdline_fixed_string_t ops;
10256 cmdline_fixed_string_t flow;
10257 cmdline_fixed_string_t flow_type;
10258 cmdline_fixed_string_t ether;
10259 uint16_t ether_type;
10260 cmdline_fixed_string_t src;
10261 cmdline_ipaddr_t ip_src;
10263 cmdline_fixed_string_t dst;
10264 cmdline_ipaddr_t ip_dst;
10266 cmdline_fixed_string_t verify_tag;
10267 uint32_t verify_tag_value;
10268 cmdline_fixed_string_t tos;
10270 cmdline_fixed_string_t proto;
10271 uint8_t proto_value;
10272 cmdline_fixed_string_t ttl;
10274 cmdline_fixed_string_t vlan;
10275 uint16_t vlan_value;
10276 cmdline_fixed_string_t flexbytes;
10277 cmdline_fixed_string_t flexbytes_value;
10278 cmdline_fixed_string_t pf_vf;
10279 cmdline_fixed_string_t drop;
10280 cmdline_fixed_string_t queue;
10282 cmdline_fixed_string_t fd_id;
10283 uint32_t fd_id_value;
10284 cmdline_fixed_string_t mac;
10285 struct ether_addr mac_addr;
10286 cmdline_fixed_string_t tunnel;
10287 cmdline_fixed_string_t tunnel_type;
10288 cmdline_fixed_string_t tunnel_id;
10289 uint32_t tunnel_id_value;
10290 cmdline_fixed_string_t packet;
10295 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
10298 const char *p, *p0 = q_arg;
10300 unsigned long int_fld;
10301 char *str_fld[max_num];
10306 p = strchr(p0, '(');
10310 p0 = strchr(p, ')');
10315 if (size >= sizeof(s))
10318 snprintf(s, sizeof(s), "%.*s", size, p);
10319 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10320 if (ret < 0 || ret > max_num)
10322 for (i = 0; i < ret; i++) {
10324 int_fld = strtoul(str_fld[i], &end, 0);
10325 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
10327 flexbytes[i] = (uint8_t)int_fld;
10333 str2flowtype(char *string)
10336 static const struct {
10339 } flowtype_str[] = {
10340 {"raw", RTE_ETH_FLOW_RAW},
10341 {"ipv4", RTE_ETH_FLOW_IPV4},
10342 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10343 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10344 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10345 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10346 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10347 {"ipv6", RTE_ETH_FLOW_IPV6},
10348 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10349 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10350 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10351 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10352 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10353 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10356 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10357 if (!strcmp(flowtype_str[i].str, string))
10358 return flowtype_str[i].type;
10361 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10362 return (uint16_t)atoi(string);
10364 return RTE_ETH_FLOW_UNKNOWN;
10367 static enum rte_eth_fdir_tunnel_type
10368 str2fdir_tunneltype(char *string)
10372 static const struct {
10374 enum rte_eth_fdir_tunnel_type type;
10375 } tunneltype_str[] = {
10376 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
10377 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
10380 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
10381 if (!strcmp(tunneltype_str[i].str, string))
10382 return tunneltype_str[i].type;
10384 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
10387 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10389 if ((ip_addr).family == AF_INET) \
10390 (ip) = (ip_addr).addr.ipv4.s_addr; \
10392 printf("invalid parameter.\n"); \
10397 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10399 if ((ip_addr).family == AF_INET6) \
10400 rte_memcpy(&(ip), \
10401 &((ip_addr).addr.ipv6), \
10402 sizeof(struct in6_addr)); \
10404 printf("invalid parameter.\n"); \
10410 cmd_flow_director_filter_parsed(void *parsed_result,
10411 __attribute__((unused)) struct cmdline *cl,
10412 __attribute__((unused)) void *data)
10414 struct cmd_flow_director_result *res = parsed_result;
10415 struct rte_eth_fdir_filter entry;
10416 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
10418 unsigned long vf_id;
10421 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10423 printf("flow director is not supported on port %u.\n",
10427 memset(flexbytes, 0, sizeof(flexbytes));
10428 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
10430 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10431 if (strcmp(res->mode_value, "MAC-VLAN")) {
10432 printf("Please set mode to MAC-VLAN.\n");
10435 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10436 if (strcmp(res->mode_value, "Tunnel")) {
10437 printf("Please set mode to Tunnel.\n");
10441 if (!strcmp(res->mode_value, "raw")) {
10442 #ifdef RTE_LIBRTE_I40E_PMD
10443 struct rte_pmd_i40e_flow_type_mapping
10444 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10445 struct rte_pmd_i40e_pkt_template_conf conf;
10446 uint16_t flow_type = str2flowtype(res->flow_type);
10447 uint16_t i, port = res->port_id;
10450 memset(&conf, 0, sizeof(conf));
10452 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10453 printf("Invalid flow type specified.\n");
10456 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10460 if (mapping[flow_type].pctype == 0ULL) {
10461 printf("Invalid flow type specified.\n");
10464 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10465 if (mapping[flow_type].pctype & (1ULL << i)) {
10466 conf.input.pctype = i;
10471 conf.input.packet = open_file(res->filepath,
10472 &conf.input.length);
10473 if (!conf.input.packet)
10475 if (!strcmp(res->drop, "drop"))
10476 conf.action.behavior =
10477 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10479 conf.action.behavior =
10480 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10481 conf.action.report_status =
10482 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10483 conf.action.rx_queue = res->queue_id;
10484 conf.soft_id = res->fd_id_value;
10485 add = strcmp(res->ops, "del") ? 1 : 0;
10486 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10490 printf("flow director config error: (%s)\n",
10492 close_file(conf.input.packet);
10495 } else if (strcmp(res->mode_value, "IP")) {
10496 printf("Please set mode to IP or raw.\n");
10499 entry.input.flow_type = str2flowtype(res->flow_type);
10502 ret = parse_flexbytes(res->flexbytes_value,
10504 RTE_ETH_FDIR_MAX_FLEXLEN);
10506 printf("error: Cannot parse flexbytes input.\n");
10510 switch (entry.input.flow_type) {
10511 case RTE_ETH_FLOW_FRAG_IPV4:
10512 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
10513 entry.input.flow.ip4_flow.proto = res->proto_value;
10515 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
10516 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
10517 IPV4_ADDR_TO_UINT(res->ip_dst,
10518 entry.input.flow.ip4_flow.dst_ip);
10519 IPV4_ADDR_TO_UINT(res->ip_src,
10520 entry.input.flow.ip4_flow.src_ip);
10521 entry.input.flow.ip4_flow.tos = res->tos_value;
10522 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10523 /* need convert to big endian. */
10524 entry.input.flow.udp4_flow.dst_port =
10525 rte_cpu_to_be_16(res->port_dst);
10526 entry.input.flow.udp4_flow.src_port =
10527 rte_cpu_to_be_16(res->port_src);
10529 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
10530 IPV4_ADDR_TO_UINT(res->ip_dst,
10531 entry.input.flow.sctp4_flow.ip.dst_ip);
10532 IPV4_ADDR_TO_UINT(res->ip_src,
10533 entry.input.flow.sctp4_flow.ip.src_ip);
10534 entry.input.flow.ip4_flow.tos = res->tos_value;
10535 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10536 /* need convert to big endian. */
10537 entry.input.flow.sctp4_flow.dst_port =
10538 rte_cpu_to_be_16(res->port_dst);
10539 entry.input.flow.sctp4_flow.src_port =
10540 rte_cpu_to_be_16(res->port_src);
10541 entry.input.flow.sctp4_flow.verify_tag =
10542 rte_cpu_to_be_32(res->verify_tag_value);
10544 case RTE_ETH_FLOW_FRAG_IPV6:
10545 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
10546 entry.input.flow.ipv6_flow.proto = res->proto_value;
10548 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
10549 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
10550 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10551 entry.input.flow.ipv6_flow.dst_ip);
10552 IPV6_ADDR_TO_ARRAY(res->ip_src,
10553 entry.input.flow.ipv6_flow.src_ip);
10554 entry.input.flow.ipv6_flow.tc = res->tos_value;
10555 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10556 /* need convert to big endian. */
10557 entry.input.flow.udp6_flow.dst_port =
10558 rte_cpu_to_be_16(res->port_dst);
10559 entry.input.flow.udp6_flow.src_port =
10560 rte_cpu_to_be_16(res->port_src);
10562 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
10563 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10564 entry.input.flow.sctp6_flow.ip.dst_ip);
10565 IPV6_ADDR_TO_ARRAY(res->ip_src,
10566 entry.input.flow.sctp6_flow.ip.src_ip);
10567 entry.input.flow.ipv6_flow.tc = res->tos_value;
10568 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10569 /* need convert to big endian. */
10570 entry.input.flow.sctp6_flow.dst_port =
10571 rte_cpu_to_be_16(res->port_dst);
10572 entry.input.flow.sctp6_flow.src_port =
10573 rte_cpu_to_be_16(res->port_src);
10574 entry.input.flow.sctp6_flow.verify_tag =
10575 rte_cpu_to_be_32(res->verify_tag_value);
10577 case RTE_ETH_FLOW_L2_PAYLOAD:
10578 entry.input.flow.l2_flow.ether_type =
10579 rte_cpu_to_be_16(res->ether_type);
10585 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
10586 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
10588 sizeof(struct ether_addr));
10590 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10591 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
10593 sizeof(struct ether_addr));
10594 entry.input.flow.tunnel_flow.tunnel_type =
10595 str2fdir_tunneltype(res->tunnel_type);
10596 entry.input.flow.tunnel_flow.tunnel_id =
10597 rte_cpu_to_be_32(res->tunnel_id_value);
10600 rte_memcpy(entry.input.flow_ext.flexbytes,
10602 RTE_ETH_FDIR_MAX_FLEXLEN);
10604 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
10606 entry.action.flex_off = 0; /*use 0 by default */
10607 if (!strcmp(res->drop, "drop"))
10608 entry.action.behavior = RTE_ETH_FDIR_REJECT;
10610 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
10612 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
10613 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
10614 if (!strcmp(res->pf_vf, "pf"))
10615 entry.input.flow_ext.is_vf = 0;
10616 else if (!strncmp(res->pf_vf, "vf", 2)) {
10617 struct rte_eth_dev_info dev_info;
10619 memset(&dev_info, 0, sizeof(dev_info));
10620 rte_eth_dev_info_get(res->port_id, &dev_info);
10622 vf_id = strtoul(res->pf_vf + 2, &end, 10);
10623 if (errno != 0 || *end != '\0' ||
10624 vf_id >= dev_info.max_vfs) {
10625 printf("invalid parameter %s.\n", res->pf_vf);
10628 entry.input.flow_ext.is_vf = 1;
10629 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
10631 printf("invalid parameter %s.\n", res->pf_vf);
10636 /* set to report FD ID by default */
10637 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
10638 entry.action.rx_queue = res->queue_id;
10639 entry.soft_id = res->fd_id_value;
10640 if (!strcmp(res->ops, "add"))
10641 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10642 RTE_ETH_FILTER_ADD, &entry);
10643 else if (!strcmp(res->ops, "del"))
10644 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10645 RTE_ETH_FILTER_DELETE, &entry);
10647 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10648 RTE_ETH_FILTER_UPDATE, &entry);
10650 printf("flow director programming error: (%s)\n",
10654 cmdline_parse_token_string_t cmd_flow_director_filter =
10655 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10656 flow_director_filter, "flow_director_filter");
10657 cmdline_parse_token_num_t cmd_flow_director_port_id =
10658 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10660 cmdline_parse_token_string_t cmd_flow_director_ops =
10661 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10662 ops, "add#del#update");
10663 cmdline_parse_token_string_t cmd_flow_director_flow =
10664 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10666 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10667 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10669 cmdline_parse_token_string_t cmd_flow_director_ether =
10670 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10672 cmdline_parse_token_num_t cmd_flow_director_ether_type =
10673 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10674 ether_type, UINT16);
10675 cmdline_parse_token_string_t cmd_flow_director_src =
10676 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10678 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
10679 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10681 cmdline_parse_token_num_t cmd_flow_director_port_src =
10682 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10684 cmdline_parse_token_string_t cmd_flow_director_dst =
10685 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10687 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
10688 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10690 cmdline_parse_token_num_t cmd_flow_director_port_dst =
10691 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10693 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
10694 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10695 verify_tag, "verify_tag");
10696 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
10697 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10698 verify_tag_value, UINT32);
10699 cmdline_parse_token_string_t cmd_flow_director_tos =
10700 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10702 cmdline_parse_token_num_t cmd_flow_director_tos_value =
10703 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10705 cmdline_parse_token_string_t cmd_flow_director_proto =
10706 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10708 cmdline_parse_token_num_t cmd_flow_director_proto_value =
10709 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10710 proto_value, UINT8);
10711 cmdline_parse_token_string_t cmd_flow_director_ttl =
10712 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10714 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
10715 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10717 cmdline_parse_token_string_t cmd_flow_director_vlan =
10718 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10720 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
10721 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10722 vlan_value, UINT16);
10723 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
10724 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10725 flexbytes, "flexbytes");
10726 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
10727 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10728 flexbytes_value, NULL);
10729 cmdline_parse_token_string_t cmd_flow_director_drop =
10730 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10732 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
10733 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10735 cmdline_parse_token_string_t cmd_flow_director_queue =
10736 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10738 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10739 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10741 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10742 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10744 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10745 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10746 fd_id_value, UINT32);
10748 cmdline_parse_token_string_t cmd_flow_director_mode =
10749 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10751 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
10752 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10754 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
10755 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10756 mode_value, "MAC-VLAN");
10757 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
10758 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10759 mode_value, "Tunnel");
10760 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
10761 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10762 mode_value, "raw");
10763 cmdline_parse_token_string_t cmd_flow_director_mac =
10764 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10766 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
10767 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
10769 cmdline_parse_token_string_t cmd_flow_director_tunnel =
10770 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10772 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
10773 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10774 tunnel_type, "NVGRE#VxLAN");
10775 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
10776 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10777 tunnel_id, "tunnel-id");
10778 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
10779 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10780 tunnel_id_value, UINT32);
10781 cmdline_parse_token_string_t cmd_flow_director_packet =
10782 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10784 cmdline_parse_token_string_t cmd_flow_director_filepath =
10785 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10788 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
10789 .f = cmd_flow_director_filter_parsed,
10791 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
10792 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
10793 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
10794 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
10795 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
10796 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
10797 "fd_id <fd_id_value>: "
10798 "Add or delete an ip flow director entry on NIC",
10800 (void *)&cmd_flow_director_filter,
10801 (void *)&cmd_flow_director_port_id,
10802 (void *)&cmd_flow_director_mode,
10803 (void *)&cmd_flow_director_mode_ip,
10804 (void *)&cmd_flow_director_ops,
10805 (void *)&cmd_flow_director_flow,
10806 (void *)&cmd_flow_director_flow_type,
10807 (void *)&cmd_flow_director_src,
10808 (void *)&cmd_flow_director_ip_src,
10809 (void *)&cmd_flow_director_dst,
10810 (void *)&cmd_flow_director_ip_dst,
10811 (void *)&cmd_flow_director_tos,
10812 (void *)&cmd_flow_director_tos_value,
10813 (void *)&cmd_flow_director_proto,
10814 (void *)&cmd_flow_director_proto_value,
10815 (void *)&cmd_flow_director_ttl,
10816 (void *)&cmd_flow_director_ttl_value,
10817 (void *)&cmd_flow_director_vlan,
10818 (void *)&cmd_flow_director_vlan_value,
10819 (void *)&cmd_flow_director_flexbytes,
10820 (void *)&cmd_flow_director_flexbytes_value,
10821 (void *)&cmd_flow_director_drop,
10822 (void *)&cmd_flow_director_pf_vf,
10823 (void *)&cmd_flow_director_queue,
10824 (void *)&cmd_flow_director_queue_id,
10825 (void *)&cmd_flow_director_fd_id,
10826 (void *)&cmd_flow_director_fd_id_value,
10831 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
10832 .f = cmd_flow_director_filter_parsed,
10834 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
10835 "director entry on NIC",
10837 (void *)&cmd_flow_director_filter,
10838 (void *)&cmd_flow_director_port_id,
10839 (void *)&cmd_flow_director_mode,
10840 (void *)&cmd_flow_director_mode_ip,
10841 (void *)&cmd_flow_director_ops,
10842 (void *)&cmd_flow_director_flow,
10843 (void *)&cmd_flow_director_flow_type,
10844 (void *)&cmd_flow_director_src,
10845 (void *)&cmd_flow_director_ip_src,
10846 (void *)&cmd_flow_director_port_src,
10847 (void *)&cmd_flow_director_dst,
10848 (void *)&cmd_flow_director_ip_dst,
10849 (void *)&cmd_flow_director_port_dst,
10850 (void *)&cmd_flow_director_tos,
10851 (void *)&cmd_flow_director_tos_value,
10852 (void *)&cmd_flow_director_ttl,
10853 (void *)&cmd_flow_director_ttl_value,
10854 (void *)&cmd_flow_director_vlan,
10855 (void *)&cmd_flow_director_vlan_value,
10856 (void *)&cmd_flow_director_flexbytes,
10857 (void *)&cmd_flow_director_flexbytes_value,
10858 (void *)&cmd_flow_director_drop,
10859 (void *)&cmd_flow_director_pf_vf,
10860 (void *)&cmd_flow_director_queue,
10861 (void *)&cmd_flow_director_queue_id,
10862 (void *)&cmd_flow_director_fd_id,
10863 (void *)&cmd_flow_director_fd_id_value,
10868 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
10869 .f = cmd_flow_director_filter_parsed,
10871 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
10872 "director entry on NIC",
10874 (void *)&cmd_flow_director_filter,
10875 (void *)&cmd_flow_director_port_id,
10876 (void *)&cmd_flow_director_mode,
10877 (void *)&cmd_flow_director_mode_ip,
10878 (void *)&cmd_flow_director_ops,
10879 (void *)&cmd_flow_director_flow,
10880 (void *)&cmd_flow_director_flow_type,
10881 (void *)&cmd_flow_director_src,
10882 (void *)&cmd_flow_director_ip_src,
10883 (void *)&cmd_flow_director_port_src,
10884 (void *)&cmd_flow_director_dst,
10885 (void *)&cmd_flow_director_ip_dst,
10886 (void *)&cmd_flow_director_port_dst,
10887 (void *)&cmd_flow_director_verify_tag,
10888 (void *)&cmd_flow_director_verify_tag_value,
10889 (void *)&cmd_flow_director_tos,
10890 (void *)&cmd_flow_director_tos_value,
10891 (void *)&cmd_flow_director_ttl,
10892 (void *)&cmd_flow_director_ttl_value,
10893 (void *)&cmd_flow_director_vlan,
10894 (void *)&cmd_flow_director_vlan_value,
10895 (void *)&cmd_flow_director_flexbytes,
10896 (void *)&cmd_flow_director_flexbytes_value,
10897 (void *)&cmd_flow_director_drop,
10898 (void *)&cmd_flow_director_pf_vf,
10899 (void *)&cmd_flow_director_queue,
10900 (void *)&cmd_flow_director_queue_id,
10901 (void *)&cmd_flow_director_fd_id,
10902 (void *)&cmd_flow_director_fd_id_value,
10907 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
10908 .f = cmd_flow_director_filter_parsed,
10910 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
10911 "director entry on NIC",
10913 (void *)&cmd_flow_director_filter,
10914 (void *)&cmd_flow_director_port_id,
10915 (void *)&cmd_flow_director_mode,
10916 (void *)&cmd_flow_director_mode_ip,
10917 (void *)&cmd_flow_director_ops,
10918 (void *)&cmd_flow_director_flow,
10919 (void *)&cmd_flow_director_flow_type,
10920 (void *)&cmd_flow_director_ether,
10921 (void *)&cmd_flow_director_ether_type,
10922 (void *)&cmd_flow_director_flexbytes,
10923 (void *)&cmd_flow_director_flexbytes_value,
10924 (void *)&cmd_flow_director_drop,
10925 (void *)&cmd_flow_director_pf_vf,
10926 (void *)&cmd_flow_director_queue,
10927 (void *)&cmd_flow_director_queue_id,
10928 (void *)&cmd_flow_director_fd_id,
10929 (void *)&cmd_flow_director_fd_id_value,
10934 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
10935 .f = cmd_flow_director_filter_parsed,
10937 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
10938 "director entry on NIC",
10940 (void *)&cmd_flow_director_filter,
10941 (void *)&cmd_flow_director_port_id,
10942 (void *)&cmd_flow_director_mode,
10943 (void *)&cmd_flow_director_mode_mac_vlan,
10944 (void *)&cmd_flow_director_ops,
10945 (void *)&cmd_flow_director_mac,
10946 (void *)&cmd_flow_director_mac_addr,
10947 (void *)&cmd_flow_director_vlan,
10948 (void *)&cmd_flow_director_vlan_value,
10949 (void *)&cmd_flow_director_flexbytes,
10950 (void *)&cmd_flow_director_flexbytes_value,
10951 (void *)&cmd_flow_director_drop,
10952 (void *)&cmd_flow_director_queue,
10953 (void *)&cmd_flow_director_queue_id,
10954 (void *)&cmd_flow_director_fd_id,
10955 (void *)&cmd_flow_director_fd_id_value,
10960 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
10961 .f = cmd_flow_director_filter_parsed,
10963 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
10964 "director entry on NIC",
10966 (void *)&cmd_flow_director_filter,
10967 (void *)&cmd_flow_director_port_id,
10968 (void *)&cmd_flow_director_mode,
10969 (void *)&cmd_flow_director_mode_tunnel,
10970 (void *)&cmd_flow_director_ops,
10971 (void *)&cmd_flow_director_mac,
10972 (void *)&cmd_flow_director_mac_addr,
10973 (void *)&cmd_flow_director_vlan,
10974 (void *)&cmd_flow_director_vlan_value,
10975 (void *)&cmd_flow_director_tunnel,
10976 (void *)&cmd_flow_director_tunnel_type,
10977 (void *)&cmd_flow_director_tunnel_id,
10978 (void *)&cmd_flow_director_tunnel_id_value,
10979 (void *)&cmd_flow_director_flexbytes,
10980 (void *)&cmd_flow_director_flexbytes_value,
10981 (void *)&cmd_flow_director_drop,
10982 (void *)&cmd_flow_director_queue,
10983 (void *)&cmd_flow_director_queue_id,
10984 (void *)&cmd_flow_director_fd_id,
10985 (void *)&cmd_flow_director_fd_id_value,
10990 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
10991 .f = cmd_flow_director_filter_parsed,
10993 .help_str = "flow_director_filter ... : Add or delete a raw flow "
10994 "director entry on NIC",
10996 (void *)&cmd_flow_director_filter,
10997 (void *)&cmd_flow_director_port_id,
10998 (void *)&cmd_flow_director_mode,
10999 (void *)&cmd_flow_director_mode_raw,
11000 (void *)&cmd_flow_director_ops,
11001 (void *)&cmd_flow_director_flow,
11002 (void *)&cmd_flow_director_flow_type,
11003 (void *)&cmd_flow_director_drop,
11004 (void *)&cmd_flow_director_queue,
11005 (void *)&cmd_flow_director_queue_id,
11006 (void *)&cmd_flow_director_fd_id,
11007 (void *)&cmd_flow_director_fd_id_value,
11008 (void *)&cmd_flow_director_packet,
11009 (void *)&cmd_flow_director_filepath,
11014 struct cmd_flush_flow_director_result {
11015 cmdline_fixed_string_t flush_flow_director;
11019 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
11020 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
11021 flush_flow_director, "flush_flow_director");
11022 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
11023 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
11027 cmd_flush_flow_director_parsed(void *parsed_result,
11028 __attribute__((unused)) struct cmdline *cl,
11029 __attribute__((unused)) void *data)
11031 struct cmd_flow_director_result *res = parsed_result;
11034 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11036 printf("flow director is not supported on port %u.\n",
11041 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11042 RTE_ETH_FILTER_FLUSH, NULL);
11044 printf("flow director table flushing error: (%s)\n",
11048 cmdline_parse_inst_t cmd_flush_flow_director = {
11049 .f = cmd_flush_flow_director_parsed,
11051 .help_str = "flush_flow_director <port_id>: "
11052 "Flush all flow director entries of a device on NIC",
11054 (void *)&cmd_flush_flow_director_flush,
11055 (void *)&cmd_flush_flow_director_port_id,
11060 /* *** deal with flow director mask *** */
11061 struct cmd_flow_director_mask_result {
11062 cmdline_fixed_string_t flow_director_mask;
11064 cmdline_fixed_string_t mode;
11065 cmdline_fixed_string_t mode_value;
11066 cmdline_fixed_string_t vlan;
11067 uint16_t vlan_mask;
11068 cmdline_fixed_string_t src_mask;
11069 cmdline_ipaddr_t ipv4_src;
11070 cmdline_ipaddr_t ipv6_src;
11072 cmdline_fixed_string_t dst_mask;
11073 cmdline_ipaddr_t ipv4_dst;
11074 cmdline_ipaddr_t ipv6_dst;
11076 cmdline_fixed_string_t mac;
11077 uint8_t mac_addr_byte_mask;
11078 cmdline_fixed_string_t tunnel_id;
11079 uint32_t tunnel_id_mask;
11080 cmdline_fixed_string_t tunnel_type;
11081 uint8_t tunnel_type_mask;
11085 cmd_flow_director_mask_parsed(void *parsed_result,
11086 __attribute__((unused)) struct cmdline *cl,
11087 __attribute__((unused)) void *data)
11089 struct cmd_flow_director_mask_result *res = parsed_result;
11090 struct rte_eth_fdir_masks *mask;
11091 struct rte_port *port;
11093 port = &ports[res->port_id];
11094 /** Check if the port is not started **/
11095 if (port->port_status != RTE_PORT_STOPPED) {
11096 printf("Please stop port %d first\n", res->port_id);
11100 mask = &port->dev_conf.fdir_conf.mask;
11102 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11103 if (strcmp(res->mode_value, "MAC-VLAN")) {
11104 printf("Please set mode to MAC-VLAN.\n");
11108 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11109 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11110 if (strcmp(res->mode_value, "Tunnel")) {
11111 printf("Please set mode to Tunnel.\n");
11115 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11116 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
11117 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
11118 mask->tunnel_type_mask = res->tunnel_type_mask;
11120 if (strcmp(res->mode_value, "IP")) {
11121 printf("Please set mode to IP.\n");
11125 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11126 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
11127 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
11128 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
11129 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
11130 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
11131 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
11134 cmd_reconfig_device_queue(res->port_id, 1, 1);
11137 cmdline_parse_token_string_t cmd_flow_director_mask =
11138 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11139 flow_director_mask, "flow_director_mask");
11140 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
11141 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11143 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
11144 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11146 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
11147 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11148 vlan_mask, UINT16);
11149 cmdline_parse_token_string_t cmd_flow_director_mask_src =
11150 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11151 src_mask, "src_mask");
11152 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
11153 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11155 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
11156 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11158 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
11159 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11161 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
11162 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11163 dst_mask, "dst_mask");
11164 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
11165 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11167 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
11168 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11170 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
11171 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11174 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
11175 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11177 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
11178 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11180 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
11181 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11182 mode_value, "MAC-VLAN");
11183 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
11184 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11185 mode_value, "Tunnel");
11186 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
11187 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11189 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
11190 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11191 mac_addr_byte_mask, UINT8);
11192 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
11193 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11194 tunnel_type, "tunnel-type");
11195 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
11196 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11197 tunnel_type_mask, UINT8);
11198 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
11199 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11200 tunnel_id, "tunnel-id");
11201 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
11202 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11203 tunnel_id_mask, UINT32);
11205 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
11206 .f = cmd_flow_director_mask_parsed,
11208 .help_str = "flow_director_mask ... : "
11209 "Set IP mode flow director's mask on NIC",
11211 (void *)&cmd_flow_director_mask,
11212 (void *)&cmd_flow_director_mask_port_id,
11213 (void *)&cmd_flow_director_mask_mode,
11214 (void *)&cmd_flow_director_mask_mode_ip,
11215 (void *)&cmd_flow_director_mask_vlan,
11216 (void *)&cmd_flow_director_mask_vlan_value,
11217 (void *)&cmd_flow_director_mask_src,
11218 (void *)&cmd_flow_director_mask_ipv4_src,
11219 (void *)&cmd_flow_director_mask_ipv6_src,
11220 (void *)&cmd_flow_director_mask_port_src,
11221 (void *)&cmd_flow_director_mask_dst,
11222 (void *)&cmd_flow_director_mask_ipv4_dst,
11223 (void *)&cmd_flow_director_mask_ipv6_dst,
11224 (void *)&cmd_flow_director_mask_port_dst,
11229 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
11230 .f = cmd_flow_director_mask_parsed,
11232 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
11233 "flow director's mask on NIC",
11235 (void *)&cmd_flow_director_mask,
11236 (void *)&cmd_flow_director_mask_port_id,
11237 (void *)&cmd_flow_director_mask_mode,
11238 (void *)&cmd_flow_director_mask_mode_mac_vlan,
11239 (void *)&cmd_flow_director_mask_vlan,
11240 (void *)&cmd_flow_director_mask_vlan_value,
11245 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
11246 .f = cmd_flow_director_mask_parsed,
11248 .help_str = "flow_director_mask ... : Set tunnel mode "
11249 "flow director's mask on NIC",
11251 (void *)&cmd_flow_director_mask,
11252 (void *)&cmd_flow_director_mask_port_id,
11253 (void *)&cmd_flow_director_mask_mode,
11254 (void *)&cmd_flow_director_mask_mode_tunnel,
11255 (void *)&cmd_flow_director_mask_vlan,
11256 (void *)&cmd_flow_director_mask_vlan_value,
11257 (void *)&cmd_flow_director_mask_mac,
11258 (void *)&cmd_flow_director_mask_mac_value,
11259 (void *)&cmd_flow_director_mask_tunnel_type,
11260 (void *)&cmd_flow_director_mask_tunnel_type_value,
11261 (void *)&cmd_flow_director_mask_tunnel_id,
11262 (void *)&cmd_flow_director_mask_tunnel_id_value,
11267 /* *** deal with flow director mask on flexible payload *** */
11268 struct cmd_flow_director_flex_mask_result {
11269 cmdline_fixed_string_t flow_director_flexmask;
11271 cmdline_fixed_string_t flow;
11272 cmdline_fixed_string_t flow_type;
11273 cmdline_fixed_string_t mask;
11277 cmd_flow_director_flex_mask_parsed(void *parsed_result,
11278 __attribute__((unused)) struct cmdline *cl,
11279 __attribute__((unused)) void *data)
11281 struct cmd_flow_director_flex_mask_result *res = parsed_result;
11282 struct rte_eth_fdir_info fdir_info;
11283 struct rte_eth_fdir_flex_mask flex_mask;
11284 struct rte_port *port;
11285 uint64_t flow_type_mask;
11289 port = &ports[res->port_id];
11290 /** Check if the port is not started **/
11291 if (port->port_status != RTE_PORT_STOPPED) {
11292 printf("Please stop port %d first\n", res->port_id);
11296 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
11297 ret = parse_flexbytes(res->mask,
11299 RTE_ETH_FDIR_MAX_FLEXLEN);
11301 printf("error: Cannot parse mask input.\n");
11305 memset(&fdir_info, 0, sizeof(fdir_info));
11306 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11307 RTE_ETH_FILTER_INFO, &fdir_info);
11309 printf("Cannot get FDir filter info\n");
11313 if (!strcmp(res->flow_type, "none")) {
11314 /* means don't specify the flow type */
11315 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
11316 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
11317 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
11318 0, sizeof(struct rte_eth_fdir_flex_mask));
11319 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
11320 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
11322 sizeof(struct rte_eth_fdir_flex_mask));
11323 cmd_reconfig_device_queue(res->port_id, 1, 1);
11326 flow_type_mask = fdir_info.flow_types_mask[0];
11327 if (!strcmp(res->flow_type, "all")) {
11328 if (!flow_type_mask) {
11329 printf("No flow type supported\n");
11332 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
11333 if (flow_type_mask & (1ULL << i)) {
11334 flex_mask.flow_type = i;
11335 fdir_set_flex_mask(res->port_id, &flex_mask);
11338 cmd_reconfig_device_queue(res->port_id, 1, 1);
11341 flex_mask.flow_type = str2flowtype(res->flow_type);
11342 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
11343 printf("Flow type %s not supported on port %d\n",
11344 res->flow_type, res->port_id);
11347 fdir_set_flex_mask(res->port_id, &flex_mask);
11348 cmd_reconfig_device_queue(res->port_id, 1, 1);
11351 cmdline_parse_token_string_t cmd_flow_director_flexmask =
11352 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11353 flow_director_flexmask,
11354 "flow_director_flex_mask");
11355 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
11356 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11358 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
11359 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11361 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
11362 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11363 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
11364 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
11365 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
11366 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11369 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
11370 .f = cmd_flow_director_flex_mask_parsed,
11372 .help_str = "flow_director_flex_mask ... : "
11373 "Set flow director's flex mask on NIC",
11375 (void *)&cmd_flow_director_flexmask,
11376 (void *)&cmd_flow_director_flexmask_port_id,
11377 (void *)&cmd_flow_director_flexmask_flow,
11378 (void *)&cmd_flow_director_flexmask_flow_type,
11379 (void *)&cmd_flow_director_flexmask_mask,
11384 /* *** deal with flow director flexible payload configuration *** */
11385 struct cmd_flow_director_flexpayload_result {
11386 cmdline_fixed_string_t flow_director_flexpayload;
11388 cmdline_fixed_string_t payload_layer;
11389 cmdline_fixed_string_t payload_cfg;
11393 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
11396 const char *p, *p0 = q_arg;
11398 unsigned long int_fld;
11399 char *str_fld[max_num];
11404 p = strchr(p0, '(');
11408 p0 = strchr(p, ')');
11413 if (size >= sizeof(s))
11416 snprintf(s, sizeof(s), "%.*s", size, p);
11417 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
11418 if (ret < 0 || ret > max_num)
11420 for (i = 0; i < ret; i++) {
11422 int_fld = strtoul(str_fld[i], &end, 0);
11423 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
11425 offsets[i] = (uint16_t)int_fld;
11431 cmd_flow_director_flxpld_parsed(void *parsed_result,
11432 __attribute__((unused)) struct cmdline *cl,
11433 __attribute__((unused)) void *data)
11435 struct cmd_flow_director_flexpayload_result *res = parsed_result;
11436 struct rte_eth_flex_payload_cfg flex_cfg;
11437 struct rte_port *port;
11440 port = &ports[res->port_id];
11441 /** Check if the port is not started **/
11442 if (port->port_status != RTE_PORT_STOPPED) {
11443 printf("Please stop port %d first\n", res->port_id);
11447 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
11449 if (!strcmp(res->payload_layer, "raw"))
11450 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
11451 else if (!strcmp(res->payload_layer, "l2"))
11452 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
11453 else if (!strcmp(res->payload_layer, "l3"))
11454 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
11455 else if (!strcmp(res->payload_layer, "l4"))
11456 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
11458 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
11459 RTE_ETH_FDIR_MAX_FLEXLEN);
11461 printf("error: Cannot parse flex payload input.\n");
11465 fdir_set_flex_payload(res->port_id, &flex_cfg);
11466 cmd_reconfig_device_queue(res->port_id, 1, 1);
11469 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
11470 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11471 flow_director_flexpayload,
11472 "flow_director_flex_payload");
11473 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
11474 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11476 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
11477 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11478 payload_layer, "raw#l2#l3#l4");
11479 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
11480 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11481 payload_cfg, NULL);
11483 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
11484 .f = cmd_flow_director_flxpld_parsed,
11486 .help_str = "flow_director_flexpayload ... : "
11487 "Set flow director's flex payload on NIC",
11489 (void *)&cmd_flow_director_flexpayload,
11490 (void *)&cmd_flow_director_flexpayload_port_id,
11491 (void *)&cmd_flow_director_flexpayload_payload_layer,
11492 (void *)&cmd_flow_director_flexpayload_payload_cfg,
11497 /* Generic flow interface command. */
11498 extern cmdline_parse_inst_t cmd_flow;
11500 /* *** Classification Filters Control *** */
11501 /* *** Get symmetric hash enable per port *** */
11502 struct cmd_get_sym_hash_ena_per_port_result {
11503 cmdline_fixed_string_t get_sym_hash_ena_per_port;
11508 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
11509 __rte_unused struct cmdline *cl,
11510 __rte_unused void *data)
11512 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
11513 struct rte_eth_hash_filter_info info;
11516 if (rte_eth_dev_filter_supported(res->port_id,
11517 RTE_ETH_FILTER_HASH) < 0) {
11518 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11523 memset(&info, 0, sizeof(info));
11524 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11525 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11526 RTE_ETH_FILTER_GET, &info);
11529 printf("Cannot get symmetric hash enable per port "
11530 "on port %u\n", res->port_id);
11534 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
11535 "enabled" : "disabled", res->port_id);
11538 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
11539 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11540 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
11541 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
11542 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11545 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
11546 .f = cmd_get_sym_hash_per_port_parsed,
11548 .help_str = "get_sym_hash_ena_per_port <port_id>",
11550 (void *)&cmd_get_sym_hash_ena_per_port_all,
11551 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
11556 /* *** Set symmetric hash enable per port *** */
11557 struct cmd_set_sym_hash_ena_per_port_result {
11558 cmdline_fixed_string_t set_sym_hash_ena_per_port;
11559 cmdline_fixed_string_t enable;
11564 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
11565 __rte_unused struct cmdline *cl,
11566 __rte_unused void *data)
11568 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
11569 struct rte_eth_hash_filter_info info;
11572 if (rte_eth_dev_filter_supported(res->port_id,
11573 RTE_ETH_FILTER_HASH) < 0) {
11574 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11579 memset(&info, 0, sizeof(info));
11580 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11581 if (!strcmp(res->enable, "enable"))
11582 info.info.enable = 1;
11583 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11584 RTE_ETH_FILTER_SET, &info);
11586 printf("Cannot set symmetric hash enable per port on "
11587 "port %u\n", res->port_id);
11590 printf("Symmetric hash has been set to %s on port %u\n",
11591 res->enable, res->port_id);
11594 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
11595 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11596 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
11597 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
11598 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11600 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
11601 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11602 enable, "enable#disable");
11604 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
11605 .f = cmd_set_sym_hash_per_port_parsed,
11607 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
11609 (void *)&cmd_set_sym_hash_ena_per_port_all,
11610 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
11611 (void *)&cmd_set_sym_hash_ena_per_port_enable,
11616 /* Get global config of hash function */
11617 struct cmd_get_hash_global_config_result {
11618 cmdline_fixed_string_t get_hash_global_config;
11623 flowtype_to_str(uint16_t ftype)
11629 } ftype_table[] = {
11630 {"ipv4", RTE_ETH_FLOW_IPV4},
11631 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
11632 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
11633 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
11634 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
11635 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
11636 {"ipv6", RTE_ETH_FLOW_IPV6},
11637 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
11638 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
11639 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
11640 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
11641 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
11642 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
11643 {"port", RTE_ETH_FLOW_PORT},
11644 {"vxlan", RTE_ETH_FLOW_VXLAN},
11645 {"geneve", RTE_ETH_FLOW_GENEVE},
11646 {"nvgre", RTE_ETH_FLOW_NVGRE},
11649 for (i = 0; i < RTE_DIM(ftype_table); i++) {
11650 if (ftype_table[i].ftype == ftype)
11651 return ftype_table[i].str;
11658 cmd_get_hash_global_config_parsed(void *parsed_result,
11659 __rte_unused struct cmdline *cl,
11660 __rte_unused void *data)
11662 struct cmd_get_hash_global_config_result *res = parsed_result;
11663 struct rte_eth_hash_filter_info info;
11664 uint32_t idx, offset;
11669 if (rte_eth_dev_filter_supported(res->port_id,
11670 RTE_ETH_FILTER_HASH) < 0) {
11671 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11676 memset(&info, 0, sizeof(info));
11677 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11678 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11679 RTE_ETH_FILTER_GET, &info);
11681 printf("Cannot get hash global configurations by port %d\n",
11686 switch (info.info.global_conf.hash_func) {
11687 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
11688 printf("Hash function is Toeplitz\n");
11690 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
11691 printf("Hash function is Simple XOR\n");
11694 printf("Unknown hash function\n");
11698 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
11699 idx = i / UINT64_BIT;
11700 offset = i % UINT64_BIT;
11701 if (!(info.info.global_conf.valid_bit_mask[idx] &
11704 str = flowtype_to_str(i);
11707 printf("Symmetric hash is %s globally for flow type %s "
11709 ((info.info.global_conf.sym_hash_enable_mask[idx] &
11710 (1ULL << offset)) ? "enabled" : "disabled"), str,
11715 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
11716 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
11717 get_hash_global_config, "get_hash_global_config");
11718 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
11719 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
11722 cmdline_parse_inst_t cmd_get_hash_global_config = {
11723 .f = cmd_get_hash_global_config_parsed,
11725 .help_str = "get_hash_global_config <port_id>",
11727 (void *)&cmd_get_hash_global_config_all,
11728 (void *)&cmd_get_hash_global_config_port_id,
11733 /* Set global config of hash function */
11734 struct cmd_set_hash_global_config_result {
11735 cmdline_fixed_string_t set_hash_global_config;
11737 cmdline_fixed_string_t hash_func;
11738 cmdline_fixed_string_t flow_type;
11739 cmdline_fixed_string_t enable;
11743 cmd_set_hash_global_config_parsed(void *parsed_result,
11744 __rte_unused struct cmdline *cl,
11745 __rte_unused void *data)
11747 struct cmd_set_hash_global_config_result *res = parsed_result;
11748 struct rte_eth_hash_filter_info info;
11749 uint32_t ftype, idx, offset;
11752 if (rte_eth_dev_filter_supported(res->port_id,
11753 RTE_ETH_FILTER_HASH) < 0) {
11754 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11758 memset(&info, 0, sizeof(info));
11759 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11760 if (!strcmp(res->hash_func, "toeplitz"))
11761 info.info.global_conf.hash_func =
11762 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
11763 else if (!strcmp(res->hash_func, "simple_xor"))
11764 info.info.global_conf.hash_func =
11765 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
11766 else if (!strcmp(res->hash_func, "default"))
11767 info.info.global_conf.hash_func =
11768 RTE_ETH_HASH_FUNCTION_DEFAULT;
11770 ftype = str2flowtype(res->flow_type);
11771 idx = ftype / UINT64_BIT;
11772 offset = ftype % UINT64_BIT;
11773 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
11774 if (!strcmp(res->enable, "enable"))
11775 info.info.global_conf.sym_hash_enable_mask[idx] |=
11777 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11778 RTE_ETH_FILTER_SET, &info);
11780 printf("Cannot set global hash configurations by port %d\n",
11783 printf("Global hash configurations have been set "
11784 "succcessfully by port %d\n", res->port_id);
11787 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
11788 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11789 set_hash_global_config, "set_hash_global_config");
11790 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
11791 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
11793 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
11794 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11795 hash_func, "toeplitz#simple_xor#default");
11796 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
11797 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11799 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
11800 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11801 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
11802 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11803 enable, "enable#disable");
11805 cmdline_parse_inst_t cmd_set_hash_global_config = {
11806 .f = cmd_set_hash_global_config_parsed,
11808 .help_str = "set_hash_global_config <port_id> "
11809 "toeplitz|simple_xor|default "
11810 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11811 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
11812 "l2_payload enable|disable",
11814 (void *)&cmd_set_hash_global_config_all,
11815 (void *)&cmd_set_hash_global_config_port_id,
11816 (void *)&cmd_set_hash_global_config_hash_func,
11817 (void *)&cmd_set_hash_global_config_flow_type,
11818 (void *)&cmd_set_hash_global_config_enable,
11823 /* Set hash input set */
11824 struct cmd_set_hash_input_set_result {
11825 cmdline_fixed_string_t set_hash_input_set;
11827 cmdline_fixed_string_t flow_type;
11828 cmdline_fixed_string_t inset_field;
11829 cmdline_fixed_string_t select;
11832 static enum rte_eth_input_set_field
11833 str2inset(char *string)
11837 static const struct {
11839 enum rte_eth_input_set_field inset;
11840 } inset_table[] = {
11841 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
11842 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
11843 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
11844 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
11845 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
11846 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
11847 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
11848 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
11849 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
11850 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
11851 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
11852 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
11853 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
11854 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
11855 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
11856 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
11857 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
11858 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
11859 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
11860 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
11861 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
11862 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
11863 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
11864 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
11865 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
11866 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
11867 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
11868 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
11869 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
11870 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
11871 {"none", RTE_ETH_INPUT_SET_NONE},
11874 for (i = 0; i < RTE_DIM(inset_table); i++) {
11875 if (!strcmp(string, inset_table[i].str))
11876 return inset_table[i].inset;
11879 return RTE_ETH_INPUT_SET_UNKNOWN;
11883 cmd_set_hash_input_set_parsed(void *parsed_result,
11884 __rte_unused struct cmdline *cl,
11885 __rte_unused void *data)
11887 struct cmd_set_hash_input_set_result *res = parsed_result;
11888 struct rte_eth_hash_filter_info info;
11890 memset(&info, 0, sizeof(info));
11891 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
11892 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
11893 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
11894 info.info.input_set_conf.inset_size = 1;
11895 if (!strcmp(res->select, "select"))
11896 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
11897 else if (!strcmp(res->select, "add"))
11898 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
11899 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11900 RTE_ETH_FILTER_SET, &info);
11903 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
11904 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11905 set_hash_input_set, "set_hash_input_set");
11906 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
11907 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
11909 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
11910 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11912 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
11913 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11915 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
11916 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
11917 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
11918 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
11919 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
11921 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
11922 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11923 select, "select#add");
11925 cmdline_parse_inst_t cmd_set_hash_input_set = {
11926 .f = cmd_set_hash_input_set_parsed,
11928 .help_str = "set_hash_input_set <port_id> "
11929 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11930 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
11931 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
11932 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
11933 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
11934 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
11935 "fld-7th|fld-8th|none select|add",
11937 (void *)&cmd_set_hash_input_set_cmd,
11938 (void *)&cmd_set_hash_input_set_port_id,
11939 (void *)&cmd_set_hash_input_set_flow_type,
11940 (void *)&cmd_set_hash_input_set_field,
11941 (void *)&cmd_set_hash_input_set_select,
11946 /* Set flow director input set */
11947 struct cmd_set_fdir_input_set_result {
11948 cmdline_fixed_string_t set_fdir_input_set;
11950 cmdline_fixed_string_t flow_type;
11951 cmdline_fixed_string_t inset_field;
11952 cmdline_fixed_string_t select;
11956 cmd_set_fdir_input_set_parsed(void *parsed_result,
11957 __rte_unused struct cmdline *cl,
11958 __rte_unused void *data)
11960 struct cmd_set_fdir_input_set_result *res = parsed_result;
11961 struct rte_eth_fdir_filter_info info;
11963 memset(&info, 0, sizeof(info));
11964 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
11965 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
11966 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
11967 info.info.input_set_conf.inset_size = 1;
11968 if (!strcmp(res->select, "select"))
11969 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
11970 else if (!strcmp(res->select, "add"))
11971 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
11972 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11973 RTE_ETH_FILTER_SET, &info);
11976 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
11977 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11978 set_fdir_input_set, "set_fdir_input_set");
11979 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
11980 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
11982 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
11983 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11985 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
11986 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11987 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
11988 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11990 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
11991 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
11992 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
11993 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
11994 "sctp-veri-tag#none");
11995 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
11996 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11997 select, "select#add");
11999 cmdline_parse_inst_t cmd_set_fdir_input_set = {
12000 .f = cmd_set_fdir_input_set_parsed,
12002 .help_str = "set_fdir_input_set <port_id> "
12003 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12004 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
12005 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
12006 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
12007 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
12008 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
12009 "sctp-veri-tag|none select|add",
12011 (void *)&cmd_set_fdir_input_set_cmd,
12012 (void *)&cmd_set_fdir_input_set_port_id,
12013 (void *)&cmd_set_fdir_input_set_flow_type,
12014 (void *)&cmd_set_fdir_input_set_field,
12015 (void *)&cmd_set_fdir_input_set_select,
12020 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
12021 struct cmd_mcast_addr_result {
12022 cmdline_fixed_string_t mcast_addr_cmd;
12023 cmdline_fixed_string_t what;
12025 struct ether_addr mc_addr;
12028 static void cmd_mcast_addr_parsed(void *parsed_result,
12029 __attribute__((unused)) struct cmdline *cl,
12030 __attribute__((unused)) void *data)
12032 struct cmd_mcast_addr_result *res = parsed_result;
12034 if (!is_multicast_ether_addr(&res->mc_addr)) {
12035 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
12036 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
12037 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
12038 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
12041 if (strcmp(res->what, "add") == 0)
12042 mcast_addr_add(res->port_num, &res->mc_addr);
12044 mcast_addr_remove(res->port_num, &res->mc_addr);
12047 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
12048 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
12049 mcast_addr_cmd, "mcast_addr");
12050 cmdline_parse_token_string_t cmd_mcast_addr_what =
12051 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
12053 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
12054 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
12055 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
12056 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
12058 cmdline_parse_inst_t cmd_mcast_addr = {
12059 .f = cmd_mcast_addr_parsed,
12061 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
12062 "Add/Remove multicast MAC address on port_id",
12064 (void *)&cmd_mcast_addr_cmd,
12065 (void *)&cmd_mcast_addr_what,
12066 (void *)&cmd_mcast_addr_portnum,
12067 (void *)&cmd_mcast_addr_addr,
12072 /* l2 tunnel config
12073 * only support E-tag now.
12076 /* Ether type config */
12077 struct cmd_config_l2_tunnel_eth_type_result {
12078 cmdline_fixed_string_t port;
12079 cmdline_fixed_string_t config;
12080 cmdline_fixed_string_t all;
12082 cmdline_fixed_string_t l2_tunnel;
12083 cmdline_fixed_string_t l2_tunnel_type;
12084 cmdline_fixed_string_t eth_type;
12085 uint16_t eth_type_val;
12088 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
12089 TOKEN_STRING_INITIALIZER
12090 (struct cmd_config_l2_tunnel_eth_type_result,
12092 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
12093 TOKEN_STRING_INITIALIZER
12094 (struct cmd_config_l2_tunnel_eth_type_result,
12096 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
12097 TOKEN_STRING_INITIALIZER
12098 (struct cmd_config_l2_tunnel_eth_type_result,
12100 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
12101 TOKEN_NUM_INITIALIZER
12102 (struct cmd_config_l2_tunnel_eth_type_result,
12104 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
12105 TOKEN_STRING_INITIALIZER
12106 (struct cmd_config_l2_tunnel_eth_type_result,
12107 l2_tunnel, "l2-tunnel");
12108 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
12109 TOKEN_STRING_INITIALIZER
12110 (struct cmd_config_l2_tunnel_eth_type_result,
12111 l2_tunnel_type, "E-tag");
12112 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
12113 TOKEN_STRING_INITIALIZER
12114 (struct cmd_config_l2_tunnel_eth_type_result,
12115 eth_type, "ether-type");
12116 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
12117 TOKEN_NUM_INITIALIZER
12118 (struct cmd_config_l2_tunnel_eth_type_result,
12119 eth_type_val, UINT16);
12121 static enum rte_eth_tunnel_type
12122 str2fdir_l2_tunnel_type(char *string)
12126 static const struct {
12128 enum rte_eth_tunnel_type type;
12129 } l2_tunnel_type_str[] = {
12130 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
12133 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
12134 if (!strcmp(l2_tunnel_type_str[i].str, string))
12135 return l2_tunnel_type_str[i].type;
12137 return RTE_TUNNEL_TYPE_NONE;
12140 /* ether type config for all ports */
12142 cmd_config_l2_tunnel_eth_type_all_parsed
12143 (void *parsed_result,
12144 __attribute__((unused)) struct cmdline *cl,
12145 __attribute__((unused)) void *data)
12147 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
12148 struct rte_eth_l2_tunnel_conf entry;
12151 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12152 entry.ether_type = res->eth_type_val;
12154 RTE_ETH_FOREACH_DEV(pid) {
12155 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
12159 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
12160 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
12162 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
12164 (void *)&cmd_config_l2_tunnel_eth_type_port,
12165 (void *)&cmd_config_l2_tunnel_eth_type_config,
12166 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
12167 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12168 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12169 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12170 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12175 /* ether type config for a specific port */
12177 cmd_config_l2_tunnel_eth_type_specific_parsed(
12178 void *parsed_result,
12179 __attribute__((unused)) struct cmdline *cl,
12180 __attribute__((unused)) void *data)
12182 struct cmd_config_l2_tunnel_eth_type_result *res =
12184 struct rte_eth_l2_tunnel_conf entry;
12186 if (port_id_is_invalid(res->id, ENABLED_WARN))
12189 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12190 entry.ether_type = res->eth_type_val;
12192 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
12195 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
12196 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
12198 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
12200 (void *)&cmd_config_l2_tunnel_eth_type_port,
12201 (void *)&cmd_config_l2_tunnel_eth_type_config,
12202 (void *)&cmd_config_l2_tunnel_eth_type_id,
12203 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12204 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12205 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12206 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12211 /* Enable/disable l2 tunnel */
12212 struct cmd_config_l2_tunnel_en_dis_result {
12213 cmdline_fixed_string_t port;
12214 cmdline_fixed_string_t config;
12215 cmdline_fixed_string_t all;
12217 cmdline_fixed_string_t l2_tunnel;
12218 cmdline_fixed_string_t l2_tunnel_type;
12219 cmdline_fixed_string_t en_dis;
12222 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
12223 TOKEN_STRING_INITIALIZER
12224 (struct cmd_config_l2_tunnel_en_dis_result,
12226 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
12227 TOKEN_STRING_INITIALIZER
12228 (struct cmd_config_l2_tunnel_en_dis_result,
12230 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
12231 TOKEN_STRING_INITIALIZER
12232 (struct cmd_config_l2_tunnel_en_dis_result,
12234 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
12235 TOKEN_NUM_INITIALIZER
12236 (struct cmd_config_l2_tunnel_en_dis_result,
12238 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
12239 TOKEN_STRING_INITIALIZER
12240 (struct cmd_config_l2_tunnel_en_dis_result,
12241 l2_tunnel, "l2-tunnel");
12242 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
12243 TOKEN_STRING_INITIALIZER
12244 (struct cmd_config_l2_tunnel_en_dis_result,
12245 l2_tunnel_type, "E-tag");
12246 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
12247 TOKEN_STRING_INITIALIZER
12248 (struct cmd_config_l2_tunnel_en_dis_result,
12249 en_dis, "enable#disable");
12251 /* enable/disable l2 tunnel for all ports */
12253 cmd_config_l2_tunnel_en_dis_all_parsed(
12254 void *parsed_result,
12255 __attribute__((unused)) struct cmdline *cl,
12256 __attribute__((unused)) void *data)
12258 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
12259 struct rte_eth_l2_tunnel_conf entry;
12263 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12265 if (!strcmp("enable", res->en_dis))
12270 RTE_ETH_FOREACH_DEV(pid) {
12271 rte_eth_dev_l2_tunnel_offload_set(pid,
12273 ETH_L2_TUNNEL_ENABLE_MASK,
12278 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
12279 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
12281 .help_str = "port config all l2-tunnel E-tag enable|disable",
12283 (void *)&cmd_config_l2_tunnel_en_dis_port,
12284 (void *)&cmd_config_l2_tunnel_en_dis_config,
12285 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
12286 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12287 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12288 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12293 /* enable/disable l2 tunnel for a port */
12295 cmd_config_l2_tunnel_en_dis_specific_parsed(
12296 void *parsed_result,
12297 __attribute__((unused)) struct cmdline *cl,
12298 __attribute__((unused)) void *data)
12300 struct cmd_config_l2_tunnel_en_dis_result *res =
12302 struct rte_eth_l2_tunnel_conf entry;
12304 if (port_id_is_invalid(res->id, ENABLED_WARN))
12307 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12309 if (!strcmp("enable", res->en_dis))
12310 rte_eth_dev_l2_tunnel_offload_set(res->id,
12312 ETH_L2_TUNNEL_ENABLE_MASK,
12315 rte_eth_dev_l2_tunnel_offload_set(res->id,
12317 ETH_L2_TUNNEL_ENABLE_MASK,
12321 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
12322 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
12324 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
12326 (void *)&cmd_config_l2_tunnel_en_dis_port,
12327 (void *)&cmd_config_l2_tunnel_en_dis_config,
12328 (void *)&cmd_config_l2_tunnel_en_dis_id,
12329 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12330 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12331 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12336 /* E-tag configuration */
12338 /* Common result structure for all E-tag configuration */
12339 struct cmd_config_e_tag_result {
12340 cmdline_fixed_string_t e_tag;
12341 cmdline_fixed_string_t set;
12342 cmdline_fixed_string_t insertion;
12343 cmdline_fixed_string_t stripping;
12344 cmdline_fixed_string_t forwarding;
12345 cmdline_fixed_string_t filter;
12346 cmdline_fixed_string_t add;
12347 cmdline_fixed_string_t del;
12348 cmdline_fixed_string_t on;
12349 cmdline_fixed_string_t off;
12350 cmdline_fixed_string_t on_off;
12351 cmdline_fixed_string_t port_tag_id;
12352 uint32_t port_tag_id_val;
12353 cmdline_fixed_string_t e_tag_id;
12354 uint16_t e_tag_id_val;
12355 cmdline_fixed_string_t dst_pool;
12356 uint8_t dst_pool_val;
12357 cmdline_fixed_string_t port;
12359 cmdline_fixed_string_t vf;
12363 /* Common CLI fields for all E-tag configuration */
12364 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
12365 TOKEN_STRING_INITIALIZER
12366 (struct cmd_config_e_tag_result,
12368 cmdline_parse_token_string_t cmd_config_e_tag_set =
12369 TOKEN_STRING_INITIALIZER
12370 (struct cmd_config_e_tag_result,
12372 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
12373 TOKEN_STRING_INITIALIZER
12374 (struct cmd_config_e_tag_result,
12375 insertion, "insertion");
12376 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
12377 TOKEN_STRING_INITIALIZER
12378 (struct cmd_config_e_tag_result,
12379 stripping, "stripping");
12380 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
12381 TOKEN_STRING_INITIALIZER
12382 (struct cmd_config_e_tag_result,
12383 forwarding, "forwarding");
12384 cmdline_parse_token_string_t cmd_config_e_tag_filter =
12385 TOKEN_STRING_INITIALIZER
12386 (struct cmd_config_e_tag_result,
12388 cmdline_parse_token_string_t cmd_config_e_tag_add =
12389 TOKEN_STRING_INITIALIZER
12390 (struct cmd_config_e_tag_result,
12392 cmdline_parse_token_string_t cmd_config_e_tag_del =
12393 TOKEN_STRING_INITIALIZER
12394 (struct cmd_config_e_tag_result,
12396 cmdline_parse_token_string_t cmd_config_e_tag_on =
12397 TOKEN_STRING_INITIALIZER
12398 (struct cmd_config_e_tag_result,
12400 cmdline_parse_token_string_t cmd_config_e_tag_off =
12401 TOKEN_STRING_INITIALIZER
12402 (struct cmd_config_e_tag_result,
12404 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
12405 TOKEN_STRING_INITIALIZER
12406 (struct cmd_config_e_tag_result,
12408 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
12409 TOKEN_STRING_INITIALIZER
12410 (struct cmd_config_e_tag_result,
12411 port_tag_id, "port-tag-id");
12412 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
12413 TOKEN_NUM_INITIALIZER
12414 (struct cmd_config_e_tag_result,
12415 port_tag_id_val, UINT32);
12416 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
12417 TOKEN_STRING_INITIALIZER
12418 (struct cmd_config_e_tag_result,
12419 e_tag_id, "e-tag-id");
12420 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
12421 TOKEN_NUM_INITIALIZER
12422 (struct cmd_config_e_tag_result,
12423 e_tag_id_val, UINT16);
12424 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
12425 TOKEN_STRING_INITIALIZER
12426 (struct cmd_config_e_tag_result,
12427 dst_pool, "dst-pool");
12428 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
12429 TOKEN_NUM_INITIALIZER
12430 (struct cmd_config_e_tag_result,
12431 dst_pool_val, UINT8);
12432 cmdline_parse_token_string_t cmd_config_e_tag_port =
12433 TOKEN_STRING_INITIALIZER
12434 (struct cmd_config_e_tag_result,
12436 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
12437 TOKEN_NUM_INITIALIZER
12438 (struct cmd_config_e_tag_result,
12440 cmdline_parse_token_string_t cmd_config_e_tag_vf =
12441 TOKEN_STRING_INITIALIZER
12442 (struct cmd_config_e_tag_result,
12444 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
12445 TOKEN_NUM_INITIALIZER
12446 (struct cmd_config_e_tag_result,
12449 /* E-tag insertion configuration */
12451 cmd_config_e_tag_insertion_en_parsed(
12452 void *parsed_result,
12453 __attribute__((unused)) struct cmdline *cl,
12454 __attribute__((unused)) void *data)
12456 struct cmd_config_e_tag_result *res =
12458 struct rte_eth_l2_tunnel_conf entry;
12460 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12463 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12464 entry.tunnel_id = res->port_tag_id_val;
12465 entry.vf_id = res->vf_id;
12466 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12468 ETH_L2_TUNNEL_INSERTION_MASK,
12473 cmd_config_e_tag_insertion_dis_parsed(
12474 void *parsed_result,
12475 __attribute__((unused)) struct cmdline *cl,
12476 __attribute__((unused)) void *data)
12478 struct cmd_config_e_tag_result *res =
12480 struct rte_eth_l2_tunnel_conf entry;
12482 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12485 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12486 entry.vf_id = res->vf_id;
12488 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12490 ETH_L2_TUNNEL_INSERTION_MASK,
12494 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
12495 .f = cmd_config_e_tag_insertion_en_parsed,
12497 .help_str = "E-tag ... : E-tag insertion enable",
12499 (void *)&cmd_config_e_tag_e_tag,
12500 (void *)&cmd_config_e_tag_set,
12501 (void *)&cmd_config_e_tag_insertion,
12502 (void *)&cmd_config_e_tag_on,
12503 (void *)&cmd_config_e_tag_port_tag_id,
12504 (void *)&cmd_config_e_tag_port_tag_id_val,
12505 (void *)&cmd_config_e_tag_port,
12506 (void *)&cmd_config_e_tag_port_id,
12507 (void *)&cmd_config_e_tag_vf,
12508 (void *)&cmd_config_e_tag_vf_id,
12513 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
12514 .f = cmd_config_e_tag_insertion_dis_parsed,
12516 .help_str = "E-tag ... : E-tag insertion disable",
12518 (void *)&cmd_config_e_tag_e_tag,
12519 (void *)&cmd_config_e_tag_set,
12520 (void *)&cmd_config_e_tag_insertion,
12521 (void *)&cmd_config_e_tag_off,
12522 (void *)&cmd_config_e_tag_port,
12523 (void *)&cmd_config_e_tag_port_id,
12524 (void *)&cmd_config_e_tag_vf,
12525 (void *)&cmd_config_e_tag_vf_id,
12530 /* E-tag stripping configuration */
12532 cmd_config_e_tag_stripping_parsed(
12533 void *parsed_result,
12534 __attribute__((unused)) struct cmdline *cl,
12535 __attribute__((unused)) void *data)
12537 struct cmd_config_e_tag_result *res =
12539 struct rte_eth_l2_tunnel_conf entry;
12541 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12544 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12546 if (!strcmp(res->on_off, "on"))
12547 rte_eth_dev_l2_tunnel_offload_set
12550 ETH_L2_TUNNEL_STRIPPING_MASK,
12553 rte_eth_dev_l2_tunnel_offload_set
12556 ETH_L2_TUNNEL_STRIPPING_MASK,
12560 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
12561 .f = cmd_config_e_tag_stripping_parsed,
12563 .help_str = "E-tag ... : E-tag stripping enable/disable",
12565 (void *)&cmd_config_e_tag_e_tag,
12566 (void *)&cmd_config_e_tag_set,
12567 (void *)&cmd_config_e_tag_stripping,
12568 (void *)&cmd_config_e_tag_on_off,
12569 (void *)&cmd_config_e_tag_port,
12570 (void *)&cmd_config_e_tag_port_id,
12575 /* E-tag forwarding configuration */
12577 cmd_config_e_tag_forwarding_parsed(
12578 void *parsed_result,
12579 __attribute__((unused)) struct cmdline *cl,
12580 __attribute__((unused)) void *data)
12582 struct cmd_config_e_tag_result *res = parsed_result;
12583 struct rte_eth_l2_tunnel_conf entry;
12585 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12588 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12590 if (!strcmp(res->on_off, "on"))
12591 rte_eth_dev_l2_tunnel_offload_set
12594 ETH_L2_TUNNEL_FORWARDING_MASK,
12597 rte_eth_dev_l2_tunnel_offload_set
12600 ETH_L2_TUNNEL_FORWARDING_MASK,
12604 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
12605 .f = cmd_config_e_tag_forwarding_parsed,
12607 .help_str = "E-tag ... : E-tag forwarding enable/disable",
12609 (void *)&cmd_config_e_tag_e_tag,
12610 (void *)&cmd_config_e_tag_set,
12611 (void *)&cmd_config_e_tag_forwarding,
12612 (void *)&cmd_config_e_tag_on_off,
12613 (void *)&cmd_config_e_tag_port,
12614 (void *)&cmd_config_e_tag_port_id,
12619 /* E-tag filter configuration */
12621 cmd_config_e_tag_filter_add_parsed(
12622 void *parsed_result,
12623 __attribute__((unused)) struct cmdline *cl,
12624 __attribute__((unused)) void *data)
12626 struct cmd_config_e_tag_result *res = parsed_result;
12627 struct rte_eth_l2_tunnel_conf entry;
12630 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12633 if (res->e_tag_id_val > 0x3fff) {
12634 printf("e-tag-id must be equal or less than 0x3fff.\n");
12638 ret = rte_eth_dev_filter_supported(res->port_id,
12639 RTE_ETH_FILTER_L2_TUNNEL);
12641 printf("E-tag filter is not supported on port %u.\n",
12646 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12647 entry.tunnel_id = res->e_tag_id_val;
12648 entry.pool = res->dst_pool_val;
12650 ret = rte_eth_dev_filter_ctrl(res->port_id,
12651 RTE_ETH_FILTER_L2_TUNNEL,
12652 RTE_ETH_FILTER_ADD,
12655 printf("E-tag filter programming error: (%s)\n",
12659 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
12660 .f = cmd_config_e_tag_filter_add_parsed,
12662 .help_str = "E-tag ... : E-tag filter add",
12664 (void *)&cmd_config_e_tag_e_tag,
12665 (void *)&cmd_config_e_tag_set,
12666 (void *)&cmd_config_e_tag_filter,
12667 (void *)&cmd_config_e_tag_add,
12668 (void *)&cmd_config_e_tag_e_tag_id,
12669 (void *)&cmd_config_e_tag_e_tag_id_val,
12670 (void *)&cmd_config_e_tag_dst_pool,
12671 (void *)&cmd_config_e_tag_dst_pool_val,
12672 (void *)&cmd_config_e_tag_port,
12673 (void *)&cmd_config_e_tag_port_id,
12679 cmd_config_e_tag_filter_del_parsed(
12680 void *parsed_result,
12681 __attribute__((unused)) struct cmdline *cl,
12682 __attribute__((unused)) void *data)
12684 struct cmd_config_e_tag_result *res = parsed_result;
12685 struct rte_eth_l2_tunnel_conf entry;
12688 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12691 if (res->e_tag_id_val > 0x3fff) {
12692 printf("e-tag-id must be less than 0x3fff.\n");
12696 ret = rte_eth_dev_filter_supported(res->port_id,
12697 RTE_ETH_FILTER_L2_TUNNEL);
12699 printf("E-tag filter is not supported on port %u.\n",
12704 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12705 entry.tunnel_id = res->e_tag_id_val;
12707 ret = rte_eth_dev_filter_ctrl(res->port_id,
12708 RTE_ETH_FILTER_L2_TUNNEL,
12709 RTE_ETH_FILTER_DELETE,
12712 printf("E-tag filter programming error: (%s)\n",
12716 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
12717 .f = cmd_config_e_tag_filter_del_parsed,
12719 .help_str = "E-tag ... : E-tag filter delete",
12721 (void *)&cmd_config_e_tag_e_tag,
12722 (void *)&cmd_config_e_tag_set,
12723 (void *)&cmd_config_e_tag_filter,
12724 (void *)&cmd_config_e_tag_del,
12725 (void *)&cmd_config_e_tag_e_tag_id,
12726 (void *)&cmd_config_e_tag_e_tag_id_val,
12727 (void *)&cmd_config_e_tag_port,
12728 (void *)&cmd_config_e_tag_port_id,
12733 /* vf vlan anti spoof configuration */
12735 /* Common result structure for vf vlan anti spoof */
12736 struct cmd_vf_vlan_anti_spoof_result {
12737 cmdline_fixed_string_t set;
12738 cmdline_fixed_string_t vf;
12739 cmdline_fixed_string_t vlan;
12740 cmdline_fixed_string_t antispoof;
12743 cmdline_fixed_string_t on_off;
12746 /* Common CLI fields for vf vlan anti spoof enable disable */
12747 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
12748 TOKEN_STRING_INITIALIZER
12749 (struct cmd_vf_vlan_anti_spoof_result,
12751 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
12752 TOKEN_STRING_INITIALIZER
12753 (struct cmd_vf_vlan_anti_spoof_result,
12755 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
12756 TOKEN_STRING_INITIALIZER
12757 (struct cmd_vf_vlan_anti_spoof_result,
12759 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
12760 TOKEN_STRING_INITIALIZER
12761 (struct cmd_vf_vlan_anti_spoof_result,
12762 antispoof, "antispoof");
12763 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
12764 TOKEN_NUM_INITIALIZER
12765 (struct cmd_vf_vlan_anti_spoof_result,
12767 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
12768 TOKEN_NUM_INITIALIZER
12769 (struct cmd_vf_vlan_anti_spoof_result,
12771 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
12772 TOKEN_STRING_INITIALIZER
12773 (struct cmd_vf_vlan_anti_spoof_result,
12777 cmd_set_vf_vlan_anti_spoof_parsed(
12778 void *parsed_result,
12779 __attribute__((unused)) struct cmdline *cl,
12780 __attribute__((unused)) void *data)
12782 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
12783 int ret = -ENOTSUP;
12785 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12787 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12790 #ifdef RTE_LIBRTE_IXGBE_PMD
12791 if (ret == -ENOTSUP)
12792 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
12793 res->vf_id, is_on);
12795 #ifdef RTE_LIBRTE_I40E_PMD
12796 if (ret == -ENOTSUP)
12797 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
12798 res->vf_id, is_on);
12800 #ifdef RTE_LIBRTE_BNXT_PMD
12801 if (ret == -ENOTSUP)
12802 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
12803 res->vf_id, is_on);
12810 printf("invalid vf_id %d\n", res->vf_id);
12813 printf("invalid port_id %d\n", res->port_id);
12816 printf("function not implemented\n");
12819 printf("programming error: (%s)\n", strerror(-ret));
12823 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
12824 .f = cmd_set_vf_vlan_anti_spoof_parsed,
12826 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
12828 (void *)&cmd_vf_vlan_anti_spoof_set,
12829 (void *)&cmd_vf_vlan_anti_spoof_vf,
12830 (void *)&cmd_vf_vlan_anti_spoof_vlan,
12831 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
12832 (void *)&cmd_vf_vlan_anti_spoof_port_id,
12833 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
12834 (void *)&cmd_vf_vlan_anti_spoof_on_off,
12839 /* vf mac anti spoof configuration */
12841 /* Common result structure for vf mac anti spoof */
12842 struct cmd_vf_mac_anti_spoof_result {
12843 cmdline_fixed_string_t set;
12844 cmdline_fixed_string_t vf;
12845 cmdline_fixed_string_t mac;
12846 cmdline_fixed_string_t antispoof;
12849 cmdline_fixed_string_t on_off;
12852 /* Common CLI fields for vf mac anti spoof enable disable */
12853 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
12854 TOKEN_STRING_INITIALIZER
12855 (struct cmd_vf_mac_anti_spoof_result,
12857 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
12858 TOKEN_STRING_INITIALIZER
12859 (struct cmd_vf_mac_anti_spoof_result,
12861 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
12862 TOKEN_STRING_INITIALIZER
12863 (struct cmd_vf_mac_anti_spoof_result,
12865 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
12866 TOKEN_STRING_INITIALIZER
12867 (struct cmd_vf_mac_anti_spoof_result,
12868 antispoof, "antispoof");
12869 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
12870 TOKEN_NUM_INITIALIZER
12871 (struct cmd_vf_mac_anti_spoof_result,
12873 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
12874 TOKEN_NUM_INITIALIZER
12875 (struct cmd_vf_mac_anti_spoof_result,
12877 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
12878 TOKEN_STRING_INITIALIZER
12879 (struct cmd_vf_mac_anti_spoof_result,
12883 cmd_set_vf_mac_anti_spoof_parsed(
12884 void *parsed_result,
12885 __attribute__((unused)) struct cmdline *cl,
12886 __attribute__((unused)) void *data)
12888 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
12889 int ret = -ENOTSUP;
12891 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12893 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12896 #ifdef RTE_LIBRTE_IXGBE_PMD
12897 if (ret == -ENOTSUP)
12898 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
12899 res->vf_id, is_on);
12901 #ifdef RTE_LIBRTE_I40E_PMD
12902 if (ret == -ENOTSUP)
12903 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
12904 res->vf_id, is_on);
12906 #ifdef RTE_LIBRTE_BNXT_PMD
12907 if (ret == -ENOTSUP)
12908 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
12909 res->vf_id, is_on);
12916 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12919 printf("invalid port_id %d\n", res->port_id);
12922 printf("function not implemented\n");
12925 printf("programming error: (%s)\n", strerror(-ret));
12929 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
12930 .f = cmd_set_vf_mac_anti_spoof_parsed,
12932 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
12934 (void *)&cmd_vf_mac_anti_spoof_set,
12935 (void *)&cmd_vf_mac_anti_spoof_vf,
12936 (void *)&cmd_vf_mac_anti_spoof_mac,
12937 (void *)&cmd_vf_mac_anti_spoof_antispoof,
12938 (void *)&cmd_vf_mac_anti_spoof_port_id,
12939 (void *)&cmd_vf_mac_anti_spoof_vf_id,
12940 (void *)&cmd_vf_mac_anti_spoof_on_off,
12945 /* vf vlan strip queue configuration */
12947 /* Common result structure for vf mac anti spoof */
12948 struct cmd_vf_vlan_stripq_result {
12949 cmdline_fixed_string_t set;
12950 cmdline_fixed_string_t vf;
12951 cmdline_fixed_string_t vlan;
12952 cmdline_fixed_string_t stripq;
12955 cmdline_fixed_string_t on_off;
12958 /* Common CLI fields for vf vlan strip enable disable */
12959 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
12960 TOKEN_STRING_INITIALIZER
12961 (struct cmd_vf_vlan_stripq_result,
12963 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
12964 TOKEN_STRING_INITIALIZER
12965 (struct cmd_vf_vlan_stripq_result,
12967 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
12968 TOKEN_STRING_INITIALIZER
12969 (struct cmd_vf_vlan_stripq_result,
12971 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
12972 TOKEN_STRING_INITIALIZER
12973 (struct cmd_vf_vlan_stripq_result,
12975 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
12976 TOKEN_NUM_INITIALIZER
12977 (struct cmd_vf_vlan_stripq_result,
12979 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
12980 TOKEN_NUM_INITIALIZER
12981 (struct cmd_vf_vlan_stripq_result,
12983 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
12984 TOKEN_STRING_INITIALIZER
12985 (struct cmd_vf_vlan_stripq_result,
12989 cmd_set_vf_vlan_stripq_parsed(
12990 void *parsed_result,
12991 __attribute__((unused)) struct cmdline *cl,
12992 __attribute__((unused)) void *data)
12994 struct cmd_vf_vlan_stripq_result *res = parsed_result;
12995 int ret = -ENOTSUP;
12997 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12999 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13002 #ifdef RTE_LIBRTE_IXGBE_PMD
13003 if (ret == -ENOTSUP)
13004 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
13005 res->vf_id, is_on);
13007 #ifdef RTE_LIBRTE_I40E_PMD
13008 if (ret == -ENOTSUP)
13009 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
13010 res->vf_id, is_on);
13012 #ifdef RTE_LIBRTE_BNXT_PMD
13013 if (ret == -ENOTSUP)
13014 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
13015 res->vf_id, is_on);
13022 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13025 printf("invalid port_id %d\n", res->port_id);
13028 printf("function not implemented\n");
13031 printf("programming error: (%s)\n", strerror(-ret));
13035 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
13036 .f = cmd_set_vf_vlan_stripq_parsed,
13038 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
13040 (void *)&cmd_vf_vlan_stripq_set,
13041 (void *)&cmd_vf_vlan_stripq_vf,
13042 (void *)&cmd_vf_vlan_stripq_vlan,
13043 (void *)&cmd_vf_vlan_stripq_stripq,
13044 (void *)&cmd_vf_vlan_stripq_port_id,
13045 (void *)&cmd_vf_vlan_stripq_vf_id,
13046 (void *)&cmd_vf_vlan_stripq_on_off,
13051 /* vf vlan insert configuration */
13053 /* Common result structure for vf vlan insert */
13054 struct cmd_vf_vlan_insert_result {
13055 cmdline_fixed_string_t set;
13056 cmdline_fixed_string_t vf;
13057 cmdline_fixed_string_t vlan;
13058 cmdline_fixed_string_t insert;
13064 /* Common CLI fields for vf vlan insert enable disable */
13065 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
13066 TOKEN_STRING_INITIALIZER
13067 (struct cmd_vf_vlan_insert_result,
13069 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
13070 TOKEN_STRING_INITIALIZER
13071 (struct cmd_vf_vlan_insert_result,
13073 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
13074 TOKEN_STRING_INITIALIZER
13075 (struct cmd_vf_vlan_insert_result,
13077 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
13078 TOKEN_STRING_INITIALIZER
13079 (struct cmd_vf_vlan_insert_result,
13081 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
13082 TOKEN_NUM_INITIALIZER
13083 (struct cmd_vf_vlan_insert_result,
13085 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
13086 TOKEN_NUM_INITIALIZER
13087 (struct cmd_vf_vlan_insert_result,
13089 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
13090 TOKEN_NUM_INITIALIZER
13091 (struct cmd_vf_vlan_insert_result,
13095 cmd_set_vf_vlan_insert_parsed(
13096 void *parsed_result,
13097 __attribute__((unused)) struct cmdline *cl,
13098 __attribute__((unused)) void *data)
13100 struct cmd_vf_vlan_insert_result *res = parsed_result;
13101 int ret = -ENOTSUP;
13103 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13106 #ifdef RTE_LIBRTE_IXGBE_PMD
13107 if (ret == -ENOTSUP)
13108 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
13111 #ifdef RTE_LIBRTE_I40E_PMD
13112 if (ret == -ENOTSUP)
13113 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
13116 #ifdef RTE_LIBRTE_BNXT_PMD
13117 if (ret == -ENOTSUP)
13118 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
13126 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
13129 printf("invalid port_id %d\n", res->port_id);
13132 printf("function not implemented\n");
13135 printf("programming error: (%s)\n", strerror(-ret));
13139 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
13140 .f = cmd_set_vf_vlan_insert_parsed,
13142 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
13144 (void *)&cmd_vf_vlan_insert_set,
13145 (void *)&cmd_vf_vlan_insert_vf,
13146 (void *)&cmd_vf_vlan_insert_vlan,
13147 (void *)&cmd_vf_vlan_insert_insert,
13148 (void *)&cmd_vf_vlan_insert_port_id,
13149 (void *)&cmd_vf_vlan_insert_vf_id,
13150 (void *)&cmd_vf_vlan_insert_vlan_id,
13155 /* tx loopback configuration */
13157 /* Common result structure for tx loopback */
13158 struct cmd_tx_loopback_result {
13159 cmdline_fixed_string_t set;
13160 cmdline_fixed_string_t tx;
13161 cmdline_fixed_string_t loopback;
13163 cmdline_fixed_string_t on_off;
13166 /* Common CLI fields for tx loopback enable disable */
13167 cmdline_parse_token_string_t cmd_tx_loopback_set =
13168 TOKEN_STRING_INITIALIZER
13169 (struct cmd_tx_loopback_result,
13171 cmdline_parse_token_string_t cmd_tx_loopback_tx =
13172 TOKEN_STRING_INITIALIZER
13173 (struct cmd_tx_loopback_result,
13175 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
13176 TOKEN_STRING_INITIALIZER
13177 (struct cmd_tx_loopback_result,
13178 loopback, "loopback");
13179 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
13180 TOKEN_NUM_INITIALIZER
13181 (struct cmd_tx_loopback_result,
13183 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
13184 TOKEN_STRING_INITIALIZER
13185 (struct cmd_tx_loopback_result,
13189 cmd_set_tx_loopback_parsed(
13190 void *parsed_result,
13191 __attribute__((unused)) struct cmdline *cl,
13192 __attribute__((unused)) void *data)
13194 struct cmd_tx_loopback_result *res = parsed_result;
13195 int ret = -ENOTSUP;
13197 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13199 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13202 #ifdef RTE_LIBRTE_IXGBE_PMD
13203 if (ret == -ENOTSUP)
13204 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
13206 #ifdef RTE_LIBRTE_I40E_PMD
13207 if (ret == -ENOTSUP)
13208 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
13210 #ifdef RTE_LIBRTE_BNXT_PMD
13211 if (ret == -ENOTSUP)
13212 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
13214 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
13215 if (ret == -ENOTSUP)
13216 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
13223 printf("invalid is_on %d\n", is_on);
13226 printf("invalid port_id %d\n", res->port_id);
13229 printf("function not implemented\n");
13232 printf("programming error: (%s)\n", strerror(-ret));
13236 cmdline_parse_inst_t cmd_set_tx_loopback = {
13237 .f = cmd_set_tx_loopback_parsed,
13239 .help_str = "set tx loopback <port_id> on|off",
13241 (void *)&cmd_tx_loopback_set,
13242 (void *)&cmd_tx_loopback_tx,
13243 (void *)&cmd_tx_loopback_loopback,
13244 (void *)&cmd_tx_loopback_port_id,
13245 (void *)&cmd_tx_loopback_on_off,
13250 /* all queues drop enable configuration */
13252 /* Common result structure for all queues drop enable */
13253 struct cmd_all_queues_drop_en_result {
13254 cmdline_fixed_string_t set;
13255 cmdline_fixed_string_t all;
13256 cmdline_fixed_string_t queues;
13257 cmdline_fixed_string_t drop;
13259 cmdline_fixed_string_t on_off;
13262 /* Common CLI fields for tx loopback enable disable */
13263 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
13264 TOKEN_STRING_INITIALIZER
13265 (struct cmd_all_queues_drop_en_result,
13267 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
13268 TOKEN_STRING_INITIALIZER
13269 (struct cmd_all_queues_drop_en_result,
13271 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
13272 TOKEN_STRING_INITIALIZER
13273 (struct cmd_all_queues_drop_en_result,
13275 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
13276 TOKEN_STRING_INITIALIZER
13277 (struct cmd_all_queues_drop_en_result,
13279 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
13280 TOKEN_NUM_INITIALIZER
13281 (struct cmd_all_queues_drop_en_result,
13283 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
13284 TOKEN_STRING_INITIALIZER
13285 (struct cmd_all_queues_drop_en_result,
13289 cmd_set_all_queues_drop_en_parsed(
13290 void *parsed_result,
13291 __attribute__((unused)) struct cmdline *cl,
13292 __attribute__((unused)) void *data)
13294 struct cmd_all_queues_drop_en_result *res = parsed_result;
13295 int ret = -ENOTSUP;
13296 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13298 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13301 #ifdef RTE_LIBRTE_IXGBE_PMD
13302 if (ret == -ENOTSUP)
13303 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
13305 #ifdef RTE_LIBRTE_BNXT_PMD
13306 if (ret == -ENOTSUP)
13307 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
13313 printf("invalid is_on %d\n", is_on);
13316 printf("invalid port_id %d\n", res->port_id);
13319 printf("function not implemented\n");
13322 printf("programming error: (%s)\n", strerror(-ret));
13326 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
13327 .f = cmd_set_all_queues_drop_en_parsed,
13329 .help_str = "set all queues drop <port_id> on|off",
13331 (void *)&cmd_all_queues_drop_en_set,
13332 (void *)&cmd_all_queues_drop_en_all,
13333 (void *)&cmd_all_queues_drop_en_queues,
13334 (void *)&cmd_all_queues_drop_en_drop,
13335 (void *)&cmd_all_queues_drop_en_port_id,
13336 (void *)&cmd_all_queues_drop_en_on_off,
13341 /* vf split drop enable configuration */
13343 /* Common result structure for vf split drop enable */
13344 struct cmd_vf_split_drop_en_result {
13345 cmdline_fixed_string_t set;
13346 cmdline_fixed_string_t vf;
13347 cmdline_fixed_string_t split;
13348 cmdline_fixed_string_t drop;
13351 cmdline_fixed_string_t on_off;
13354 /* Common CLI fields for vf split drop enable disable */
13355 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
13356 TOKEN_STRING_INITIALIZER
13357 (struct cmd_vf_split_drop_en_result,
13359 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
13360 TOKEN_STRING_INITIALIZER
13361 (struct cmd_vf_split_drop_en_result,
13363 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
13364 TOKEN_STRING_INITIALIZER
13365 (struct cmd_vf_split_drop_en_result,
13367 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
13368 TOKEN_STRING_INITIALIZER
13369 (struct cmd_vf_split_drop_en_result,
13371 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
13372 TOKEN_NUM_INITIALIZER
13373 (struct cmd_vf_split_drop_en_result,
13375 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
13376 TOKEN_NUM_INITIALIZER
13377 (struct cmd_vf_split_drop_en_result,
13379 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
13380 TOKEN_STRING_INITIALIZER
13381 (struct cmd_vf_split_drop_en_result,
13385 cmd_set_vf_split_drop_en_parsed(
13386 void *parsed_result,
13387 __attribute__((unused)) struct cmdline *cl,
13388 __attribute__((unused)) void *data)
13390 struct cmd_vf_split_drop_en_result *res = parsed_result;
13391 int ret = -ENOTSUP;
13392 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13394 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13397 #ifdef RTE_LIBRTE_IXGBE_PMD
13398 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
13405 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13408 printf("invalid port_id %d\n", res->port_id);
13411 printf("not supported on port %d\n", res->port_id);
13414 printf("programming error: (%s)\n", strerror(-ret));
13418 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
13419 .f = cmd_set_vf_split_drop_en_parsed,
13421 .help_str = "set vf split drop <port_id> <vf_id> on|off",
13423 (void *)&cmd_vf_split_drop_en_set,
13424 (void *)&cmd_vf_split_drop_en_vf,
13425 (void *)&cmd_vf_split_drop_en_split,
13426 (void *)&cmd_vf_split_drop_en_drop,
13427 (void *)&cmd_vf_split_drop_en_port_id,
13428 (void *)&cmd_vf_split_drop_en_vf_id,
13429 (void *)&cmd_vf_split_drop_en_on_off,
13434 /* vf mac address configuration */
13436 /* Common result structure for vf mac address */
13437 struct cmd_set_vf_mac_addr_result {
13438 cmdline_fixed_string_t set;
13439 cmdline_fixed_string_t vf;
13440 cmdline_fixed_string_t mac;
13441 cmdline_fixed_string_t addr;
13444 struct ether_addr mac_addr;
13448 /* Common CLI fields for vf split drop enable disable */
13449 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
13450 TOKEN_STRING_INITIALIZER
13451 (struct cmd_set_vf_mac_addr_result,
13453 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
13454 TOKEN_STRING_INITIALIZER
13455 (struct cmd_set_vf_mac_addr_result,
13457 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
13458 TOKEN_STRING_INITIALIZER
13459 (struct cmd_set_vf_mac_addr_result,
13461 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
13462 TOKEN_STRING_INITIALIZER
13463 (struct cmd_set_vf_mac_addr_result,
13465 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
13466 TOKEN_NUM_INITIALIZER
13467 (struct cmd_set_vf_mac_addr_result,
13469 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
13470 TOKEN_NUM_INITIALIZER
13471 (struct cmd_set_vf_mac_addr_result,
13473 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
13474 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
13478 cmd_set_vf_mac_addr_parsed(
13479 void *parsed_result,
13480 __attribute__((unused)) struct cmdline *cl,
13481 __attribute__((unused)) void *data)
13483 struct cmd_set_vf_mac_addr_result *res = parsed_result;
13484 int ret = -ENOTSUP;
13486 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13489 #ifdef RTE_LIBRTE_IXGBE_PMD
13490 if (ret == -ENOTSUP)
13491 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
13494 #ifdef RTE_LIBRTE_I40E_PMD
13495 if (ret == -ENOTSUP)
13496 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
13499 #ifdef RTE_LIBRTE_BNXT_PMD
13500 if (ret == -ENOTSUP)
13501 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
13509 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
13512 printf("invalid port_id %d\n", res->port_id);
13515 printf("function not implemented\n");
13518 printf("programming error: (%s)\n", strerror(-ret));
13522 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
13523 .f = cmd_set_vf_mac_addr_parsed,
13525 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
13527 (void *)&cmd_set_vf_mac_addr_set,
13528 (void *)&cmd_set_vf_mac_addr_vf,
13529 (void *)&cmd_set_vf_mac_addr_mac,
13530 (void *)&cmd_set_vf_mac_addr_addr,
13531 (void *)&cmd_set_vf_mac_addr_port_id,
13532 (void *)&cmd_set_vf_mac_addr_vf_id,
13533 (void *)&cmd_set_vf_mac_addr_mac_addr,
13538 /* MACsec configuration */
13540 /* Common result structure for MACsec offload enable */
13541 struct cmd_macsec_offload_on_result {
13542 cmdline_fixed_string_t set;
13543 cmdline_fixed_string_t macsec;
13544 cmdline_fixed_string_t offload;
13546 cmdline_fixed_string_t on;
13547 cmdline_fixed_string_t encrypt;
13548 cmdline_fixed_string_t en_on_off;
13549 cmdline_fixed_string_t replay_protect;
13550 cmdline_fixed_string_t rp_on_off;
13553 /* Common CLI fields for MACsec offload disable */
13554 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
13555 TOKEN_STRING_INITIALIZER
13556 (struct cmd_macsec_offload_on_result,
13558 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
13559 TOKEN_STRING_INITIALIZER
13560 (struct cmd_macsec_offload_on_result,
13562 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
13563 TOKEN_STRING_INITIALIZER
13564 (struct cmd_macsec_offload_on_result,
13565 offload, "offload");
13566 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
13567 TOKEN_NUM_INITIALIZER
13568 (struct cmd_macsec_offload_on_result,
13570 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
13571 TOKEN_STRING_INITIALIZER
13572 (struct cmd_macsec_offload_on_result,
13574 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
13575 TOKEN_STRING_INITIALIZER
13576 (struct cmd_macsec_offload_on_result,
13577 encrypt, "encrypt");
13578 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
13579 TOKEN_STRING_INITIALIZER
13580 (struct cmd_macsec_offload_on_result,
13581 en_on_off, "on#off");
13582 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
13583 TOKEN_STRING_INITIALIZER
13584 (struct cmd_macsec_offload_on_result,
13585 replay_protect, "replay-protect");
13586 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
13587 TOKEN_STRING_INITIALIZER
13588 (struct cmd_macsec_offload_on_result,
13589 rp_on_off, "on#off");
13592 cmd_set_macsec_offload_on_parsed(
13593 void *parsed_result,
13594 __attribute__((unused)) struct cmdline *cl,
13595 __attribute__((unused)) void *data)
13597 struct cmd_macsec_offload_on_result *res = parsed_result;
13598 int ret = -ENOTSUP;
13599 portid_t port_id = res->port_id;
13600 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
13601 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
13602 struct rte_eth_dev_info dev_info;
13604 if (port_id_is_invalid(port_id, ENABLED_WARN))
13606 if (!port_is_stopped(port_id)) {
13607 printf("Please stop port %d first\n", port_id);
13611 rte_eth_dev_info_get(port_id, &dev_info);
13612 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13613 #ifdef RTE_LIBRTE_IXGBE_PMD
13614 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
13622 ports[port_id].dev_conf.txmode.offloads |=
13623 DEV_TX_OFFLOAD_MACSEC_INSERT;
13624 cmd_reconfig_device_queue(port_id, 1, 1);
13627 printf("invalid port_id %d\n", port_id);
13630 printf("not supported on port %d\n", port_id);
13633 printf("programming error: (%s)\n", strerror(-ret));
13637 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
13638 .f = cmd_set_macsec_offload_on_parsed,
13640 .help_str = "set macsec offload <port_id> on "
13641 "encrypt on|off replay-protect on|off",
13643 (void *)&cmd_macsec_offload_on_set,
13644 (void *)&cmd_macsec_offload_on_macsec,
13645 (void *)&cmd_macsec_offload_on_offload,
13646 (void *)&cmd_macsec_offload_on_port_id,
13647 (void *)&cmd_macsec_offload_on_on,
13648 (void *)&cmd_macsec_offload_on_encrypt,
13649 (void *)&cmd_macsec_offload_on_en_on_off,
13650 (void *)&cmd_macsec_offload_on_replay_protect,
13651 (void *)&cmd_macsec_offload_on_rp_on_off,
13656 /* Common result structure for MACsec offload disable */
13657 struct cmd_macsec_offload_off_result {
13658 cmdline_fixed_string_t set;
13659 cmdline_fixed_string_t macsec;
13660 cmdline_fixed_string_t offload;
13662 cmdline_fixed_string_t off;
13665 /* Common CLI fields for MACsec offload disable */
13666 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
13667 TOKEN_STRING_INITIALIZER
13668 (struct cmd_macsec_offload_off_result,
13670 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
13671 TOKEN_STRING_INITIALIZER
13672 (struct cmd_macsec_offload_off_result,
13674 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
13675 TOKEN_STRING_INITIALIZER
13676 (struct cmd_macsec_offload_off_result,
13677 offload, "offload");
13678 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
13679 TOKEN_NUM_INITIALIZER
13680 (struct cmd_macsec_offload_off_result,
13682 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
13683 TOKEN_STRING_INITIALIZER
13684 (struct cmd_macsec_offload_off_result,
13688 cmd_set_macsec_offload_off_parsed(
13689 void *parsed_result,
13690 __attribute__((unused)) struct cmdline *cl,
13691 __attribute__((unused)) void *data)
13693 struct cmd_macsec_offload_off_result *res = parsed_result;
13694 int ret = -ENOTSUP;
13695 struct rte_eth_dev_info dev_info;
13696 portid_t port_id = res->port_id;
13698 if (port_id_is_invalid(port_id, ENABLED_WARN))
13700 if (!port_is_stopped(port_id)) {
13701 printf("Please stop port %d first\n", port_id);
13705 rte_eth_dev_info_get(port_id, &dev_info);
13706 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13707 #ifdef RTE_LIBRTE_IXGBE_PMD
13708 ret = rte_pmd_ixgbe_macsec_disable(port_id);
13713 ports[port_id].dev_conf.txmode.offloads &=
13714 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
13715 cmd_reconfig_device_queue(port_id, 1, 1);
13718 printf("invalid port_id %d\n", port_id);
13721 printf("not supported on port %d\n", port_id);
13724 printf("programming error: (%s)\n", strerror(-ret));
13728 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
13729 .f = cmd_set_macsec_offload_off_parsed,
13731 .help_str = "set macsec offload <port_id> off",
13733 (void *)&cmd_macsec_offload_off_set,
13734 (void *)&cmd_macsec_offload_off_macsec,
13735 (void *)&cmd_macsec_offload_off_offload,
13736 (void *)&cmd_macsec_offload_off_port_id,
13737 (void *)&cmd_macsec_offload_off_off,
13742 /* Common result structure for MACsec secure connection configure */
13743 struct cmd_macsec_sc_result {
13744 cmdline_fixed_string_t set;
13745 cmdline_fixed_string_t macsec;
13746 cmdline_fixed_string_t sc;
13747 cmdline_fixed_string_t tx_rx;
13749 struct ether_addr mac;
13753 /* Common CLI fields for MACsec secure connection configure */
13754 cmdline_parse_token_string_t cmd_macsec_sc_set =
13755 TOKEN_STRING_INITIALIZER
13756 (struct cmd_macsec_sc_result,
13758 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
13759 TOKEN_STRING_INITIALIZER
13760 (struct cmd_macsec_sc_result,
13762 cmdline_parse_token_string_t cmd_macsec_sc_sc =
13763 TOKEN_STRING_INITIALIZER
13764 (struct cmd_macsec_sc_result,
13766 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
13767 TOKEN_STRING_INITIALIZER
13768 (struct cmd_macsec_sc_result,
13770 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
13771 TOKEN_NUM_INITIALIZER
13772 (struct cmd_macsec_sc_result,
13774 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
13775 TOKEN_ETHERADDR_INITIALIZER
13776 (struct cmd_macsec_sc_result,
13778 cmdline_parse_token_num_t cmd_macsec_sc_pi =
13779 TOKEN_NUM_INITIALIZER
13780 (struct cmd_macsec_sc_result,
13784 cmd_set_macsec_sc_parsed(
13785 void *parsed_result,
13786 __attribute__((unused)) struct cmdline *cl,
13787 __attribute__((unused)) void *data)
13789 struct cmd_macsec_sc_result *res = parsed_result;
13790 int ret = -ENOTSUP;
13791 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13793 #ifdef RTE_LIBRTE_IXGBE_PMD
13795 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
13796 res->mac.addr_bytes) :
13797 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
13798 res->mac.addr_bytes, res->pi);
13800 RTE_SET_USED(is_tx);
13806 printf("invalid port_id %d\n", res->port_id);
13809 printf("not supported on port %d\n", res->port_id);
13812 printf("programming error: (%s)\n", strerror(-ret));
13816 cmdline_parse_inst_t cmd_set_macsec_sc = {
13817 .f = cmd_set_macsec_sc_parsed,
13819 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
13821 (void *)&cmd_macsec_sc_set,
13822 (void *)&cmd_macsec_sc_macsec,
13823 (void *)&cmd_macsec_sc_sc,
13824 (void *)&cmd_macsec_sc_tx_rx,
13825 (void *)&cmd_macsec_sc_port_id,
13826 (void *)&cmd_macsec_sc_mac,
13827 (void *)&cmd_macsec_sc_pi,
13832 /* Common result structure for MACsec secure connection configure */
13833 struct cmd_macsec_sa_result {
13834 cmdline_fixed_string_t set;
13835 cmdline_fixed_string_t macsec;
13836 cmdline_fixed_string_t sa;
13837 cmdline_fixed_string_t tx_rx;
13842 cmdline_fixed_string_t key;
13845 /* Common CLI fields for MACsec secure connection configure */
13846 cmdline_parse_token_string_t cmd_macsec_sa_set =
13847 TOKEN_STRING_INITIALIZER
13848 (struct cmd_macsec_sa_result,
13850 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
13851 TOKEN_STRING_INITIALIZER
13852 (struct cmd_macsec_sa_result,
13854 cmdline_parse_token_string_t cmd_macsec_sa_sa =
13855 TOKEN_STRING_INITIALIZER
13856 (struct cmd_macsec_sa_result,
13858 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
13859 TOKEN_STRING_INITIALIZER
13860 (struct cmd_macsec_sa_result,
13862 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
13863 TOKEN_NUM_INITIALIZER
13864 (struct cmd_macsec_sa_result,
13866 cmdline_parse_token_num_t cmd_macsec_sa_idx =
13867 TOKEN_NUM_INITIALIZER
13868 (struct cmd_macsec_sa_result,
13870 cmdline_parse_token_num_t cmd_macsec_sa_an =
13871 TOKEN_NUM_INITIALIZER
13872 (struct cmd_macsec_sa_result,
13874 cmdline_parse_token_num_t cmd_macsec_sa_pn =
13875 TOKEN_NUM_INITIALIZER
13876 (struct cmd_macsec_sa_result,
13878 cmdline_parse_token_string_t cmd_macsec_sa_key =
13879 TOKEN_STRING_INITIALIZER
13880 (struct cmd_macsec_sa_result,
13884 cmd_set_macsec_sa_parsed(
13885 void *parsed_result,
13886 __attribute__((unused)) struct cmdline *cl,
13887 __attribute__((unused)) void *data)
13889 struct cmd_macsec_sa_result *res = parsed_result;
13890 int ret = -ENOTSUP;
13891 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13892 uint8_t key[16] = { 0 };
13898 key_len = strlen(res->key) / 2;
13902 for (i = 0; i < key_len; i++) {
13903 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
13906 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
13909 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
13912 #ifdef RTE_LIBRTE_IXGBE_PMD
13914 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
13915 res->idx, res->an, res->pn, key) :
13916 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
13917 res->idx, res->an, res->pn, key);
13919 RTE_SET_USED(is_tx);
13926 printf("invalid idx %d or an %d\n", res->idx, res->an);
13929 printf("invalid port_id %d\n", res->port_id);
13932 printf("not supported on port %d\n", res->port_id);
13935 printf("programming error: (%s)\n", strerror(-ret));
13939 cmdline_parse_inst_t cmd_set_macsec_sa = {
13940 .f = cmd_set_macsec_sa_parsed,
13942 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
13944 (void *)&cmd_macsec_sa_set,
13945 (void *)&cmd_macsec_sa_macsec,
13946 (void *)&cmd_macsec_sa_sa,
13947 (void *)&cmd_macsec_sa_tx_rx,
13948 (void *)&cmd_macsec_sa_port_id,
13949 (void *)&cmd_macsec_sa_idx,
13950 (void *)&cmd_macsec_sa_an,
13951 (void *)&cmd_macsec_sa_pn,
13952 (void *)&cmd_macsec_sa_key,
13957 /* VF unicast promiscuous mode configuration */
13959 /* Common result structure for VF unicast promiscuous mode */
13960 struct cmd_vf_promisc_result {
13961 cmdline_fixed_string_t set;
13962 cmdline_fixed_string_t vf;
13963 cmdline_fixed_string_t promisc;
13966 cmdline_fixed_string_t on_off;
13969 /* Common CLI fields for VF unicast promiscuous mode enable disable */
13970 cmdline_parse_token_string_t cmd_vf_promisc_set =
13971 TOKEN_STRING_INITIALIZER
13972 (struct cmd_vf_promisc_result,
13974 cmdline_parse_token_string_t cmd_vf_promisc_vf =
13975 TOKEN_STRING_INITIALIZER
13976 (struct cmd_vf_promisc_result,
13978 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
13979 TOKEN_STRING_INITIALIZER
13980 (struct cmd_vf_promisc_result,
13981 promisc, "promisc");
13982 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
13983 TOKEN_NUM_INITIALIZER
13984 (struct cmd_vf_promisc_result,
13986 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
13987 TOKEN_NUM_INITIALIZER
13988 (struct cmd_vf_promisc_result,
13990 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
13991 TOKEN_STRING_INITIALIZER
13992 (struct cmd_vf_promisc_result,
13996 cmd_set_vf_promisc_parsed(
13997 void *parsed_result,
13998 __attribute__((unused)) struct cmdline *cl,
13999 __attribute__((unused)) void *data)
14001 struct cmd_vf_promisc_result *res = parsed_result;
14002 int ret = -ENOTSUP;
14004 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14006 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14009 #ifdef RTE_LIBRTE_I40E_PMD
14010 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
14011 res->vf_id, is_on);
14018 printf("invalid vf_id %d\n", res->vf_id);
14021 printf("invalid port_id %d\n", res->port_id);
14024 printf("function not implemented\n");
14027 printf("programming error: (%s)\n", strerror(-ret));
14031 cmdline_parse_inst_t cmd_set_vf_promisc = {
14032 .f = cmd_set_vf_promisc_parsed,
14034 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
14035 "Set unicast promiscuous mode for a VF from the PF",
14037 (void *)&cmd_vf_promisc_set,
14038 (void *)&cmd_vf_promisc_vf,
14039 (void *)&cmd_vf_promisc_promisc,
14040 (void *)&cmd_vf_promisc_port_id,
14041 (void *)&cmd_vf_promisc_vf_id,
14042 (void *)&cmd_vf_promisc_on_off,
14047 /* VF multicast promiscuous mode configuration */
14049 /* Common result structure for VF multicast promiscuous mode */
14050 struct cmd_vf_allmulti_result {
14051 cmdline_fixed_string_t set;
14052 cmdline_fixed_string_t vf;
14053 cmdline_fixed_string_t allmulti;
14056 cmdline_fixed_string_t on_off;
14059 /* Common CLI fields for VF multicast promiscuous mode enable disable */
14060 cmdline_parse_token_string_t cmd_vf_allmulti_set =
14061 TOKEN_STRING_INITIALIZER
14062 (struct cmd_vf_allmulti_result,
14064 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
14065 TOKEN_STRING_INITIALIZER
14066 (struct cmd_vf_allmulti_result,
14068 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
14069 TOKEN_STRING_INITIALIZER
14070 (struct cmd_vf_allmulti_result,
14071 allmulti, "allmulti");
14072 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
14073 TOKEN_NUM_INITIALIZER
14074 (struct cmd_vf_allmulti_result,
14076 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
14077 TOKEN_NUM_INITIALIZER
14078 (struct cmd_vf_allmulti_result,
14080 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
14081 TOKEN_STRING_INITIALIZER
14082 (struct cmd_vf_allmulti_result,
14086 cmd_set_vf_allmulti_parsed(
14087 void *parsed_result,
14088 __attribute__((unused)) struct cmdline *cl,
14089 __attribute__((unused)) void *data)
14091 struct cmd_vf_allmulti_result *res = parsed_result;
14092 int ret = -ENOTSUP;
14094 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14096 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14099 #ifdef RTE_LIBRTE_I40E_PMD
14100 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
14101 res->vf_id, is_on);
14108 printf("invalid vf_id %d\n", res->vf_id);
14111 printf("invalid port_id %d\n", res->port_id);
14114 printf("function not implemented\n");
14117 printf("programming error: (%s)\n", strerror(-ret));
14121 cmdline_parse_inst_t cmd_set_vf_allmulti = {
14122 .f = cmd_set_vf_allmulti_parsed,
14124 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
14125 "Set multicast promiscuous mode for a VF from the PF",
14127 (void *)&cmd_vf_allmulti_set,
14128 (void *)&cmd_vf_allmulti_vf,
14129 (void *)&cmd_vf_allmulti_allmulti,
14130 (void *)&cmd_vf_allmulti_port_id,
14131 (void *)&cmd_vf_allmulti_vf_id,
14132 (void *)&cmd_vf_allmulti_on_off,
14137 /* vf broadcast mode configuration */
14139 /* Common result structure for vf broadcast */
14140 struct cmd_set_vf_broadcast_result {
14141 cmdline_fixed_string_t set;
14142 cmdline_fixed_string_t vf;
14143 cmdline_fixed_string_t broadcast;
14146 cmdline_fixed_string_t on_off;
14149 /* Common CLI fields for vf broadcast enable disable */
14150 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
14151 TOKEN_STRING_INITIALIZER
14152 (struct cmd_set_vf_broadcast_result,
14154 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
14155 TOKEN_STRING_INITIALIZER
14156 (struct cmd_set_vf_broadcast_result,
14158 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
14159 TOKEN_STRING_INITIALIZER
14160 (struct cmd_set_vf_broadcast_result,
14161 broadcast, "broadcast");
14162 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
14163 TOKEN_NUM_INITIALIZER
14164 (struct cmd_set_vf_broadcast_result,
14166 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
14167 TOKEN_NUM_INITIALIZER
14168 (struct cmd_set_vf_broadcast_result,
14170 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
14171 TOKEN_STRING_INITIALIZER
14172 (struct cmd_set_vf_broadcast_result,
14176 cmd_set_vf_broadcast_parsed(
14177 void *parsed_result,
14178 __attribute__((unused)) struct cmdline *cl,
14179 __attribute__((unused)) void *data)
14181 struct cmd_set_vf_broadcast_result *res = parsed_result;
14182 int ret = -ENOTSUP;
14184 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14186 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14189 #ifdef RTE_LIBRTE_I40E_PMD
14190 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
14191 res->vf_id, is_on);
14198 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14201 printf("invalid port_id %d\n", res->port_id);
14204 printf("function not implemented\n");
14207 printf("programming error: (%s)\n", strerror(-ret));
14211 cmdline_parse_inst_t cmd_set_vf_broadcast = {
14212 .f = cmd_set_vf_broadcast_parsed,
14214 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
14216 (void *)&cmd_set_vf_broadcast_set,
14217 (void *)&cmd_set_vf_broadcast_vf,
14218 (void *)&cmd_set_vf_broadcast_broadcast,
14219 (void *)&cmd_set_vf_broadcast_port_id,
14220 (void *)&cmd_set_vf_broadcast_vf_id,
14221 (void *)&cmd_set_vf_broadcast_on_off,
14226 /* vf vlan tag configuration */
14228 /* Common result structure for vf vlan tag */
14229 struct cmd_set_vf_vlan_tag_result {
14230 cmdline_fixed_string_t set;
14231 cmdline_fixed_string_t vf;
14232 cmdline_fixed_string_t vlan;
14233 cmdline_fixed_string_t tag;
14236 cmdline_fixed_string_t on_off;
14239 /* Common CLI fields for vf vlan tag enable disable */
14240 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
14241 TOKEN_STRING_INITIALIZER
14242 (struct cmd_set_vf_vlan_tag_result,
14244 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
14245 TOKEN_STRING_INITIALIZER
14246 (struct cmd_set_vf_vlan_tag_result,
14248 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
14249 TOKEN_STRING_INITIALIZER
14250 (struct cmd_set_vf_vlan_tag_result,
14252 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
14253 TOKEN_STRING_INITIALIZER
14254 (struct cmd_set_vf_vlan_tag_result,
14256 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
14257 TOKEN_NUM_INITIALIZER
14258 (struct cmd_set_vf_vlan_tag_result,
14260 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
14261 TOKEN_NUM_INITIALIZER
14262 (struct cmd_set_vf_vlan_tag_result,
14264 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
14265 TOKEN_STRING_INITIALIZER
14266 (struct cmd_set_vf_vlan_tag_result,
14270 cmd_set_vf_vlan_tag_parsed(
14271 void *parsed_result,
14272 __attribute__((unused)) struct cmdline *cl,
14273 __attribute__((unused)) void *data)
14275 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
14276 int ret = -ENOTSUP;
14278 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14280 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14283 #ifdef RTE_LIBRTE_I40E_PMD
14284 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
14285 res->vf_id, is_on);
14292 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14295 printf("invalid port_id %d\n", res->port_id);
14298 printf("function not implemented\n");
14301 printf("programming error: (%s)\n", strerror(-ret));
14305 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
14306 .f = cmd_set_vf_vlan_tag_parsed,
14308 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
14310 (void *)&cmd_set_vf_vlan_tag_set,
14311 (void *)&cmd_set_vf_vlan_tag_vf,
14312 (void *)&cmd_set_vf_vlan_tag_vlan,
14313 (void *)&cmd_set_vf_vlan_tag_tag,
14314 (void *)&cmd_set_vf_vlan_tag_port_id,
14315 (void *)&cmd_set_vf_vlan_tag_vf_id,
14316 (void *)&cmd_set_vf_vlan_tag_on_off,
14321 /* Common definition of VF and TC TX bandwidth configuration */
14322 struct cmd_vf_tc_bw_result {
14323 cmdline_fixed_string_t set;
14324 cmdline_fixed_string_t vf;
14325 cmdline_fixed_string_t tc;
14326 cmdline_fixed_string_t tx;
14327 cmdline_fixed_string_t min_bw;
14328 cmdline_fixed_string_t max_bw;
14329 cmdline_fixed_string_t strict_link_prio;
14334 cmdline_fixed_string_t bw_list;
14338 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
14339 TOKEN_STRING_INITIALIZER
14340 (struct cmd_vf_tc_bw_result,
14342 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
14343 TOKEN_STRING_INITIALIZER
14344 (struct cmd_vf_tc_bw_result,
14346 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
14347 TOKEN_STRING_INITIALIZER
14348 (struct cmd_vf_tc_bw_result,
14350 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
14351 TOKEN_STRING_INITIALIZER
14352 (struct cmd_vf_tc_bw_result,
14354 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
14355 TOKEN_STRING_INITIALIZER
14356 (struct cmd_vf_tc_bw_result,
14357 strict_link_prio, "strict-link-priority");
14358 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
14359 TOKEN_STRING_INITIALIZER
14360 (struct cmd_vf_tc_bw_result,
14361 min_bw, "min-bandwidth");
14362 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
14363 TOKEN_STRING_INITIALIZER
14364 (struct cmd_vf_tc_bw_result,
14365 max_bw, "max-bandwidth");
14366 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
14367 TOKEN_NUM_INITIALIZER
14368 (struct cmd_vf_tc_bw_result,
14370 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
14371 TOKEN_NUM_INITIALIZER
14372 (struct cmd_vf_tc_bw_result,
14374 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
14375 TOKEN_NUM_INITIALIZER
14376 (struct cmd_vf_tc_bw_result,
14378 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
14379 TOKEN_NUM_INITIALIZER
14380 (struct cmd_vf_tc_bw_result,
14382 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
14383 TOKEN_STRING_INITIALIZER
14384 (struct cmd_vf_tc_bw_result,
14386 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
14387 TOKEN_NUM_INITIALIZER
14388 (struct cmd_vf_tc_bw_result,
14391 /* VF max bandwidth setting */
14393 cmd_vf_max_bw_parsed(
14394 void *parsed_result,
14395 __attribute__((unused)) struct cmdline *cl,
14396 __attribute__((unused)) void *data)
14398 struct cmd_vf_tc_bw_result *res = parsed_result;
14399 int ret = -ENOTSUP;
14401 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14404 #ifdef RTE_LIBRTE_I40E_PMD
14405 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
14406 res->vf_id, res->bw);
14413 printf("invalid vf_id %d or bandwidth %d\n",
14414 res->vf_id, res->bw);
14417 printf("invalid port_id %d\n", res->port_id);
14420 printf("function not implemented\n");
14423 printf("programming error: (%s)\n", strerror(-ret));
14427 cmdline_parse_inst_t cmd_vf_max_bw = {
14428 .f = cmd_vf_max_bw_parsed,
14430 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
14432 (void *)&cmd_vf_tc_bw_set,
14433 (void *)&cmd_vf_tc_bw_vf,
14434 (void *)&cmd_vf_tc_bw_tx,
14435 (void *)&cmd_vf_tc_bw_max_bw,
14436 (void *)&cmd_vf_tc_bw_port_id,
14437 (void *)&cmd_vf_tc_bw_vf_id,
14438 (void *)&cmd_vf_tc_bw_bw,
14444 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
14449 const char *p, *p0 = str;
14456 p = strchr(p0, '(');
14458 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14462 p0 = strchr(p, ')');
14464 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14468 if (size >= sizeof(s)) {
14469 printf("The string size exceeds the internal buffer size\n");
14472 snprintf(s, sizeof(s), "%.*s", size, p);
14473 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
14475 printf("Failed to get the bandwidth list. ");
14479 for (i = 0; i < ret; i++)
14480 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
14485 /* TC min bandwidth setting */
14487 cmd_vf_tc_min_bw_parsed(
14488 void *parsed_result,
14489 __attribute__((unused)) struct cmdline *cl,
14490 __attribute__((unused)) void *data)
14492 struct cmd_vf_tc_bw_result *res = parsed_result;
14495 int ret = -ENOTSUP;
14497 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14500 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14504 #ifdef RTE_LIBRTE_I40E_PMD
14505 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
14513 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
14516 printf("invalid port_id %d\n", res->port_id);
14519 printf("function not implemented\n");
14522 printf("programming error: (%s)\n", strerror(-ret));
14526 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
14527 .f = cmd_vf_tc_min_bw_parsed,
14529 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
14530 " <bw1, bw2, ...>",
14532 (void *)&cmd_vf_tc_bw_set,
14533 (void *)&cmd_vf_tc_bw_vf,
14534 (void *)&cmd_vf_tc_bw_tc,
14535 (void *)&cmd_vf_tc_bw_tx,
14536 (void *)&cmd_vf_tc_bw_min_bw,
14537 (void *)&cmd_vf_tc_bw_port_id,
14538 (void *)&cmd_vf_tc_bw_vf_id,
14539 (void *)&cmd_vf_tc_bw_bw_list,
14545 cmd_tc_min_bw_parsed(
14546 void *parsed_result,
14547 __attribute__((unused)) struct cmdline *cl,
14548 __attribute__((unused)) void *data)
14550 struct cmd_vf_tc_bw_result *res = parsed_result;
14551 struct rte_port *port;
14554 int ret = -ENOTSUP;
14556 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14559 port = &ports[res->port_id];
14560 /** Check if the port is not started **/
14561 if (port->port_status != RTE_PORT_STOPPED) {
14562 printf("Please stop port %d first\n", res->port_id);
14566 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14570 #ifdef RTE_LIBRTE_IXGBE_PMD
14571 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
14578 printf("invalid bandwidth\n");
14581 printf("invalid port_id %d\n", res->port_id);
14584 printf("function not implemented\n");
14587 printf("programming error: (%s)\n", strerror(-ret));
14591 cmdline_parse_inst_t cmd_tc_min_bw = {
14592 .f = cmd_tc_min_bw_parsed,
14594 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
14596 (void *)&cmd_vf_tc_bw_set,
14597 (void *)&cmd_vf_tc_bw_tc,
14598 (void *)&cmd_vf_tc_bw_tx,
14599 (void *)&cmd_vf_tc_bw_min_bw,
14600 (void *)&cmd_vf_tc_bw_port_id,
14601 (void *)&cmd_vf_tc_bw_bw_list,
14606 /* TC max bandwidth setting */
14608 cmd_vf_tc_max_bw_parsed(
14609 void *parsed_result,
14610 __attribute__((unused)) struct cmdline *cl,
14611 __attribute__((unused)) void *data)
14613 struct cmd_vf_tc_bw_result *res = parsed_result;
14614 int ret = -ENOTSUP;
14616 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14619 #ifdef RTE_LIBRTE_I40E_PMD
14620 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
14621 res->tc_no, res->bw);
14628 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
14629 res->vf_id, res->tc_no, res->bw);
14632 printf("invalid port_id %d\n", res->port_id);
14635 printf("function not implemented\n");
14638 printf("programming error: (%s)\n", strerror(-ret));
14642 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
14643 .f = cmd_vf_tc_max_bw_parsed,
14645 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
14648 (void *)&cmd_vf_tc_bw_set,
14649 (void *)&cmd_vf_tc_bw_vf,
14650 (void *)&cmd_vf_tc_bw_tc,
14651 (void *)&cmd_vf_tc_bw_tx,
14652 (void *)&cmd_vf_tc_bw_max_bw,
14653 (void *)&cmd_vf_tc_bw_port_id,
14654 (void *)&cmd_vf_tc_bw_vf_id,
14655 (void *)&cmd_vf_tc_bw_tc_no,
14656 (void *)&cmd_vf_tc_bw_bw,
14662 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
14664 /* *** Set Port default Traffic Management Hierarchy *** */
14665 struct cmd_set_port_tm_hierarchy_default_result {
14666 cmdline_fixed_string_t set;
14667 cmdline_fixed_string_t port;
14668 cmdline_fixed_string_t tm;
14669 cmdline_fixed_string_t hierarchy;
14670 cmdline_fixed_string_t def;
14674 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
14675 TOKEN_STRING_INITIALIZER(
14676 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
14677 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
14678 TOKEN_STRING_INITIALIZER(
14679 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
14680 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
14681 TOKEN_STRING_INITIALIZER(
14682 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
14683 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
14684 TOKEN_STRING_INITIALIZER(
14685 struct cmd_set_port_tm_hierarchy_default_result,
14686 hierarchy, "hierarchy");
14687 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
14688 TOKEN_STRING_INITIALIZER(
14689 struct cmd_set_port_tm_hierarchy_default_result,
14691 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
14692 TOKEN_NUM_INITIALIZER(
14693 struct cmd_set_port_tm_hierarchy_default_result,
14696 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
14697 __attribute__((unused)) struct cmdline *cl,
14698 __attribute__((unused)) void *data)
14700 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
14701 struct rte_port *p;
14702 portid_t port_id = res->port_id;
14704 if (port_id_is_invalid(port_id, ENABLED_WARN))
14707 p = &ports[port_id];
14710 if (p->softport.tm_flag == 0) {
14711 printf(" tm not enabled on port %u (error)\n", port_id);
14715 /* Forward mode: tm */
14716 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "tm")) {
14717 printf(" tm mode not enabled(error)\n");
14721 /* Set the default tm hierarchy */
14722 p->softport.tm.default_hierarchy_enable = 1;
14725 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
14726 .f = cmd_set_port_tm_hierarchy_default_parsed,
14728 .help_str = "set port tm hierarchy default <port_id>",
14730 (void *)&cmd_set_port_tm_hierarchy_default_set,
14731 (void *)&cmd_set_port_tm_hierarchy_default_port,
14732 (void *)&cmd_set_port_tm_hierarchy_default_tm,
14733 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
14734 (void *)&cmd_set_port_tm_hierarchy_default_default,
14735 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
14741 /* Strict link priority scheduling mode setting */
14743 cmd_strict_link_prio_parsed(
14744 void *parsed_result,
14745 __attribute__((unused)) struct cmdline *cl,
14746 __attribute__((unused)) void *data)
14748 struct cmd_vf_tc_bw_result *res = parsed_result;
14749 int ret = -ENOTSUP;
14751 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14754 #ifdef RTE_LIBRTE_I40E_PMD
14755 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
14762 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
14765 printf("invalid port_id %d\n", res->port_id);
14768 printf("function not implemented\n");
14771 printf("programming error: (%s)\n", strerror(-ret));
14775 cmdline_parse_inst_t cmd_strict_link_prio = {
14776 .f = cmd_strict_link_prio_parsed,
14778 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
14780 (void *)&cmd_vf_tc_bw_set,
14781 (void *)&cmd_vf_tc_bw_tx,
14782 (void *)&cmd_vf_tc_bw_strict_link_prio,
14783 (void *)&cmd_vf_tc_bw_port_id,
14784 (void *)&cmd_vf_tc_bw_tc_map,
14789 /* Load dynamic device personalization*/
14790 struct cmd_ddp_add_result {
14791 cmdline_fixed_string_t ddp;
14792 cmdline_fixed_string_t add;
14797 cmdline_parse_token_string_t cmd_ddp_add_ddp =
14798 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
14799 cmdline_parse_token_string_t cmd_ddp_add_add =
14800 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
14801 cmdline_parse_token_num_t cmd_ddp_add_port_id =
14802 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
14803 cmdline_parse_token_string_t cmd_ddp_add_filepath =
14804 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
14807 cmd_ddp_add_parsed(
14808 void *parsed_result,
14809 __attribute__((unused)) struct cmdline *cl,
14810 __attribute__((unused)) void *data)
14812 struct cmd_ddp_add_result *res = parsed_result;
14818 int ret = -ENOTSUP;
14820 if (!all_ports_stopped()) {
14821 printf("Please stop all ports first\n");
14825 filepath = strdup(res->filepath);
14826 if (filepath == NULL) {
14827 printf("Failed to allocate memory\n");
14830 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
14832 buff = open_file(file_fld[0], &size);
14834 free((void *)filepath);
14838 #ifdef RTE_LIBRTE_I40E_PMD
14839 if (ret == -ENOTSUP)
14840 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14842 RTE_PMD_I40E_PKG_OP_WR_ADD);
14845 if (ret == -EEXIST)
14846 printf("Profile has already existed.\n");
14848 printf("Failed to load profile.\n");
14849 else if (file_num == 2)
14850 save_file(file_fld[1], buff, size);
14853 free((void *)filepath);
14856 cmdline_parse_inst_t cmd_ddp_add = {
14857 .f = cmd_ddp_add_parsed,
14859 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
14861 (void *)&cmd_ddp_add_ddp,
14862 (void *)&cmd_ddp_add_add,
14863 (void *)&cmd_ddp_add_port_id,
14864 (void *)&cmd_ddp_add_filepath,
14869 /* Delete dynamic device personalization*/
14870 struct cmd_ddp_del_result {
14871 cmdline_fixed_string_t ddp;
14872 cmdline_fixed_string_t del;
14877 cmdline_parse_token_string_t cmd_ddp_del_ddp =
14878 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
14879 cmdline_parse_token_string_t cmd_ddp_del_del =
14880 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
14881 cmdline_parse_token_num_t cmd_ddp_del_port_id =
14882 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
14883 cmdline_parse_token_string_t cmd_ddp_del_filepath =
14884 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
14887 cmd_ddp_del_parsed(
14888 void *parsed_result,
14889 __attribute__((unused)) struct cmdline *cl,
14890 __attribute__((unused)) void *data)
14892 struct cmd_ddp_del_result *res = parsed_result;
14895 int ret = -ENOTSUP;
14897 if (!all_ports_stopped()) {
14898 printf("Please stop all ports first\n");
14902 buff = open_file(res->filepath, &size);
14906 #ifdef RTE_LIBRTE_I40E_PMD
14907 if (ret == -ENOTSUP)
14908 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14910 RTE_PMD_I40E_PKG_OP_WR_DEL);
14913 if (ret == -EACCES)
14914 printf("Profile does not exist.\n");
14916 printf("Failed to delete profile.\n");
14921 cmdline_parse_inst_t cmd_ddp_del = {
14922 .f = cmd_ddp_del_parsed,
14924 .help_str = "ddp del <port_id> <backup_profile_path>",
14926 (void *)&cmd_ddp_del_ddp,
14927 (void *)&cmd_ddp_del_del,
14928 (void *)&cmd_ddp_del_port_id,
14929 (void *)&cmd_ddp_del_filepath,
14934 /* Get dynamic device personalization profile info */
14935 struct cmd_ddp_info_result {
14936 cmdline_fixed_string_t ddp;
14937 cmdline_fixed_string_t get;
14938 cmdline_fixed_string_t info;
14942 cmdline_parse_token_string_t cmd_ddp_info_ddp =
14943 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
14944 cmdline_parse_token_string_t cmd_ddp_info_get =
14945 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
14946 cmdline_parse_token_string_t cmd_ddp_info_info =
14947 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
14948 cmdline_parse_token_string_t cmd_ddp_info_filepath =
14949 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
14952 cmd_ddp_info_parsed(
14953 void *parsed_result,
14954 __attribute__((unused)) struct cmdline *cl,
14955 __attribute__((unused)) void *data)
14957 struct cmd_ddp_info_result *res = parsed_result;
14960 int ret = -ENOTSUP;
14961 #ifdef RTE_LIBRTE_I40E_PMD
14964 uint32_t buff_size = 0;
14965 struct rte_pmd_i40e_profile_info info;
14966 uint32_t dev_num = 0;
14967 struct rte_pmd_i40e_ddp_device_id *devs;
14968 uint32_t proto_num = 0;
14969 struct rte_pmd_i40e_proto_info *proto = NULL;
14970 uint32_t pctype_num = 0;
14971 struct rte_pmd_i40e_ptype_info *pctype;
14972 uint32_t ptype_num = 0;
14973 struct rte_pmd_i40e_ptype_info *ptype;
14978 pkg = open_file(res->filepath, &pkg_size);
14982 #ifdef RTE_LIBRTE_I40E_PMD
14983 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14984 (uint8_t *)&info, sizeof(info),
14985 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
14987 printf("Global Track id: 0x%x\n", info.track_id);
14988 printf("Global Version: %d.%d.%d.%d\n",
14989 info.version.major,
14990 info.version.minor,
14991 info.version.update,
14992 info.version.draft);
14993 printf("Global Package name: %s\n\n", info.name);
14996 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14997 (uint8_t *)&info, sizeof(info),
14998 RTE_PMD_I40E_PKG_INFO_HEADER);
15000 printf("i40e Profile Track id: 0x%x\n", info.track_id);
15001 printf("i40e Profile Version: %d.%d.%d.%d\n",
15002 info.version.major,
15003 info.version.minor,
15004 info.version.update,
15005 info.version.draft);
15006 printf("i40e Profile name: %s\n\n", info.name);
15009 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15010 (uint8_t *)&buff_size, sizeof(buff_size),
15011 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
15012 if (!ret && buff_size) {
15013 buff = (uint8_t *)malloc(buff_size);
15015 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15017 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
15019 printf("Package Notes:\n%s\n\n", buff);
15024 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15025 (uint8_t *)&dev_num, sizeof(dev_num),
15026 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
15027 if (!ret && dev_num) {
15028 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
15029 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
15031 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15032 (uint8_t *)devs, buff_size,
15033 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
15035 printf("List of supported devices:\n");
15036 for (i = 0; i < dev_num; i++) {
15037 printf(" %04X:%04X %04X:%04X\n",
15038 devs[i].vendor_dev_id >> 16,
15039 devs[i].vendor_dev_id & 0xFFFF,
15040 devs[i].sub_vendor_dev_id >> 16,
15041 devs[i].sub_vendor_dev_id & 0xFFFF);
15049 /* get information about protocols and packet types */
15050 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15051 (uint8_t *)&proto_num, sizeof(proto_num),
15052 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
15053 if (ret || !proto_num)
15054 goto no_print_return;
15056 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
15057 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
15059 goto no_print_return;
15061 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
15063 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
15065 printf("List of used protocols:\n");
15066 for (i = 0; i < proto_num; i++)
15067 printf(" %2u: %s\n", proto[i].proto_id,
15071 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15072 (uint8_t *)&pctype_num, sizeof(pctype_num),
15073 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
15074 if (ret || !pctype_num)
15075 goto no_print_pctypes;
15077 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
15078 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
15080 goto no_print_pctypes;
15082 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
15084 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
15087 goto no_print_pctypes;
15090 printf("List of defined packet classification types:\n");
15091 for (i = 0; i < pctype_num; i++) {
15092 printf(" %2u:", pctype[i].ptype_id);
15093 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
15094 proto_id = pctype[i].protocols[j];
15095 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
15096 for (n = 0; n < proto_num; n++) {
15097 if (proto[n].proto_id == proto_id) {
15098 printf(" %s", proto[n].name);
15111 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
15113 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
15114 if (ret || !ptype_num)
15115 goto no_print_return;
15117 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
15118 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
15120 goto no_print_return;
15122 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
15124 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
15127 goto no_print_return;
15129 printf("List of defined packet types:\n");
15130 for (i = 0; i < ptype_num; i++) {
15131 printf(" %2u:", ptype[i].ptype_id);
15132 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
15133 proto_id = ptype[i].protocols[j];
15134 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
15135 for (n = 0; n < proto_num; n++) {
15136 if (proto[n].proto_id == proto_id) {
15137 printf(" %s", proto[n].name);
15153 if (ret == -ENOTSUP)
15154 printf("Function not supported in PMD driver\n");
15158 cmdline_parse_inst_t cmd_ddp_get_info = {
15159 .f = cmd_ddp_info_parsed,
15161 .help_str = "ddp get info <profile_path>",
15163 (void *)&cmd_ddp_info_ddp,
15164 (void *)&cmd_ddp_info_get,
15165 (void *)&cmd_ddp_info_info,
15166 (void *)&cmd_ddp_info_filepath,
15171 /* Get dynamic device personalization profile info list*/
15172 #define PROFILE_INFO_SIZE 48
15173 #define MAX_PROFILE_NUM 16
15175 struct cmd_ddp_get_list_result {
15176 cmdline_fixed_string_t ddp;
15177 cmdline_fixed_string_t get;
15178 cmdline_fixed_string_t list;
15182 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
15183 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
15184 cmdline_parse_token_string_t cmd_ddp_get_list_get =
15185 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
15186 cmdline_parse_token_string_t cmd_ddp_get_list_list =
15187 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
15188 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
15189 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
15192 cmd_ddp_get_list_parsed(
15193 __attribute__((unused)) void *parsed_result,
15194 __attribute__((unused)) struct cmdline *cl,
15195 __attribute__((unused)) void *data)
15197 #ifdef RTE_LIBRTE_I40E_PMD
15198 struct cmd_ddp_get_list_result *res = parsed_result;
15199 struct rte_pmd_i40e_profile_list *p_list;
15200 struct rte_pmd_i40e_profile_info *p_info;
15205 int ret = -ENOTSUP;
15207 #ifdef RTE_LIBRTE_I40E_PMD
15208 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
15209 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
15211 printf("%s: Failed to malloc buffer\n", __func__);
15213 if (ret == -ENOTSUP)
15214 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
15215 (uint8_t *)p_list, size);
15218 p_num = p_list->p_count;
15219 printf("Profile number is: %d\n\n", p_num);
15221 for (i = 0; i < p_num; i++) {
15222 p_info = &p_list->p_info[i];
15223 printf("Profile %d:\n", i);
15224 printf("Track id: 0x%x\n", p_info->track_id);
15225 printf("Version: %d.%d.%d.%d\n",
15226 p_info->version.major,
15227 p_info->version.minor,
15228 p_info->version.update,
15229 p_info->version.draft);
15230 printf("Profile name: %s\n\n", p_info->name);
15238 printf("Failed to get ddp list\n");
15241 cmdline_parse_inst_t cmd_ddp_get_list = {
15242 .f = cmd_ddp_get_list_parsed,
15244 .help_str = "ddp get list <port_id>",
15246 (void *)&cmd_ddp_get_list_ddp,
15247 (void *)&cmd_ddp_get_list_get,
15248 (void *)&cmd_ddp_get_list_list,
15249 (void *)&cmd_ddp_get_list_port_id,
15254 /* Configure input set */
15255 struct cmd_cfg_input_set_result {
15256 cmdline_fixed_string_t port;
15257 cmdline_fixed_string_t cfg;
15259 cmdline_fixed_string_t pctype;
15261 cmdline_fixed_string_t inset_type;
15262 cmdline_fixed_string_t opt;
15263 cmdline_fixed_string_t field;
15268 cmd_cfg_input_set_parsed(
15269 __attribute__((unused)) void *parsed_result,
15270 __attribute__((unused)) struct cmdline *cl,
15271 __attribute__((unused)) void *data)
15273 #ifdef RTE_LIBRTE_I40E_PMD
15274 struct cmd_cfg_input_set_result *res = parsed_result;
15275 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
15276 struct rte_pmd_i40e_inset inset;
15278 int ret = -ENOTSUP;
15280 if (!all_ports_stopped()) {
15281 printf("Please stop all ports first\n");
15285 #ifdef RTE_LIBRTE_I40E_PMD
15286 if (!strcmp(res->inset_type, "hash_inset"))
15287 inset_type = INSET_HASH;
15288 else if (!strcmp(res->inset_type, "fdir_inset"))
15289 inset_type = INSET_FDIR;
15290 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
15291 inset_type = INSET_FDIR_FLX;
15292 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
15293 &inset, inset_type);
15295 printf("Failed to get input set.\n");
15299 if (!strcmp(res->opt, "get")) {
15300 ret = rte_pmd_i40e_inset_field_get(inset.inset,
15303 printf("Field index %d is enabled.\n", res->field_idx);
15305 printf("Field index %d is disabled.\n", res->field_idx);
15307 } else if (!strcmp(res->opt, "set"))
15308 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
15310 else if (!strcmp(res->opt, "clear"))
15311 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
15314 printf("Failed to configure input set field.\n");
15318 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15319 &inset, inset_type);
15321 printf("Failed to set input set.\n");
15326 if (ret == -ENOTSUP)
15327 printf("Function not supported\n");
15330 cmdline_parse_token_string_t cmd_cfg_input_set_port =
15331 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15333 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
15334 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15336 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
15337 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15339 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
15340 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15342 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
15343 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15345 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
15346 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15348 "hash_inset#fdir_inset#fdir_flx_inset");
15349 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
15350 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15351 opt, "get#set#clear");
15352 cmdline_parse_token_string_t cmd_cfg_input_set_field =
15353 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15355 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
15356 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15359 cmdline_parse_inst_t cmd_cfg_input_set = {
15360 .f = cmd_cfg_input_set_parsed,
15362 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15363 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
15365 (void *)&cmd_cfg_input_set_port,
15366 (void *)&cmd_cfg_input_set_cfg,
15367 (void *)&cmd_cfg_input_set_port_id,
15368 (void *)&cmd_cfg_input_set_pctype,
15369 (void *)&cmd_cfg_input_set_pctype_id,
15370 (void *)&cmd_cfg_input_set_inset_type,
15371 (void *)&cmd_cfg_input_set_opt,
15372 (void *)&cmd_cfg_input_set_field,
15373 (void *)&cmd_cfg_input_set_field_idx,
15378 /* Clear input set */
15379 struct cmd_clear_input_set_result {
15380 cmdline_fixed_string_t port;
15381 cmdline_fixed_string_t cfg;
15383 cmdline_fixed_string_t pctype;
15385 cmdline_fixed_string_t inset_type;
15386 cmdline_fixed_string_t clear;
15387 cmdline_fixed_string_t all;
15391 cmd_clear_input_set_parsed(
15392 __attribute__((unused)) void *parsed_result,
15393 __attribute__((unused)) struct cmdline *cl,
15394 __attribute__((unused)) void *data)
15396 #ifdef RTE_LIBRTE_I40E_PMD
15397 struct cmd_clear_input_set_result *res = parsed_result;
15398 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
15399 struct rte_pmd_i40e_inset inset;
15401 int ret = -ENOTSUP;
15403 if (!all_ports_stopped()) {
15404 printf("Please stop all ports first\n");
15408 #ifdef RTE_LIBRTE_I40E_PMD
15409 if (!strcmp(res->inset_type, "hash_inset"))
15410 inset_type = INSET_HASH;
15411 else if (!strcmp(res->inset_type, "fdir_inset"))
15412 inset_type = INSET_FDIR;
15413 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
15414 inset_type = INSET_FDIR_FLX;
15416 memset(&inset, 0, sizeof(inset));
15418 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15419 &inset, inset_type);
15421 printf("Failed to clear input set.\n");
15427 if (ret == -ENOTSUP)
15428 printf("Function not supported\n");
15431 cmdline_parse_token_string_t cmd_clear_input_set_port =
15432 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15434 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
15435 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15437 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
15438 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15440 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
15441 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15443 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
15444 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15446 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
15447 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15449 "hash_inset#fdir_inset#fdir_flx_inset");
15450 cmdline_parse_token_string_t cmd_clear_input_set_clear =
15451 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15453 cmdline_parse_token_string_t cmd_clear_input_set_all =
15454 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15457 cmdline_parse_inst_t cmd_clear_input_set = {
15458 .f = cmd_clear_input_set_parsed,
15460 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15461 "fdir_inset|fdir_flx_inset clear all",
15463 (void *)&cmd_clear_input_set_port,
15464 (void *)&cmd_clear_input_set_cfg,
15465 (void *)&cmd_clear_input_set_port_id,
15466 (void *)&cmd_clear_input_set_pctype,
15467 (void *)&cmd_clear_input_set_pctype_id,
15468 (void *)&cmd_clear_input_set_inset_type,
15469 (void *)&cmd_clear_input_set_clear,
15470 (void *)&cmd_clear_input_set_all,
15475 /* show vf stats */
15477 /* Common result structure for show vf stats */
15478 struct cmd_show_vf_stats_result {
15479 cmdline_fixed_string_t show;
15480 cmdline_fixed_string_t vf;
15481 cmdline_fixed_string_t stats;
15486 /* Common CLI fields show vf stats*/
15487 cmdline_parse_token_string_t cmd_show_vf_stats_show =
15488 TOKEN_STRING_INITIALIZER
15489 (struct cmd_show_vf_stats_result,
15491 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
15492 TOKEN_STRING_INITIALIZER
15493 (struct cmd_show_vf_stats_result,
15495 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
15496 TOKEN_STRING_INITIALIZER
15497 (struct cmd_show_vf_stats_result,
15499 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
15500 TOKEN_NUM_INITIALIZER
15501 (struct cmd_show_vf_stats_result,
15503 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
15504 TOKEN_NUM_INITIALIZER
15505 (struct cmd_show_vf_stats_result,
15509 cmd_show_vf_stats_parsed(
15510 void *parsed_result,
15511 __attribute__((unused)) struct cmdline *cl,
15512 __attribute__((unused)) void *data)
15514 struct cmd_show_vf_stats_result *res = parsed_result;
15515 struct rte_eth_stats stats;
15516 int ret = -ENOTSUP;
15517 static const char *nic_stats_border = "########################";
15519 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15522 memset(&stats, 0, sizeof(stats));
15524 #ifdef RTE_LIBRTE_I40E_PMD
15525 if (ret == -ENOTSUP)
15526 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
15530 #ifdef RTE_LIBRTE_BNXT_PMD
15531 if (ret == -ENOTSUP)
15532 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
15541 printf("invalid vf_id %d\n", res->vf_id);
15544 printf("invalid port_id %d\n", res->port_id);
15547 printf("function not implemented\n");
15550 printf("programming error: (%s)\n", strerror(-ret));
15553 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
15554 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
15556 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
15558 stats.ipackets, stats.imissed, stats.ibytes);
15559 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
15560 printf(" RX-nombuf: %-10"PRIu64"\n",
15562 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
15564 stats.opackets, stats.oerrors, stats.obytes);
15566 printf(" %s############################%s\n",
15567 nic_stats_border, nic_stats_border);
15570 cmdline_parse_inst_t cmd_show_vf_stats = {
15571 .f = cmd_show_vf_stats_parsed,
15573 .help_str = "show vf stats <port_id> <vf_id>",
15575 (void *)&cmd_show_vf_stats_show,
15576 (void *)&cmd_show_vf_stats_vf,
15577 (void *)&cmd_show_vf_stats_stats,
15578 (void *)&cmd_show_vf_stats_port_id,
15579 (void *)&cmd_show_vf_stats_vf_id,
15584 /* clear vf stats */
15586 /* Common result structure for clear vf stats */
15587 struct cmd_clear_vf_stats_result {
15588 cmdline_fixed_string_t clear;
15589 cmdline_fixed_string_t vf;
15590 cmdline_fixed_string_t stats;
15595 /* Common CLI fields clear vf stats*/
15596 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
15597 TOKEN_STRING_INITIALIZER
15598 (struct cmd_clear_vf_stats_result,
15600 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
15601 TOKEN_STRING_INITIALIZER
15602 (struct cmd_clear_vf_stats_result,
15604 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
15605 TOKEN_STRING_INITIALIZER
15606 (struct cmd_clear_vf_stats_result,
15608 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
15609 TOKEN_NUM_INITIALIZER
15610 (struct cmd_clear_vf_stats_result,
15612 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
15613 TOKEN_NUM_INITIALIZER
15614 (struct cmd_clear_vf_stats_result,
15618 cmd_clear_vf_stats_parsed(
15619 void *parsed_result,
15620 __attribute__((unused)) struct cmdline *cl,
15621 __attribute__((unused)) void *data)
15623 struct cmd_clear_vf_stats_result *res = parsed_result;
15624 int ret = -ENOTSUP;
15626 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15629 #ifdef RTE_LIBRTE_I40E_PMD
15630 if (ret == -ENOTSUP)
15631 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
15634 #ifdef RTE_LIBRTE_BNXT_PMD
15635 if (ret == -ENOTSUP)
15636 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
15644 printf("invalid vf_id %d\n", res->vf_id);
15647 printf("invalid port_id %d\n", res->port_id);
15650 printf("function not implemented\n");
15653 printf("programming error: (%s)\n", strerror(-ret));
15657 cmdline_parse_inst_t cmd_clear_vf_stats = {
15658 .f = cmd_clear_vf_stats_parsed,
15660 .help_str = "clear vf stats <port_id> <vf_id>",
15662 (void *)&cmd_clear_vf_stats_clear,
15663 (void *)&cmd_clear_vf_stats_vf,
15664 (void *)&cmd_clear_vf_stats_stats,
15665 (void *)&cmd_clear_vf_stats_port_id,
15666 (void *)&cmd_clear_vf_stats_vf_id,
15671 /* port config pctype mapping reset */
15673 /* Common result structure for port config pctype mapping reset */
15674 struct cmd_pctype_mapping_reset_result {
15675 cmdline_fixed_string_t port;
15676 cmdline_fixed_string_t config;
15678 cmdline_fixed_string_t pctype;
15679 cmdline_fixed_string_t mapping;
15680 cmdline_fixed_string_t reset;
15683 /* Common CLI fields for port config pctype mapping reset*/
15684 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
15685 TOKEN_STRING_INITIALIZER
15686 (struct cmd_pctype_mapping_reset_result,
15688 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
15689 TOKEN_STRING_INITIALIZER
15690 (struct cmd_pctype_mapping_reset_result,
15692 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
15693 TOKEN_NUM_INITIALIZER
15694 (struct cmd_pctype_mapping_reset_result,
15696 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
15697 TOKEN_STRING_INITIALIZER
15698 (struct cmd_pctype_mapping_reset_result,
15700 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
15701 TOKEN_STRING_INITIALIZER
15702 (struct cmd_pctype_mapping_reset_result,
15703 mapping, "mapping");
15704 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
15705 TOKEN_STRING_INITIALIZER
15706 (struct cmd_pctype_mapping_reset_result,
15710 cmd_pctype_mapping_reset_parsed(
15711 void *parsed_result,
15712 __attribute__((unused)) struct cmdline *cl,
15713 __attribute__((unused)) void *data)
15715 struct cmd_pctype_mapping_reset_result *res = parsed_result;
15716 int ret = -ENOTSUP;
15718 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15721 #ifdef RTE_LIBRTE_I40E_PMD
15722 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
15729 printf("invalid port_id %d\n", res->port_id);
15732 printf("function not implemented\n");
15735 printf("programming error: (%s)\n", strerror(-ret));
15739 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
15740 .f = cmd_pctype_mapping_reset_parsed,
15742 .help_str = "port config <port_id> pctype mapping reset",
15744 (void *)&cmd_pctype_mapping_reset_port,
15745 (void *)&cmd_pctype_mapping_reset_config,
15746 (void *)&cmd_pctype_mapping_reset_port_id,
15747 (void *)&cmd_pctype_mapping_reset_pctype,
15748 (void *)&cmd_pctype_mapping_reset_mapping,
15749 (void *)&cmd_pctype_mapping_reset_reset,
15754 /* show port pctype mapping */
15756 /* Common result structure for show port pctype mapping */
15757 struct cmd_pctype_mapping_get_result {
15758 cmdline_fixed_string_t show;
15759 cmdline_fixed_string_t port;
15761 cmdline_fixed_string_t pctype;
15762 cmdline_fixed_string_t mapping;
15765 /* Common CLI fields for pctype mapping get */
15766 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
15767 TOKEN_STRING_INITIALIZER
15768 (struct cmd_pctype_mapping_get_result,
15770 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
15771 TOKEN_STRING_INITIALIZER
15772 (struct cmd_pctype_mapping_get_result,
15774 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
15775 TOKEN_NUM_INITIALIZER
15776 (struct cmd_pctype_mapping_get_result,
15778 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
15779 TOKEN_STRING_INITIALIZER
15780 (struct cmd_pctype_mapping_get_result,
15782 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
15783 TOKEN_STRING_INITIALIZER
15784 (struct cmd_pctype_mapping_get_result,
15785 mapping, "mapping");
15788 cmd_pctype_mapping_get_parsed(
15789 void *parsed_result,
15790 __attribute__((unused)) struct cmdline *cl,
15791 __attribute__((unused)) void *data)
15793 struct cmd_pctype_mapping_get_result *res = parsed_result;
15794 int ret = -ENOTSUP;
15795 #ifdef RTE_LIBRTE_I40E_PMD
15796 struct rte_pmd_i40e_flow_type_mapping
15797 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
15798 int i, j, first_pctype;
15801 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15804 #ifdef RTE_LIBRTE_I40E_PMD
15805 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
15812 printf("invalid port_id %d\n", res->port_id);
15815 printf("function not implemented\n");
15818 printf("programming error: (%s)\n", strerror(-ret));
15822 #ifdef RTE_LIBRTE_I40E_PMD
15823 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
15824 if (mapping[i].pctype != 0ULL) {
15827 printf("pctype: ");
15828 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
15829 if (mapping[i].pctype & (1ULL << j)) {
15830 printf(first_pctype ?
15831 "%02d" : ",%02d", j);
15835 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
15841 cmdline_parse_inst_t cmd_pctype_mapping_get = {
15842 .f = cmd_pctype_mapping_get_parsed,
15844 .help_str = "show port <port_id> pctype mapping",
15846 (void *)&cmd_pctype_mapping_get_show,
15847 (void *)&cmd_pctype_mapping_get_port,
15848 (void *)&cmd_pctype_mapping_get_port_id,
15849 (void *)&cmd_pctype_mapping_get_pctype,
15850 (void *)&cmd_pctype_mapping_get_mapping,
15855 /* port config pctype mapping update */
15857 /* Common result structure for port config pctype mapping update */
15858 struct cmd_pctype_mapping_update_result {
15859 cmdline_fixed_string_t port;
15860 cmdline_fixed_string_t config;
15862 cmdline_fixed_string_t pctype;
15863 cmdline_fixed_string_t mapping;
15864 cmdline_fixed_string_t update;
15865 cmdline_fixed_string_t pctype_list;
15866 uint16_t flow_type;
15869 /* Common CLI fields for pctype mapping update*/
15870 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
15871 TOKEN_STRING_INITIALIZER
15872 (struct cmd_pctype_mapping_update_result,
15874 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
15875 TOKEN_STRING_INITIALIZER
15876 (struct cmd_pctype_mapping_update_result,
15878 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
15879 TOKEN_NUM_INITIALIZER
15880 (struct cmd_pctype_mapping_update_result,
15882 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
15883 TOKEN_STRING_INITIALIZER
15884 (struct cmd_pctype_mapping_update_result,
15886 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
15887 TOKEN_STRING_INITIALIZER
15888 (struct cmd_pctype_mapping_update_result,
15889 mapping, "mapping");
15890 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
15891 TOKEN_STRING_INITIALIZER
15892 (struct cmd_pctype_mapping_update_result,
15894 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
15895 TOKEN_STRING_INITIALIZER
15896 (struct cmd_pctype_mapping_update_result,
15897 pctype_list, NULL);
15898 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
15899 TOKEN_NUM_INITIALIZER
15900 (struct cmd_pctype_mapping_update_result,
15901 flow_type, UINT16);
15904 cmd_pctype_mapping_update_parsed(
15905 void *parsed_result,
15906 __attribute__((unused)) struct cmdline *cl,
15907 __attribute__((unused)) void *data)
15909 struct cmd_pctype_mapping_update_result *res = parsed_result;
15910 int ret = -ENOTSUP;
15911 #ifdef RTE_LIBRTE_I40E_PMD
15912 struct rte_pmd_i40e_flow_type_mapping mapping;
15914 unsigned int nb_item;
15915 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
15918 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15921 #ifdef RTE_LIBRTE_I40E_PMD
15922 nb_item = parse_item_list(res->pctype_list, "pctypes",
15923 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
15924 mapping.flow_type = res->flow_type;
15925 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
15926 mapping.pctype |= (1ULL << pctype_list[i]);
15927 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
15937 printf("invalid pctype or flow type\n");
15940 printf("invalid port_id %d\n", res->port_id);
15943 printf("function not implemented\n");
15946 printf("programming error: (%s)\n", strerror(-ret));
15950 cmdline_parse_inst_t cmd_pctype_mapping_update = {
15951 .f = cmd_pctype_mapping_update_parsed,
15953 .help_str = "port config <port_id> pctype mapping update"
15954 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
15956 (void *)&cmd_pctype_mapping_update_port,
15957 (void *)&cmd_pctype_mapping_update_config,
15958 (void *)&cmd_pctype_mapping_update_port_id,
15959 (void *)&cmd_pctype_mapping_update_pctype,
15960 (void *)&cmd_pctype_mapping_update_mapping,
15961 (void *)&cmd_pctype_mapping_update_update,
15962 (void *)&cmd_pctype_mapping_update_pc_type,
15963 (void *)&cmd_pctype_mapping_update_flow_type,
15968 /* ptype mapping get */
15970 /* Common result structure for ptype mapping get */
15971 struct cmd_ptype_mapping_get_result {
15972 cmdline_fixed_string_t ptype;
15973 cmdline_fixed_string_t mapping;
15974 cmdline_fixed_string_t get;
15976 uint8_t valid_only;
15979 /* Common CLI fields for ptype mapping get */
15980 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
15981 TOKEN_STRING_INITIALIZER
15982 (struct cmd_ptype_mapping_get_result,
15984 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
15985 TOKEN_STRING_INITIALIZER
15986 (struct cmd_ptype_mapping_get_result,
15987 mapping, "mapping");
15988 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
15989 TOKEN_STRING_INITIALIZER
15990 (struct cmd_ptype_mapping_get_result,
15992 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
15993 TOKEN_NUM_INITIALIZER
15994 (struct cmd_ptype_mapping_get_result,
15996 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
15997 TOKEN_NUM_INITIALIZER
15998 (struct cmd_ptype_mapping_get_result,
15999 valid_only, UINT8);
16002 cmd_ptype_mapping_get_parsed(
16003 void *parsed_result,
16004 __attribute__((unused)) struct cmdline *cl,
16005 __attribute__((unused)) void *data)
16007 struct cmd_ptype_mapping_get_result *res = parsed_result;
16008 int ret = -ENOTSUP;
16009 #ifdef RTE_LIBRTE_I40E_PMD
16010 int max_ptype_num = 256;
16011 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
16016 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16019 #ifdef RTE_LIBRTE_I40E_PMD
16020 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
16031 printf("invalid port_id %d\n", res->port_id);
16034 printf("function not implemented\n");
16037 printf("programming error: (%s)\n", strerror(-ret));
16040 #ifdef RTE_LIBRTE_I40E_PMD
16042 for (i = 0; i < count; i++)
16043 printf("%3d\t0x%08x\n",
16044 mapping[i].hw_ptype, mapping[i].sw_ptype);
16049 cmdline_parse_inst_t cmd_ptype_mapping_get = {
16050 .f = cmd_ptype_mapping_get_parsed,
16052 .help_str = "ptype mapping get <port_id> <valid_only>",
16054 (void *)&cmd_ptype_mapping_get_ptype,
16055 (void *)&cmd_ptype_mapping_get_mapping,
16056 (void *)&cmd_ptype_mapping_get_get,
16057 (void *)&cmd_ptype_mapping_get_port_id,
16058 (void *)&cmd_ptype_mapping_get_valid_only,
16063 /* ptype mapping replace */
16065 /* Common result structure for ptype mapping replace */
16066 struct cmd_ptype_mapping_replace_result {
16067 cmdline_fixed_string_t ptype;
16068 cmdline_fixed_string_t mapping;
16069 cmdline_fixed_string_t replace;
16076 /* Common CLI fields for ptype mapping replace */
16077 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
16078 TOKEN_STRING_INITIALIZER
16079 (struct cmd_ptype_mapping_replace_result,
16081 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
16082 TOKEN_STRING_INITIALIZER
16083 (struct cmd_ptype_mapping_replace_result,
16084 mapping, "mapping");
16085 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
16086 TOKEN_STRING_INITIALIZER
16087 (struct cmd_ptype_mapping_replace_result,
16088 replace, "replace");
16089 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
16090 TOKEN_NUM_INITIALIZER
16091 (struct cmd_ptype_mapping_replace_result,
16093 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
16094 TOKEN_NUM_INITIALIZER
16095 (struct cmd_ptype_mapping_replace_result,
16097 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
16098 TOKEN_NUM_INITIALIZER
16099 (struct cmd_ptype_mapping_replace_result,
16101 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
16102 TOKEN_NUM_INITIALIZER
16103 (struct cmd_ptype_mapping_replace_result,
16107 cmd_ptype_mapping_replace_parsed(
16108 void *parsed_result,
16109 __attribute__((unused)) struct cmdline *cl,
16110 __attribute__((unused)) void *data)
16112 struct cmd_ptype_mapping_replace_result *res = parsed_result;
16113 int ret = -ENOTSUP;
16115 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16118 #ifdef RTE_LIBRTE_I40E_PMD
16119 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
16129 printf("invalid ptype 0x%8x or 0x%8x\n",
16130 res->target, res->pkt_type);
16133 printf("invalid port_id %d\n", res->port_id);
16136 printf("function not implemented\n");
16139 printf("programming error: (%s)\n", strerror(-ret));
16143 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
16144 .f = cmd_ptype_mapping_replace_parsed,
16147 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
16149 (void *)&cmd_ptype_mapping_replace_ptype,
16150 (void *)&cmd_ptype_mapping_replace_mapping,
16151 (void *)&cmd_ptype_mapping_replace_replace,
16152 (void *)&cmd_ptype_mapping_replace_port_id,
16153 (void *)&cmd_ptype_mapping_replace_target,
16154 (void *)&cmd_ptype_mapping_replace_mask,
16155 (void *)&cmd_ptype_mapping_replace_pkt_type,
16160 /* ptype mapping reset */
16162 /* Common result structure for ptype mapping reset */
16163 struct cmd_ptype_mapping_reset_result {
16164 cmdline_fixed_string_t ptype;
16165 cmdline_fixed_string_t mapping;
16166 cmdline_fixed_string_t reset;
16170 /* Common CLI fields for ptype mapping reset*/
16171 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
16172 TOKEN_STRING_INITIALIZER
16173 (struct cmd_ptype_mapping_reset_result,
16175 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
16176 TOKEN_STRING_INITIALIZER
16177 (struct cmd_ptype_mapping_reset_result,
16178 mapping, "mapping");
16179 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
16180 TOKEN_STRING_INITIALIZER
16181 (struct cmd_ptype_mapping_reset_result,
16183 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
16184 TOKEN_NUM_INITIALIZER
16185 (struct cmd_ptype_mapping_reset_result,
16189 cmd_ptype_mapping_reset_parsed(
16190 void *parsed_result,
16191 __attribute__((unused)) struct cmdline *cl,
16192 __attribute__((unused)) void *data)
16194 struct cmd_ptype_mapping_reset_result *res = parsed_result;
16195 int ret = -ENOTSUP;
16197 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16200 #ifdef RTE_LIBRTE_I40E_PMD
16201 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
16208 printf("invalid port_id %d\n", res->port_id);
16211 printf("function not implemented\n");
16214 printf("programming error: (%s)\n", strerror(-ret));
16218 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
16219 .f = cmd_ptype_mapping_reset_parsed,
16221 .help_str = "ptype mapping reset <port_id>",
16223 (void *)&cmd_ptype_mapping_reset_ptype,
16224 (void *)&cmd_ptype_mapping_reset_mapping,
16225 (void *)&cmd_ptype_mapping_reset_reset,
16226 (void *)&cmd_ptype_mapping_reset_port_id,
16231 /* ptype mapping update */
16233 /* Common result structure for ptype mapping update */
16234 struct cmd_ptype_mapping_update_result {
16235 cmdline_fixed_string_t ptype;
16236 cmdline_fixed_string_t mapping;
16237 cmdline_fixed_string_t reset;
16243 /* Common CLI fields for ptype mapping update*/
16244 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
16245 TOKEN_STRING_INITIALIZER
16246 (struct cmd_ptype_mapping_update_result,
16248 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
16249 TOKEN_STRING_INITIALIZER
16250 (struct cmd_ptype_mapping_update_result,
16251 mapping, "mapping");
16252 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
16253 TOKEN_STRING_INITIALIZER
16254 (struct cmd_ptype_mapping_update_result,
16256 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
16257 TOKEN_NUM_INITIALIZER
16258 (struct cmd_ptype_mapping_update_result,
16260 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
16261 TOKEN_NUM_INITIALIZER
16262 (struct cmd_ptype_mapping_update_result,
16264 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
16265 TOKEN_NUM_INITIALIZER
16266 (struct cmd_ptype_mapping_update_result,
16270 cmd_ptype_mapping_update_parsed(
16271 void *parsed_result,
16272 __attribute__((unused)) struct cmdline *cl,
16273 __attribute__((unused)) void *data)
16275 struct cmd_ptype_mapping_update_result *res = parsed_result;
16276 int ret = -ENOTSUP;
16277 #ifdef RTE_LIBRTE_I40E_PMD
16278 struct rte_pmd_i40e_ptype_mapping mapping;
16280 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16283 #ifdef RTE_LIBRTE_I40E_PMD
16284 mapping.hw_ptype = res->hw_ptype;
16285 mapping.sw_ptype = res->sw_ptype;
16286 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
16296 printf("invalid ptype 0x%8x\n", res->sw_ptype);
16299 printf("invalid port_id %d\n", res->port_id);
16302 printf("function not implemented\n");
16305 printf("programming error: (%s)\n", strerror(-ret));
16309 cmdline_parse_inst_t cmd_ptype_mapping_update = {
16310 .f = cmd_ptype_mapping_update_parsed,
16312 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
16314 (void *)&cmd_ptype_mapping_update_ptype,
16315 (void *)&cmd_ptype_mapping_update_mapping,
16316 (void *)&cmd_ptype_mapping_update_update,
16317 (void *)&cmd_ptype_mapping_update_port_id,
16318 (void *)&cmd_ptype_mapping_update_hw_ptype,
16319 (void *)&cmd_ptype_mapping_update_sw_ptype,
16324 /* Common result structure for file commands */
16325 struct cmd_cmdfile_result {
16326 cmdline_fixed_string_t load;
16327 cmdline_fixed_string_t filename;
16330 /* Common CLI fields for file commands */
16331 cmdline_parse_token_string_t cmd_load_cmdfile =
16332 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
16333 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
16334 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
16337 cmd_load_from_file_parsed(
16338 void *parsed_result,
16339 __attribute__((unused)) struct cmdline *cl,
16340 __attribute__((unused)) void *data)
16342 struct cmd_cmdfile_result *res = parsed_result;
16344 cmdline_read_from_file(res->filename);
16347 cmdline_parse_inst_t cmd_load_from_file = {
16348 .f = cmd_load_from_file_parsed,
16350 .help_str = "load <filename>",
16352 (void *)&cmd_load_cmdfile,
16353 (void *)&cmd_load_cmdfile_filename,
16358 /* ******************************************************************************** */
16360 /* list of instructions */
16361 cmdline_parse_ctx_t main_ctx[] = {
16362 (cmdline_parse_inst_t *)&cmd_help_brief,
16363 (cmdline_parse_inst_t *)&cmd_help_long,
16364 (cmdline_parse_inst_t *)&cmd_quit,
16365 (cmdline_parse_inst_t *)&cmd_load_from_file,
16366 (cmdline_parse_inst_t *)&cmd_showport,
16367 (cmdline_parse_inst_t *)&cmd_showqueue,
16368 (cmdline_parse_inst_t *)&cmd_showportall,
16369 (cmdline_parse_inst_t *)&cmd_showcfg,
16370 (cmdline_parse_inst_t *)&cmd_start,
16371 (cmdline_parse_inst_t *)&cmd_start_tx_first,
16372 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
16373 (cmdline_parse_inst_t *)&cmd_set_link_up,
16374 (cmdline_parse_inst_t *)&cmd_set_link_down,
16375 (cmdline_parse_inst_t *)&cmd_reset,
16376 (cmdline_parse_inst_t *)&cmd_set_numbers,
16377 (cmdline_parse_inst_t *)&cmd_set_log,
16378 (cmdline_parse_inst_t *)&cmd_set_txpkts,
16379 (cmdline_parse_inst_t *)&cmd_set_txsplit,
16380 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
16381 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
16382 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
16383 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
16384 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
16385 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
16386 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
16387 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
16388 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
16389 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
16390 (cmdline_parse_inst_t *)&cmd_set_link_check,
16391 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
16392 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
16393 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
16394 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
16395 #ifdef RTE_LIBRTE_PMD_BOND
16396 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
16397 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
16398 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
16399 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
16400 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
16401 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
16402 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
16403 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
16404 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
16405 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
16406 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
16408 (cmdline_parse_inst_t *)&cmd_vlan_offload,
16409 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
16410 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
16411 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
16412 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
16413 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
16414 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
16415 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
16416 (cmdline_parse_inst_t *)&cmd_csum_set,
16417 (cmdline_parse_inst_t *)&cmd_csum_show,
16418 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
16419 (cmdline_parse_inst_t *)&cmd_tso_set,
16420 (cmdline_parse_inst_t *)&cmd_tso_show,
16421 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
16422 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
16423 (cmdline_parse_inst_t *)&cmd_gro_enable,
16424 (cmdline_parse_inst_t *)&cmd_gro_flush,
16425 (cmdline_parse_inst_t *)&cmd_gro_show,
16426 (cmdline_parse_inst_t *)&cmd_gso_enable,
16427 (cmdline_parse_inst_t *)&cmd_gso_size,
16428 (cmdline_parse_inst_t *)&cmd_gso_show,
16429 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
16430 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
16431 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
16432 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
16433 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
16434 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
16435 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
16436 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
16437 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
16438 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
16439 (cmdline_parse_inst_t *)&cmd_config_dcb,
16440 (cmdline_parse_inst_t *)&cmd_read_reg,
16441 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
16442 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
16443 (cmdline_parse_inst_t *)&cmd_write_reg,
16444 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
16445 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
16446 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
16447 (cmdline_parse_inst_t *)&cmd_stop,
16448 (cmdline_parse_inst_t *)&cmd_mac_addr,
16449 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
16450 (cmdline_parse_inst_t *)&cmd_set_qmap,
16451 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
16452 (cmdline_parse_inst_t *)&cmd_operate_port,
16453 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
16454 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
16455 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
16456 (cmdline_parse_inst_t *)&cmd_config_speed_all,
16457 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
16458 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
16459 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
16460 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
16461 (cmdline_parse_inst_t *)&cmd_config_mtu,
16462 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
16463 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
16464 (cmdline_parse_inst_t *)&cmd_config_rss,
16465 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
16466 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
16467 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
16468 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
16469 (cmdline_parse_inst_t *)&cmd_showport_reta,
16470 (cmdline_parse_inst_t *)&cmd_config_burst,
16471 (cmdline_parse_inst_t *)&cmd_config_thresh,
16472 (cmdline_parse_inst_t *)&cmd_config_threshold,
16473 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
16474 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
16475 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
16476 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
16477 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
16478 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
16479 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
16480 (cmdline_parse_inst_t *)&cmd_global_config,
16481 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
16482 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
16483 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
16484 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
16485 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
16486 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
16487 (cmdline_parse_inst_t *)&cmd_dump,
16488 (cmdline_parse_inst_t *)&cmd_dump_one,
16489 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
16490 (cmdline_parse_inst_t *)&cmd_syn_filter,
16491 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
16492 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
16493 (cmdline_parse_inst_t *)&cmd_flex_filter,
16494 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
16495 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
16496 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
16497 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
16498 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
16499 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
16500 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
16501 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
16502 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
16503 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
16504 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
16505 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
16506 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
16507 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
16508 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
16509 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
16510 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
16511 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
16512 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
16513 (cmdline_parse_inst_t *)&cmd_flow,
16514 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
16515 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
16516 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
16517 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
16518 (cmdline_parse_inst_t *)&cmd_create_port_meter,
16519 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
16520 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
16521 (cmdline_parse_inst_t *)&cmd_del_port_meter,
16522 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
16523 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
16524 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
16525 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
16526 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
16527 (cmdline_parse_inst_t *)&cmd_mcast_addr,
16528 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
16529 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
16530 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
16531 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
16532 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
16533 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
16534 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
16535 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
16536 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
16537 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
16538 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
16539 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
16540 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
16541 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
16542 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
16543 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
16544 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
16545 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
16546 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
16547 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
16548 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
16549 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
16550 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
16551 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
16552 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
16553 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
16554 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
16555 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
16556 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
16557 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
16558 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
16559 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
16560 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
16561 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
16562 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
16563 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
16564 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
16566 (cmdline_parse_inst_t *)&cmd_ddp_add,
16567 (cmdline_parse_inst_t *)&cmd_ddp_del,
16568 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
16569 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
16570 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
16571 (cmdline_parse_inst_t *)&cmd_clear_input_set,
16572 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
16573 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
16574 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
16575 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
16576 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
16577 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
16579 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
16580 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
16581 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
16582 (cmdline_parse_inst_t *)&cmd_queue_region,
16583 (cmdline_parse_inst_t *)&cmd_region_flowtype,
16584 (cmdline_parse_inst_t *)&cmd_user_priority_region,
16585 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
16586 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
16587 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
16588 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
16589 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
16590 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
16591 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
16592 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
16593 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
16594 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
16595 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
16596 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
16597 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
16598 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
16599 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
16600 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
16601 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
16602 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
16603 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
16607 /* read cmdline commands from file */
16609 cmdline_read_from_file(const char *filename)
16611 struct cmdline *cl;
16613 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
16615 printf("Failed to create file based cmdline context: %s\n",
16620 cmdline_interact(cl);
16625 printf("Read CLI commands from %s\n", filename);
16628 /* prompt function, called from main on MASTER lcore */
16632 /* initialize non-constant commands */
16633 cmd_set_fwd_mode_init();
16634 cmd_set_fwd_retry_mode_init();
16636 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
16637 if (testpmd_cl == NULL)
16639 cmdline_interact(testpmd_cl);
16640 cmdline_stdin_exit(testpmd_cl);
16646 if (testpmd_cl != NULL)
16647 cmdline_quit(testpmd_cl);
16651 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
16653 if (id == (portid_t)RTE_PORT_ALL) {
16656 RTE_ETH_FOREACH_DEV(pid) {
16657 /* check if need_reconfig has been set to 1 */
16658 if (ports[pid].need_reconfig == 0)
16659 ports[pid].need_reconfig = dev;
16660 /* check if need_reconfig_queues has been set to 1 */
16661 if (ports[pid].need_reconfig_queues == 0)
16662 ports[pid].need_reconfig_queues = queue;
16664 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
16665 /* check if need_reconfig has been set to 1 */
16666 if (ports[id].need_reconfig == 0)
16667 ports[id].need_reconfig = dev;
16668 /* check if need_reconfig_queues has been set to 1 */
16669 if (ports[id].need_reconfig_queues == 0)
16670 ports[id].need_reconfig_queues = queue;