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|ip|tcp|udp|sctp|ether|port|vxlan|"
825 "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 (port_id) (rxq|txq) (queue_id) (start|stop)\n"
850 " Start/stop a rx/tx queue of port X. Only take effect"
851 " when port X is started\n\n"
853 "port config (port_id|all) l2-tunnel E-tag ether-type"
855 " Set the value of E-tag ether-type.\n\n"
857 "port config (port_id|all) l2-tunnel E-tag"
858 " (enable|disable)\n"
859 " Enable/disable the E-tag support.\n\n"
861 "port config (port_id) pctype mapping reset\n"
862 " Reset flow type to pctype mapping on a port\n\n"
864 "port config (port_id) pctype mapping update"
865 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
866 " Update a flow type to pctype mapping item on a port\n\n"
868 "port config (port_id) pctype (pctype_id) hash_inset|"
869 "fdir_inset|fdir_flx_inset get|set|clear field\n"
871 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
873 "port config (port_id) pctype (pctype_id) hash_inset|"
874 "fdir_inset|fdir_flx_inset clear all"
875 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
879 if (show_all || !strcmp(res->section, "registers")) {
887 "read reg (port_id) (address)\n"
888 " Display value of a port register.\n\n"
890 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
891 " Display a port register bit field.\n\n"
893 "read regbit (port_id) (address) (bit_x)\n"
894 " Display a single port register bit.\n\n"
896 "write reg (port_id) (address) (value)\n"
897 " Set value of a port register.\n\n"
899 "write regfield (port_id) (address) (bit_x) (bit_y)"
901 " Set bit field of a port register.\n\n"
903 "write regbit (port_id) (address) (bit_x) (value)\n"
904 " Set single bit value of a port register.\n\n"
907 if (show_all || !strcmp(res->section, "filters")) {
915 "ethertype_filter (port_id) (add|del)"
916 " (mac_addr|mac_ignr) (mac_address) ethertype"
917 " (ether_type) (drop|fwd) queue (queue_id)\n"
918 " Add/Del an ethertype filter.\n\n"
920 "2tuple_filter (port_id) (add|del)"
921 " dst_port (dst_port_value) protocol (protocol_value)"
922 " mask (mask_value) tcp_flags (tcp_flags_value)"
923 " priority (prio_value) queue (queue_id)\n"
924 " Add/Del a 2tuple filter.\n\n"
926 "5tuple_filter (port_id) (add|del)"
927 " dst_ip (dst_address) src_ip (src_address)"
928 " dst_port (dst_port_value) src_port (src_port_value)"
929 " protocol (protocol_value)"
930 " mask (mask_value) tcp_flags (tcp_flags_value)"
931 " priority (prio_value) queue (queue_id)\n"
932 " Add/Del a 5tuple filter.\n\n"
934 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
935 " Add/Del syn filter.\n\n"
937 "flex_filter (port_id) (add|del) len (len_value)"
938 " bytes (bytes_value) mask (mask_value)"
939 " priority (prio_value) queue (queue_id)\n"
940 " Add/Del a flex filter.\n\n"
942 "flow_director_filter (port_id) mode IP (add|del|update)"
943 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
944 " src (src_ip_address) dst (dst_ip_address)"
945 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
946 " vlan (vlan_value) flexbytes (flexbytes_value)"
947 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
948 " fd_id (fd_id_value)\n"
949 " Add/Del an IP type flow director filter.\n\n"
951 "flow_director_filter (port_id) mode IP (add|del|update)"
952 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
953 " src (src_ip_address) (src_port)"
954 " dst (dst_ip_address) (dst_port)"
955 " tos (tos_value) ttl (ttl_value)"
956 " vlan (vlan_value) flexbytes (flexbytes_value)"
957 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
958 " fd_id (fd_id_value)\n"
959 " Add/Del an UDP/TCP type flow director filter.\n\n"
961 "flow_director_filter (port_id) mode IP (add|del|update)"
962 " flow (ipv4-sctp|ipv6-sctp)"
963 " src (src_ip_address) (src_port)"
964 " dst (dst_ip_address) (dst_port)"
965 " tag (verification_tag) "
966 " tos (tos_value) ttl (ttl_value)"
968 " flexbytes (flexbytes_value) (drop|fwd)"
969 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
970 " Add/Del a SCTP type flow director filter.\n\n"
972 "flow_director_filter (port_id) mode IP (add|del|update)"
973 " flow l2_payload ether (ethertype)"
974 " flexbytes (flexbytes_value) (drop|fwd)"
975 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
976 " Add/Del a l2 payload type flow director filter.\n\n"
978 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
979 " mac (mac_address) vlan (vlan_value)"
980 " flexbytes (flexbytes_value) (drop|fwd)"
981 " queue (queue_id) fd_id (fd_id_value)\n"
982 " Add/Del a MAC-VLAN flow director filter.\n\n"
984 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
985 " mac (mac_address) vlan (vlan_value)"
986 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
987 " flexbytes (flexbytes_value) (drop|fwd)"
988 " queue (queue_id) fd_id (fd_id_value)\n"
989 " Add/Del a Tunnel flow director filter.\n\n"
991 "flow_director_filter (port_id) mode raw (add|del|update)"
992 " flow (flow_id) (drop|fwd) queue (queue_id)"
993 " fd_id (fd_id_value) packet (packet file name)\n"
994 " Add/Del a raw type flow director filter.\n\n"
996 "flush_flow_director (port_id)\n"
997 " Flush all flow director entries of a device.\n\n"
999 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
1000 " src_mask (ipv4_src) (ipv6_src) (src_port)"
1001 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
1002 " Set flow director IP mask.\n\n"
1004 "flow_director_mask (port_id) mode MAC-VLAN"
1005 " vlan (vlan_value)\n"
1006 " Set flow director MAC-VLAN mask.\n\n"
1008 "flow_director_mask (port_id) mode Tunnel"
1009 " vlan (vlan_value) mac (mac_value)"
1010 " tunnel-type (tunnel_type_value)"
1011 " tunnel-id (tunnel_id_value)\n"
1012 " Set flow director Tunnel mask.\n\n"
1014 "flow_director_flex_mask (port_id)"
1015 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
1016 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
1018 " Configure mask of flex payload.\n\n"
1020 "flow_director_flex_payload (port_id)"
1021 " (raw|l2|l3|l4) (config)\n"
1022 " Configure flex payload selection.\n\n"
1024 "get_sym_hash_ena_per_port (port_id)\n"
1025 " get symmetric hash enable configuration per port.\n\n"
1027 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
1028 " set symmetric hash enable configuration per port"
1029 " to enable or disable.\n\n"
1031 "get_hash_global_config (port_id)\n"
1032 " Get the global configurations of hash filters.\n\n"
1034 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
1035 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1036 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
1037 " (enable|disable)\n"
1038 " Set the global configurations of hash filters.\n\n"
1040 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
1041 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1042 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1043 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
1044 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
1045 "ipv6-next-header|udp-src-port|udp-dst-port|"
1046 "tcp-src-port|tcp-dst-port|sctp-src-port|"
1047 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
1048 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
1049 "fld-8th|none) (select|add)\n"
1050 " Set the input set for hash.\n\n"
1052 "set_fdir_input_set (port_id) "
1053 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1054 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1055 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
1056 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
1057 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
1058 "udp-dst-port|tcp-src-port|tcp-dst-port|"
1059 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
1061 " Set the input set for FDir.\n\n"
1063 "flow validate {port_id}"
1064 " [group {group_id}] [priority {level}]"
1065 " [ingress] [egress]"
1066 " pattern {item} [/ {item} [...]] / end"
1067 " actions {action} [/ {action} [...]] / end\n"
1068 " Check whether a flow rule can be created.\n\n"
1070 "flow create {port_id}"
1071 " [group {group_id}] [priority {level}]"
1072 " [ingress] [egress]"
1073 " pattern {item} [/ {item} [...]] / end"
1074 " actions {action} [/ {action} [...]] / end\n"
1075 " Create a flow rule.\n\n"
1077 "flow destroy {port_id} rule {rule_id} [...]\n"
1078 " Destroy specific flow rules.\n\n"
1080 "flow flush {port_id}\n"
1081 " Destroy all flow rules.\n\n"
1083 "flow query {port_id} {rule_id} {action}\n"
1084 " Query an existing flow rule.\n\n"
1086 "flow list {port_id} [group {group_id}] [...]\n"
1087 " List existing flow rules sorted by priority,"
1088 " filtered by group identifiers.\n\n"
1090 "flow isolate {port_id} {boolean}\n"
1091 " Restrict ingress traffic to the defined"
1097 cmdline_parse_token_string_t cmd_help_long_help =
1098 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1100 cmdline_parse_token_string_t cmd_help_long_section =
1101 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1102 "all#control#display#config#"
1103 "ports#registers#filters");
1105 cmdline_parse_inst_t cmd_help_long = {
1106 .f = cmd_help_long_parsed,
1108 .help_str = "help all|control|display|config|ports|register|filters: "
1111 (void *)&cmd_help_long_help,
1112 (void *)&cmd_help_long_section,
1118 /* *** start/stop/close all ports *** */
1119 struct cmd_operate_port_result {
1120 cmdline_fixed_string_t keyword;
1121 cmdline_fixed_string_t name;
1122 cmdline_fixed_string_t value;
1125 static void cmd_operate_port_parsed(void *parsed_result,
1126 __attribute__((unused)) struct cmdline *cl,
1127 __attribute__((unused)) void *data)
1129 struct cmd_operate_port_result *res = parsed_result;
1131 if (!strcmp(res->name, "start"))
1132 start_port(RTE_PORT_ALL);
1133 else if (!strcmp(res->name, "stop"))
1134 stop_port(RTE_PORT_ALL);
1135 else if (!strcmp(res->name, "close"))
1136 close_port(RTE_PORT_ALL);
1137 else if (!strcmp(res->name, "reset"))
1138 reset_port(RTE_PORT_ALL);
1140 printf("Unknown parameter\n");
1143 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1144 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1146 cmdline_parse_token_string_t cmd_operate_port_all_port =
1147 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1148 "start#stop#close#reset");
1149 cmdline_parse_token_string_t cmd_operate_port_all_all =
1150 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1152 cmdline_parse_inst_t cmd_operate_port = {
1153 .f = cmd_operate_port_parsed,
1155 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1157 (void *)&cmd_operate_port_all_cmd,
1158 (void *)&cmd_operate_port_all_port,
1159 (void *)&cmd_operate_port_all_all,
1164 /* *** start/stop/close specific port *** */
1165 struct cmd_operate_specific_port_result {
1166 cmdline_fixed_string_t keyword;
1167 cmdline_fixed_string_t name;
1171 static void cmd_operate_specific_port_parsed(void *parsed_result,
1172 __attribute__((unused)) struct cmdline *cl,
1173 __attribute__((unused)) void *data)
1175 struct cmd_operate_specific_port_result *res = parsed_result;
1177 if (!strcmp(res->name, "start"))
1178 start_port(res->value);
1179 else if (!strcmp(res->name, "stop"))
1180 stop_port(res->value);
1181 else if (!strcmp(res->name, "close"))
1182 close_port(res->value);
1183 else if (!strcmp(res->name, "reset"))
1184 reset_port(res->value);
1186 printf("Unknown parameter\n");
1189 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1190 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1192 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1193 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1194 name, "start#stop#close#reset");
1195 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1196 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1199 cmdline_parse_inst_t cmd_operate_specific_port = {
1200 .f = cmd_operate_specific_port_parsed,
1202 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1204 (void *)&cmd_operate_specific_port_cmd,
1205 (void *)&cmd_operate_specific_port_port,
1206 (void *)&cmd_operate_specific_port_id,
1211 /* *** attach a specified port *** */
1212 struct cmd_operate_attach_port_result {
1213 cmdline_fixed_string_t port;
1214 cmdline_fixed_string_t keyword;
1215 cmdline_fixed_string_t identifier;
1218 static void cmd_operate_attach_port_parsed(void *parsed_result,
1219 __attribute__((unused)) struct cmdline *cl,
1220 __attribute__((unused)) void *data)
1222 struct cmd_operate_attach_port_result *res = parsed_result;
1224 if (!strcmp(res->keyword, "attach"))
1225 attach_port(res->identifier);
1227 printf("Unknown parameter\n");
1230 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1231 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1233 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1234 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1236 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1237 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1240 cmdline_parse_inst_t cmd_operate_attach_port = {
1241 .f = cmd_operate_attach_port_parsed,
1243 .help_str = "port attach <identifier>: "
1244 "(identifier: pci address or virtual dev name)",
1246 (void *)&cmd_operate_attach_port_port,
1247 (void *)&cmd_operate_attach_port_keyword,
1248 (void *)&cmd_operate_attach_port_identifier,
1253 /* *** detach a specified port *** */
1254 struct cmd_operate_detach_port_result {
1255 cmdline_fixed_string_t port;
1256 cmdline_fixed_string_t keyword;
1260 static void cmd_operate_detach_port_parsed(void *parsed_result,
1261 __attribute__((unused)) struct cmdline *cl,
1262 __attribute__((unused)) void *data)
1264 struct cmd_operate_detach_port_result *res = parsed_result;
1266 if (!strcmp(res->keyword, "detach"))
1267 detach_port(res->port_id);
1269 printf("Unknown parameter\n");
1272 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1273 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1275 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1276 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1278 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1279 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1282 cmdline_parse_inst_t cmd_operate_detach_port = {
1283 .f = cmd_operate_detach_port_parsed,
1285 .help_str = "port detach <port_id>",
1287 (void *)&cmd_operate_detach_port_port,
1288 (void *)&cmd_operate_detach_port_keyword,
1289 (void *)&cmd_operate_detach_port_port_id,
1294 /* *** configure speed for all ports *** */
1295 struct cmd_config_speed_all {
1296 cmdline_fixed_string_t port;
1297 cmdline_fixed_string_t keyword;
1298 cmdline_fixed_string_t all;
1299 cmdline_fixed_string_t item1;
1300 cmdline_fixed_string_t item2;
1301 cmdline_fixed_string_t value1;
1302 cmdline_fixed_string_t value2;
1306 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1311 if (!strcmp(duplexstr, "half")) {
1312 duplex = ETH_LINK_HALF_DUPLEX;
1313 } else if (!strcmp(duplexstr, "full")) {
1314 duplex = ETH_LINK_FULL_DUPLEX;
1315 } else if (!strcmp(duplexstr, "auto")) {
1316 duplex = ETH_LINK_FULL_DUPLEX;
1318 printf("Unknown duplex parameter\n");
1322 if (!strcmp(speedstr, "10")) {
1323 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1324 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1325 } else if (!strcmp(speedstr, "100")) {
1326 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1327 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1329 if (duplex != ETH_LINK_FULL_DUPLEX) {
1330 printf("Invalid speed/duplex parameters\n");
1333 if (!strcmp(speedstr, "1000")) {
1334 *speed = ETH_LINK_SPEED_1G;
1335 } else if (!strcmp(speedstr, "10000")) {
1336 *speed = ETH_LINK_SPEED_10G;
1337 } else if (!strcmp(speedstr, "25000")) {
1338 *speed = ETH_LINK_SPEED_25G;
1339 } else if (!strcmp(speedstr, "40000")) {
1340 *speed = ETH_LINK_SPEED_40G;
1341 } else if (!strcmp(speedstr, "50000")) {
1342 *speed = ETH_LINK_SPEED_50G;
1343 } else if (!strcmp(speedstr, "100000")) {
1344 *speed = ETH_LINK_SPEED_100G;
1345 } else if (!strcmp(speedstr, "auto")) {
1346 *speed = ETH_LINK_SPEED_AUTONEG;
1348 printf("Unknown speed parameter\n");
1357 cmd_config_speed_all_parsed(void *parsed_result,
1358 __attribute__((unused)) struct cmdline *cl,
1359 __attribute__((unused)) void *data)
1361 struct cmd_config_speed_all *res = parsed_result;
1362 uint32_t link_speed;
1365 if (!all_ports_stopped()) {
1366 printf("Please stop all ports first\n");
1370 if (parse_and_check_speed_duplex(res->value1, res->value2,
1374 RTE_ETH_FOREACH_DEV(pid) {
1375 ports[pid].dev_conf.link_speeds = link_speed;
1378 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1381 cmdline_parse_token_string_t cmd_config_speed_all_port =
1382 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1383 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1384 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1386 cmdline_parse_token_string_t cmd_config_speed_all_all =
1387 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1388 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1389 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1390 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1391 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1392 "10#100#1000#10000#25000#40000#50000#100000#auto");
1393 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1394 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1395 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1396 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1399 cmdline_parse_inst_t cmd_config_speed_all = {
1400 .f = cmd_config_speed_all_parsed,
1402 .help_str = "port config all speed "
1403 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1406 (void *)&cmd_config_speed_all_port,
1407 (void *)&cmd_config_speed_all_keyword,
1408 (void *)&cmd_config_speed_all_all,
1409 (void *)&cmd_config_speed_all_item1,
1410 (void *)&cmd_config_speed_all_value1,
1411 (void *)&cmd_config_speed_all_item2,
1412 (void *)&cmd_config_speed_all_value2,
1417 /* *** configure speed for specific port *** */
1418 struct cmd_config_speed_specific {
1419 cmdline_fixed_string_t port;
1420 cmdline_fixed_string_t keyword;
1422 cmdline_fixed_string_t item1;
1423 cmdline_fixed_string_t item2;
1424 cmdline_fixed_string_t value1;
1425 cmdline_fixed_string_t value2;
1429 cmd_config_speed_specific_parsed(void *parsed_result,
1430 __attribute__((unused)) struct cmdline *cl,
1431 __attribute__((unused)) void *data)
1433 struct cmd_config_speed_specific *res = parsed_result;
1434 uint32_t link_speed;
1436 if (!all_ports_stopped()) {
1437 printf("Please stop all ports first\n");
1441 if (port_id_is_invalid(res->id, ENABLED_WARN))
1444 if (parse_and_check_speed_duplex(res->value1, res->value2,
1448 ports[res->id].dev_conf.link_speeds = link_speed;
1450 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1454 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1455 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1457 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1458 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1460 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1461 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1462 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1463 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1465 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1466 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1467 "10#100#1000#10000#25000#40000#50000#100000#auto");
1468 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1469 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1471 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1472 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1475 cmdline_parse_inst_t cmd_config_speed_specific = {
1476 .f = cmd_config_speed_specific_parsed,
1478 .help_str = "port config <port_id> speed "
1479 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1482 (void *)&cmd_config_speed_specific_port,
1483 (void *)&cmd_config_speed_specific_keyword,
1484 (void *)&cmd_config_speed_specific_id,
1485 (void *)&cmd_config_speed_specific_item1,
1486 (void *)&cmd_config_speed_specific_value1,
1487 (void *)&cmd_config_speed_specific_item2,
1488 (void *)&cmd_config_speed_specific_value2,
1493 /* *** configure loopback for all ports *** */
1494 struct cmd_config_loopback_all {
1495 cmdline_fixed_string_t port;
1496 cmdline_fixed_string_t keyword;
1497 cmdline_fixed_string_t all;
1498 cmdline_fixed_string_t item;
1503 cmd_config_loopback_all_parsed(void *parsed_result,
1504 __attribute__((unused)) struct cmdline *cl,
1505 __attribute__((unused)) void *data)
1507 struct cmd_config_loopback_all *res = parsed_result;
1510 if (!all_ports_stopped()) {
1511 printf("Please stop all ports first\n");
1515 RTE_ETH_FOREACH_DEV(pid) {
1516 ports[pid].dev_conf.lpbk_mode = res->mode;
1519 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1522 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1523 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1524 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1525 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1527 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1528 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1529 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1530 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1532 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1533 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32);
1535 cmdline_parse_inst_t cmd_config_loopback_all = {
1536 .f = cmd_config_loopback_all_parsed,
1538 .help_str = "port config all loopback <mode>",
1540 (void *)&cmd_config_loopback_all_port,
1541 (void *)&cmd_config_loopback_all_keyword,
1542 (void *)&cmd_config_loopback_all_all,
1543 (void *)&cmd_config_loopback_all_item,
1544 (void *)&cmd_config_loopback_all_mode,
1549 /* *** configure loopback for specific port *** */
1550 struct cmd_config_loopback_specific {
1551 cmdline_fixed_string_t port;
1552 cmdline_fixed_string_t keyword;
1554 cmdline_fixed_string_t item;
1559 cmd_config_loopback_specific_parsed(void *parsed_result,
1560 __attribute__((unused)) struct cmdline *cl,
1561 __attribute__((unused)) void *data)
1563 struct cmd_config_loopback_specific *res = parsed_result;
1565 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1568 if (!port_is_stopped(res->port_id)) {
1569 printf("Please stop port %u first\n", res->port_id);
1573 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1575 cmd_reconfig_device_queue(res->port_id, 1, 1);
1579 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1580 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1582 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1583 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1585 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1586 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1588 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1589 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1591 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1592 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1595 cmdline_parse_inst_t cmd_config_loopback_specific = {
1596 .f = cmd_config_loopback_specific_parsed,
1598 .help_str = "port config <port_id> loopback <mode>",
1600 (void *)&cmd_config_loopback_specific_port,
1601 (void *)&cmd_config_loopback_specific_keyword,
1602 (void *)&cmd_config_loopback_specific_id,
1603 (void *)&cmd_config_loopback_specific_item,
1604 (void *)&cmd_config_loopback_specific_mode,
1609 /* *** configure txq/rxq, txd/rxd *** */
1610 struct cmd_config_rx_tx {
1611 cmdline_fixed_string_t port;
1612 cmdline_fixed_string_t keyword;
1613 cmdline_fixed_string_t all;
1614 cmdline_fixed_string_t name;
1619 cmd_config_rx_tx_parsed(void *parsed_result,
1620 __attribute__((unused)) struct cmdline *cl,
1621 __attribute__((unused)) void *data)
1623 struct cmd_config_rx_tx *res = parsed_result;
1625 if (!all_ports_stopped()) {
1626 printf("Please stop all ports first\n");
1629 if (!strcmp(res->name, "rxq")) {
1630 if (!res->value && !nb_txq) {
1631 printf("Warning: Either rx or tx queues should be non zero\n");
1634 if (check_nb_rxq(res->value) != 0)
1636 nb_rxq = res->value;
1638 else if (!strcmp(res->name, "txq")) {
1639 if (!res->value && !nb_rxq) {
1640 printf("Warning: Either rx or tx queues should be non zero\n");
1643 if (check_nb_txq(res->value) != 0)
1645 nb_txq = res->value;
1647 else if (!strcmp(res->name, "rxd")) {
1648 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1649 printf("rxd %d invalid - must be > 0 && <= %d\n",
1650 res->value, RTE_TEST_RX_DESC_MAX);
1653 nb_rxd = res->value;
1654 } else if (!strcmp(res->name, "txd")) {
1655 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1656 printf("txd %d invalid - must be > 0 && <= %d\n",
1657 res->value, RTE_TEST_TX_DESC_MAX);
1660 nb_txd = res->value;
1662 printf("Unknown parameter\n");
1670 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1673 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1674 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1675 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1676 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1677 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1678 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1679 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1680 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1682 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1683 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1685 cmdline_parse_inst_t cmd_config_rx_tx = {
1686 .f = cmd_config_rx_tx_parsed,
1688 .help_str = "port config all rxq|txq|rxd|txd <value>",
1690 (void *)&cmd_config_rx_tx_port,
1691 (void *)&cmd_config_rx_tx_keyword,
1692 (void *)&cmd_config_rx_tx_all,
1693 (void *)&cmd_config_rx_tx_name,
1694 (void *)&cmd_config_rx_tx_value,
1699 /* *** config max packet length *** */
1700 struct cmd_config_max_pkt_len_result {
1701 cmdline_fixed_string_t port;
1702 cmdline_fixed_string_t keyword;
1703 cmdline_fixed_string_t all;
1704 cmdline_fixed_string_t name;
1709 cmd_config_max_pkt_len_parsed(void *parsed_result,
1710 __attribute__((unused)) struct cmdline *cl,
1711 __attribute__((unused)) void *data)
1713 struct cmd_config_max_pkt_len_result *res = parsed_result;
1716 if (!all_ports_stopped()) {
1717 printf("Please stop all ports first\n");
1721 RTE_ETH_FOREACH_DEV(pid) {
1722 struct rte_port *port = &ports[pid];
1723 uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
1725 if (!strcmp(res->name, "max-pkt-len")) {
1726 if (res->value < ETHER_MIN_LEN) {
1727 printf("max-pkt-len can not be less than %d\n",
1731 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
1734 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
1735 if (res->value > ETHER_MAX_LEN)
1736 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
1738 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
1739 port->dev_conf.rxmode.offloads = rx_offloads;
1741 printf("Unknown parameter\n");
1748 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1751 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1752 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1754 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1755 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1757 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1758 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1760 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1761 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1763 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1764 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1767 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1768 .f = cmd_config_max_pkt_len_parsed,
1770 .help_str = "port config all max-pkt-len <value>",
1772 (void *)&cmd_config_max_pkt_len_port,
1773 (void *)&cmd_config_max_pkt_len_keyword,
1774 (void *)&cmd_config_max_pkt_len_all,
1775 (void *)&cmd_config_max_pkt_len_name,
1776 (void *)&cmd_config_max_pkt_len_value,
1781 /* *** configure port MTU *** */
1782 struct cmd_config_mtu_result {
1783 cmdline_fixed_string_t port;
1784 cmdline_fixed_string_t keyword;
1785 cmdline_fixed_string_t mtu;
1791 cmd_config_mtu_parsed(void *parsed_result,
1792 __attribute__((unused)) struct cmdline *cl,
1793 __attribute__((unused)) void *data)
1795 struct cmd_config_mtu_result *res = parsed_result;
1797 if (res->value < ETHER_MIN_LEN) {
1798 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1801 port_mtu_set(res->port_id, res->value);
1804 cmdline_parse_token_string_t cmd_config_mtu_port =
1805 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1807 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1808 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1810 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1811 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1813 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1814 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
1815 cmdline_parse_token_num_t cmd_config_mtu_value =
1816 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1818 cmdline_parse_inst_t cmd_config_mtu = {
1819 .f = cmd_config_mtu_parsed,
1821 .help_str = "port config mtu <port_id> <value>",
1823 (void *)&cmd_config_mtu_port,
1824 (void *)&cmd_config_mtu_keyword,
1825 (void *)&cmd_config_mtu_mtu,
1826 (void *)&cmd_config_mtu_port_id,
1827 (void *)&cmd_config_mtu_value,
1832 /* *** configure rx mode *** */
1833 struct cmd_config_rx_mode_flag {
1834 cmdline_fixed_string_t port;
1835 cmdline_fixed_string_t keyword;
1836 cmdline_fixed_string_t all;
1837 cmdline_fixed_string_t name;
1838 cmdline_fixed_string_t value;
1842 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1843 __attribute__((unused)) struct cmdline *cl,
1844 __attribute__((unused)) void *data)
1846 struct cmd_config_rx_mode_flag *res = parsed_result;
1849 if (!all_ports_stopped()) {
1850 printf("Please stop all ports first\n");
1854 RTE_ETH_FOREACH_DEV(pid) {
1855 struct rte_port *port;
1856 uint64_t rx_offloads;
1859 rx_offloads = port->dev_conf.rxmode.offloads;
1860 if (!strcmp(res->name, "crc-strip")) {
1861 if (!strcmp(res->value, "on"))
1862 rx_offloads |= DEV_RX_OFFLOAD_CRC_STRIP;
1863 else if (!strcmp(res->value, "off"))
1864 rx_offloads &= ~DEV_RX_OFFLOAD_CRC_STRIP;
1866 printf("Unknown parameter\n");
1869 } else if (!strcmp(res->name, "scatter")) {
1870 if (!strcmp(res->value, "on")) {
1871 rx_offloads |= DEV_RX_OFFLOAD_SCATTER;
1872 } else if (!strcmp(res->value, "off")) {
1873 rx_offloads &= ~DEV_RX_OFFLOAD_SCATTER;
1875 printf("Unknown parameter\n");
1878 } else if (!strcmp(res->name, "rx-cksum")) {
1879 if (!strcmp(res->value, "on"))
1880 rx_offloads |= DEV_RX_OFFLOAD_CHECKSUM;
1881 else if (!strcmp(res->value, "off"))
1882 rx_offloads &= ~DEV_RX_OFFLOAD_CHECKSUM;
1884 printf("Unknown parameter\n");
1887 } else if (!strcmp(res->name, "rx-timestamp")) {
1888 if (!strcmp(res->value, "on"))
1889 rx_offloads |= DEV_RX_OFFLOAD_TIMESTAMP;
1890 else if (!strcmp(res->value, "off"))
1891 rx_offloads &= ~DEV_RX_OFFLOAD_TIMESTAMP;
1893 printf("Unknown parameter\n");
1896 } else if (!strcmp(res->name, "hw-vlan")) {
1897 if (!strcmp(res->value, "on")) {
1898 rx_offloads |= (DEV_RX_OFFLOAD_VLAN_FILTER |
1899 DEV_RX_OFFLOAD_VLAN_STRIP);
1900 } else if (!strcmp(res->value, "off")) {
1901 rx_offloads &= ~(DEV_RX_OFFLOAD_VLAN_FILTER |
1902 DEV_RX_OFFLOAD_VLAN_STRIP);
1904 printf("Unknown parameter\n");
1907 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1908 if (!strcmp(res->value, "on"))
1909 rx_offloads |= DEV_RX_OFFLOAD_VLAN_FILTER;
1910 else if (!strcmp(res->value, "off"))
1911 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_FILTER;
1913 printf("Unknown parameter\n");
1916 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1917 if (!strcmp(res->value, "on"))
1918 rx_offloads |= DEV_RX_OFFLOAD_VLAN_STRIP;
1919 else if (!strcmp(res->value, "off"))
1920 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_STRIP;
1922 printf("Unknown parameter\n");
1925 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1926 if (!strcmp(res->value, "on"))
1927 rx_offloads |= DEV_RX_OFFLOAD_VLAN_EXTEND;
1928 else if (!strcmp(res->value, "off"))
1929 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_EXTEND;
1931 printf("Unknown parameter\n");
1934 } else if (!strcmp(res->name, "drop-en")) {
1935 if (!strcmp(res->value, "on"))
1937 else if (!strcmp(res->value, "off"))
1940 printf("Unknown parameter\n");
1944 printf("Unknown parameter\n");
1947 port->dev_conf.rxmode.offloads = rx_offloads;
1952 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1955 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1956 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1957 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1958 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1960 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1961 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1962 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1963 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1964 "crc-strip#scatter#rx-cksum#rx-timestamp#hw-vlan#"
1965 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1966 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1967 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1970 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1971 .f = cmd_config_rx_mode_flag_parsed,
1973 .help_str = "port config all crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|"
1974 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1976 (void *)&cmd_config_rx_mode_flag_port,
1977 (void *)&cmd_config_rx_mode_flag_keyword,
1978 (void *)&cmd_config_rx_mode_flag_all,
1979 (void *)&cmd_config_rx_mode_flag_name,
1980 (void *)&cmd_config_rx_mode_flag_value,
1985 /* *** configure rss *** */
1986 struct cmd_config_rss {
1987 cmdline_fixed_string_t port;
1988 cmdline_fixed_string_t keyword;
1989 cmdline_fixed_string_t all;
1990 cmdline_fixed_string_t name;
1991 cmdline_fixed_string_t value;
1995 cmd_config_rss_parsed(void *parsed_result,
1996 __attribute__((unused)) struct cmdline *cl,
1997 __attribute__((unused)) void *data)
1999 struct cmd_config_rss *res = parsed_result;
2000 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2004 if (!strcmp(res->value, "all"))
2005 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
2006 ETH_RSS_UDP | ETH_RSS_SCTP |
2008 else if (!strcmp(res->value, "ip"))
2009 rss_conf.rss_hf = ETH_RSS_IP;
2010 else if (!strcmp(res->value, "udp"))
2011 rss_conf.rss_hf = ETH_RSS_UDP;
2012 else if (!strcmp(res->value, "tcp"))
2013 rss_conf.rss_hf = ETH_RSS_TCP;
2014 else if (!strcmp(res->value, "sctp"))
2015 rss_conf.rss_hf = ETH_RSS_SCTP;
2016 else if (!strcmp(res->value, "ether"))
2017 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2018 else if (!strcmp(res->value, "port"))
2019 rss_conf.rss_hf = ETH_RSS_PORT;
2020 else if (!strcmp(res->value, "vxlan"))
2021 rss_conf.rss_hf = ETH_RSS_VXLAN;
2022 else if (!strcmp(res->value, "geneve"))
2023 rss_conf.rss_hf = ETH_RSS_GENEVE;
2024 else if (!strcmp(res->value, "nvgre"))
2025 rss_conf.rss_hf = ETH_RSS_NVGRE;
2026 else if (!strcmp(res->value, "none"))
2027 rss_conf.rss_hf = 0;
2028 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2029 atoi(res->value) < 64)
2030 rss_conf.rss_hf = 1ULL << atoi(res->value);
2032 printf("Unknown parameter\n");
2035 rss_conf.rss_key = NULL;
2036 /* Update global configuration for RSS types. */
2037 rss_hf = rss_conf.rss_hf;
2038 RTE_ETH_FOREACH_DEV(i) {
2039 diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
2041 printf("Configuration of RSS hash at ethernet port %d "
2042 "failed with error (%d): %s.\n",
2043 i, -diag, strerror(-diag));
2047 cmdline_parse_token_string_t cmd_config_rss_port =
2048 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2049 cmdline_parse_token_string_t cmd_config_rss_keyword =
2050 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2051 cmdline_parse_token_string_t cmd_config_rss_all =
2052 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2053 cmdline_parse_token_string_t cmd_config_rss_name =
2054 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2055 cmdline_parse_token_string_t cmd_config_rss_value =
2056 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2058 cmdline_parse_inst_t cmd_config_rss = {
2059 .f = cmd_config_rss_parsed,
2061 .help_str = "port config all rss "
2062 "all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none|<flowtype_id>",
2064 (void *)&cmd_config_rss_port,
2065 (void *)&cmd_config_rss_keyword,
2066 (void *)&cmd_config_rss_all,
2067 (void *)&cmd_config_rss_name,
2068 (void *)&cmd_config_rss_value,
2073 /* *** configure rss hash key *** */
2074 struct cmd_config_rss_hash_key {
2075 cmdline_fixed_string_t port;
2076 cmdline_fixed_string_t config;
2078 cmdline_fixed_string_t rss_hash_key;
2079 cmdline_fixed_string_t rss_type;
2080 cmdline_fixed_string_t key;
2084 hexa_digit_to_value(char hexa_digit)
2086 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2087 return (uint8_t) (hexa_digit - '0');
2088 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2089 return (uint8_t) ((hexa_digit - 'a') + 10);
2090 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2091 return (uint8_t) ((hexa_digit - 'A') + 10);
2092 /* Invalid hexa digit */
2097 parse_and_check_key_hexa_digit(char *key, int idx)
2101 hexa_v = hexa_digit_to_value(key[idx]);
2103 printf("invalid key: character %c at position %d is not a "
2104 "valid hexa digit\n", key[idx], idx);
2109 cmd_config_rss_hash_key_parsed(void *parsed_result,
2110 __attribute__((unused)) struct cmdline *cl,
2111 __attribute__((unused)) void *data)
2113 struct cmd_config_rss_hash_key *res = parsed_result;
2114 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2118 struct rte_eth_dev_info dev_info;
2119 uint8_t hash_key_size;
2122 memset(&dev_info, 0, sizeof(dev_info));
2123 rte_eth_dev_info_get(res->port_id, &dev_info);
2124 if (dev_info.hash_key_size > 0 &&
2125 dev_info.hash_key_size <= sizeof(hash_key))
2126 hash_key_size = dev_info.hash_key_size;
2128 printf("dev_info did not provide a valid hash key size\n");
2131 /* Check the length of the RSS hash key */
2132 key_len = strlen(res->key);
2133 if (key_len != (hash_key_size * 2)) {
2134 printf("key length: %d invalid - key must be a string of %d"
2135 " hexa-decimal numbers\n",
2136 (int) key_len, hash_key_size * 2);
2139 /* Translate RSS hash key into binary representation */
2140 for (i = 0; i < hash_key_size; i++) {
2141 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2144 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2147 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2149 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2153 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2154 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2155 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2156 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2158 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2159 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2160 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2161 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2162 rss_hash_key, "rss-hash-key");
2163 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2164 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2165 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2166 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2167 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2168 "ipv6-tcp-ex#ipv6-udp-ex");
2169 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2170 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2172 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2173 .f = cmd_config_rss_hash_key_parsed,
2175 .help_str = "port config <port_id> rss-hash-key "
2176 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2177 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2178 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
2179 "<string of hex digits (variable length, NIC dependent)>",
2181 (void *)&cmd_config_rss_hash_key_port,
2182 (void *)&cmd_config_rss_hash_key_config,
2183 (void *)&cmd_config_rss_hash_key_port_id,
2184 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2185 (void *)&cmd_config_rss_hash_key_rss_type,
2186 (void *)&cmd_config_rss_hash_key_value,
2191 /* *** configure port rxq/txq start/stop *** */
2192 struct cmd_config_rxtx_queue {
2193 cmdline_fixed_string_t port;
2195 cmdline_fixed_string_t rxtxq;
2197 cmdline_fixed_string_t opname;
2201 cmd_config_rxtx_queue_parsed(void *parsed_result,
2202 __attribute__((unused)) struct cmdline *cl,
2203 __attribute__((unused)) void *data)
2205 struct cmd_config_rxtx_queue *res = parsed_result;
2210 if (test_done == 0) {
2211 printf("Please stop forwarding first\n");
2215 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2218 if (port_is_started(res->portid) != 1) {
2219 printf("Please start port %u first\n", res->portid);
2223 if (!strcmp(res->rxtxq, "rxq"))
2225 else if (!strcmp(res->rxtxq, "txq"))
2228 printf("Unknown parameter\n");
2232 if (isrx && rx_queue_id_is_invalid(res->qid))
2234 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2237 if (!strcmp(res->opname, "start"))
2239 else if (!strcmp(res->opname, "stop"))
2242 printf("Unknown parameter\n");
2246 if (isstart && isrx)
2247 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2248 else if (!isstart && isrx)
2249 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2250 else if (isstart && !isrx)
2251 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2253 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2255 if (ret == -ENOTSUP)
2256 printf("Function not supported in PMD driver\n");
2259 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2260 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2261 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2262 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2263 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2264 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2265 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2266 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2267 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2268 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2271 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2272 .f = cmd_config_rxtx_queue_parsed,
2274 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2276 (void *)&cmd_config_speed_all_port,
2277 (void *)&cmd_config_rxtx_queue_portid,
2278 (void *)&cmd_config_rxtx_queue_rxtxq,
2279 (void *)&cmd_config_rxtx_queue_qid,
2280 (void *)&cmd_config_rxtx_queue_opname,
2285 /* *** Configure RSS RETA *** */
2286 struct cmd_config_rss_reta {
2287 cmdline_fixed_string_t port;
2288 cmdline_fixed_string_t keyword;
2290 cmdline_fixed_string_t name;
2291 cmdline_fixed_string_t list_name;
2292 cmdline_fixed_string_t list_of_items;
2296 parse_reta_config(const char *str,
2297 struct rte_eth_rss_reta_entry64 *reta_conf,
2298 uint16_t nb_entries)
2302 uint16_t hash_index, idx, shift;
2305 const char *p, *p0 = str;
2312 unsigned long int_fld[_NUM_FLD];
2313 char *str_fld[_NUM_FLD];
2315 while ((p = strchr(p0,'(')) != NULL) {
2317 if((p0 = strchr(p,')')) == NULL)
2321 if(size >= sizeof(s))
2324 snprintf(s, sizeof(s), "%.*s", size, p);
2325 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2327 for (i = 0; i < _NUM_FLD; i++) {
2329 int_fld[i] = strtoul(str_fld[i], &end, 0);
2330 if (errno != 0 || end == str_fld[i] ||
2335 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2336 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2338 if (hash_index >= nb_entries) {
2339 printf("Invalid RETA hash index=%d\n", hash_index);
2343 idx = hash_index / RTE_RETA_GROUP_SIZE;
2344 shift = hash_index % RTE_RETA_GROUP_SIZE;
2345 reta_conf[idx].mask |= (1ULL << shift);
2346 reta_conf[idx].reta[shift] = nb_queue;
2353 cmd_set_rss_reta_parsed(void *parsed_result,
2354 __attribute__((unused)) struct cmdline *cl,
2355 __attribute__((unused)) void *data)
2358 struct rte_eth_dev_info dev_info;
2359 struct rte_eth_rss_reta_entry64 reta_conf[8];
2360 struct cmd_config_rss_reta *res = parsed_result;
2362 memset(&dev_info, 0, sizeof(dev_info));
2363 rte_eth_dev_info_get(res->port_id, &dev_info);
2364 if (dev_info.reta_size == 0) {
2365 printf("Redirection table size is 0 which is "
2366 "invalid for RSS\n");
2369 printf("The reta size of port %d is %u\n",
2370 res->port_id, dev_info.reta_size);
2371 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2372 printf("Currently do not support more than %u entries of "
2373 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2377 memset(reta_conf, 0, sizeof(reta_conf));
2378 if (!strcmp(res->list_name, "reta")) {
2379 if (parse_reta_config(res->list_of_items, reta_conf,
2380 dev_info.reta_size)) {
2381 printf("Invalid RSS Redirection Table "
2382 "config entered\n");
2385 ret = rte_eth_dev_rss_reta_update(res->port_id,
2386 reta_conf, dev_info.reta_size);
2388 printf("Bad redirection table parameter, "
2389 "return code = %d \n", ret);
2393 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2394 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2395 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2396 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2397 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2398 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
2399 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2400 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2401 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2402 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2403 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2404 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2406 cmdline_parse_inst_t cmd_config_rss_reta = {
2407 .f = cmd_set_rss_reta_parsed,
2409 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2411 (void *)&cmd_config_rss_reta_port,
2412 (void *)&cmd_config_rss_reta_keyword,
2413 (void *)&cmd_config_rss_reta_port_id,
2414 (void *)&cmd_config_rss_reta_name,
2415 (void *)&cmd_config_rss_reta_list_name,
2416 (void *)&cmd_config_rss_reta_list_of_items,
2421 /* *** SHOW PORT RETA INFO *** */
2422 struct cmd_showport_reta {
2423 cmdline_fixed_string_t show;
2424 cmdline_fixed_string_t port;
2426 cmdline_fixed_string_t rss;
2427 cmdline_fixed_string_t reta;
2429 cmdline_fixed_string_t list_of_items;
2433 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2434 uint16_t nb_entries,
2438 const char *p, *p0 = str;
2443 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2444 RTE_RETA_GROUP_SIZE;
2447 p = strchr(p0, '(');
2451 p0 = strchr(p, ')');
2455 if (size >= sizeof(s)) {
2456 printf("The string size exceeds the internal buffer size\n");
2459 snprintf(s, sizeof(s), "%.*s", size, p);
2460 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2461 if (ret <= 0 || ret != num) {
2462 printf("The bits of masks do not match the number of "
2463 "reta entries: %u\n", num);
2466 for (i = 0; i < ret; i++)
2467 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2473 cmd_showport_reta_parsed(void *parsed_result,
2474 __attribute__((unused)) struct cmdline *cl,
2475 __attribute__((unused)) void *data)
2477 struct cmd_showport_reta *res = parsed_result;
2478 struct rte_eth_rss_reta_entry64 reta_conf[8];
2479 struct rte_eth_dev_info dev_info;
2480 uint16_t max_reta_size;
2482 memset(&dev_info, 0, sizeof(dev_info));
2483 rte_eth_dev_info_get(res->port_id, &dev_info);
2484 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
2485 if (res->size == 0 || res->size > max_reta_size) {
2486 printf("Invalid redirection table size: %u (1-%u)\n",
2487 res->size, max_reta_size);
2491 memset(reta_conf, 0, sizeof(reta_conf));
2492 if (showport_parse_reta_config(reta_conf, res->size,
2493 res->list_of_items) < 0) {
2494 printf("Invalid string: %s for reta masks\n",
2495 res->list_of_items);
2498 port_rss_reta_info(res->port_id, reta_conf, res->size);
2501 cmdline_parse_token_string_t cmd_showport_reta_show =
2502 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2503 cmdline_parse_token_string_t cmd_showport_reta_port =
2504 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2505 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2506 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
2507 cmdline_parse_token_string_t cmd_showport_reta_rss =
2508 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2509 cmdline_parse_token_string_t cmd_showport_reta_reta =
2510 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2511 cmdline_parse_token_num_t cmd_showport_reta_size =
2512 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2513 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2514 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2515 list_of_items, NULL);
2517 cmdline_parse_inst_t cmd_showport_reta = {
2518 .f = cmd_showport_reta_parsed,
2520 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2522 (void *)&cmd_showport_reta_show,
2523 (void *)&cmd_showport_reta_port,
2524 (void *)&cmd_showport_reta_port_id,
2525 (void *)&cmd_showport_reta_rss,
2526 (void *)&cmd_showport_reta_reta,
2527 (void *)&cmd_showport_reta_size,
2528 (void *)&cmd_showport_reta_list_of_items,
2533 /* *** Show RSS hash configuration *** */
2534 struct cmd_showport_rss_hash {
2535 cmdline_fixed_string_t show;
2536 cmdline_fixed_string_t port;
2538 cmdline_fixed_string_t rss_hash;
2539 cmdline_fixed_string_t rss_type;
2540 cmdline_fixed_string_t key; /* optional argument */
2543 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2544 __attribute__((unused)) struct cmdline *cl,
2547 struct cmd_showport_rss_hash *res = parsed_result;
2549 port_rss_hash_conf_show(res->port_id, res->rss_type,
2550 show_rss_key != NULL);
2553 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2554 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2555 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2556 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2557 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2558 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
2559 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2560 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2562 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2563 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2564 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2565 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2566 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2567 "ipv6-tcp-ex#ipv6-udp-ex");
2568 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2569 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2571 cmdline_parse_inst_t cmd_showport_rss_hash = {
2572 .f = cmd_showport_rss_hash_parsed,
2574 .help_str = "show port <port_id> rss-hash "
2575 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2576 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2577 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex",
2579 (void *)&cmd_showport_rss_hash_show,
2580 (void *)&cmd_showport_rss_hash_port,
2581 (void *)&cmd_showport_rss_hash_port_id,
2582 (void *)&cmd_showport_rss_hash_rss_hash,
2583 (void *)&cmd_showport_rss_hash_rss_hash_info,
2588 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2589 .f = cmd_showport_rss_hash_parsed,
2591 .help_str = "show port <port_id> rss-hash "
2592 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2593 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2594 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key",
2596 (void *)&cmd_showport_rss_hash_show,
2597 (void *)&cmd_showport_rss_hash_port,
2598 (void *)&cmd_showport_rss_hash_port_id,
2599 (void *)&cmd_showport_rss_hash_rss_hash,
2600 (void *)&cmd_showport_rss_hash_rss_hash_info,
2601 (void *)&cmd_showport_rss_hash_rss_key,
2606 /* *** Configure DCB *** */
2607 struct cmd_config_dcb {
2608 cmdline_fixed_string_t port;
2609 cmdline_fixed_string_t config;
2611 cmdline_fixed_string_t dcb;
2612 cmdline_fixed_string_t vt;
2613 cmdline_fixed_string_t vt_en;
2615 cmdline_fixed_string_t pfc;
2616 cmdline_fixed_string_t pfc_en;
2620 cmd_config_dcb_parsed(void *parsed_result,
2621 __attribute__((unused)) struct cmdline *cl,
2622 __attribute__((unused)) void *data)
2624 struct cmd_config_dcb *res = parsed_result;
2625 portid_t port_id = res->port_id;
2626 struct rte_port *port;
2630 port = &ports[port_id];
2631 /** Check if the port is not started **/
2632 if (port->port_status != RTE_PORT_STOPPED) {
2633 printf("Please stop port %d first\n", port_id);
2637 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2638 printf("The invalid number of traffic class,"
2639 " only 4 or 8 allowed.\n");
2643 if (nb_fwd_lcores < res->num_tcs) {
2644 printf("nb_cores shouldn't be less than number of TCs.\n");
2647 if (!strncmp(res->pfc_en, "on", 2))
2652 /* DCB in VT mode */
2653 if (!strncmp(res->vt_en, "on", 2))
2654 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2655 (enum rte_eth_nb_tcs)res->num_tcs,
2658 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2659 (enum rte_eth_nb_tcs)res->num_tcs,
2664 printf("Cannot initialize network ports.\n");
2668 cmd_reconfig_device_queue(port_id, 1, 1);
2671 cmdline_parse_token_string_t cmd_config_dcb_port =
2672 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2673 cmdline_parse_token_string_t cmd_config_dcb_config =
2674 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2675 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2676 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
2677 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2678 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2679 cmdline_parse_token_string_t cmd_config_dcb_vt =
2680 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2681 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2682 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2683 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2684 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2685 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2686 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2687 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2688 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2690 cmdline_parse_inst_t cmd_config_dcb = {
2691 .f = cmd_config_dcb_parsed,
2693 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
2695 (void *)&cmd_config_dcb_port,
2696 (void *)&cmd_config_dcb_config,
2697 (void *)&cmd_config_dcb_port_id,
2698 (void *)&cmd_config_dcb_dcb,
2699 (void *)&cmd_config_dcb_vt,
2700 (void *)&cmd_config_dcb_vt_en,
2701 (void *)&cmd_config_dcb_num_tcs,
2702 (void *)&cmd_config_dcb_pfc,
2703 (void *)&cmd_config_dcb_pfc_en,
2708 /* *** configure number of packets per burst *** */
2709 struct cmd_config_burst {
2710 cmdline_fixed_string_t port;
2711 cmdline_fixed_string_t keyword;
2712 cmdline_fixed_string_t all;
2713 cmdline_fixed_string_t name;
2718 cmd_config_burst_parsed(void *parsed_result,
2719 __attribute__((unused)) struct cmdline *cl,
2720 __attribute__((unused)) void *data)
2722 struct cmd_config_burst *res = parsed_result;
2723 struct rte_eth_dev_info dev_info;
2724 uint16_t rec_nb_pkts;
2726 if (!all_ports_stopped()) {
2727 printf("Please stop all ports first\n");
2731 if (!strcmp(res->name, "burst")) {
2732 if (res->value == 0) {
2733 /* If user gives a value of zero, query the PMD for
2734 * its recommended Rx burst size. Testpmd uses a single
2735 * size for all ports, so assume all ports are the same
2736 * NIC model and use the values from Port 0.
2738 rte_eth_dev_info_get(0, &dev_info);
2739 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
2741 if (rec_nb_pkts == 0) {
2742 printf("PMD does not recommend a burst size.\n"
2743 "User provided value must be between"
2744 " 1 and %d\n", MAX_PKT_BURST);
2746 } else if (rec_nb_pkts > MAX_PKT_BURST) {
2747 printf("PMD recommended burst size of %d"
2748 " exceeds maximum value of %d\n",
2749 rec_nb_pkts, MAX_PKT_BURST);
2752 printf("Using PMD-provided burst value of %d\n",
2754 nb_pkt_per_burst = rec_nb_pkts;
2755 } else if (res->value > MAX_PKT_BURST) {
2756 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2759 nb_pkt_per_burst = res->value;
2761 printf("Unknown parameter\n");
2767 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2770 cmdline_parse_token_string_t cmd_config_burst_port =
2771 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2772 cmdline_parse_token_string_t cmd_config_burst_keyword =
2773 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2774 cmdline_parse_token_string_t cmd_config_burst_all =
2775 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2776 cmdline_parse_token_string_t cmd_config_burst_name =
2777 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2778 cmdline_parse_token_num_t cmd_config_burst_value =
2779 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2781 cmdline_parse_inst_t cmd_config_burst = {
2782 .f = cmd_config_burst_parsed,
2784 .help_str = "port config all burst <value>",
2786 (void *)&cmd_config_burst_port,
2787 (void *)&cmd_config_burst_keyword,
2788 (void *)&cmd_config_burst_all,
2789 (void *)&cmd_config_burst_name,
2790 (void *)&cmd_config_burst_value,
2795 /* *** configure rx/tx queues *** */
2796 struct cmd_config_thresh {
2797 cmdline_fixed_string_t port;
2798 cmdline_fixed_string_t keyword;
2799 cmdline_fixed_string_t all;
2800 cmdline_fixed_string_t name;
2805 cmd_config_thresh_parsed(void *parsed_result,
2806 __attribute__((unused)) struct cmdline *cl,
2807 __attribute__((unused)) void *data)
2809 struct cmd_config_thresh *res = parsed_result;
2811 if (!all_ports_stopped()) {
2812 printf("Please stop all ports first\n");
2816 if (!strcmp(res->name, "txpt"))
2817 tx_pthresh = res->value;
2818 else if(!strcmp(res->name, "txht"))
2819 tx_hthresh = res->value;
2820 else if(!strcmp(res->name, "txwt"))
2821 tx_wthresh = res->value;
2822 else if(!strcmp(res->name, "rxpt"))
2823 rx_pthresh = res->value;
2824 else if(!strcmp(res->name, "rxht"))
2825 rx_hthresh = res->value;
2826 else if(!strcmp(res->name, "rxwt"))
2827 rx_wthresh = res->value;
2829 printf("Unknown parameter\n");
2835 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2838 cmdline_parse_token_string_t cmd_config_thresh_port =
2839 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2840 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2841 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2842 cmdline_parse_token_string_t cmd_config_thresh_all =
2843 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2844 cmdline_parse_token_string_t cmd_config_thresh_name =
2845 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2846 "txpt#txht#txwt#rxpt#rxht#rxwt");
2847 cmdline_parse_token_num_t cmd_config_thresh_value =
2848 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2850 cmdline_parse_inst_t cmd_config_thresh = {
2851 .f = cmd_config_thresh_parsed,
2853 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
2855 (void *)&cmd_config_thresh_port,
2856 (void *)&cmd_config_thresh_keyword,
2857 (void *)&cmd_config_thresh_all,
2858 (void *)&cmd_config_thresh_name,
2859 (void *)&cmd_config_thresh_value,
2864 /* *** configure free/rs threshold *** */
2865 struct cmd_config_threshold {
2866 cmdline_fixed_string_t port;
2867 cmdline_fixed_string_t keyword;
2868 cmdline_fixed_string_t all;
2869 cmdline_fixed_string_t name;
2874 cmd_config_threshold_parsed(void *parsed_result,
2875 __attribute__((unused)) struct cmdline *cl,
2876 __attribute__((unused)) void *data)
2878 struct cmd_config_threshold *res = parsed_result;
2880 if (!all_ports_stopped()) {
2881 printf("Please stop all ports first\n");
2885 if (!strcmp(res->name, "txfreet"))
2886 tx_free_thresh = res->value;
2887 else if (!strcmp(res->name, "txrst"))
2888 tx_rs_thresh = res->value;
2889 else if (!strcmp(res->name, "rxfreet"))
2890 rx_free_thresh = res->value;
2892 printf("Unknown parameter\n");
2898 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2901 cmdline_parse_token_string_t cmd_config_threshold_port =
2902 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2903 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2904 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2906 cmdline_parse_token_string_t cmd_config_threshold_all =
2907 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2908 cmdline_parse_token_string_t cmd_config_threshold_name =
2909 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2910 "txfreet#txrst#rxfreet");
2911 cmdline_parse_token_num_t cmd_config_threshold_value =
2912 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2914 cmdline_parse_inst_t cmd_config_threshold = {
2915 .f = cmd_config_threshold_parsed,
2917 .help_str = "port config all txfreet|txrst|rxfreet <value>",
2919 (void *)&cmd_config_threshold_port,
2920 (void *)&cmd_config_threshold_keyword,
2921 (void *)&cmd_config_threshold_all,
2922 (void *)&cmd_config_threshold_name,
2923 (void *)&cmd_config_threshold_value,
2929 struct cmd_stop_result {
2930 cmdline_fixed_string_t stop;
2933 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2934 __attribute__((unused)) struct cmdline *cl,
2935 __attribute__((unused)) void *data)
2937 stop_packet_forwarding();
2940 cmdline_parse_token_string_t cmd_stop_stop =
2941 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2943 cmdline_parse_inst_t cmd_stop = {
2944 .f = cmd_stop_parsed,
2946 .help_str = "stop: Stop packet forwarding",
2948 (void *)&cmd_stop_stop,
2953 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2956 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2957 unsigned int *parsed_items, int check_unique_values)
2959 unsigned int nb_item;
2967 * First parse all items in the list and store their value.
2972 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2974 if ((c >= '0') && (c <= '9')) {
2975 value = (unsigned int) (value * 10 + (c - '0'));
2980 printf("character %c is not a decimal digit\n", c);
2984 printf("No valid value before comma\n");
2987 if (nb_item < max_items) {
2988 parsed_items[nb_item] = value;
2994 if (nb_item >= max_items) {
2995 printf("Number of %s = %u > %u (maximum items)\n",
2996 item_name, nb_item + 1, max_items);
2999 parsed_items[nb_item++] = value;
3000 if (! check_unique_values)
3004 * Then, check that all values in the list are differents.
3005 * No optimization here...
3007 for (i = 0; i < nb_item; i++) {
3008 for (j = i + 1; j < nb_item; j++) {
3009 if (parsed_items[j] == parsed_items[i]) {
3010 printf("duplicated %s %u at index %u and %u\n",
3011 item_name, parsed_items[i], i, j);
3019 struct cmd_set_list_result {
3020 cmdline_fixed_string_t cmd_keyword;
3021 cmdline_fixed_string_t list_name;
3022 cmdline_fixed_string_t list_of_items;
3025 static void cmd_set_list_parsed(void *parsed_result,
3026 __attribute__((unused)) struct cmdline *cl,
3027 __attribute__((unused)) void *data)
3029 struct cmd_set_list_result *res;
3031 unsigned int lcorelist[RTE_MAX_LCORE];
3032 unsigned int portlist[RTE_MAX_ETHPORTS];
3034 unsigned int nb_item;
3036 if (test_done == 0) {
3037 printf("Please stop forwarding first\n");
3041 res = parsed_result;
3042 if (!strcmp(res->list_name, "corelist")) {
3043 nb_item = parse_item_list(res->list_of_items, "core",
3045 parsed_items.lcorelist, 1);
3047 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3052 if (!strcmp(res->list_name, "portlist")) {
3053 nb_item = parse_item_list(res->list_of_items, "port",
3055 parsed_items.portlist, 1);
3057 set_fwd_ports_list(parsed_items.portlist, nb_item);
3063 cmdline_parse_token_string_t cmd_set_list_keyword =
3064 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3066 cmdline_parse_token_string_t cmd_set_list_name =
3067 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3068 "corelist#portlist");
3069 cmdline_parse_token_string_t cmd_set_list_of_items =
3070 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3073 cmdline_parse_inst_t cmd_set_fwd_list = {
3074 .f = cmd_set_list_parsed,
3076 .help_str = "set corelist|portlist <list0[,list1]*>",
3078 (void *)&cmd_set_list_keyword,
3079 (void *)&cmd_set_list_name,
3080 (void *)&cmd_set_list_of_items,
3085 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3087 struct cmd_setmask_result {
3088 cmdline_fixed_string_t set;
3089 cmdline_fixed_string_t mask;
3093 static void cmd_set_mask_parsed(void *parsed_result,
3094 __attribute__((unused)) struct cmdline *cl,
3095 __attribute__((unused)) void *data)
3097 struct cmd_setmask_result *res = parsed_result;
3099 if (test_done == 0) {
3100 printf("Please stop forwarding first\n");
3103 if (!strcmp(res->mask, "coremask")) {
3104 set_fwd_lcores_mask(res->hexavalue);
3106 } else if (!strcmp(res->mask, "portmask")) {
3107 set_fwd_ports_mask(res->hexavalue);
3112 cmdline_parse_token_string_t cmd_setmask_set =
3113 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3114 cmdline_parse_token_string_t cmd_setmask_mask =
3115 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3116 "coremask#portmask");
3117 cmdline_parse_token_num_t cmd_setmask_value =
3118 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3120 cmdline_parse_inst_t cmd_set_fwd_mask = {
3121 .f = cmd_set_mask_parsed,
3123 .help_str = "set coremask|portmask <hexadecimal value>",
3125 (void *)&cmd_setmask_set,
3126 (void *)&cmd_setmask_mask,
3127 (void *)&cmd_setmask_value,
3133 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3135 struct cmd_set_result {
3136 cmdline_fixed_string_t set;
3137 cmdline_fixed_string_t what;
3141 static void cmd_set_parsed(void *parsed_result,
3142 __attribute__((unused)) struct cmdline *cl,
3143 __attribute__((unused)) void *data)
3145 struct cmd_set_result *res = parsed_result;
3146 if (!strcmp(res->what, "nbport")) {
3147 set_fwd_ports_number(res->value);
3149 } else if (!strcmp(res->what, "nbcore")) {
3150 set_fwd_lcores_number(res->value);
3152 } else if (!strcmp(res->what, "burst"))
3153 set_nb_pkt_per_burst(res->value);
3154 else if (!strcmp(res->what, "verbose"))
3155 set_verbose_level(res->value);
3158 cmdline_parse_token_string_t cmd_set_set =
3159 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3160 cmdline_parse_token_string_t cmd_set_what =
3161 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3162 "nbport#nbcore#burst#verbose");
3163 cmdline_parse_token_num_t cmd_set_value =
3164 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3166 cmdline_parse_inst_t cmd_set_numbers = {
3167 .f = cmd_set_parsed,
3169 .help_str = "set nbport|nbcore|burst|verbose <value>",
3171 (void *)&cmd_set_set,
3172 (void *)&cmd_set_what,
3173 (void *)&cmd_set_value,
3178 /* *** SET LOG LEVEL CONFIGURATION *** */
3180 struct cmd_set_log_result {
3181 cmdline_fixed_string_t set;
3182 cmdline_fixed_string_t log;
3183 cmdline_fixed_string_t type;
3188 cmd_set_log_parsed(void *parsed_result,
3189 __attribute__((unused)) struct cmdline *cl,
3190 __attribute__((unused)) void *data)
3192 struct cmd_set_log_result *res;
3195 res = parsed_result;
3196 if (!strcmp(res->type, "global"))
3197 rte_log_set_global_level(res->level);
3199 ret = rte_log_set_level_regexp(res->type, res->level);
3201 printf("Unable to set log level\n");
3205 cmdline_parse_token_string_t cmd_set_log_set =
3206 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3207 cmdline_parse_token_string_t cmd_set_log_log =
3208 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3209 cmdline_parse_token_string_t cmd_set_log_type =
3210 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3211 cmdline_parse_token_num_t cmd_set_log_level =
3212 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3214 cmdline_parse_inst_t cmd_set_log = {
3215 .f = cmd_set_log_parsed,
3217 .help_str = "set log global|<type> <level>",
3219 (void *)&cmd_set_log_set,
3220 (void *)&cmd_set_log_log,
3221 (void *)&cmd_set_log_type,
3222 (void *)&cmd_set_log_level,
3227 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3229 struct cmd_set_txpkts_result {
3230 cmdline_fixed_string_t cmd_keyword;
3231 cmdline_fixed_string_t txpkts;
3232 cmdline_fixed_string_t seg_lengths;
3236 cmd_set_txpkts_parsed(void *parsed_result,
3237 __attribute__((unused)) struct cmdline *cl,
3238 __attribute__((unused)) void *data)
3240 struct cmd_set_txpkts_result *res;
3241 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3242 unsigned int nb_segs;
3244 res = parsed_result;
3245 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3246 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3248 set_tx_pkt_segments(seg_lengths, nb_segs);
3251 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3252 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3253 cmd_keyword, "set");
3254 cmdline_parse_token_string_t cmd_set_txpkts_name =
3255 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3257 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3258 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3261 cmdline_parse_inst_t cmd_set_txpkts = {
3262 .f = cmd_set_txpkts_parsed,
3264 .help_str = "set txpkts <len0[,len1]*>",
3266 (void *)&cmd_set_txpkts_keyword,
3267 (void *)&cmd_set_txpkts_name,
3268 (void *)&cmd_set_txpkts_lengths,
3273 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3275 struct cmd_set_txsplit_result {
3276 cmdline_fixed_string_t cmd_keyword;
3277 cmdline_fixed_string_t txsplit;
3278 cmdline_fixed_string_t mode;
3282 cmd_set_txsplit_parsed(void *parsed_result,
3283 __attribute__((unused)) struct cmdline *cl,
3284 __attribute__((unused)) void *data)
3286 struct cmd_set_txsplit_result *res;
3288 res = parsed_result;
3289 set_tx_pkt_split(res->mode);
3292 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3293 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3294 cmd_keyword, "set");
3295 cmdline_parse_token_string_t cmd_set_txsplit_name =
3296 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3297 txsplit, "txsplit");
3298 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3299 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3302 cmdline_parse_inst_t cmd_set_txsplit = {
3303 .f = cmd_set_txsplit_parsed,
3305 .help_str = "set txsplit on|off|rand",
3307 (void *)&cmd_set_txsplit_keyword,
3308 (void *)&cmd_set_txsplit_name,
3309 (void *)&cmd_set_txsplit_mode,
3314 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3315 struct cmd_rx_vlan_filter_all_result {
3316 cmdline_fixed_string_t rx_vlan;
3317 cmdline_fixed_string_t what;
3318 cmdline_fixed_string_t all;
3323 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3324 __attribute__((unused)) struct cmdline *cl,
3325 __attribute__((unused)) void *data)
3327 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3329 if (!strcmp(res->what, "add"))
3330 rx_vlan_all_filter_set(res->port_id, 1);
3332 rx_vlan_all_filter_set(res->port_id, 0);
3335 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3336 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3337 rx_vlan, "rx_vlan");
3338 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3339 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3341 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3342 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3344 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3345 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3348 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3349 .f = cmd_rx_vlan_filter_all_parsed,
3351 .help_str = "rx_vlan add|rm all <port_id>: "
3352 "Add/Remove all identifiers to/from the set of VLAN "
3353 "identifiers filtered by a port",
3355 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3356 (void *)&cmd_rx_vlan_filter_all_what,
3357 (void *)&cmd_rx_vlan_filter_all_all,
3358 (void *)&cmd_rx_vlan_filter_all_portid,
3363 /* *** VLAN OFFLOAD SET ON A PORT *** */
3364 struct cmd_vlan_offload_result {
3365 cmdline_fixed_string_t vlan;
3366 cmdline_fixed_string_t set;
3367 cmdline_fixed_string_t vlan_type;
3368 cmdline_fixed_string_t what;
3369 cmdline_fixed_string_t on;
3370 cmdline_fixed_string_t port_id;
3374 cmd_vlan_offload_parsed(void *parsed_result,
3375 __attribute__((unused)) struct cmdline *cl,
3376 __attribute__((unused)) void *data)
3379 struct cmd_vlan_offload_result *res = parsed_result;
3382 portid_t port_id = 0;
3386 len = strnlen(str, STR_TOKEN_SIZE);
3388 /* Get port_id first */
3396 tmp = strtoul(str, NULL, 0);
3397 /* If port_id greater that what portid_t can represent, return */
3398 if(tmp >= RTE_MAX_ETHPORTS)
3400 port_id = (portid_t)tmp;
3402 if (!strcmp(res->on, "on"))
3407 if (!strcmp(res->what, "strip"))
3408 rx_vlan_strip_set(port_id, on);
3409 else if(!strcmp(res->what, "stripq")){
3410 uint16_t queue_id = 0;
3412 /* No queue_id, return */
3414 printf("must specify (port,queue_id)\n");
3417 tmp = strtoul(str + i + 1, NULL, 0);
3418 /* If queue_id greater that what 16-bits can represent, return */
3422 queue_id = (uint16_t)tmp;
3423 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3425 else if (!strcmp(res->what, "filter"))
3426 rx_vlan_filter_set(port_id, on);
3428 vlan_extend_set(port_id, on);
3433 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3434 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3436 cmdline_parse_token_string_t cmd_vlan_offload_set =
3437 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3439 cmdline_parse_token_string_t cmd_vlan_offload_what =
3440 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3441 what, "strip#filter#qinq#stripq");
3442 cmdline_parse_token_string_t cmd_vlan_offload_on =
3443 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3445 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3446 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3449 cmdline_parse_inst_t cmd_vlan_offload = {
3450 .f = cmd_vlan_offload_parsed,
3452 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3453 "<port_id[,queue_id]>: "
3454 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3456 (void *)&cmd_vlan_offload_vlan,
3457 (void *)&cmd_vlan_offload_set,
3458 (void *)&cmd_vlan_offload_what,
3459 (void *)&cmd_vlan_offload_on,
3460 (void *)&cmd_vlan_offload_portid,
3465 /* *** VLAN TPID SET ON A PORT *** */
3466 struct cmd_vlan_tpid_result {
3467 cmdline_fixed_string_t vlan;
3468 cmdline_fixed_string_t set;
3469 cmdline_fixed_string_t vlan_type;
3470 cmdline_fixed_string_t what;
3476 cmd_vlan_tpid_parsed(void *parsed_result,
3477 __attribute__((unused)) struct cmdline *cl,
3478 __attribute__((unused)) void *data)
3480 struct cmd_vlan_tpid_result *res = parsed_result;
3481 enum rte_vlan_type vlan_type;
3483 if (!strcmp(res->vlan_type, "inner"))
3484 vlan_type = ETH_VLAN_TYPE_INNER;
3485 else if (!strcmp(res->vlan_type, "outer"))
3486 vlan_type = ETH_VLAN_TYPE_OUTER;
3488 printf("Unknown vlan type\n");
3491 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3494 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3495 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3497 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3498 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3500 cmdline_parse_token_string_t cmd_vlan_type =
3501 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3502 vlan_type, "inner#outer");
3503 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3504 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3506 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3507 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3509 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3510 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3513 cmdline_parse_inst_t cmd_vlan_tpid = {
3514 .f = cmd_vlan_tpid_parsed,
3516 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3517 "Set the VLAN Ether type",
3519 (void *)&cmd_vlan_tpid_vlan,
3520 (void *)&cmd_vlan_tpid_set,
3521 (void *)&cmd_vlan_type,
3522 (void *)&cmd_vlan_tpid_what,
3523 (void *)&cmd_vlan_tpid_tpid,
3524 (void *)&cmd_vlan_tpid_portid,
3529 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3530 struct cmd_rx_vlan_filter_result {
3531 cmdline_fixed_string_t rx_vlan;
3532 cmdline_fixed_string_t what;
3538 cmd_rx_vlan_filter_parsed(void *parsed_result,
3539 __attribute__((unused)) struct cmdline *cl,
3540 __attribute__((unused)) void *data)
3542 struct cmd_rx_vlan_filter_result *res = parsed_result;
3544 if (!strcmp(res->what, "add"))
3545 rx_vft_set(res->port_id, res->vlan_id, 1);
3547 rx_vft_set(res->port_id, res->vlan_id, 0);
3550 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3551 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3552 rx_vlan, "rx_vlan");
3553 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3554 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3556 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3557 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3559 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3560 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3563 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3564 .f = cmd_rx_vlan_filter_parsed,
3566 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3567 "Add/Remove a VLAN identifier to/from the set of VLAN "
3568 "identifiers filtered by a port",
3570 (void *)&cmd_rx_vlan_filter_rx_vlan,
3571 (void *)&cmd_rx_vlan_filter_what,
3572 (void *)&cmd_rx_vlan_filter_vlanid,
3573 (void *)&cmd_rx_vlan_filter_portid,
3578 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3579 struct cmd_tx_vlan_set_result {
3580 cmdline_fixed_string_t tx_vlan;
3581 cmdline_fixed_string_t set;
3587 cmd_tx_vlan_set_parsed(void *parsed_result,
3588 __attribute__((unused)) struct cmdline *cl,
3589 __attribute__((unused)) void *data)
3591 struct cmd_tx_vlan_set_result *res = parsed_result;
3593 if (!port_is_stopped(res->port_id)) {
3594 printf("Please stop port %d first\n", res->port_id);
3598 tx_vlan_set(res->port_id, res->vlan_id);
3600 cmd_reconfig_device_queue(res->port_id, 1, 1);
3603 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3604 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3605 tx_vlan, "tx_vlan");
3606 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3607 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3609 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3610 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3612 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3613 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3616 cmdline_parse_inst_t cmd_tx_vlan_set = {
3617 .f = cmd_tx_vlan_set_parsed,
3619 .help_str = "tx_vlan set <port_id> <vlan_id>: "
3620 "Enable hardware insertion of a single VLAN header "
3621 "with a given TAG Identifier in packets sent on a port",
3623 (void *)&cmd_tx_vlan_set_tx_vlan,
3624 (void *)&cmd_tx_vlan_set_set,
3625 (void *)&cmd_tx_vlan_set_portid,
3626 (void *)&cmd_tx_vlan_set_vlanid,
3631 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3632 struct cmd_tx_vlan_set_qinq_result {
3633 cmdline_fixed_string_t tx_vlan;
3634 cmdline_fixed_string_t set;
3637 uint16_t vlan_id_outer;
3641 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3642 __attribute__((unused)) struct cmdline *cl,
3643 __attribute__((unused)) void *data)
3645 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3647 if (!port_is_stopped(res->port_id)) {
3648 printf("Please stop port %d first\n", res->port_id);
3652 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3654 cmd_reconfig_device_queue(res->port_id, 1, 1);
3657 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3658 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3659 tx_vlan, "tx_vlan");
3660 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3661 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3663 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3664 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3666 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3667 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3669 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3670 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3671 vlan_id_outer, UINT16);
3673 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3674 .f = cmd_tx_vlan_set_qinq_parsed,
3676 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3677 "Enable hardware insertion of double VLAN header "
3678 "with given TAG Identifiers in packets sent on a port",
3680 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3681 (void *)&cmd_tx_vlan_set_qinq_set,
3682 (void *)&cmd_tx_vlan_set_qinq_portid,
3683 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3684 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3689 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3690 struct cmd_tx_vlan_set_pvid_result {
3691 cmdline_fixed_string_t tx_vlan;
3692 cmdline_fixed_string_t set;
3693 cmdline_fixed_string_t pvid;
3696 cmdline_fixed_string_t mode;
3700 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3701 __attribute__((unused)) struct cmdline *cl,
3702 __attribute__((unused)) void *data)
3704 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3706 if (strcmp(res->mode, "on") == 0)
3707 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3709 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3712 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3713 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3714 tx_vlan, "tx_vlan");
3715 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3716 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3718 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3719 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3721 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3722 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3724 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3725 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3727 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3728 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3731 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3732 .f = cmd_tx_vlan_set_pvid_parsed,
3734 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
3736 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3737 (void *)&cmd_tx_vlan_set_pvid_set,
3738 (void *)&cmd_tx_vlan_set_pvid_pvid,
3739 (void *)&cmd_tx_vlan_set_pvid_port_id,
3740 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3741 (void *)&cmd_tx_vlan_set_pvid_mode,
3746 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3747 struct cmd_tx_vlan_reset_result {
3748 cmdline_fixed_string_t tx_vlan;
3749 cmdline_fixed_string_t reset;
3754 cmd_tx_vlan_reset_parsed(void *parsed_result,
3755 __attribute__((unused)) struct cmdline *cl,
3756 __attribute__((unused)) void *data)
3758 struct cmd_tx_vlan_reset_result *res = parsed_result;
3760 if (!port_is_stopped(res->port_id)) {
3761 printf("Please stop port %d first\n", res->port_id);
3765 tx_vlan_reset(res->port_id);
3767 cmd_reconfig_device_queue(res->port_id, 1, 1);
3770 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3771 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3772 tx_vlan, "tx_vlan");
3773 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3774 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3776 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3777 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3780 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3781 .f = cmd_tx_vlan_reset_parsed,
3783 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
3784 "VLAN header in packets sent on a port",
3786 (void *)&cmd_tx_vlan_reset_tx_vlan,
3787 (void *)&cmd_tx_vlan_reset_reset,
3788 (void *)&cmd_tx_vlan_reset_portid,
3794 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3795 struct cmd_csum_result {
3796 cmdline_fixed_string_t csum;
3797 cmdline_fixed_string_t mode;
3798 cmdline_fixed_string_t proto;
3799 cmdline_fixed_string_t hwsw;
3804 csum_show(int port_id)
3806 struct rte_eth_dev_info dev_info;
3807 uint64_t tx_offloads;
3809 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
3810 printf("Parse tunnel is %s\n",
3811 (ports[port_id].parse_tunnel) ? "on" : "off");
3812 printf("IP checksum offload is %s\n",
3813 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
3814 printf("UDP checksum offload is %s\n",
3815 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3816 printf("TCP checksum offload is %s\n",
3817 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3818 printf("SCTP checksum offload is %s\n",
3819 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3820 printf("Outer-Ip checksum offload is %s\n",
3821 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
3823 /* display warnings if configuration is not supported by the NIC */
3824 rte_eth_dev_info_get(port_id, &dev_info);
3825 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
3826 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3827 printf("Warning: hardware IP checksum enabled but not "
3828 "supported by port %d\n", port_id);
3830 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
3831 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3832 printf("Warning: hardware UDP checksum enabled but not "
3833 "supported by port %d\n", port_id);
3835 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
3836 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3837 printf("Warning: hardware TCP checksum enabled but not "
3838 "supported by port %d\n", port_id);
3840 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
3841 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3842 printf("Warning: hardware SCTP checksum enabled but not "
3843 "supported by port %d\n", port_id);
3845 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
3846 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3847 printf("Warning: hardware outer IP checksum enabled but not "
3848 "supported by port %d\n", port_id);
3853 cmd_csum_parsed(void *parsed_result,
3854 __attribute__((unused)) struct cmdline *cl,
3855 __attribute__((unused)) void *data)
3857 struct cmd_csum_result *res = parsed_result;
3859 uint64_t csum_offloads = 0;
3860 struct rte_eth_dev_info dev_info;
3862 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3863 printf("invalid port %d\n", res->port_id);
3866 if (!port_is_stopped(res->port_id)) {
3867 printf("Please stop port %d first\n", res->port_id);
3871 rte_eth_dev_info_get(res->port_id, &dev_info);
3872 if (!strcmp(res->mode, "set")) {
3874 if (!strcmp(res->hwsw, "hw"))
3877 if (!strcmp(res->proto, "ip")) {
3878 if (hw == 0 || (dev_info.tx_offload_capa &
3879 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
3880 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
3882 printf("IP checksum offload is not supported "
3883 "by port %u\n", res->port_id);
3885 } else if (!strcmp(res->proto, "udp")) {
3886 if (hw == 0 || (dev_info.tx_offload_capa &
3887 DEV_TX_OFFLOAD_UDP_CKSUM)) {
3888 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
3890 printf("UDP checksum offload is not supported "
3891 "by port %u\n", res->port_id);
3893 } else if (!strcmp(res->proto, "tcp")) {
3894 if (hw == 0 || (dev_info.tx_offload_capa &
3895 DEV_TX_OFFLOAD_TCP_CKSUM)) {
3896 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
3898 printf("TCP checksum offload is not supported "
3899 "by port %u\n", res->port_id);
3901 } else if (!strcmp(res->proto, "sctp")) {
3902 if (hw == 0 || (dev_info.tx_offload_capa &
3903 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
3904 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
3906 printf("SCTP checksum offload is not supported "
3907 "by port %u\n", res->port_id);
3909 } else if (!strcmp(res->proto, "outer-ip")) {
3910 if (hw == 0 || (dev_info.tx_offload_capa &
3911 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
3913 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
3915 printf("Outer IP checksum offload is not "
3916 "supported by port %u\n", res->port_id);
3921 ports[res->port_id].dev_conf.txmode.offloads |=
3924 ports[res->port_id].dev_conf.txmode.offloads &=
3928 csum_show(res->port_id);
3930 cmd_reconfig_device_queue(res->port_id, 1, 1);
3933 cmdline_parse_token_string_t cmd_csum_csum =
3934 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3936 cmdline_parse_token_string_t cmd_csum_mode =
3937 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3939 cmdline_parse_token_string_t cmd_csum_proto =
3940 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3941 proto, "ip#tcp#udp#sctp#outer-ip");
3942 cmdline_parse_token_string_t cmd_csum_hwsw =
3943 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3945 cmdline_parse_token_num_t cmd_csum_portid =
3946 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3949 cmdline_parse_inst_t cmd_csum_set = {
3950 .f = cmd_csum_parsed,
3952 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
3953 "Enable/Disable hardware calculation of L3/L4 checksum when "
3954 "using csum forward engine",
3956 (void *)&cmd_csum_csum,
3957 (void *)&cmd_csum_mode,
3958 (void *)&cmd_csum_proto,
3959 (void *)&cmd_csum_hwsw,
3960 (void *)&cmd_csum_portid,
3965 cmdline_parse_token_string_t cmd_csum_mode_show =
3966 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3969 cmdline_parse_inst_t cmd_csum_show = {
3970 .f = cmd_csum_parsed,
3972 .help_str = "csum show <port_id>: Show checksum offload configuration",
3974 (void *)&cmd_csum_csum,
3975 (void *)&cmd_csum_mode_show,
3976 (void *)&cmd_csum_portid,
3981 /* Enable/disable tunnel parsing */
3982 struct cmd_csum_tunnel_result {
3983 cmdline_fixed_string_t csum;
3984 cmdline_fixed_string_t parse;
3985 cmdline_fixed_string_t onoff;
3990 cmd_csum_tunnel_parsed(void *parsed_result,
3991 __attribute__((unused)) struct cmdline *cl,
3992 __attribute__((unused)) void *data)
3994 struct cmd_csum_tunnel_result *res = parsed_result;
3996 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3999 if (!strcmp(res->onoff, "on"))
4000 ports[res->port_id].parse_tunnel = 1;
4002 ports[res->port_id].parse_tunnel = 0;
4004 csum_show(res->port_id);
4007 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4008 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4010 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4011 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4012 parse, "parse_tunnel");
4013 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4014 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4016 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4017 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4020 cmdline_parse_inst_t cmd_csum_tunnel = {
4021 .f = cmd_csum_tunnel_parsed,
4023 .help_str = "csum parse_tunnel on|off <port_id>: "
4024 "Enable/Disable parsing of tunnels for csum engine",
4026 (void *)&cmd_csum_tunnel_csum,
4027 (void *)&cmd_csum_tunnel_parse,
4028 (void *)&cmd_csum_tunnel_onoff,
4029 (void *)&cmd_csum_tunnel_portid,
4034 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4035 struct cmd_tso_set_result {
4036 cmdline_fixed_string_t tso;
4037 cmdline_fixed_string_t mode;
4043 cmd_tso_set_parsed(void *parsed_result,
4044 __attribute__((unused)) struct cmdline *cl,
4045 __attribute__((unused)) void *data)
4047 struct cmd_tso_set_result *res = parsed_result;
4048 struct rte_eth_dev_info dev_info;
4050 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4052 if (!port_is_stopped(res->port_id)) {
4053 printf("Please stop port %d first\n", res->port_id);
4057 if (!strcmp(res->mode, "set"))
4058 ports[res->port_id].tso_segsz = res->tso_segsz;
4060 rte_eth_dev_info_get(res->port_id, &dev_info);
4061 if ((ports[res->port_id].tso_segsz != 0) &&
4062 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4063 printf("Error: TSO is not supported by port %d\n",
4068 if (ports[res->port_id].tso_segsz == 0) {
4069 ports[res->port_id].dev_conf.txmode.offloads &=
4070 ~DEV_TX_OFFLOAD_TCP_TSO;
4071 printf("TSO for non-tunneled packets is disabled\n");
4073 ports[res->port_id].dev_conf.txmode.offloads |=
4074 DEV_TX_OFFLOAD_TCP_TSO;
4075 printf("TSO segment size for non-tunneled packets is %d\n",
4076 ports[res->port_id].tso_segsz);
4079 /* display warnings if configuration is not supported by the NIC */
4080 rte_eth_dev_info_get(res->port_id, &dev_info);
4081 if ((ports[res->port_id].tso_segsz != 0) &&
4082 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4083 printf("Warning: TSO enabled but not "
4084 "supported by port %d\n", res->port_id);
4087 cmd_reconfig_device_queue(res->port_id, 1, 1);
4090 cmdline_parse_token_string_t cmd_tso_set_tso =
4091 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4093 cmdline_parse_token_string_t cmd_tso_set_mode =
4094 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4096 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4097 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4099 cmdline_parse_token_num_t cmd_tso_set_portid =
4100 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4103 cmdline_parse_inst_t cmd_tso_set = {
4104 .f = cmd_tso_set_parsed,
4106 .help_str = "tso set <tso_segsz> <port_id>: "
4107 "Set TSO segment size of non-tunneled packets for csum engine "
4110 (void *)&cmd_tso_set_tso,
4111 (void *)&cmd_tso_set_mode,
4112 (void *)&cmd_tso_set_tso_segsz,
4113 (void *)&cmd_tso_set_portid,
4118 cmdline_parse_token_string_t cmd_tso_show_mode =
4119 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4123 cmdline_parse_inst_t cmd_tso_show = {
4124 .f = cmd_tso_set_parsed,
4126 .help_str = "tso show <port_id>: "
4127 "Show TSO segment size of non-tunneled packets for csum engine",
4129 (void *)&cmd_tso_set_tso,
4130 (void *)&cmd_tso_show_mode,
4131 (void *)&cmd_tso_set_portid,
4136 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4137 struct cmd_tunnel_tso_set_result {
4138 cmdline_fixed_string_t tso;
4139 cmdline_fixed_string_t mode;
4144 static struct rte_eth_dev_info
4145 check_tunnel_tso_nic_support(portid_t port_id)
4147 struct rte_eth_dev_info dev_info;
4149 rte_eth_dev_info_get(port_id, &dev_info);
4150 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4151 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4152 "not enabled for port %d\n", port_id);
4153 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4154 printf("Warning: GRE TUNNEL TSO not supported therefore "
4155 "not enabled for port %d\n", port_id);
4156 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4157 printf("Warning: IPIP TUNNEL TSO not supported therefore "
4158 "not enabled for port %d\n", port_id);
4159 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4160 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4161 "not enabled for port %d\n", port_id);
4166 cmd_tunnel_tso_set_parsed(void *parsed_result,
4167 __attribute__((unused)) struct cmdline *cl,
4168 __attribute__((unused)) void *data)
4170 struct cmd_tunnel_tso_set_result *res = parsed_result;
4171 struct rte_eth_dev_info dev_info;
4173 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4175 if (!port_is_stopped(res->port_id)) {
4176 printf("Please stop port %d first\n", res->port_id);
4180 if (!strcmp(res->mode, "set"))
4181 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4183 dev_info = check_tunnel_tso_nic_support(res->port_id);
4184 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4185 ports[res->port_id].dev_conf.txmode.offloads &=
4186 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4187 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4188 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4189 DEV_TX_OFFLOAD_GENEVE_TNL_TSO);
4190 printf("TSO for tunneled packets is disabled\n");
4192 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4193 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4194 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4195 DEV_TX_OFFLOAD_GENEVE_TNL_TSO);
4197 ports[res->port_id].dev_conf.txmode.offloads |=
4198 (tso_offloads & dev_info.tx_offload_capa);
4199 printf("TSO segment size for tunneled packets is %d\n",
4200 ports[res->port_id].tunnel_tso_segsz);
4202 /* Below conditions are needed to make it work:
4203 * (1) tunnel TSO is supported by the NIC;
4204 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4206 * (3) for tunneled pkts with outer L3 of IPv4,
4207 * "csum set outer-ip" must be set to hw, because after tso,
4208 * total_len of outer IP header is changed, and the checksum
4209 * of outer IP header calculated by sw should be wrong; that
4210 * is not necessary for IPv6 tunneled pkts because there's no
4211 * checksum in IP header anymore.
4214 if (!ports[res->port_id].parse_tunnel)
4215 printf("Warning: csum parse_tunnel must be set "
4216 "so that tunneled packets are recognized\n");
4217 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4218 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4219 printf("Warning: csum set outer-ip must be set to hw "
4220 "if outer L3 is IPv4; not necessary for IPv6\n");
4223 cmd_reconfig_device_queue(res->port_id, 1, 1);
4226 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4227 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4229 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4230 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4232 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4233 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4235 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4236 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4239 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4240 .f = cmd_tunnel_tso_set_parsed,
4242 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4243 "Set TSO segment size of tunneled packets for csum engine "
4246 (void *)&cmd_tunnel_tso_set_tso,
4247 (void *)&cmd_tunnel_tso_set_mode,
4248 (void *)&cmd_tunnel_tso_set_tso_segsz,
4249 (void *)&cmd_tunnel_tso_set_portid,
4254 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4255 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4259 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4260 .f = cmd_tunnel_tso_set_parsed,
4262 .help_str = "tunnel_tso show <port_id> "
4263 "Show TSO segment size of tunneled packets for csum engine",
4265 (void *)&cmd_tunnel_tso_set_tso,
4266 (void *)&cmd_tunnel_tso_show_mode,
4267 (void *)&cmd_tunnel_tso_set_portid,
4272 /* *** SET GRO FOR A PORT *** */
4273 struct cmd_gro_enable_result {
4274 cmdline_fixed_string_t cmd_set;
4275 cmdline_fixed_string_t cmd_port;
4276 cmdline_fixed_string_t cmd_keyword;
4277 cmdline_fixed_string_t cmd_onoff;
4282 cmd_gro_enable_parsed(void *parsed_result,
4283 __attribute__((unused)) struct cmdline *cl,
4284 __attribute__((unused)) void *data)
4286 struct cmd_gro_enable_result *res;
4288 res = parsed_result;
4289 if (!strcmp(res->cmd_keyword, "gro"))
4290 setup_gro(res->cmd_onoff, res->cmd_pid);
4293 cmdline_parse_token_string_t cmd_gro_enable_set =
4294 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4296 cmdline_parse_token_string_t cmd_gro_enable_port =
4297 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4298 cmd_keyword, "port");
4299 cmdline_parse_token_num_t cmd_gro_enable_pid =
4300 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4302 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4303 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4304 cmd_keyword, "gro");
4305 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4306 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4307 cmd_onoff, "on#off");
4309 cmdline_parse_inst_t cmd_gro_enable = {
4310 .f = cmd_gro_enable_parsed,
4312 .help_str = "set port <port_id> gro on|off",
4314 (void *)&cmd_gro_enable_set,
4315 (void *)&cmd_gro_enable_port,
4316 (void *)&cmd_gro_enable_pid,
4317 (void *)&cmd_gro_enable_keyword,
4318 (void *)&cmd_gro_enable_onoff,
4323 /* *** DISPLAY GRO CONFIGURATION *** */
4324 struct cmd_gro_show_result {
4325 cmdline_fixed_string_t cmd_show;
4326 cmdline_fixed_string_t cmd_port;
4327 cmdline_fixed_string_t cmd_keyword;
4332 cmd_gro_show_parsed(void *parsed_result,
4333 __attribute__((unused)) struct cmdline *cl,
4334 __attribute__((unused)) void *data)
4336 struct cmd_gro_show_result *res;
4338 res = parsed_result;
4339 if (!strcmp(res->cmd_keyword, "gro"))
4340 show_gro(res->cmd_pid);
4343 cmdline_parse_token_string_t cmd_gro_show_show =
4344 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4346 cmdline_parse_token_string_t cmd_gro_show_port =
4347 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4349 cmdline_parse_token_num_t cmd_gro_show_pid =
4350 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
4352 cmdline_parse_token_string_t cmd_gro_show_keyword =
4353 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4354 cmd_keyword, "gro");
4356 cmdline_parse_inst_t cmd_gro_show = {
4357 .f = cmd_gro_show_parsed,
4359 .help_str = "show port <port_id> gro",
4361 (void *)&cmd_gro_show_show,
4362 (void *)&cmd_gro_show_port,
4363 (void *)&cmd_gro_show_pid,
4364 (void *)&cmd_gro_show_keyword,
4369 /* *** SET FLUSH CYCLES FOR GRO *** */
4370 struct cmd_gro_flush_result {
4371 cmdline_fixed_string_t cmd_set;
4372 cmdline_fixed_string_t cmd_keyword;
4373 cmdline_fixed_string_t cmd_flush;
4378 cmd_gro_flush_parsed(void *parsed_result,
4379 __attribute__((unused)) struct cmdline *cl,
4380 __attribute__((unused)) void *data)
4382 struct cmd_gro_flush_result *res;
4384 res = parsed_result;
4385 if ((!strcmp(res->cmd_keyword, "gro")) &&
4386 (!strcmp(res->cmd_flush, "flush")))
4387 setup_gro_flush_cycles(res->cmd_cycles);
4390 cmdline_parse_token_string_t cmd_gro_flush_set =
4391 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4393 cmdline_parse_token_string_t cmd_gro_flush_keyword =
4394 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4395 cmd_keyword, "gro");
4396 cmdline_parse_token_string_t cmd_gro_flush_flush =
4397 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4398 cmd_flush, "flush");
4399 cmdline_parse_token_num_t cmd_gro_flush_cycles =
4400 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
4403 cmdline_parse_inst_t cmd_gro_flush = {
4404 .f = cmd_gro_flush_parsed,
4406 .help_str = "set gro flush <cycles>",
4408 (void *)&cmd_gro_flush_set,
4409 (void *)&cmd_gro_flush_keyword,
4410 (void *)&cmd_gro_flush_flush,
4411 (void *)&cmd_gro_flush_cycles,
4416 /* *** ENABLE/DISABLE GSO *** */
4417 struct cmd_gso_enable_result {
4418 cmdline_fixed_string_t cmd_set;
4419 cmdline_fixed_string_t cmd_port;
4420 cmdline_fixed_string_t cmd_keyword;
4421 cmdline_fixed_string_t cmd_mode;
4426 cmd_gso_enable_parsed(void *parsed_result,
4427 __attribute__((unused)) struct cmdline *cl,
4428 __attribute__((unused)) void *data)
4430 struct cmd_gso_enable_result *res;
4432 res = parsed_result;
4433 if (!strcmp(res->cmd_keyword, "gso"))
4434 setup_gso(res->cmd_mode, res->cmd_pid);
4437 cmdline_parse_token_string_t cmd_gso_enable_set =
4438 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4440 cmdline_parse_token_string_t cmd_gso_enable_port =
4441 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4443 cmdline_parse_token_string_t cmd_gso_enable_keyword =
4444 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4445 cmd_keyword, "gso");
4446 cmdline_parse_token_string_t cmd_gso_enable_mode =
4447 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4448 cmd_mode, "on#off");
4449 cmdline_parse_token_num_t cmd_gso_enable_pid =
4450 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
4453 cmdline_parse_inst_t cmd_gso_enable = {
4454 .f = cmd_gso_enable_parsed,
4456 .help_str = "set port <port_id> gso on|off",
4458 (void *)&cmd_gso_enable_set,
4459 (void *)&cmd_gso_enable_port,
4460 (void *)&cmd_gso_enable_pid,
4461 (void *)&cmd_gso_enable_keyword,
4462 (void *)&cmd_gso_enable_mode,
4467 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
4468 struct cmd_gso_size_result {
4469 cmdline_fixed_string_t cmd_set;
4470 cmdline_fixed_string_t cmd_keyword;
4471 cmdline_fixed_string_t cmd_segsz;
4476 cmd_gso_size_parsed(void *parsed_result,
4477 __attribute__((unused)) struct cmdline *cl,
4478 __attribute__((unused)) void *data)
4480 struct cmd_gso_size_result *res = parsed_result;
4482 if (test_done == 0) {
4483 printf("Before setting GSO segsz, please first"
4484 " stop fowarding\n");
4488 if (!strcmp(res->cmd_keyword, "gso") &&
4489 !strcmp(res->cmd_segsz, "segsz")) {
4490 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
4491 printf("gso_size should be larger than %zu."
4492 " Please input a legal value\n",
4493 RTE_GSO_SEG_SIZE_MIN);
4495 gso_max_segment_size = res->cmd_size;
4499 cmdline_parse_token_string_t cmd_gso_size_set =
4500 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4502 cmdline_parse_token_string_t cmd_gso_size_keyword =
4503 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4504 cmd_keyword, "gso");
4505 cmdline_parse_token_string_t cmd_gso_size_segsz =
4506 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4507 cmd_segsz, "segsz");
4508 cmdline_parse_token_num_t cmd_gso_size_size =
4509 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
4512 cmdline_parse_inst_t cmd_gso_size = {
4513 .f = cmd_gso_size_parsed,
4515 .help_str = "set gso segsz <length>",
4517 (void *)&cmd_gso_size_set,
4518 (void *)&cmd_gso_size_keyword,
4519 (void *)&cmd_gso_size_segsz,
4520 (void *)&cmd_gso_size_size,
4525 /* *** SHOW GSO CONFIGURATION *** */
4526 struct cmd_gso_show_result {
4527 cmdline_fixed_string_t cmd_show;
4528 cmdline_fixed_string_t cmd_port;
4529 cmdline_fixed_string_t cmd_keyword;
4534 cmd_gso_show_parsed(void *parsed_result,
4535 __attribute__((unused)) struct cmdline *cl,
4536 __attribute__((unused)) void *data)
4538 struct cmd_gso_show_result *res = parsed_result;
4540 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
4541 printf("invalid port id %u\n", res->cmd_pid);
4544 if (!strcmp(res->cmd_keyword, "gso")) {
4545 if (gso_ports[res->cmd_pid].enable) {
4546 printf("Max GSO'd packet size: %uB\n"
4547 "Supported GSO types: TCP/IPv4, "
4548 "VxLAN with inner TCP/IPv4 packet, "
4549 "GRE with inner TCP/IPv4 packet\n",
4550 gso_max_segment_size);
4552 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
4556 cmdline_parse_token_string_t cmd_gso_show_show =
4557 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4559 cmdline_parse_token_string_t cmd_gso_show_port =
4560 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4562 cmdline_parse_token_string_t cmd_gso_show_keyword =
4563 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4564 cmd_keyword, "gso");
4565 cmdline_parse_token_num_t cmd_gso_show_pid =
4566 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
4569 cmdline_parse_inst_t cmd_gso_show = {
4570 .f = cmd_gso_show_parsed,
4572 .help_str = "show port <port_id> gso",
4574 (void *)&cmd_gso_show_show,
4575 (void *)&cmd_gso_show_port,
4576 (void *)&cmd_gso_show_pid,
4577 (void *)&cmd_gso_show_keyword,
4582 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
4583 struct cmd_set_flush_rx {
4584 cmdline_fixed_string_t set;
4585 cmdline_fixed_string_t flush_rx;
4586 cmdline_fixed_string_t mode;
4590 cmd_set_flush_rx_parsed(void *parsed_result,
4591 __attribute__((unused)) struct cmdline *cl,
4592 __attribute__((unused)) void *data)
4594 struct cmd_set_flush_rx *res = parsed_result;
4595 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4598 cmdline_parse_token_string_t cmd_setflushrx_set =
4599 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4601 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
4602 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4603 flush_rx, "flush_rx");
4604 cmdline_parse_token_string_t cmd_setflushrx_mode =
4605 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4609 cmdline_parse_inst_t cmd_set_flush_rx = {
4610 .f = cmd_set_flush_rx_parsed,
4611 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
4614 (void *)&cmd_setflushrx_set,
4615 (void *)&cmd_setflushrx_flush_rx,
4616 (void *)&cmd_setflushrx_mode,
4621 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
4622 struct cmd_set_link_check {
4623 cmdline_fixed_string_t set;
4624 cmdline_fixed_string_t link_check;
4625 cmdline_fixed_string_t mode;
4629 cmd_set_link_check_parsed(void *parsed_result,
4630 __attribute__((unused)) struct cmdline *cl,
4631 __attribute__((unused)) void *data)
4633 struct cmd_set_link_check *res = parsed_result;
4634 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4637 cmdline_parse_token_string_t cmd_setlinkcheck_set =
4638 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4640 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
4641 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4642 link_check, "link_check");
4643 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
4644 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4648 cmdline_parse_inst_t cmd_set_link_check = {
4649 .f = cmd_set_link_check_parsed,
4650 .help_str = "set link_check on|off: Enable/Disable link status check "
4651 "when starting/stopping a port",
4654 (void *)&cmd_setlinkcheck_set,
4655 (void *)&cmd_setlinkcheck_link_check,
4656 (void *)&cmd_setlinkcheck_mode,
4661 /* *** SET NIC BYPASS MODE *** */
4662 struct cmd_set_bypass_mode_result {
4663 cmdline_fixed_string_t set;
4664 cmdline_fixed_string_t bypass;
4665 cmdline_fixed_string_t mode;
4666 cmdline_fixed_string_t value;
4671 cmd_set_bypass_mode_parsed(void *parsed_result,
4672 __attribute__((unused)) struct cmdline *cl,
4673 __attribute__((unused)) void *data)
4675 struct cmd_set_bypass_mode_result *res = parsed_result;
4676 portid_t port_id = res->port_id;
4677 int32_t rc = -EINVAL;
4679 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4680 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4682 if (!strcmp(res->value, "bypass"))
4683 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4684 else if (!strcmp(res->value, "isolate"))
4685 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4687 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4689 /* Set the bypass mode for the relevant port. */
4690 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
4693 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
4696 cmdline_parse_token_string_t cmd_setbypass_mode_set =
4697 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4699 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
4700 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4702 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
4703 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4705 cmdline_parse_token_string_t cmd_setbypass_mode_value =
4706 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4707 value, "normal#bypass#isolate");
4708 cmdline_parse_token_num_t cmd_setbypass_mode_port =
4709 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
4712 cmdline_parse_inst_t cmd_set_bypass_mode = {
4713 .f = cmd_set_bypass_mode_parsed,
4714 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
4715 "Set the NIC bypass mode for port_id",
4718 (void *)&cmd_setbypass_mode_set,
4719 (void *)&cmd_setbypass_mode_bypass,
4720 (void *)&cmd_setbypass_mode_mode,
4721 (void *)&cmd_setbypass_mode_value,
4722 (void *)&cmd_setbypass_mode_port,
4727 /* *** SET NIC BYPASS EVENT *** */
4728 struct cmd_set_bypass_event_result {
4729 cmdline_fixed_string_t set;
4730 cmdline_fixed_string_t bypass;
4731 cmdline_fixed_string_t event;
4732 cmdline_fixed_string_t event_value;
4733 cmdline_fixed_string_t mode;
4734 cmdline_fixed_string_t mode_value;
4739 cmd_set_bypass_event_parsed(void *parsed_result,
4740 __attribute__((unused)) struct cmdline *cl,
4741 __attribute__((unused)) void *data)
4743 int32_t rc = -EINVAL;
4744 struct cmd_set_bypass_event_result *res = parsed_result;
4745 portid_t port_id = res->port_id;
4747 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4748 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4749 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4751 if (!strcmp(res->event_value, "timeout"))
4752 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
4753 else if (!strcmp(res->event_value, "os_on"))
4754 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
4755 else if (!strcmp(res->event_value, "os_off"))
4756 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
4757 else if (!strcmp(res->event_value, "power_on"))
4758 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
4759 else if (!strcmp(res->event_value, "power_off"))
4760 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
4762 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4764 if (!strcmp(res->mode_value, "bypass"))
4765 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4766 else if (!strcmp(res->mode_value, "isolate"))
4767 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4769 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4771 /* Set the watchdog timeout. */
4772 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
4775 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
4776 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
4780 printf("Failed to set timeout value %u "
4781 "for port %d, errto code: %d.\n",
4782 bypass_timeout, port_id, rc);
4786 /* Set the bypass event to transition to bypass mode. */
4787 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
4792 printf("\t Failed to set bypass event for port = %d.\n",
4796 cmdline_parse_token_string_t cmd_setbypass_event_set =
4797 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4799 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
4800 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4802 cmdline_parse_token_string_t cmd_setbypass_event_event =
4803 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4805 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
4806 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4807 event_value, "none#timeout#os_off#os_on#power_on#power_off");
4808 cmdline_parse_token_string_t cmd_setbypass_event_mode =
4809 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4811 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
4812 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4813 mode_value, "normal#bypass#isolate");
4814 cmdline_parse_token_num_t cmd_setbypass_event_port =
4815 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
4818 cmdline_parse_inst_t cmd_set_bypass_event = {
4819 .f = cmd_set_bypass_event_parsed,
4820 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
4821 "power_off mode normal|bypass|isolate <port_id>: "
4822 "Set the NIC bypass event mode for port_id",
4825 (void *)&cmd_setbypass_event_set,
4826 (void *)&cmd_setbypass_event_bypass,
4827 (void *)&cmd_setbypass_event_event,
4828 (void *)&cmd_setbypass_event_event_value,
4829 (void *)&cmd_setbypass_event_mode,
4830 (void *)&cmd_setbypass_event_mode_value,
4831 (void *)&cmd_setbypass_event_port,
4837 /* *** SET NIC BYPASS TIMEOUT *** */
4838 struct cmd_set_bypass_timeout_result {
4839 cmdline_fixed_string_t set;
4840 cmdline_fixed_string_t bypass;
4841 cmdline_fixed_string_t timeout;
4842 cmdline_fixed_string_t value;
4846 cmd_set_bypass_timeout_parsed(void *parsed_result,
4847 __attribute__((unused)) struct cmdline *cl,
4848 __attribute__((unused)) void *data)
4850 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
4852 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4853 if (!strcmp(res->value, "1.5"))
4854 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
4855 else if (!strcmp(res->value, "2"))
4856 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
4857 else if (!strcmp(res->value, "3"))
4858 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
4859 else if (!strcmp(res->value, "4"))
4860 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
4861 else if (!strcmp(res->value, "8"))
4862 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
4863 else if (!strcmp(res->value, "16"))
4864 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
4865 else if (!strcmp(res->value, "32"))
4866 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
4868 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4872 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
4873 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4875 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
4876 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4878 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
4879 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4880 timeout, "timeout");
4881 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
4882 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4883 value, "0#1.5#2#3#4#8#16#32");
4885 cmdline_parse_inst_t cmd_set_bypass_timeout = {
4886 .f = cmd_set_bypass_timeout_parsed,
4887 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
4888 "Set the NIC bypass watchdog timeout in seconds",
4891 (void *)&cmd_setbypass_timeout_set,
4892 (void *)&cmd_setbypass_timeout_bypass,
4893 (void *)&cmd_setbypass_timeout_timeout,
4894 (void *)&cmd_setbypass_timeout_value,
4899 /* *** SHOW NIC BYPASS MODE *** */
4900 struct cmd_show_bypass_config_result {
4901 cmdline_fixed_string_t show;
4902 cmdline_fixed_string_t bypass;
4903 cmdline_fixed_string_t config;
4908 cmd_show_bypass_config_parsed(void *parsed_result,
4909 __attribute__((unused)) struct cmdline *cl,
4910 __attribute__((unused)) void *data)
4912 struct cmd_show_bypass_config_result *res = parsed_result;
4913 portid_t port_id = res->port_id;
4915 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4916 uint32_t event_mode;
4917 uint32_t bypass_mode;
4918 uint32_t timeout = bypass_timeout;
4921 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
4922 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
4923 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
4924 {"UNKNOWN", "normal", "bypass", "isolate"};
4925 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
4932 int num_events = (sizeof events) / (sizeof events[0]);
4934 /* Display the bypass mode.*/
4935 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
4936 printf("\tFailed to get bypass mode for port = %d\n", port_id);
4940 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
4941 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4943 printf("\tbypass mode = %s\n", modes[bypass_mode]);
4946 /* Display the bypass timeout.*/
4947 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
4948 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4950 printf("\tbypass timeout = %s\n", timeouts[timeout]);
4952 /* Display the bypass events and associated modes. */
4953 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
4955 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
4956 printf("\tFailed to get bypass mode for event = %s\n",
4959 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
4960 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4962 printf("\tbypass event: %-16s = %s\n", events[i],
4968 printf("\tFailed to get bypass configuration for port = %d\n",
4972 cmdline_parse_token_string_t cmd_showbypass_config_show =
4973 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4975 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
4976 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4978 cmdline_parse_token_string_t cmd_showbypass_config_config =
4979 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4981 cmdline_parse_token_num_t cmd_showbypass_config_port =
4982 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
4985 cmdline_parse_inst_t cmd_show_bypass_config = {
4986 .f = cmd_show_bypass_config_parsed,
4987 .help_str = "show bypass config <port_id>: "
4988 "Show the NIC bypass config for port_id",
4991 (void *)&cmd_showbypass_config_show,
4992 (void *)&cmd_showbypass_config_bypass,
4993 (void *)&cmd_showbypass_config_config,
4994 (void *)&cmd_showbypass_config_port,
4999 #ifdef RTE_LIBRTE_PMD_BOND
5000 /* *** SET BONDING MODE *** */
5001 struct cmd_set_bonding_mode_result {
5002 cmdline_fixed_string_t set;
5003 cmdline_fixed_string_t bonding;
5004 cmdline_fixed_string_t mode;
5009 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5010 __attribute__((unused)) struct cmdline *cl,
5011 __attribute__((unused)) void *data)
5013 struct cmd_set_bonding_mode_result *res = parsed_result;
5014 portid_t port_id = res->port_id;
5016 /* Set the bonding mode for the relevant port. */
5017 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5018 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5021 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5022 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5024 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5025 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5026 bonding, "bonding");
5027 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5028 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5030 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5031 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5033 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5034 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5037 cmdline_parse_inst_t cmd_set_bonding_mode = {
5038 .f = cmd_set_bonding_mode_parsed,
5039 .help_str = "set bonding mode <mode_value> <port_id>: "
5040 "Set the bonding mode for port_id",
5043 (void *) &cmd_setbonding_mode_set,
5044 (void *) &cmd_setbonding_mode_bonding,
5045 (void *) &cmd_setbonding_mode_mode,
5046 (void *) &cmd_setbonding_mode_value,
5047 (void *) &cmd_setbonding_mode_port,
5052 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5053 struct cmd_set_bonding_lacp_dedicated_queues_result {
5054 cmdline_fixed_string_t set;
5055 cmdline_fixed_string_t bonding;
5056 cmdline_fixed_string_t lacp;
5057 cmdline_fixed_string_t dedicated_queues;
5059 cmdline_fixed_string_t mode;
5062 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5063 __attribute__((unused)) struct cmdline *cl,
5064 __attribute__((unused)) void *data)
5066 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5067 portid_t port_id = res->port_id;
5068 struct rte_port *port;
5070 port = &ports[port_id];
5072 /** Check if the port is not started **/
5073 if (port->port_status != RTE_PORT_STOPPED) {
5074 printf("Please stop port %d first\n", port_id);
5078 if (!strcmp(res->mode, "enable")) {
5079 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5080 printf("Dedicate queues for LACP control packets"
5083 printf("Enabling dedicate queues for LACP control "
5084 "packets on port %d failed\n", port_id);
5085 } else if (!strcmp(res->mode, "disable")) {
5086 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5087 printf("Dedicated queues for LACP control packets "
5090 printf("Disabling dedicated queues for LACP control "
5091 "traffic on port %d failed\n", port_id);
5095 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5096 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5098 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5099 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5100 bonding, "bonding");
5101 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5102 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5104 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5105 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5106 dedicated_queues, "dedicated_queues");
5107 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5108 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5110 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5111 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5112 mode, "enable#disable");
5114 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5115 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5116 .help_str = "set bonding lacp dedicated_queues <port_id> "
5118 "Enable/disable dedicated queues for LACP control traffic for port_id",
5121 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5122 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5123 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5124 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5125 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5126 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5131 /* *** SET BALANCE XMIT POLICY *** */
5132 struct cmd_set_bonding_balance_xmit_policy_result {
5133 cmdline_fixed_string_t set;
5134 cmdline_fixed_string_t bonding;
5135 cmdline_fixed_string_t balance_xmit_policy;
5137 cmdline_fixed_string_t policy;
5140 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5141 __attribute__((unused)) struct cmdline *cl,
5142 __attribute__((unused)) void *data)
5144 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5145 portid_t port_id = res->port_id;
5148 if (!strcmp(res->policy, "l2")) {
5149 policy = BALANCE_XMIT_POLICY_LAYER2;
5150 } else if (!strcmp(res->policy, "l23")) {
5151 policy = BALANCE_XMIT_POLICY_LAYER23;
5152 } else if (!strcmp(res->policy, "l34")) {
5153 policy = BALANCE_XMIT_POLICY_LAYER34;
5155 printf("\t Invalid xmit policy selection");
5159 /* Set the bonding mode for the relevant port. */
5160 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5161 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5166 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5167 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5169 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5170 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5171 bonding, "bonding");
5172 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5173 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5174 balance_xmit_policy, "balance_xmit_policy");
5175 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5176 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5178 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5179 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5180 policy, "l2#l23#l34");
5182 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5183 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5184 .help_str = "set bonding balance_xmit_policy <port_id> "
5186 "Set the bonding balance_xmit_policy for port_id",
5189 (void *)&cmd_setbonding_balance_xmit_policy_set,
5190 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5191 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5192 (void *)&cmd_setbonding_balance_xmit_policy_port,
5193 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5198 /* *** SHOW NIC BONDING CONFIGURATION *** */
5199 struct cmd_show_bonding_config_result {
5200 cmdline_fixed_string_t show;
5201 cmdline_fixed_string_t bonding;
5202 cmdline_fixed_string_t config;
5206 static void cmd_show_bonding_config_parsed(void *parsed_result,
5207 __attribute__((unused)) struct cmdline *cl,
5208 __attribute__((unused)) void *data)
5210 struct cmd_show_bonding_config_result *res = parsed_result;
5211 int bonding_mode, agg_mode;
5212 portid_t slaves[RTE_MAX_ETHPORTS];
5213 int num_slaves, num_active_slaves;
5216 portid_t port_id = res->port_id;
5218 /* Display the bonding mode.*/
5219 bonding_mode = rte_eth_bond_mode_get(port_id);
5220 if (bonding_mode < 0) {
5221 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5224 printf("\tBonding mode: %d\n", bonding_mode);
5226 if (bonding_mode == BONDING_MODE_BALANCE) {
5227 int balance_xmit_policy;
5229 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5230 if (balance_xmit_policy < 0) {
5231 printf("\tFailed to get balance xmit policy for port = %d\n",
5235 printf("\tBalance Xmit Policy: ");
5237 switch (balance_xmit_policy) {
5238 case BALANCE_XMIT_POLICY_LAYER2:
5239 printf("BALANCE_XMIT_POLICY_LAYER2");
5241 case BALANCE_XMIT_POLICY_LAYER23:
5242 printf("BALANCE_XMIT_POLICY_LAYER23");
5244 case BALANCE_XMIT_POLICY_LAYER34:
5245 printf("BALANCE_XMIT_POLICY_LAYER34");
5252 if (bonding_mode == BONDING_MODE_8023AD) {
5253 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5254 printf("\tIEEE802.3AD Aggregator Mode: ");
5257 printf("bandwidth");
5269 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5271 if (num_slaves < 0) {
5272 printf("\tFailed to get slave list for port = %d\n", port_id);
5275 if (num_slaves > 0) {
5276 printf("\tSlaves (%d): [", num_slaves);
5277 for (i = 0; i < num_slaves - 1; i++)
5278 printf("%d ", slaves[i]);
5280 printf("%d]\n", slaves[num_slaves - 1]);
5282 printf("\tSlaves: []\n");
5286 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5289 if (num_active_slaves < 0) {
5290 printf("\tFailed to get active slave list for port = %d\n", port_id);
5293 if (num_active_slaves > 0) {
5294 printf("\tActive Slaves (%d): [", num_active_slaves);
5295 for (i = 0; i < num_active_slaves - 1; i++)
5296 printf("%d ", slaves[i]);
5298 printf("%d]\n", slaves[num_active_slaves - 1]);
5301 printf("\tActive Slaves: []\n");
5305 primary_id = rte_eth_bond_primary_get(port_id);
5306 if (primary_id < 0) {
5307 printf("\tFailed to get primary slave for port = %d\n", port_id);
5310 printf("\tPrimary: [%d]\n", primary_id);
5314 cmdline_parse_token_string_t cmd_showbonding_config_show =
5315 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5317 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5318 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5319 bonding, "bonding");
5320 cmdline_parse_token_string_t cmd_showbonding_config_config =
5321 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5323 cmdline_parse_token_num_t cmd_showbonding_config_port =
5324 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
5327 cmdline_parse_inst_t cmd_show_bonding_config = {
5328 .f = cmd_show_bonding_config_parsed,
5329 .help_str = "show bonding config <port_id>: "
5330 "Show the bonding config for port_id",
5333 (void *)&cmd_showbonding_config_show,
5334 (void *)&cmd_showbonding_config_bonding,
5335 (void *)&cmd_showbonding_config_config,
5336 (void *)&cmd_showbonding_config_port,
5341 /* *** SET BONDING PRIMARY *** */
5342 struct cmd_set_bonding_primary_result {
5343 cmdline_fixed_string_t set;
5344 cmdline_fixed_string_t bonding;
5345 cmdline_fixed_string_t primary;
5350 static void cmd_set_bonding_primary_parsed(void *parsed_result,
5351 __attribute__((unused)) struct cmdline *cl,
5352 __attribute__((unused)) void *data)
5354 struct cmd_set_bonding_primary_result *res = parsed_result;
5355 portid_t master_port_id = res->port_id;
5356 portid_t slave_port_id = res->slave_id;
5358 /* Set the primary slave for a bonded device. */
5359 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
5360 printf("\t Failed to set primary slave for port = %d.\n",
5367 cmdline_parse_token_string_t cmd_setbonding_primary_set =
5368 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5370 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
5371 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5372 bonding, "bonding");
5373 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
5374 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5375 primary, "primary");
5376 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
5377 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5379 cmdline_parse_token_num_t cmd_setbonding_primary_port =
5380 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5383 cmdline_parse_inst_t cmd_set_bonding_primary = {
5384 .f = cmd_set_bonding_primary_parsed,
5385 .help_str = "set bonding primary <slave_id> <port_id>: "
5386 "Set the primary slave for port_id",
5389 (void *)&cmd_setbonding_primary_set,
5390 (void *)&cmd_setbonding_primary_bonding,
5391 (void *)&cmd_setbonding_primary_primary,
5392 (void *)&cmd_setbonding_primary_slave,
5393 (void *)&cmd_setbonding_primary_port,
5398 /* *** ADD SLAVE *** */
5399 struct cmd_add_bonding_slave_result {
5400 cmdline_fixed_string_t add;
5401 cmdline_fixed_string_t bonding;
5402 cmdline_fixed_string_t slave;
5407 static void cmd_add_bonding_slave_parsed(void *parsed_result,
5408 __attribute__((unused)) struct cmdline *cl,
5409 __attribute__((unused)) void *data)
5411 struct cmd_add_bonding_slave_result *res = parsed_result;
5412 portid_t master_port_id = res->port_id;
5413 portid_t slave_port_id = res->slave_id;
5415 /* add the slave for a bonded device. */
5416 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
5417 printf("\t Failed to add slave %d to master port = %d.\n",
5418 slave_port_id, master_port_id);
5422 set_port_slave_flag(slave_port_id);
5425 cmdline_parse_token_string_t cmd_addbonding_slave_add =
5426 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5428 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
5429 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5430 bonding, "bonding");
5431 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
5432 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5434 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
5435 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5437 cmdline_parse_token_num_t cmd_addbonding_slave_port =
5438 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5441 cmdline_parse_inst_t cmd_add_bonding_slave = {
5442 .f = cmd_add_bonding_slave_parsed,
5443 .help_str = "add bonding slave <slave_id> <port_id>: "
5444 "Add a slave device to a bonded device",
5447 (void *)&cmd_addbonding_slave_add,
5448 (void *)&cmd_addbonding_slave_bonding,
5449 (void *)&cmd_addbonding_slave_slave,
5450 (void *)&cmd_addbonding_slave_slaveid,
5451 (void *)&cmd_addbonding_slave_port,
5456 /* *** REMOVE SLAVE *** */
5457 struct cmd_remove_bonding_slave_result {
5458 cmdline_fixed_string_t remove;
5459 cmdline_fixed_string_t bonding;
5460 cmdline_fixed_string_t slave;
5465 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
5466 __attribute__((unused)) struct cmdline *cl,
5467 __attribute__((unused)) void *data)
5469 struct cmd_remove_bonding_slave_result *res = parsed_result;
5470 portid_t master_port_id = res->port_id;
5471 portid_t slave_port_id = res->slave_id;
5473 /* remove the slave from a bonded device. */
5474 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
5475 printf("\t Failed to remove slave %d from master port = %d.\n",
5476 slave_port_id, master_port_id);
5480 clear_port_slave_flag(slave_port_id);
5483 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
5484 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5486 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
5487 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5488 bonding, "bonding");
5489 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
5490 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5492 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
5493 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5495 cmdline_parse_token_num_t cmd_removebonding_slave_port =
5496 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5499 cmdline_parse_inst_t cmd_remove_bonding_slave = {
5500 .f = cmd_remove_bonding_slave_parsed,
5501 .help_str = "remove bonding slave <slave_id> <port_id>: "
5502 "Remove a slave device from a bonded device",
5505 (void *)&cmd_removebonding_slave_remove,
5506 (void *)&cmd_removebonding_slave_bonding,
5507 (void *)&cmd_removebonding_slave_slave,
5508 (void *)&cmd_removebonding_slave_slaveid,
5509 (void *)&cmd_removebonding_slave_port,
5514 /* *** CREATE BONDED DEVICE *** */
5515 struct cmd_create_bonded_device_result {
5516 cmdline_fixed_string_t create;
5517 cmdline_fixed_string_t bonded;
5518 cmdline_fixed_string_t device;
5523 static int bond_dev_num = 0;
5525 static void cmd_create_bonded_device_parsed(void *parsed_result,
5526 __attribute__((unused)) struct cmdline *cl,
5527 __attribute__((unused)) void *data)
5529 struct cmd_create_bonded_device_result *res = parsed_result;
5530 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
5533 if (test_done == 0) {
5534 printf("Please stop forwarding first\n");
5538 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
5541 /* Create a new bonded device. */
5542 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
5544 printf("\t Failed to create bonded device.\n");
5547 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
5550 /* Update number of ports */
5551 nb_ports = rte_eth_dev_count_avail();
5552 reconfig(port_id, res->socket);
5553 rte_eth_promiscuous_enable(port_id);
5558 cmdline_parse_token_string_t cmd_createbonded_device_create =
5559 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5561 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
5562 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5564 cmdline_parse_token_string_t cmd_createbonded_device_device =
5565 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5567 cmdline_parse_token_num_t cmd_createbonded_device_mode =
5568 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5570 cmdline_parse_token_num_t cmd_createbonded_device_socket =
5571 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5574 cmdline_parse_inst_t cmd_create_bonded_device = {
5575 .f = cmd_create_bonded_device_parsed,
5576 .help_str = "create bonded device <mode> <socket>: "
5577 "Create a new bonded device with specific bonding mode and socket",
5580 (void *)&cmd_createbonded_device_create,
5581 (void *)&cmd_createbonded_device_bonded,
5582 (void *)&cmd_createbonded_device_device,
5583 (void *)&cmd_createbonded_device_mode,
5584 (void *)&cmd_createbonded_device_socket,
5589 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
5590 struct cmd_set_bond_mac_addr_result {
5591 cmdline_fixed_string_t set;
5592 cmdline_fixed_string_t bonding;
5593 cmdline_fixed_string_t mac_addr;
5595 struct ether_addr address;
5598 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
5599 __attribute__((unused)) struct cmdline *cl,
5600 __attribute__((unused)) void *data)
5602 struct cmd_set_bond_mac_addr_result *res = parsed_result;
5605 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
5608 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
5610 /* check the return value and print it if is < 0 */
5612 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5615 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
5616 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
5617 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
5618 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
5620 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
5621 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
5623 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
5624 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
5626 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
5627 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
5629 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
5630 .f = cmd_set_bond_mac_addr_parsed,
5632 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
5634 (void *)&cmd_set_bond_mac_addr_set,
5635 (void *)&cmd_set_bond_mac_addr_bonding,
5636 (void *)&cmd_set_bond_mac_addr_mac,
5637 (void *)&cmd_set_bond_mac_addr_portnum,
5638 (void *)&cmd_set_bond_mac_addr_addr,
5644 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
5645 struct cmd_set_bond_mon_period_result {
5646 cmdline_fixed_string_t set;
5647 cmdline_fixed_string_t bonding;
5648 cmdline_fixed_string_t mon_period;
5653 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
5654 __attribute__((unused)) struct cmdline *cl,
5655 __attribute__((unused)) void *data)
5657 struct cmd_set_bond_mon_period_result *res = parsed_result;
5660 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
5662 /* check the return value and print it if is < 0 */
5664 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5667 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
5668 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5670 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
5671 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5672 bonding, "bonding");
5673 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
5674 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5675 mon_period, "mon_period");
5676 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
5677 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5679 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
5680 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5683 cmdline_parse_inst_t cmd_set_bond_mon_period = {
5684 .f = cmd_set_bond_mon_period_parsed,
5686 .help_str = "set bonding mon_period <port_id> <period_ms>",
5688 (void *)&cmd_set_bond_mon_period_set,
5689 (void *)&cmd_set_bond_mon_period_bonding,
5690 (void *)&cmd_set_bond_mon_period_mon_period,
5691 (void *)&cmd_set_bond_mon_period_portnum,
5692 (void *)&cmd_set_bond_mon_period_period_ms,
5699 struct cmd_set_bonding_agg_mode_policy_result {
5700 cmdline_fixed_string_t set;
5701 cmdline_fixed_string_t bonding;
5702 cmdline_fixed_string_t agg_mode;
5704 cmdline_fixed_string_t policy;
5709 cmd_set_bonding_agg_mode(void *parsed_result,
5710 __attribute__((unused)) struct cmdline *cl,
5711 __attribute__((unused)) void *data)
5713 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
5714 uint8_t policy = AGG_BANDWIDTH;
5716 if (!strcmp(res->policy, "bandwidth"))
5717 policy = AGG_BANDWIDTH;
5718 else if (!strcmp(res->policy, "stable"))
5719 policy = AGG_STABLE;
5720 else if (!strcmp(res->policy, "count"))
5723 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
5727 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
5728 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5730 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
5731 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5732 bonding, "bonding");
5734 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
5735 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5736 agg_mode, "agg_mode");
5738 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
5739 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5742 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
5743 TOKEN_STRING_INITIALIZER(
5744 struct cmd_set_bonding_balance_xmit_policy_result,
5745 policy, "stable#bandwidth#count");
5747 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
5748 .f = cmd_set_bonding_agg_mode,
5750 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
5752 (void *)&cmd_set_bonding_agg_mode_set,
5753 (void *)&cmd_set_bonding_agg_mode_bonding,
5754 (void *)&cmd_set_bonding_agg_mode_agg_mode,
5755 (void *)&cmd_set_bonding_agg_mode_portnum,
5756 (void *)&cmd_set_bonding_agg_mode_policy_string,
5762 #endif /* RTE_LIBRTE_PMD_BOND */
5764 /* *** SET FORWARDING MODE *** */
5765 struct cmd_set_fwd_mode_result {
5766 cmdline_fixed_string_t set;
5767 cmdline_fixed_string_t fwd;
5768 cmdline_fixed_string_t mode;
5771 static void cmd_set_fwd_mode_parsed(void *parsed_result,
5772 __attribute__((unused)) struct cmdline *cl,
5773 __attribute__((unused)) void *data)
5775 struct cmd_set_fwd_mode_result *res = parsed_result;
5778 set_pkt_forwarding_mode(res->mode);
5781 cmdline_parse_token_string_t cmd_setfwd_set =
5782 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
5783 cmdline_parse_token_string_t cmd_setfwd_fwd =
5784 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
5785 cmdline_parse_token_string_t cmd_setfwd_mode =
5786 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
5787 "" /* defined at init */);
5789 cmdline_parse_inst_t cmd_set_fwd_mode = {
5790 .f = cmd_set_fwd_mode_parsed,
5792 .help_str = NULL, /* defined at init */
5794 (void *)&cmd_setfwd_set,
5795 (void *)&cmd_setfwd_fwd,
5796 (void *)&cmd_setfwd_mode,
5801 static void cmd_set_fwd_mode_init(void)
5804 static char token[128];
5805 static char help[256];
5806 cmdline_parse_token_string_t *token_struct;
5808 modes = list_pkt_forwarding_modes();
5809 snprintf(help, sizeof(help), "set fwd %s: "
5810 "Set packet forwarding mode", modes);
5811 cmd_set_fwd_mode.help_str = help;
5813 /* string token separator is # */
5814 for (c = token; *modes != '\0'; modes++)
5819 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
5820 token_struct->string_data.str = token;
5823 /* *** SET RETRY FORWARDING MODE *** */
5824 struct cmd_set_fwd_retry_mode_result {
5825 cmdline_fixed_string_t set;
5826 cmdline_fixed_string_t fwd;
5827 cmdline_fixed_string_t mode;
5828 cmdline_fixed_string_t retry;
5831 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
5832 __attribute__((unused)) struct cmdline *cl,
5833 __attribute__((unused)) void *data)
5835 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
5838 set_pkt_forwarding_mode(res->mode);
5841 cmdline_parse_token_string_t cmd_setfwd_retry_set =
5842 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5844 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
5845 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5847 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
5848 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5850 "" /* defined at init */);
5851 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
5852 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5855 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
5856 .f = cmd_set_fwd_retry_mode_parsed,
5858 .help_str = NULL, /* defined at init */
5860 (void *)&cmd_setfwd_retry_set,
5861 (void *)&cmd_setfwd_retry_fwd,
5862 (void *)&cmd_setfwd_retry_mode,
5863 (void *)&cmd_setfwd_retry_retry,
5868 static void cmd_set_fwd_retry_mode_init(void)
5871 static char token[128];
5872 static char help[256];
5873 cmdline_parse_token_string_t *token_struct;
5875 modes = list_pkt_forwarding_retry_modes();
5876 snprintf(help, sizeof(help), "set fwd %s retry: "
5877 "Set packet forwarding mode with retry", modes);
5878 cmd_set_fwd_retry_mode.help_str = help;
5880 /* string token separator is # */
5881 for (c = token; *modes != '\0'; modes++)
5886 token_struct = (cmdline_parse_token_string_t *)
5887 cmd_set_fwd_retry_mode.tokens[2];
5888 token_struct->string_data.str = token;
5891 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
5892 struct cmd_set_burst_tx_retry_result {
5893 cmdline_fixed_string_t set;
5894 cmdline_fixed_string_t burst;
5895 cmdline_fixed_string_t tx;
5896 cmdline_fixed_string_t delay;
5898 cmdline_fixed_string_t retry;
5902 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
5903 __attribute__((unused)) struct cmdline *cl,
5904 __attribute__((unused)) void *data)
5906 struct cmd_set_burst_tx_retry_result *res = parsed_result;
5908 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
5909 && !strcmp(res->tx, "tx")) {
5910 if (!strcmp(res->delay, "delay"))
5911 burst_tx_delay_time = res->time;
5912 if (!strcmp(res->retry, "retry"))
5913 burst_tx_retry_num = res->retry_num;
5918 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
5919 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
5920 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
5921 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
5923 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
5924 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
5925 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
5926 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
5927 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
5928 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
5929 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
5930 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
5931 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
5932 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
5934 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
5935 .f = cmd_set_burst_tx_retry_parsed,
5936 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
5938 (void *)&cmd_set_burst_tx_retry_set,
5939 (void *)&cmd_set_burst_tx_retry_burst,
5940 (void *)&cmd_set_burst_tx_retry_tx,
5941 (void *)&cmd_set_burst_tx_retry_delay,
5942 (void *)&cmd_set_burst_tx_retry_time,
5943 (void *)&cmd_set_burst_tx_retry_retry,
5944 (void *)&cmd_set_burst_tx_retry_retry_num,
5949 /* *** SET PROMISC MODE *** */
5950 struct cmd_set_promisc_mode_result {
5951 cmdline_fixed_string_t set;
5952 cmdline_fixed_string_t promisc;
5953 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5954 uint16_t port_num; /* valid if "allports" argument == 0 */
5955 cmdline_fixed_string_t mode;
5958 static void cmd_set_promisc_mode_parsed(void *parsed_result,
5959 __attribute__((unused)) struct cmdline *cl,
5962 struct cmd_set_promisc_mode_result *res = parsed_result;
5966 if (!strcmp(res->mode, "on"))
5973 RTE_ETH_FOREACH_DEV(i) {
5975 rte_eth_promiscuous_enable(i);
5977 rte_eth_promiscuous_disable(i);
5982 rte_eth_promiscuous_enable(res->port_num);
5984 rte_eth_promiscuous_disable(res->port_num);
5988 cmdline_parse_token_string_t cmd_setpromisc_set =
5989 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
5990 cmdline_parse_token_string_t cmd_setpromisc_promisc =
5991 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
5993 cmdline_parse_token_string_t cmd_setpromisc_portall =
5994 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
5996 cmdline_parse_token_num_t cmd_setpromisc_portnum =
5997 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
5999 cmdline_parse_token_string_t cmd_setpromisc_mode =
6000 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6003 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6004 .f = cmd_set_promisc_mode_parsed,
6006 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6008 (void *)&cmd_setpromisc_set,
6009 (void *)&cmd_setpromisc_promisc,
6010 (void *)&cmd_setpromisc_portall,
6011 (void *)&cmd_setpromisc_mode,
6016 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6017 .f = cmd_set_promisc_mode_parsed,
6019 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6021 (void *)&cmd_setpromisc_set,
6022 (void *)&cmd_setpromisc_promisc,
6023 (void *)&cmd_setpromisc_portnum,
6024 (void *)&cmd_setpromisc_mode,
6029 /* *** SET ALLMULTI MODE *** */
6030 struct cmd_set_allmulti_mode_result {
6031 cmdline_fixed_string_t set;
6032 cmdline_fixed_string_t allmulti;
6033 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6034 uint16_t port_num; /* valid if "allports" argument == 0 */
6035 cmdline_fixed_string_t mode;
6038 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6039 __attribute__((unused)) struct cmdline *cl,
6042 struct cmd_set_allmulti_mode_result *res = parsed_result;
6046 if (!strcmp(res->mode, "on"))
6053 RTE_ETH_FOREACH_DEV(i) {
6055 rte_eth_allmulticast_enable(i);
6057 rte_eth_allmulticast_disable(i);
6062 rte_eth_allmulticast_enable(res->port_num);
6064 rte_eth_allmulticast_disable(res->port_num);
6068 cmdline_parse_token_string_t cmd_setallmulti_set =
6069 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6070 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6071 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6073 cmdline_parse_token_string_t cmd_setallmulti_portall =
6074 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6076 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6077 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6079 cmdline_parse_token_string_t cmd_setallmulti_mode =
6080 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6083 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6084 .f = cmd_set_allmulti_mode_parsed,
6086 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6088 (void *)&cmd_setallmulti_set,
6089 (void *)&cmd_setallmulti_allmulti,
6090 (void *)&cmd_setallmulti_portall,
6091 (void *)&cmd_setallmulti_mode,
6096 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6097 .f = cmd_set_allmulti_mode_parsed,
6099 .help_str = "set allmulti <port_id> on|off: "
6100 "Set allmulti mode on port_id",
6102 (void *)&cmd_setallmulti_set,
6103 (void *)&cmd_setallmulti_allmulti,
6104 (void *)&cmd_setallmulti_portnum,
6105 (void *)&cmd_setallmulti_mode,
6110 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6111 struct cmd_link_flow_ctrl_set_result {
6112 cmdline_fixed_string_t set;
6113 cmdline_fixed_string_t flow_ctrl;
6114 cmdline_fixed_string_t rx;
6115 cmdline_fixed_string_t rx_lfc_mode;
6116 cmdline_fixed_string_t tx;
6117 cmdline_fixed_string_t tx_lfc_mode;
6118 cmdline_fixed_string_t mac_ctrl_frame_fwd;
6119 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6120 cmdline_fixed_string_t autoneg_str;
6121 cmdline_fixed_string_t autoneg;
6122 cmdline_fixed_string_t hw_str;
6123 uint32_t high_water;
6124 cmdline_fixed_string_t lw_str;
6126 cmdline_fixed_string_t pt_str;
6127 uint16_t pause_time;
6128 cmdline_fixed_string_t xon_str;
6133 cmdline_parse_token_string_t cmd_lfc_set_set =
6134 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6136 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6137 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6138 flow_ctrl, "flow_ctrl");
6139 cmdline_parse_token_string_t cmd_lfc_set_rx =
6140 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6142 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6143 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6144 rx_lfc_mode, "on#off");
6145 cmdline_parse_token_string_t cmd_lfc_set_tx =
6146 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6148 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6149 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6150 tx_lfc_mode, "on#off");
6151 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6152 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6153 hw_str, "high_water");
6154 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6155 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6156 high_water, UINT32);
6157 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6158 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6159 lw_str, "low_water");
6160 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6161 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6163 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6164 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6165 pt_str, "pause_time");
6166 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6167 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6168 pause_time, UINT16);
6169 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6170 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6171 xon_str, "send_xon");
6172 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6173 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6175 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6176 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6177 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6178 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6179 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6180 mac_ctrl_frame_fwd_mode, "on#off");
6181 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6182 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6183 autoneg_str, "autoneg");
6184 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6185 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6187 cmdline_parse_token_num_t cmd_lfc_set_portid =
6188 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6191 /* forward declaration */
6193 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6196 cmdline_parse_inst_t cmd_link_flow_control_set = {
6197 .f = cmd_link_flow_ctrl_set_parsed,
6199 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6200 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6201 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6203 (void *)&cmd_lfc_set_set,
6204 (void *)&cmd_lfc_set_flow_ctrl,
6205 (void *)&cmd_lfc_set_rx,
6206 (void *)&cmd_lfc_set_rx_mode,
6207 (void *)&cmd_lfc_set_tx,
6208 (void *)&cmd_lfc_set_tx_mode,
6209 (void *)&cmd_lfc_set_high_water,
6210 (void *)&cmd_lfc_set_low_water,
6211 (void *)&cmd_lfc_set_pause_time,
6212 (void *)&cmd_lfc_set_send_xon,
6213 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6214 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6215 (void *)&cmd_lfc_set_autoneg_str,
6216 (void *)&cmd_lfc_set_autoneg,
6217 (void *)&cmd_lfc_set_portid,
6222 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6223 .f = cmd_link_flow_ctrl_set_parsed,
6224 .data = (void *)&cmd_link_flow_control_set_rx,
6225 .help_str = "set flow_ctrl rx on|off <port_id>: "
6226 "Change rx flow control parameter",
6228 (void *)&cmd_lfc_set_set,
6229 (void *)&cmd_lfc_set_flow_ctrl,
6230 (void *)&cmd_lfc_set_rx,
6231 (void *)&cmd_lfc_set_rx_mode,
6232 (void *)&cmd_lfc_set_portid,
6237 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6238 .f = cmd_link_flow_ctrl_set_parsed,
6239 .data = (void *)&cmd_link_flow_control_set_tx,
6240 .help_str = "set flow_ctrl tx on|off <port_id>: "
6241 "Change tx flow control parameter",
6243 (void *)&cmd_lfc_set_set,
6244 (void *)&cmd_lfc_set_flow_ctrl,
6245 (void *)&cmd_lfc_set_tx,
6246 (void *)&cmd_lfc_set_tx_mode,
6247 (void *)&cmd_lfc_set_portid,
6252 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6253 .f = cmd_link_flow_ctrl_set_parsed,
6254 .data = (void *)&cmd_link_flow_control_set_hw,
6255 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6256 "Change high water flow control parameter",
6258 (void *)&cmd_lfc_set_set,
6259 (void *)&cmd_lfc_set_flow_ctrl,
6260 (void *)&cmd_lfc_set_high_water_str,
6261 (void *)&cmd_lfc_set_high_water,
6262 (void *)&cmd_lfc_set_portid,
6267 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6268 .f = cmd_link_flow_ctrl_set_parsed,
6269 .data = (void *)&cmd_link_flow_control_set_lw,
6270 .help_str = "set flow_ctrl low_water <value> <port_id>: "
6271 "Change low water flow control parameter",
6273 (void *)&cmd_lfc_set_set,
6274 (void *)&cmd_lfc_set_flow_ctrl,
6275 (void *)&cmd_lfc_set_low_water_str,
6276 (void *)&cmd_lfc_set_low_water,
6277 (void *)&cmd_lfc_set_portid,
6282 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6283 .f = cmd_link_flow_ctrl_set_parsed,
6284 .data = (void *)&cmd_link_flow_control_set_pt,
6285 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6286 "Change pause time flow control parameter",
6288 (void *)&cmd_lfc_set_set,
6289 (void *)&cmd_lfc_set_flow_ctrl,
6290 (void *)&cmd_lfc_set_pause_time_str,
6291 (void *)&cmd_lfc_set_pause_time,
6292 (void *)&cmd_lfc_set_portid,
6297 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6298 .f = cmd_link_flow_ctrl_set_parsed,
6299 .data = (void *)&cmd_link_flow_control_set_xon,
6300 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6301 "Change send_xon flow control parameter",
6303 (void *)&cmd_lfc_set_set,
6304 (void *)&cmd_lfc_set_flow_ctrl,
6305 (void *)&cmd_lfc_set_send_xon_str,
6306 (void *)&cmd_lfc_set_send_xon,
6307 (void *)&cmd_lfc_set_portid,
6312 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6313 .f = cmd_link_flow_ctrl_set_parsed,
6314 .data = (void *)&cmd_link_flow_control_set_macfwd,
6315 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6316 "Change mac ctrl fwd flow control parameter",
6318 (void *)&cmd_lfc_set_set,
6319 (void *)&cmd_lfc_set_flow_ctrl,
6320 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6321 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6322 (void *)&cmd_lfc_set_portid,
6327 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6328 .f = cmd_link_flow_ctrl_set_parsed,
6329 .data = (void *)&cmd_link_flow_control_set_autoneg,
6330 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6331 "Change autoneg flow control parameter",
6333 (void *)&cmd_lfc_set_set,
6334 (void *)&cmd_lfc_set_flow_ctrl,
6335 (void *)&cmd_lfc_set_autoneg_str,
6336 (void *)&cmd_lfc_set_autoneg,
6337 (void *)&cmd_lfc_set_portid,
6343 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6344 __attribute__((unused)) struct cmdline *cl,
6347 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6348 cmdline_parse_inst_t *cmd = data;
6349 struct rte_eth_fc_conf fc_conf;
6355 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6356 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6357 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6358 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6360 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6361 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
6364 /* Partial command line, retrieve current configuration */
6366 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6368 printf("cannot get current flow ctrl parameters, return"
6369 "code = %d\n", ret);
6373 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
6374 (fc_conf.mode == RTE_FC_FULL))
6376 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
6377 (fc_conf.mode == RTE_FC_FULL))
6381 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6382 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6384 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6385 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6387 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6389 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6390 fc_conf.high_water = res->high_water;
6392 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6393 fc_conf.low_water = res->low_water;
6395 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6396 fc_conf.pause_time = res->pause_time;
6398 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6399 fc_conf.send_xon = res->send_xon;
6401 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6402 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6403 fc_conf.mac_ctrl_frame_fwd = 1;
6405 fc_conf.mac_ctrl_frame_fwd = 0;
6408 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6409 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6411 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6413 printf("bad flow contrl parameter, return code = %d \n", ret);
6416 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6417 struct cmd_priority_flow_ctrl_set_result {
6418 cmdline_fixed_string_t set;
6419 cmdline_fixed_string_t pfc_ctrl;
6420 cmdline_fixed_string_t rx;
6421 cmdline_fixed_string_t rx_pfc_mode;
6422 cmdline_fixed_string_t tx;
6423 cmdline_fixed_string_t tx_pfc_mode;
6424 uint32_t high_water;
6426 uint16_t pause_time;
6432 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6433 __attribute__((unused)) struct cmdline *cl,
6434 __attribute__((unused)) void *data)
6436 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
6437 struct rte_eth_pfc_conf pfc_conf;
6438 int rx_fc_enable, tx_fc_enable;
6442 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6443 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6444 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6445 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6447 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
6448 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
6451 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
6452 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
6453 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
6454 pfc_conf.fc.high_water = res->high_water;
6455 pfc_conf.fc.low_water = res->low_water;
6456 pfc_conf.fc.pause_time = res->pause_time;
6457 pfc_conf.priority = res->priority;
6459 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
6461 printf("bad priority flow contrl parameter, return code = %d \n", ret);
6464 cmdline_parse_token_string_t cmd_pfc_set_set =
6465 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6467 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
6468 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6469 pfc_ctrl, "pfc_ctrl");
6470 cmdline_parse_token_string_t cmd_pfc_set_rx =
6471 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6473 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
6474 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6475 rx_pfc_mode, "on#off");
6476 cmdline_parse_token_string_t cmd_pfc_set_tx =
6477 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6479 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
6480 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6481 tx_pfc_mode, "on#off");
6482 cmdline_parse_token_num_t cmd_pfc_set_high_water =
6483 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6484 high_water, UINT32);
6485 cmdline_parse_token_num_t cmd_pfc_set_low_water =
6486 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6488 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
6489 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6490 pause_time, UINT16);
6491 cmdline_parse_token_num_t cmd_pfc_set_priority =
6492 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6494 cmdline_parse_token_num_t cmd_pfc_set_portid =
6495 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6498 cmdline_parse_inst_t cmd_priority_flow_control_set = {
6499 .f = cmd_priority_flow_ctrl_set_parsed,
6501 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
6502 "<pause_time> <priority> <port_id>: "
6503 "Configure the Ethernet priority flow control",
6505 (void *)&cmd_pfc_set_set,
6506 (void *)&cmd_pfc_set_flow_ctrl,
6507 (void *)&cmd_pfc_set_rx,
6508 (void *)&cmd_pfc_set_rx_mode,
6509 (void *)&cmd_pfc_set_tx,
6510 (void *)&cmd_pfc_set_tx_mode,
6511 (void *)&cmd_pfc_set_high_water,
6512 (void *)&cmd_pfc_set_low_water,
6513 (void *)&cmd_pfc_set_pause_time,
6514 (void *)&cmd_pfc_set_priority,
6515 (void *)&cmd_pfc_set_portid,
6520 /* *** RESET CONFIGURATION *** */
6521 struct cmd_reset_result {
6522 cmdline_fixed_string_t reset;
6523 cmdline_fixed_string_t def;
6526 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
6528 __attribute__((unused)) void *data)
6530 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
6531 set_def_fwd_config();
6534 cmdline_parse_token_string_t cmd_reset_set =
6535 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
6536 cmdline_parse_token_string_t cmd_reset_def =
6537 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
6540 cmdline_parse_inst_t cmd_reset = {
6541 .f = cmd_reset_parsed,
6543 .help_str = "set default: Reset default forwarding configuration",
6545 (void *)&cmd_reset_set,
6546 (void *)&cmd_reset_def,
6551 /* *** START FORWARDING *** */
6552 struct cmd_start_result {
6553 cmdline_fixed_string_t start;
6556 cmdline_parse_token_string_t cmd_start_start =
6557 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
6559 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
6560 __attribute__((unused)) struct cmdline *cl,
6561 __attribute__((unused)) void *data)
6563 start_packet_forwarding(0);
6566 cmdline_parse_inst_t cmd_start = {
6567 .f = cmd_start_parsed,
6569 .help_str = "start: Start packet forwarding",
6571 (void *)&cmd_start_start,
6576 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
6577 struct cmd_start_tx_first_result {
6578 cmdline_fixed_string_t start;
6579 cmdline_fixed_string_t tx_first;
6583 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
6584 __attribute__((unused)) struct cmdline *cl,
6585 __attribute__((unused)) void *data)
6587 start_packet_forwarding(1);
6590 cmdline_parse_token_string_t cmd_start_tx_first_start =
6591 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
6593 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
6594 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
6595 tx_first, "tx_first");
6597 cmdline_parse_inst_t cmd_start_tx_first = {
6598 .f = cmd_start_tx_first_parsed,
6600 .help_str = "start tx_first: Start packet forwarding, "
6601 "after sending 1 burst of packets",
6603 (void *)&cmd_start_tx_first_start,
6604 (void *)&cmd_start_tx_first_tx_first,
6609 /* *** START FORWARDING WITH N TX BURST FIRST *** */
6610 struct cmd_start_tx_first_n_result {
6611 cmdline_fixed_string_t start;
6612 cmdline_fixed_string_t tx_first;
6617 cmd_start_tx_first_n_parsed(void *parsed_result,
6618 __attribute__((unused)) struct cmdline *cl,
6619 __attribute__((unused)) void *data)
6621 struct cmd_start_tx_first_n_result *res = parsed_result;
6623 start_packet_forwarding(res->tx_num);
6626 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
6627 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6629 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
6630 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6631 tx_first, "tx_first");
6632 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
6633 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
6636 cmdline_parse_inst_t cmd_start_tx_first_n = {
6637 .f = cmd_start_tx_first_n_parsed,
6639 .help_str = "start tx_first <num>: "
6640 "packet forwarding, after sending <num> bursts of packets",
6642 (void *)&cmd_start_tx_first_n_start,
6643 (void *)&cmd_start_tx_first_n_tx_first,
6644 (void *)&cmd_start_tx_first_n_tx_num,
6649 /* *** SET LINK UP *** */
6650 struct cmd_set_link_up_result {
6651 cmdline_fixed_string_t set;
6652 cmdline_fixed_string_t link_up;
6653 cmdline_fixed_string_t port;
6657 cmdline_parse_token_string_t cmd_set_link_up_set =
6658 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
6659 cmdline_parse_token_string_t cmd_set_link_up_link_up =
6660 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
6662 cmdline_parse_token_string_t cmd_set_link_up_port =
6663 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
6664 cmdline_parse_token_num_t cmd_set_link_up_port_id =
6665 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
6667 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
6668 __attribute__((unused)) struct cmdline *cl,
6669 __attribute__((unused)) void *data)
6671 struct cmd_set_link_up_result *res = parsed_result;
6672 dev_set_link_up(res->port_id);
6675 cmdline_parse_inst_t cmd_set_link_up = {
6676 .f = cmd_set_link_up_parsed,
6678 .help_str = "set link-up port <port id>",
6680 (void *)&cmd_set_link_up_set,
6681 (void *)&cmd_set_link_up_link_up,
6682 (void *)&cmd_set_link_up_port,
6683 (void *)&cmd_set_link_up_port_id,
6688 /* *** SET LINK DOWN *** */
6689 struct cmd_set_link_down_result {
6690 cmdline_fixed_string_t set;
6691 cmdline_fixed_string_t link_down;
6692 cmdline_fixed_string_t port;
6696 cmdline_parse_token_string_t cmd_set_link_down_set =
6697 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
6698 cmdline_parse_token_string_t cmd_set_link_down_link_down =
6699 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
6701 cmdline_parse_token_string_t cmd_set_link_down_port =
6702 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
6703 cmdline_parse_token_num_t cmd_set_link_down_port_id =
6704 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
6706 static void cmd_set_link_down_parsed(
6707 __attribute__((unused)) void *parsed_result,
6708 __attribute__((unused)) struct cmdline *cl,
6709 __attribute__((unused)) void *data)
6711 struct cmd_set_link_down_result *res = parsed_result;
6712 dev_set_link_down(res->port_id);
6715 cmdline_parse_inst_t cmd_set_link_down = {
6716 .f = cmd_set_link_down_parsed,
6718 .help_str = "set link-down port <port id>",
6720 (void *)&cmd_set_link_down_set,
6721 (void *)&cmd_set_link_down_link_down,
6722 (void *)&cmd_set_link_down_port,
6723 (void *)&cmd_set_link_down_port_id,
6728 /* *** SHOW CFG *** */
6729 struct cmd_showcfg_result {
6730 cmdline_fixed_string_t show;
6731 cmdline_fixed_string_t cfg;
6732 cmdline_fixed_string_t what;
6735 static void cmd_showcfg_parsed(void *parsed_result,
6736 __attribute__((unused)) struct cmdline *cl,
6737 __attribute__((unused)) void *data)
6739 struct cmd_showcfg_result *res = parsed_result;
6740 if (!strcmp(res->what, "rxtx"))
6741 rxtx_config_display();
6742 else if (!strcmp(res->what, "cores"))
6743 fwd_lcores_config_display();
6744 else if (!strcmp(res->what, "fwd"))
6745 pkt_fwd_config_display(&cur_fwd_config);
6746 else if (!strcmp(res->what, "txpkts"))
6747 show_tx_pkt_segments();
6750 cmdline_parse_token_string_t cmd_showcfg_show =
6751 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
6752 cmdline_parse_token_string_t cmd_showcfg_port =
6753 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
6754 cmdline_parse_token_string_t cmd_showcfg_what =
6755 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
6756 "rxtx#cores#fwd#txpkts");
6758 cmdline_parse_inst_t cmd_showcfg = {
6759 .f = cmd_showcfg_parsed,
6761 .help_str = "show config rxtx|cores|fwd|txpkts",
6763 (void *)&cmd_showcfg_show,
6764 (void *)&cmd_showcfg_port,
6765 (void *)&cmd_showcfg_what,
6770 /* *** SHOW ALL PORT INFO *** */
6771 struct cmd_showportall_result {
6772 cmdline_fixed_string_t show;
6773 cmdline_fixed_string_t port;
6774 cmdline_fixed_string_t what;
6775 cmdline_fixed_string_t all;
6778 static void cmd_showportall_parsed(void *parsed_result,
6779 __attribute__((unused)) struct cmdline *cl,
6780 __attribute__((unused)) void *data)
6784 struct cmd_showportall_result *res = parsed_result;
6785 if (!strcmp(res->show, "clear")) {
6786 if (!strcmp(res->what, "stats"))
6787 RTE_ETH_FOREACH_DEV(i)
6789 else if (!strcmp(res->what, "xstats"))
6790 RTE_ETH_FOREACH_DEV(i)
6791 nic_xstats_clear(i);
6792 } else if (!strcmp(res->what, "info"))
6793 RTE_ETH_FOREACH_DEV(i)
6794 port_infos_display(i);
6795 else if (!strcmp(res->what, "stats"))
6796 RTE_ETH_FOREACH_DEV(i)
6797 nic_stats_display(i);
6798 else if (!strcmp(res->what, "xstats"))
6799 RTE_ETH_FOREACH_DEV(i)
6800 nic_xstats_display(i);
6801 else if (!strcmp(res->what, "fdir"))
6802 RTE_ETH_FOREACH_DEV(i)
6804 else if (!strcmp(res->what, "stat_qmap"))
6805 RTE_ETH_FOREACH_DEV(i)
6806 nic_stats_mapping_display(i);
6807 else if (!strcmp(res->what, "dcb_tc"))
6808 RTE_ETH_FOREACH_DEV(i)
6809 port_dcb_info_display(i);
6810 else if (!strcmp(res->what, "cap"))
6811 RTE_ETH_FOREACH_DEV(i)
6812 port_offload_cap_display(i);
6815 cmdline_parse_token_string_t cmd_showportall_show =
6816 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
6818 cmdline_parse_token_string_t cmd_showportall_port =
6819 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
6820 cmdline_parse_token_string_t cmd_showportall_what =
6821 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
6822 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
6823 cmdline_parse_token_string_t cmd_showportall_all =
6824 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
6825 cmdline_parse_inst_t cmd_showportall = {
6826 .f = cmd_showportall_parsed,
6828 .help_str = "show|clear port "
6829 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
6831 (void *)&cmd_showportall_show,
6832 (void *)&cmd_showportall_port,
6833 (void *)&cmd_showportall_what,
6834 (void *)&cmd_showportall_all,
6839 /* *** SHOW PORT INFO *** */
6840 struct cmd_showport_result {
6841 cmdline_fixed_string_t show;
6842 cmdline_fixed_string_t port;
6843 cmdline_fixed_string_t what;
6847 static void cmd_showport_parsed(void *parsed_result,
6848 __attribute__((unused)) struct cmdline *cl,
6849 __attribute__((unused)) void *data)
6851 struct cmd_showport_result *res = parsed_result;
6852 if (!strcmp(res->show, "clear")) {
6853 if (!strcmp(res->what, "stats"))
6854 nic_stats_clear(res->portnum);
6855 else if (!strcmp(res->what, "xstats"))
6856 nic_xstats_clear(res->portnum);
6857 } else if (!strcmp(res->what, "info"))
6858 port_infos_display(res->portnum);
6859 else if (!strcmp(res->what, "stats"))
6860 nic_stats_display(res->portnum);
6861 else if (!strcmp(res->what, "xstats"))
6862 nic_xstats_display(res->portnum);
6863 else if (!strcmp(res->what, "fdir"))
6864 fdir_get_infos(res->portnum);
6865 else if (!strcmp(res->what, "stat_qmap"))
6866 nic_stats_mapping_display(res->portnum);
6867 else if (!strcmp(res->what, "dcb_tc"))
6868 port_dcb_info_display(res->portnum);
6869 else if (!strcmp(res->what, "cap"))
6870 port_offload_cap_display(res->portnum);
6873 cmdline_parse_token_string_t cmd_showport_show =
6874 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
6876 cmdline_parse_token_string_t cmd_showport_port =
6877 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
6878 cmdline_parse_token_string_t cmd_showport_what =
6879 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
6880 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
6881 cmdline_parse_token_num_t cmd_showport_portnum =
6882 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
6884 cmdline_parse_inst_t cmd_showport = {
6885 .f = cmd_showport_parsed,
6887 .help_str = "show|clear port "
6888 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
6891 (void *)&cmd_showport_show,
6892 (void *)&cmd_showport_port,
6893 (void *)&cmd_showport_what,
6894 (void *)&cmd_showport_portnum,
6899 /* *** SHOW QUEUE INFO *** */
6900 struct cmd_showqueue_result {
6901 cmdline_fixed_string_t show;
6902 cmdline_fixed_string_t type;
6903 cmdline_fixed_string_t what;
6909 cmd_showqueue_parsed(void *parsed_result,
6910 __attribute__((unused)) struct cmdline *cl,
6911 __attribute__((unused)) void *data)
6913 struct cmd_showqueue_result *res = parsed_result;
6915 if (!strcmp(res->type, "rxq"))
6916 rx_queue_infos_display(res->portnum, res->queuenum);
6917 else if (!strcmp(res->type, "txq"))
6918 tx_queue_infos_display(res->portnum, res->queuenum);
6921 cmdline_parse_token_string_t cmd_showqueue_show =
6922 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
6923 cmdline_parse_token_string_t cmd_showqueue_type =
6924 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
6925 cmdline_parse_token_string_t cmd_showqueue_what =
6926 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
6927 cmdline_parse_token_num_t cmd_showqueue_portnum =
6928 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
6929 cmdline_parse_token_num_t cmd_showqueue_queuenum =
6930 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
6932 cmdline_parse_inst_t cmd_showqueue = {
6933 .f = cmd_showqueue_parsed,
6935 .help_str = "show rxq|txq info <port_id> <queue_id>",
6937 (void *)&cmd_showqueue_show,
6938 (void *)&cmd_showqueue_type,
6939 (void *)&cmd_showqueue_what,
6940 (void *)&cmd_showqueue_portnum,
6941 (void *)&cmd_showqueue_queuenum,
6946 /* *** READ PORT REGISTER *** */
6947 struct cmd_read_reg_result {
6948 cmdline_fixed_string_t read;
6949 cmdline_fixed_string_t reg;
6955 cmd_read_reg_parsed(void *parsed_result,
6956 __attribute__((unused)) struct cmdline *cl,
6957 __attribute__((unused)) void *data)
6959 struct cmd_read_reg_result *res = parsed_result;
6960 port_reg_display(res->port_id, res->reg_off);
6963 cmdline_parse_token_string_t cmd_read_reg_read =
6964 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
6965 cmdline_parse_token_string_t cmd_read_reg_reg =
6966 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
6967 cmdline_parse_token_num_t cmd_read_reg_port_id =
6968 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
6969 cmdline_parse_token_num_t cmd_read_reg_reg_off =
6970 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
6972 cmdline_parse_inst_t cmd_read_reg = {
6973 .f = cmd_read_reg_parsed,
6975 .help_str = "read reg <port_id> <reg_off>",
6977 (void *)&cmd_read_reg_read,
6978 (void *)&cmd_read_reg_reg,
6979 (void *)&cmd_read_reg_port_id,
6980 (void *)&cmd_read_reg_reg_off,
6985 /* *** READ PORT REGISTER BIT FIELD *** */
6986 struct cmd_read_reg_bit_field_result {
6987 cmdline_fixed_string_t read;
6988 cmdline_fixed_string_t regfield;
6996 cmd_read_reg_bit_field_parsed(void *parsed_result,
6997 __attribute__((unused)) struct cmdline *cl,
6998 __attribute__((unused)) void *data)
7000 struct cmd_read_reg_bit_field_result *res = parsed_result;
7001 port_reg_bit_field_display(res->port_id, res->reg_off,
7002 res->bit1_pos, res->bit2_pos);
7005 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7006 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7008 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7009 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7010 regfield, "regfield");
7011 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7012 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7014 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7015 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7017 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7018 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7020 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7021 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7024 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7025 .f = cmd_read_reg_bit_field_parsed,
7027 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7028 "Read register bit field between bit_x and bit_y included",
7030 (void *)&cmd_read_reg_bit_field_read,
7031 (void *)&cmd_read_reg_bit_field_regfield,
7032 (void *)&cmd_read_reg_bit_field_port_id,
7033 (void *)&cmd_read_reg_bit_field_reg_off,
7034 (void *)&cmd_read_reg_bit_field_bit1_pos,
7035 (void *)&cmd_read_reg_bit_field_bit2_pos,
7040 /* *** READ PORT REGISTER BIT *** */
7041 struct cmd_read_reg_bit_result {
7042 cmdline_fixed_string_t read;
7043 cmdline_fixed_string_t regbit;
7050 cmd_read_reg_bit_parsed(void *parsed_result,
7051 __attribute__((unused)) struct cmdline *cl,
7052 __attribute__((unused)) void *data)
7054 struct cmd_read_reg_bit_result *res = parsed_result;
7055 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7058 cmdline_parse_token_string_t cmd_read_reg_bit_read =
7059 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
7060 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
7061 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
7063 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
7064 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
7065 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
7066 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
7067 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
7068 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
7070 cmdline_parse_inst_t cmd_read_reg_bit = {
7071 .f = cmd_read_reg_bit_parsed,
7073 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7075 (void *)&cmd_read_reg_bit_read,
7076 (void *)&cmd_read_reg_bit_regbit,
7077 (void *)&cmd_read_reg_bit_port_id,
7078 (void *)&cmd_read_reg_bit_reg_off,
7079 (void *)&cmd_read_reg_bit_bit_pos,
7084 /* *** WRITE PORT REGISTER *** */
7085 struct cmd_write_reg_result {
7086 cmdline_fixed_string_t write;
7087 cmdline_fixed_string_t reg;
7094 cmd_write_reg_parsed(void *parsed_result,
7095 __attribute__((unused)) struct cmdline *cl,
7096 __attribute__((unused)) void *data)
7098 struct cmd_write_reg_result *res = parsed_result;
7099 port_reg_set(res->port_id, res->reg_off, res->value);
7102 cmdline_parse_token_string_t cmd_write_reg_write =
7103 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
7104 cmdline_parse_token_string_t cmd_write_reg_reg =
7105 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
7106 cmdline_parse_token_num_t cmd_write_reg_port_id =
7107 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
7108 cmdline_parse_token_num_t cmd_write_reg_reg_off =
7109 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
7110 cmdline_parse_token_num_t cmd_write_reg_value =
7111 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
7113 cmdline_parse_inst_t cmd_write_reg = {
7114 .f = cmd_write_reg_parsed,
7116 .help_str = "write reg <port_id> <reg_off> <reg_value>",
7118 (void *)&cmd_write_reg_write,
7119 (void *)&cmd_write_reg_reg,
7120 (void *)&cmd_write_reg_port_id,
7121 (void *)&cmd_write_reg_reg_off,
7122 (void *)&cmd_write_reg_value,
7127 /* *** WRITE PORT REGISTER BIT FIELD *** */
7128 struct cmd_write_reg_bit_field_result {
7129 cmdline_fixed_string_t write;
7130 cmdline_fixed_string_t regfield;
7139 cmd_write_reg_bit_field_parsed(void *parsed_result,
7140 __attribute__((unused)) struct cmdline *cl,
7141 __attribute__((unused)) void *data)
7143 struct cmd_write_reg_bit_field_result *res = parsed_result;
7144 port_reg_bit_field_set(res->port_id, res->reg_off,
7145 res->bit1_pos, res->bit2_pos, res->value);
7148 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
7149 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
7151 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
7152 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
7153 regfield, "regfield");
7154 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
7155 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
7157 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
7158 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
7160 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
7161 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
7163 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
7164 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
7166 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
7167 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
7170 cmdline_parse_inst_t cmd_write_reg_bit_field = {
7171 .f = cmd_write_reg_bit_field_parsed,
7173 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
7175 "Set register bit field between bit_x and bit_y included",
7177 (void *)&cmd_write_reg_bit_field_write,
7178 (void *)&cmd_write_reg_bit_field_regfield,
7179 (void *)&cmd_write_reg_bit_field_port_id,
7180 (void *)&cmd_write_reg_bit_field_reg_off,
7181 (void *)&cmd_write_reg_bit_field_bit1_pos,
7182 (void *)&cmd_write_reg_bit_field_bit2_pos,
7183 (void *)&cmd_write_reg_bit_field_value,
7188 /* *** WRITE PORT REGISTER BIT *** */
7189 struct cmd_write_reg_bit_result {
7190 cmdline_fixed_string_t write;
7191 cmdline_fixed_string_t regbit;
7199 cmd_write_reg_bit_parsed(void *parsed_result,
7200 __attribute__((unused)) struct cmdline *cl,
7201 __attribute__((unused)) void *data)
7203 struct cmd_write_reg_bit_result *res = parsed_result;
7204 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
7207 cmdline_parse_token_string_t cmd_write_reg_bit_write =
7208 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
7210 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
7211 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
7213 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
7214 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
7215 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
7216 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
7217 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
7218 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
7219 cmdline_parse_token_num_t cmd_write_reg_bit_value =
7220 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
7222 cmdline_parse_inst_t cmd_write_reg_bit = {
7223 .f = cmd_write_reg_bit_parsed,
7225 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
7228 (void *)&cmd_write_reg_bit_write,
7229 (void *)&cmd_write_reg_bit_regbit,
7230 (void *)&cmd_write_reg_bit_port_id,
7231 (void *)&cmd_write_reg_bit_reg_off,
7232 (void *)&cmd_write_reg_bit_bit_pos,
7233 (void *)&cmd_write_reg_bit_value,
7238 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7239 struct cmd_read_rxd_txd_result {
7240 cmdline_fixed_string_t read;
7241 cmdline_fixed_string_t rxd_txd;
7248 cmd_read_rxd_txd_parsed(void *parsed_result,
7249 __attribute__((unused)) struct cmdline *cl,
7250 __attribute__((unused)) void *data)
7252 struct cmd_read_rxd_txd_result *res = parsed_result;
7254 if (!strcmp(res->rxd_txd, "rxd"))
7255 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7256 else if (!strcmp(res->rxd_txd, "txd"))
7257 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7260 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
7261 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
7262 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
7263 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
7265 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
7266 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
7267 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
7268 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
7269 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
7270 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
7272 cmdline_parse_inst_t cmd_read_rxd_txd = {
7273 .f = cmd_read_rxd_txd_parsed,
7275 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
7277 (void *)&cmd_read_rxd_txd_read,
7278 (void *)&cmd_read_rxd_txd_rxd_txd,
7279 (void *)&cmd_read_rxd_txd_port_id,
7280 (void *)&cmd_read_rxd_txd_queue_id,
7281 (void *)&cmd_read_rxd_txd_desc_id,
7287 struct cmd_quit_result {
7288 cmdline_fixed_string_t quit;
7291 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
7293 __attribute__((unused)) void *data)
7299 cmdline_parse_token_string_t cmd_quit_quit =
7300 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
7302 cmdline_parse_inst_t cmd_quit = {
7303 .f = cmd_quit_parsed,
7305 .help_str = "quit: Exit application",
7307 (void *)&cmd_quit_quit,
7312 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
7313 struct cmd_mac_addr_result {
7314 cmdline_fixed_string_t mac_addr_cmd;
7315 cmdline_fixed_string_t what;
7317 struct ether_addr address;
7320 static void cmd_mac_addr_parsed(void *parsed_result,
7321 __attribute__((unused)) struct cmdline *cl,
7322 __attribute__((unused)) void *data)
7324 struct cmd_mac_addr_result *res = parsed_result;
7327 if (strcmp(res->what, "add") == 0)
7328 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
7329 else if (strcmp(res->what, "set") == 0)
7330 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
7333 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
7335 /* check the return value and print it if is < 0 */
7337 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
7341 cmdline_parse_token_string_t cmd_mac_addr_cmd =
7342 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
7344 cmdline_parse_token_string_t cmd_mac_addr_what =
7345 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
7347 cmdline_parse_token_num_t cmd_mac_addr_portnum =
7348 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
7350 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
7351 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
7353 cmdline_parse_inst_t cmd_mac_addr = {
7354 .f = cmd_mac_addr_parsed,
7356 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
7357 "Add/Remove/Set MAC address on port_id",
7359 (void *)&cmd_mac_addr_cmd,
7360 (void *)&cmd_mac_addr_what,
7361 (void *)&cmd_mac_addr_portnum,
7362 (void *)&cmd_mac_addr_addr,
7367 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
7368 struct cmd_eth_peer_result {
7369 cmdline_fixed_string_t set;
7370 cmdline_fixed_string_t eth_peer;
7372 cmdline_fixed_string_t peer_addr;
7375 static void cmd_set_eth_peer_parsed(void *parsed_result,
7376 __attribute__((unused)) struct cmdline *cl,
7377 __attribute__((unused)) void *data)
7379 struct cmd_eth_peer_result *res = parsed_result;
7381 if (test_done == 0) {
7382 printf("Please stop forwarding first\n");
7385 if (!strcmp(res->eth_peer, "eth-peer")) {
7386 set_fwd_eth_peer(res->port_id, res->peer_addr);
7390 cmdline_parse_token_string_t cmd_eth_peer_set =
7391 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
7392 cmdline_parse_token_string_t cmd_eth_peer =
7393 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
7394 cmdline_parse_token_num_t cmd_eth_peer_port_id =
7395 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
7396 cmdline_parse_token_string_t cmd_eth_peer_addr =
7397 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
7399 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
7400 .f = cmd_set_eth_peer_parsed,
7402 .help_str = "set eth-peer <port_id> <peer_mac>",
7404 (void *)&cmd_eth_peer_set,
7405 (void *)&cmd_eth_peer,
7406 (void *)&cmd_eth_peer_port_id,
7407 (void *)&cmd_eth_peer_addr,
7412 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
7413 struct cmd_set_qmap_result {
7414 cmdline_fixed_string_t set;
7415 cmdline_fixed_string_t qmap;
7416 cmdline_fixed_string_t what;
7423 cmd_set_qmap_parsed(void *parsed_result,
7424 __attribute__((unused)) struct cmdline *cl,
7425 __attribute__((unused)) void *data)
7427 struct cmd_set_qmap_result *res = parsed_result;
7428 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
7430 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
7433 cmdline_parse_token_string_t cmd_setqmap_set =
7434 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7436 cmdline_parse_token_string_t cmd_setqmap_qmap =
7437 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7439 cmdline_parse_token_string_t cmd_setqmap_what =
7440 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7442 cmdline_parse_token_num_t cmd_setqmap_portid =
7443 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7445 cmdline_parse_token_num_t cmd_setqmap_queueid =
7446 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7448 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
7449 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7452 cmdline_parse_inst_t cmd_set_qmap = {
7453 .f = cmd_set_qmap_parsed,
7455 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
7456 "Set statistics mapping value on tx|rx queue_id of port_id",
7458 (void *)&cmd_setqmap_set,
7459 (void *)&cmd_setqmap_qmap,
7460 (void *)&cmd_setqmap_what,
7461 (void *)&cmd_setqmap_portid,
7462 (void *)&cmd_setqmap_queueid,
7463 (void *)&cmd_setqmap_mapvalue,
7468 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
7469 struct cmd_set_xstats_hide_zero_result {
7470 cmdline_fixed_string_t keyword;
7471 cmdline_fixed_string_t name;
7472 cmdline_fixed_string_t on_off;
7476 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
7477 __attribute__((unused)) struct cmdline *cl,
7478 __attribute__((unused)) void *data)
7480 struct cmd_set_xstats_hide_zero_result *res;
7481 uint16_t on_off = 0;
7483 res = parsed_result;
7484 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
7485 set_xstats_hide_zero(on_off);
7488 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
7489 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7491 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
7492 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7493 name, "xstats-hide-zero");
7494 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
7495 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7498 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
7499 .f = cmd_set_xstats_hide_zero_parsed,
7501 .help_str = "set xstats-hide-zero on|off",
7503 (void *)&cmd_set_xstats_hide_zero_keyword,
7504 (void *)&cmd_set_xstats_hide_zero_name,
7505 (void *)&cmd_set_xstats_hide_zero_on_off,
7510 /* *** CONFIGURE UNICAST HASH TABLE *** */
7511 struct cmd_set_uc_hash_table {
7512 cmdline_fixed_string_t set;
7513 cmdline_fixed_string_t port;
7515 cmdline_fixed_string_t what;
7516 struct ether_addr address;
7517 cmdline_fixed_string_t mode;
7521 cmd_set_uc_hash_parsed(void *parsed_result,
7522 __attribute__((unused)) struct cmdline *cl,
7523 __attribute__((unused)) void *data)
7526 struct cmd_set_uc_hash_table *res = parsed_result;
7528 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7530 if (strcmp(res->what, "uta") == 0)
7531 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
7532 &res->address,(uint8_t)is_on);
7534 printf("bad unicast hash table parameter, return code = %d \n", ret);
7538 cmdline_parse_token_string_t cmd_set_uc_hash_set =
7539 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7541 cmdline_parse_token_string_t cmd_set_uc_hash_port =
7542 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7544 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
7545 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
7547 cmdline_parse_token_string_t cmd_set_uc_hash_what =
7548 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7550 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
7551 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
7553 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
7554 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7557 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
7558 .f = cmd_set_uc_hash_parsed,
7560 .help_str = "set port <port_id> uta <mac_addr> on|off)",
7562 (void *)&cmd_set_uc_hash_set,
7563 (void *)&cmd_set_uc_hash_port,
7564 (void *)&cmd_set_uc_hash_portid,
7565 (void *)&cmd_set_uc_hash_what,
7566 (void *)&cmd_set_uc_hash_mac,
7567 (void *)&cmd_set_uc_hash_mode,
7572 struct cmd_set_uc_all_hash_table {
7573 cmdline_fixed_string_t set;
7574 cmdline_fixed_string_t port;
7576 cmdline_fixed_string_t what;
7577 cmdline_fixed_string_t value;
7578 cmdline_fixed_string_t mode;
7582 cmd_set_uc_all_hash_parsed(void *parsed_result,
7583 __attribute__((unused)) struct cmdline *cl,
7584 __attribute__((unused)) void *data)
7587 struct cmd_set_uc_all_hash_table *res = parsed_result;
7589 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7591 if ((strcmp(res->what, "uta") == 0) &&
7592 (strcmp(res->value, "all") == 0))
7593 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
7595 printf("bad unicast hash table parameter,"
7596 "return code = %d \n", ret);
7599 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
7600 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7602 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
7603 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7605 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
7606 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
7608 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
7609 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7611 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
7612 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7614 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
7615 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7618 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
7619 .f = cmd_set_uc_all_hash_parsed,
7621 .help_str = "set port <port_id> uta all on|off",
7623 (void *)&cmd_set_uc_all_hash_set,
7624 (void *)&cmd_set_uc_all_hash_port,
7625 (void *)&cmd_set_uc_all_hash_portid,
7626 (void *)&cmd_set_uc_all_hash_what,
7627 (void *)&cmd_set_uc_all_hash_value,
7628 (void *)&cmd_set_uc_all_hash_mode,
7633 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
7634 struct cmd_set_vf_macvlan_filter {
7635 cmdline_fixed_string_t set;
7636 cmdline_fixed_string_t port;
7638 cmdline_fixed_string_t vf;
7640 struct ether_addr address;
7641 cmdline_fixed_string_t filter_type;
7642 cmdline_fixed_string_t mode;
7646 cmd_set_vf_macvlan_parsed(void *parsed_result,
7647 __attribute__((unused)) struct cmdline *cl,
7648 __attribute__((unused)) void *data)
7651 struct cmd_set_vf_macvlan_filter *res = parsed_result;
7652 struct rte_eth_mac_filter filter;
7654 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
7656 rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
7658 /* set VF MAC filter */
7662 filter.dst_id = res->vf_id;
7664 if (!strcmp(res->filter_type, "exact-mac"))
7665 filter.filter_type = RTE_MAC_PERFECT_MATCH;
7666 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
7667 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
7668 else if (!strcmp(res->filter_type, "hashmac"))
7669 filter.filter_type = RTE_MAC_HASH_MATCH;
7670 else if (!strcmp(res->filter_type, "hashmac-vlan"))
7671 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
7673 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7676 ret = rte_eth_dev_filter_ctrl(res->port_id,
7677 RTE_ETH_FILTER_MACVLAN,
7681 ret = rte_eth_dev_filter_ctrl(res->port_id,
7682 RTE_ETH_FILTER_MACVLAN,
7683 RTE_ETH_FILTER_DELETE,
7687 printf("bad set MAC hash parameter, return code = %d\n", ret);
7691 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
7692 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7694 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
7695 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7697 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
7698 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7700 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
7701 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7703 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
7704 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7706 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
7707 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7709 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
7710 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7711 filter_type, "exact-mac#exact-mac-vlan"
7712 "#hashmac#hashmac-vlan");
7713 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
7714 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7717 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
7718 .f = cmd_set_vf_macvlan_parsed,
7720 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
7721 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
7722 "Exact match rule: exact match of MAC or MAC and VLAN; "
7723 "hash match rule: hash match of MAC and exact match of VLAN",
7725 (void *)&cmd_set_vf_macvlan_set,
7726 (void *)&cmd_set_vf_macvlan_port,
7727 (void *)&cmd_set_vf_macvlan_portid,
7728 (void *)&cmd_set_vf_macvlan_vf,
7729 (void *)&cmd_set_vf_macvlan_vf_id,
7730 (void *)&cmd_set_vf_macvlan_mac,
7731 (void *)&cmd_set_vf_macvlan_filter_type,
7732 (void *)&cmd_set_vf_macvlan_mode,
7737 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
7738 struct cmd_set_vf_traffic {
7739 cmdline_fixed_string_t set;
7740 cmdline_fixed_string_t port;
7742 cmdline_fixed_string_t vf;
7744 cmdline_fixed_string_t what;
7745 cmdline_fixed_string_t mode;
7749 cmd_set_vf_traffic_parsed(void *parsed_result,
7750 __attribute__((unused)) struct cmdline *cl,
7751 __attribute__((unused)) void *data)
7753 struct cmd_set_vf_traffic *res = parsed_result;
7754 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
7755 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7757 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
7760 cmdline_parse_token_string_t cmd_setvf_traffic_set =
7761 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7763 cmdline_parse_token_string_t cmd_setvf_traffic_port =
7764 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7766 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
7767 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7769 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
7770 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7772 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
7773 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7775 cmdline_parse_token_string_t cmd_setvf_traffic_what =
7776 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7778 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
7779 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7782 cmdline_parse_inst_t cmd_set_vf_traffic = {
7783 .f = cmd_set_vf_traffic_parsed,
7785 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
7787 (void *)&cmd_setvf_traffic_set,
7788 (void *)&cmd_setvf_traffic_port,
7789 (void *)&cmd_setvf_traffic_portid,
7790 (void *)&cmd_setvf_traffic_vf,
7791 (void *)&cmd_setvf_traffic_vfid,
7792 (void *)&cmd_setvf_traffic_what,
7793 (void *)&cmd_setvf_traffic_mode,
7798 /* *** CONFIGURE VF RECEIVE MODE *** */
7799 struct cmd_set_vf_rxmode {
7800 cmdline_fixed_string_t set;
7801 cmdline_fixed_string_t port;
7803 cmdline_fixed_string_t vf;
7805 cmdline_fixed_string_t what;
7806 cmdline_fixed_string_t mode;
7807 cmdline_fixed_string_t on;
7811 cmd_set_vf_rxmode_parsed(void *parsed_result,
7812 __attribute__((unused)) struct cmdline *cl,
7813 __attribute__((unused)) void *data)
7816 uint16_t rx_mode = 0;
7817 struct cmd_set_vf_rxmode *res = parsed_result;
7819 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
7820 if (!strcmp(res->what,"rxmode")) {
7821 if (!strcmp(res->mode, "AUPE"))
7822 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
7823 else if (!strcmp(res->mode, "ROPE"))
7824 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
7825 else if (!strcmp(res->mode, "BAM"))
7826 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
7827 else if (!strncmp(res->mode, "MPE",3))
7828 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
7831 RTE_SET_USED(is_on);
7833 #ifdef RTE_LIBRTE_IXGBE_PMD
7834 if (ret == -ENOTSUP)
7835 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
7836 rx_mode, (uint8_t)is_on);
7838 #ifdef RTE_LIBRTE_BNXT_PMD
7839 if (ret == -ENOTSUP)
7840 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
7841 rx_mode, (uint8_t)is_on);
7844 printf("bad VF receive mode parameter, return code = %d \n",
7848 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
7849 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7851 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
7852 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7854 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
7855 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7857 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
7858 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7860 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
7861 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7863 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
7864 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7866 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
7867 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7868 mode, "AUPE#ROPE#BAM#MPE");
7869 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
7870 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7873 cmdline_parse_inst_t cmd_set_vf_rxmode = {
7874 .f = cmd_set_vf_rxmode_parsed,
7876 .help_str = "set port <port_id> vf <vf_id> rxmode "
7877 "AUPE|ROPE|BAM|MPE on|off",
7879 (void *)&cmd_set_vf_rxmode_set,
7880 (void *)&cmd_set_vf_rxmode_port,
7881 (void *)&cmd_set_vf_rxmode_portid,
7882 (void *)&cmd_set_vf_rxmode_vf,
7883 (void *)&cmd_set_vf_rxmode_vfid,
7884 (void *)&cmd_set_vf_rxmode_what,
7885 (void *)&cmd_set_vf_rxmode_mode,
7886 (void *)&cmd_set_vf_rxmode_on,
7891 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
7892 struct cmd_vf_mac_addr_result {
7893 cmdline_fixed_string_t mac_addr_cmd;
7894 cmdline_fixed_string_t what;
7895 cmdline_fixed_string_t port;
7897 cmdline_fixed_string_t vf;
7899 struct ether_addr address;
7902 static void cmd_vf_mac_addr_parsed(void *parsed_result,
7903 __attribute__((unused)) struct cmdline *cl,
7904 __attribute__((unused)) void *data)
7906 struct cmd_vf_mac_addr_result *res = parsed_result;
7909 if (strcmp(res->what, "add") != 0)
7912 #ifdef RTE_LIBRTE_I40E_PMD
7913 if (ret == -ENOTSUP)
7914 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
7917 #ifdef RTE_LIBRTE_BNXT_PMD
7918 if (ret == -ENOTSUP)
7919 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
7924 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
7928 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
7929 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7930 mac_addr_cmd,"mac_addr");
7931 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
7932 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7934 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
7935 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7937 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
7938 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7940 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
7941 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7943 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
7944 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7946 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
7947 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
7950 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
7951 .f = cmd_vf_mac_addr_parsed,
7953 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
7954 "Add MAC address filtering for a VF on port_id",
7956 (void *)&cmd_vf_mac_addr_cmd,
7957 (void *)&cmd_vf_mac_addr_what,
7958 (void *)&cmd_vf_mac_addr_port,
7959 (void *)&cmd_vf_mac_addr_portnum,
7960 (void *)&cmd_vf_mac_addr_vf,
7961 (void *)&cmd_vf_mac_addr_vfnum,
7962 (void *)&cmd_vf_mac_addr_addr,
7967 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
7968 struct cmd_vf_rx_vlan_filter {
7969 cmdline_fixed_string_t rx_vlan;
7970 cmdline_fixed_string_t what;
7972 cmdline_fixed_string_t port;
7974 cmdline_fixed_string_t vf;
7979 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
7980 __attribute__((unused)) struct cmdline *cl,
7981 __attribute__((unused)) void *data)
7983 struct cmd_vf_rx_vlan_filter *res = parsed_result;
7986 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
7988 #ifdef RTE_LIBRTE_IXGBE_PMD
7989 if (ret == -ENOTSUP)
7990 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
7991 res->vlan_id, res->vf_mask, is_add);
7993 #ifdef RTE_LIBRTE_I40E_PMD
7994 if (ret == -ENOTSUP)
7995 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
7996 res->vlan_id, res->vf_mask, is_add);
7998 #ifdef RTE_LIBRTE_BNXT_PMD
7999 if (ret == -ENOTSUP)
8000 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8001 res->vlan_id, res->vf_mask, is_add);
8008 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8009 res->vlan_id, res->vf_mask);
8012 printf("invalid port_id %d\n", res->port_id);
8015 printf("function not implemented or supported\n");
8018 printf("programming error: (%s)\n", strerror(-ret));
8022 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8023 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8024 rx_vlan, "rx_vlan");
8025 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8026 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8028 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8029 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8031 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8032 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8034 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8035 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8037 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8038 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8040 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8041 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8044 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8045 .f = cmd_vf_rx_vlan_filter_parsed,
8047 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8048 "(vf_mask = hexadecimal VF mask)",
8050 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8051 (void *)&cmd_vf_rx_vlan_filter_what,
8052 (void *)&cmd_vf_rx_vlan_filter_vlanid,
8053 (void *)&cmd_vf_rx_vlan_filter_port,
8054 (void *)&cmd_vf_rx_vlan_filter_portid,
8055 (void *)&cmd_vf_rx_vlan_filter_vf,
8056 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8061 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8062 struct cmd_queue_rate_limit_result {
8063 cmdline_fixed_string_t set;
8064 cmdline_fixed_string_t port;
8066 cmdline_fixed_string_t queue;
8068 cmdline_fixed_string_t rate;
8072 static void cmd_queue_rate_limit_parsed(void *parsed_result,
8073 __attribute__((unused)) struct cmdline *cl,
8074 __attribute__((unused)) void *data)
8076 struct cmd_queue_rate_limit_result *res = parsed_result;
8079 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8080 && (strcmp(res->queue, "queue") == 0)
8081 && (strcmp(res->rate, "rate") == 0))
8082 ret = set_queue_rate_limit(res->port_num, res->queue_num,
8085 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
8089 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8090 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8092 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8093 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8095 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8096 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8098 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8099 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8101 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8102 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8104 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8105 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8107 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8108 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8111 cmdline_parse_inst_t cmd_queue_rate_limit = {
8112 .f = cmd_queue_rate_limit_parsed,
8114 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8115 "Set rate limit for a queue on port_id",
8117 (void *)&cmd_queue_rate_limit_set,
8118 (void *)&cmd_queue_rate_limit_port,
8119 (void *)&cmd_queue_rate_limit_portnum,
8120 (void *)&cmd_queue_rate_limit_queue,
8121 (void *)&cmd_queue_rate_limit_queuenum,
8122 (void *)&cmd_queue_rate_limit_rate,
8123 (void *)&cmd_queue_rate_limit_ratenum,
8128 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
8129 struct cmd_vf_rate_limit_result {
8130 cmdline_fixed_string_t set;
8131 cmdline_fixed_string_t port;
8133 cmdline_fixed_string_t vf;
8135 cmdline_fixed_string_t rate;
8137 cmdline_fixed_string_t q_msk;
8141 static void cmd_vf_rate_limit_parsed(void *parsed_result,
8142 __attribute__((unused)) struct cmdline *cl,
8143 __attribute__((unused)) void *data)
8145 struct cmd_vf_rate_limit_result *res = parsed_result;
8148 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8149 && (strcmp(res->vf, "vf") == 0)
8150 && (strcmp(res->rate, "rate") == 0)
8151 && (strcmp(res->q_msk, "queue_mask") == 0))
8152 ret = set_vf_rate_limit(res->port_num, res->vf_num,
8153 res->rate_num, res->q_msk_val);
8155 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
8159 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
8160 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8162 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
8163 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8165 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
8166 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8168 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
8169 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8171 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
8172 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8174 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
8175 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8177 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
8178 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8180 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
8181 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8182 q_msk, "queue_mask");
8183 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
8184 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8187 cmdline_parse_inst_t cmd_vf_rate_limit = {
8188 .f = cmd_vf_rate_limit_parsed,
8190 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
8191 "queue_mask <queue_mask_value>: "
8192 "Set rate limit for queues of VF on port_id",
8194 (void *)&cmd_vf_rate_limit_set,
8195 (void *)&cmd_vf_rate_limit_port,
8196 (void *)&cmd_vf_rate_limit_portnum,
8197 (void *)&cmd_vf_rate_limit_vf,
8198 (void *)&cmd_vf_rate_limit_vfnum,
8199 (void *)&cmd_vf_rate_limit_rate,
8200 (void *)&cmd_vf_rate_limit_ratenum,
8201 (void *)&cmd_vf_rate_limit_q_msk,
8202 (void *)&cmd_vf_rate_limit_q_msk_val,
8207 /* *** ADD TUNNEL FILTER OF A PORT *** */
8208 struct cmd_tunnel_filter_result {
8209 cmdline_fixed_string_t cmd;
8210 cmdline_fixed_string_t what;
8212 struct ether_addr outer_mac;
8213 struct ether_addr inner_mac;
8214 cmdline_ipaddr_t ip_value;
8215 uint16_t inner_vlan;
8216 cmdline_fixed_string_t tunnel_type;
8217 cmdline_fixed_string_t filter_type;
8223 cmd_tunnel_filter_parsed(void *parsed_result,
8224 __attribute__((unused)) struct cmdline *cl,
8225 __attribute__((unused)) void *data)
8227 struct cmd_tunnel_filter_result *res = parsed_result;
8228 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
8231 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
8233 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
8234 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
8235 tunnel_filter_conf.inner_vlan = res->inner_vlan;
8237 if (res->ip_value.family == AF_INET) {
8238 tunnel_filter_conf.ip_addr.ipv4_addr =
8239 res->ip_value.addr.ipv4.s_addr;
8240 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
8242 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
8243 &(res->ip_value.addr.ipv6),
8244 sizeof(struct in6_addr));
8245 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
8248 if (!strcmp(res->filter_type, "imac-ivlan"))
8249 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
8250 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
8251 tunnel_filter_conf.filter_type =
8252 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
8253 else if (!strcmp(res->filter_type, "imac-tenid"))
8254 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
8255 else if (!strcmp(res->filter_type, "imac"))
8256 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
8257 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
8258 tunnel_filter_conf.filter_type =
8259 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
8260 else if (!strcmp(res->filter_type, "oip"))
8261 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
8262 else if (!strcmp(res->filter_type, "iip"))
8263 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
8265 printf("The filter type is not supported");
8269 if (!strcmp(res->tunnel_type, "vxlan"))
8270 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
8271 else if (!strcmp(res->tunnel_type, "nvgre"))
8272 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
8273 else if (!strcmp(res->tunnel_type, "ipingre"))
8274 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
8276 printf("The tunnel type %s not supported.\n", res->tunnel_type);
8280 tunnel_filter_conf.tenant_id = res->tenant_id;
8281 tunnel_filter_conf.queue_id = res->queue_num;
8282 if (!strcmp(res->what, "add"))
8283 ret = rte_eth_dev_filter_ctrl(res->port_id,
8284 RTE_ETH_FILTER_TUNNEL,
8286 &tunnel_filter_conf);
8288 ret = rte_eth_dev_filter_ctrl(res->port_id,
8289 RTE_ETH_FILTER_TUNNEL,
8290 RTE_ETH_FILTER_DELETE,
8291 &tunnel_filter_conf);
8293 printf("cmd_tunnel_filter_parsed error: (%s)\n",
8297 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
8298 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8299 cmd, "tunnel_filter");
8300 cmdline_parse_token_string_t cmd_tunnel_filter_what =
8301 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8303 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
8304 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8306 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
8307 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8309 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
8310 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8312 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
8313 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8314 inner_vlan, UINT16);
8315 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
8316 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8318 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
8319 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8320 tunnel_type, "vxlan#nvgre#ipingre");
8322 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
8323 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8324 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
8325 "imac#omac-imac-tenid");
8326 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
8327 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8329 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
8330 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8333 cmdline_parse_inst_t cmd_tunnel_filter = {
8334 .f = cmd_tunnel_filter_parsed,
8336 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
8337 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
8338 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
8339 "<queue_id>: Add/Rm tunnel filter of a port",
8341 (void *)&cmd_tunnel_filter_cmd,
8342 (void *)&cmd_tunnel_filter_what,
8343 (void *)&cmd_tunnel_filter_port_id,
8344 (void *)&cmd_tunnel_filter_outer_mac,
8345 (void *)&cmd_tunnel_filter_inner_mac,
8346 (void *)&cmd_tunnel_filter_ip_value,
8347 (void *)&cmd_tunnel_filter_innner_vlan,
8348 (void *)&cmd_tunnel_filter_tunnel_type,
8349 (void *)&cmd_tunnel_filter_filter_type,
8350 (void *)&cmd_tunnel_filter_tenant_id,
8351 (void *)&cmd_tunnel_filter_queue_num,
8356 /* *** CONFIGURE TUNNEL UDP PORT *** */
8357 struct cmd_tunnel_udp_config {
8358 cmdline_fixed_string_t cmd;
8359 cmdline_fixed_string_t what;
8365 cmd_tunnel_udp_config_parsed(void *parsed_result,
8366 __attribute__((unused)) struct cmdline *cl,
8367 __attribute__((unused)) void *data)
8369 struct cmd_tunnel_udp_config *res = parsed_result;
8370 struct rte_eth_udp_tunnel tunnel_udp;
8373 tunnel_udp.udp_port = res->udp_port;
8375 if (!strcmp(res->cmd, "rx_vxlan_port"))
8376 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8378 if (!strcmp(res->what, "add"))
8379 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8382 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8386 printf("udp tunneling add error: (%s)\n", strerror(-ret));
8389 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
8390 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8391 cmd, "rx_vxlan_port");
8392 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
8393 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8395 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
8396 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8398 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
8399 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8402 cmdline_parse_inst_t cmd_tunnel_udp_config = {
8403 .f = cmd_tunnel_udp_config_parsed,
8405 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
8406 "Add/Remove a tunneling UDP port filter",
8408 (void *)&cmd_tunnel_udp_config_cmd,
8409 (void *)&cmd_tunnel_udp_config_what,
8410 (void *)&cmd_tunnel_udp_config_udp_port,
8411 (void *)&cmd_tunnel_udp_config_port_id,
8416 /* *** GLOBAL CONFIG *** */
8417 struct cmd_global_config_result {
8418 cmdline_fixed_string_t cmd;
8420 cmdline_fixed_string_t cfg_type;
8425 cmd_global_config_parsed(void *parsed_result,
8426 __attribute__((unused)) struct cmdline *cl,
8427 __attribute__((unused)) void *data)
8429 struct cmd_global_config_result *res = parsed_result;
8430 struct rte_eth_global_cfg conf;
8433 memset(&conf, 0, sizeof(conf));
8434 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
8435 conf.cfg.gre_key_len = res->len;
8436 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
8437 RTE_ETH_FILTER_SET, &conf);
8439 printf("Global config error\n");
8442 cmdline_parse_token_string_t cmd_global_config_cmd =
8443 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
8445 cmdline_parse_token_num_t cmd_global_config_port_id =
8446 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
8448 cmdline_parse_token_string_t cmd_global_config_type =
8449 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
8450 cfg_type, "gre-key-len");
8451 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
8452 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
8455 cmdline_parse_inst_t cmd_global_config = {
8456 .f = cmd_global_config_parsed,
8457 .data = (void *)NULL,
8458 .help_str = "global_config <port_id> gre-key-len <key_len>",
8460 (void *)&cmd_global_config_cmd,
8461 (void *)&cmd_global_config_port_id,
8462 (void *)&cmd_global_config_type,
8463 (void *)&cmd_global_config_gre_key_len,
8468 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
8469 struct cmd_set_mirror_mask_result {
8470 cmdline_fixed_string_t set;
8471 cmdline_fixed_string_t port;
8473 cmdline_fixed_string_t mirror;
8475 cmdline_fixed_string_t what;
8476 cmdline_fixed_string_t value;
8477 cmdline_fixed_string_t dstpool;
8479 cmdline_fixed_string_t on;
8482 cmdline_parse_token_string_t cmd_mirror_mask_set =
8483 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8485 cmdline_parse_token_string_t cmd_mirror_mask_port =
8486 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8488 cmdline_parse_token_num_t cmd_mirror_mask_portid =
8489 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8491 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
8492 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8493 mirror, "mirror-rule");
8494 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
8495 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8497 cmdline_parse_token_string_t cmd_mirror_mask_what =
8498 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8499 what, "pool-mirror-up#pool-mirror-down"
8501 cmdline_parse_token_string_t cmd_mirror_mask_value =
8502 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8504 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
8505 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8506 dstpool, "dst-pool");
8507 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
8508 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8510 cmdline_parse_token_string_t cmd_mirror_mask_on =
8511 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8515 cmd_set_mirror_mask_parsed(void *parsed_result,
8516 __attribute__((unused)) struct cmdline *cl,
8517 __attribute__((unused)) void *data)
8520 struct cmd_set_mirror_mask_result *res = parsed_result;
8521 struct rte_eth_mirror_conf mr_conf;
8523 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8525 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
8527 mr_conf.dst_pool = res->dstpool_id;
8529 if (!strcmp(res->what, "pool-mirror-up")) {
8530 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8531 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
8532 } else if (!strcmp(res->what, "pool-mirror-down")) {
8533 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8534 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
8535 } else if (!strcmp(res->what, "vlan-mirror")) {
8536 mr_conf.rule_type = ETH_MIRROR_VLAN;
8537 nb_item = parse_item_list(res->value, "vlan",
8538 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
8542 for (i = 0; i < nb_item; i++) {
8543 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
8544 printf("Invalid vlan_id: must be < 4096\n");
8548 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
8549 mr_conf.vlan.vlan_mask |= 1ULL << i;
8553 if (!strcmp(res->on, "on"))
8554 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8557 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8560 printf("mirror rule add error: (%s)\n", strerror(-ret));
8563 cmdline_parse_inst_t cmd_set_mirror_mask = {
8564 .f = cmd_set_mirror_mask_parsed,
8566 .help_str = "set port <port_id> mirror-rule <rule_id> "
8567 "pool-mirror-up|pool-mirror-down|vlan-mirror "
8568 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
8570 (void *)&cmd_mirror_mask_set,
8571 (void *)&cmd_mirror_mask_port,
8572 (void *)&cmd_mirror_mask_portid,
8573 (void *)&cmd_mirror_mask_mirror,
8574 (void *)&cmd_mirror_mask_ruleid,
8575 (void *)&cmd_mirror_mask_what,
8576 (void *)&cmd_mirror_mask_value,
8577 (void *)&cmd_mirror_mask_dstpool,
8578 (void *)&cmd_mirror_mask_poolid,
8579 (void *)&cmd_mirror_mask_on,
8584 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
8585 struct cmd_set_mirror_link_result {
8586 cmdline_fixed_string_t set;
8587 cmdline_fixed_string_t port;
8589 cmdline_fixed_string_t mirror;
8591 cmdline_fixed_string_t what;
8592 cmdline_fixed_string_t dstpool;
8594 cmdline_fixed_string_t on;
8597 cmdline_parse_token_string_t cmd_mirror_link_set =
8598 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8600 cmdline_parse_token_string_t cmd_mirror_link_port =
8601 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8603 cmdline_parse_token_num_t cmd_mirror_link_portid =
8604 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8606 cmdline_parse_token_string_t cmd_mirror_link_mirror =
8607 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8608 mirror, "mirror-rule");
8609 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
8610 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8612 cmdline_parse_token_string_t cmd_mirror_link_what =
8613 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8614 what, "uplink-mirror#downlink-mirror");
8615 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
8616 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8617 dstpool, "dst-pool");
8618 cmdline_parse_token_num_t cmd_mirror_link_poolid =
8619 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8621 cmdline_parse_token_string_t cmd_mirror_link_on =
8622 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8626 cmd_set_mirror_link_parsed(void *parsed_result,
8627 __attribute__((unused)) struct cmdline *cl,
8628 __attribute__((unused)) void *data)
8631 struct cmd_set_mirror_link_result *res = parsed_result;
8632 struct rte_eth_mirror_conf mr_conf;
8634 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8635 if (!strcmp(res->what, "uplink-mirror"))
8636 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
8638 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
8640 mr_conf.dst_pool = res->dstpool_id;
8642 if (!strcmp(res->on, "on"))
8643 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8646 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8649 /* check the return value and print it if is < 0 */
8651 printf("mirror rule add error: (%s)\n", strerror(-ret));
8655 cmdline_parse_inst_t cmd_set_mirror_link = {
8656 .f = cmd_set_mirror_link_parsed,
8658 .help_str = "set port <port_id> mirror-rule <rule_id> "
8659 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
8661 (void *)&cmd_mirror_link_set,
8662 (void *)&cmd_mirror_link_port,
8663 (void *)&cmd_mirror_link_portid,
8664 (void *)&cmd_mirror_link_mirror,
8665 (void *)&cmd_mirror_link_ruleid,
8666 (void *)&cmd_mirror_link_what,
8667 (void *)&cmd_mirror_link_dstpool,
8668 (void *)&cmd_mirror_link_poolid,
8669 (void *)&cmd_mirror_link_on,
8674 /* *** RESET VM MIRROR RULE *** */
8675 struct cmd_rm_mirror_rule_result {
8676 cmdline_fixed_string_t reset;
8677 cmdline_fixed_string_t port;
8679 cmdline_fixed_string_t mirror;
8683 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
8684 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8686 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
8687 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8689 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
8690 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
8692 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
8693 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8694 mirror, "mirror-rule");
8695 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
8696 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
8700 cmd_reset_mirror_rule_parsed(void *parsed_result,
8701 __attribute__((unused)) struct cmdline *cl,
8702 __attribute__((unused)) void *data)
8705 struct cmd_set_mirror_link_result *res = parsed_result;
8707 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
8709 printf("mirror rule remove error: (%s)\n", strerror(-ret));
8712 cmdline_parse_inst_t cmd_reset_mirror_rule = {
8713 .f = cmd_reset_mirror_rule_parsed,
8715 .help_str = "reset port <port_id> mirror-rule <rule_id>",
8717 (void *)&cmd_rm_mirror_rule_reset,
8718 (void *)&cmd_rm_mirror_rule_port,
8719 (void *)&cmd_rm_mirror_rule_portid,
8720 (void *)&cmd_rm_mirror_rule_mirror,
8721 (void *)&cmd_rm_mirror_rule_ruleid,
8726 /* ******************************************************************************** */
8728 struct cmd_dump_result {
8729 cmdline_fixed_string_t dump;
8733 dump_struct_sizes(void)
8735 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
8736 DUMP_SIZE(struct rte_mbuf);
8737 DUMP_SIZE(struct rte_mempool);
8738 DUMP_SIZE(struct rte_ring);
8742 static void cmd_dump_parsed(void *parsed_result,
8743 __attribute__((unused)) struct cmdline *cl,
8744 __attribute__((unused)) void *data)
8746 struct cmd_dump_result *res = parsed_result;
8748 if (!strcmp(res->dump, "dump_physmem"))
8749 rte_dump_physmem_layout(stdout);
8750 else if (!strcmp(res->dump, "dump_memzone"))
8751 rte_memzone_dump(stdout);
8752 else if (!strcmp(res->dump, "dump_struct_sizes"))
8753 dump_struct_sizes();
8754 else if (!strcmp(res->dump, "dump_ring"))
8755 rte_ring_list_dump(stdout);
8756 else if (!strcmp(res->dump, "dump_mempool"))
8757 rte_mempool_list_dump(stdout);
8758 else if (!strcmp(res->dump, "dump_devargs"))
8759 rte_devargs_dump(stdout);
8760 else if (!strcmp(res->dump, "dump_log_types"))
8761 rte_log_dump(stdout);
8764 cmdline_parse_token_string_t cmd_dump_dump =
8765 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
8768 "dump_struct_sizes#"
8774 cmdline_parse_inst_t cmd_dump = {
8775 .f = cmd_dump_parsed, /* function to call */
8776 .data = NULL, /* 2nd arg of func */
8777 .help_str = "Dump status",
8778 .tokens = { /* token list, NULL terminated */
8779 (void *)&cmd_dump_dump,
8784 /* ******************************************************************************** */
8786 struct cmd_dump_one_result {
8787 cmdline_fixed_string_t dump;
8788 cmdline_fixed_string_t name;
8791 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
8792 __attribute__((unused)) void *data)
8794 struct cmd_dump_one_result *res = parsed_result;
8796 if (!strcmp(res->dump, "dump_ring")) {
8798 r = rte_ring_lookup(res->name);
8800 cmdline_printf(cl, "Cannot find ring\n");
8803 rte_ring_dump(stdout, r);
8804 } else if (!strcmp(res->dump, "dump_mempool")) {
8805 struct rte_mempool *mp;
8806 mp = rte_mempool_lookup(res->name);
8808 cmdline_printf(cl, "Cannot find mempool\n");
8811 rte_mempool_dump(stdout, mp);
8815 cmdline_parse_token_string_t cmd_dump_one_dump =
8816 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
8817 "dump_ring#dump_mempool");
8819 cmdline_parse_token_string_t cmd_dump_one_name =
8820 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
8822 cmdline_parse_inst_t cmd_dump_one = {
8823 .f = cmd_dump_one_parsed, /* function to call */
8824 .data = NULL, /* 2nd arg of func */
8825 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
8826 .tokens = { /* token list, NULL terminated */
8827 (void *)&cmd_dump_one_dump,
8828 (void *)&cmd_dump_one_name,
8833 /* *** Add/Del syn filter *** */
8834 struct cmd_syn_filter_result {
8835 cmdline_fixed_string_t filter;
8837 cmdline_fixed_string_t ops;
8838 cmdline_fixed_string_t priority;
8839 cmdline_fixed_string_t high;
8840 cmdline_fixed_string_t queue;
8845 cmd_syn_filter_parsed(void *parsed_result,
8846 __attribute__((unused)) struct cmdline *cl,
8847 __attribute__((unused)) void *data)
8849 struct cmd_syn_filter_result *res = parsed_result;
8850 struct rte_eth_syn_filter syn_filter;
8853 ret = rte_eth_dev_filter_supported(res->port_id,
8854 RTE_ETH_FILTER_SYN);
8856 printf("syn filter is not supported on port %u.\n",
8861 memset(&syn_filter, 0, sizeof(syn_filter));
8863 if (!strcmp(res->ops, "add")) {
8864 if (!strcmp(res->high, "high"))
8865 syn_filter.hig_pri = 1;
8867 syn_filter.hig_pri = 0;
8869 syn_filter.queue = res->queue_id;
8870 ret = rte_eth_dev_filter_ctrl(res->port_id,
8875 ret = rte_eth_dev_filter_ctrl(res->port_id,
8877 RTE_ETH_FILTER_DELETE,
8881 printf("syn filter programming error: (%s)\n",
8885 cmdline_parse_token_string_t cmd_syn_filter_filter =
8886 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8887 filter, "syn_filter");
8888 cmdline_parse_token_num_t cmd_syn_filter_port_id =
8889 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8891 cmdline_parse_token_string_t cmd_syn_filter_ops =
8892 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8894 cmdline_parse_token_string_t cmd_syn_filter_priority =
8895 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8896 priority, "priority");
8897 cmdline_parse_token_string_t cmd_syn_filter_high =
8898 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8900 cmdline_parse_token_string_t cmd_syn_filter_queue =
8901 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8903 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
8904 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8907 cmdline_parse_inst_t cmd_syn_filter = {
8908 .f = cmd_syn_filter_parsed,
8910 .help_str = "syn_filter <port_id> add|del priority high|low queue "
8911 "<queue_id>: Add/Delete syn filter",
8913 (void *)&cmd_syn_filter_filter,
8914 (void *)&cmd_syn_filter_port_id,
8915 (void *)&cmd_syn_filter_ops,
8916 (void *)&cmd_syn_filter_priority,
8917 (void *)&cmd_syn_filter_high,
8918 (void *)&cmd_syn_filter_queue,
8919 (void *)&cmd_syn_filter_queue_id,
8924 /* *** queue region set *** */
8925 struct cmd_queue_region_result {
8926 cmdline_fixed_string_t set;
8927 cmdline_fixed_string_t port;
8929 cmdline_fixed_string_t cmd;
8930 cmdline_fixed_string_t region;
8932 cmdline_fixed_string_t queue_start_index;
8934 cmdline_fixed_string_t queue_num;
8935 uint8_t queue_num_value;
8939 cmd_queue_region_parsed(void *parsed_result,
8940 __attribute__((unused)) struct cmdline *cl,
8941 __attribute__((unused)) void *data)
8943 struct cmd_queue_region_result *res = parsed_result;
8945 #ifdef RTE_LIBRTE_I40E_PMD
8946 struct rte_pmd_i40e_queue_region_conf region_conf;
8947 enum rte_pmd_i40e_queue_region_op op_type;
8950 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8953 #ifdef RTE_LIBRTE_I40E_PMD
8954 memset(®ion_conf, 0, sizeof(region_conf));
8955 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
8956 region_conf.region_id = res->region_id;
8957 region_conf.queue_num = res->queue_num_value;
8958 region_conf.queue_start_index = res->queue_id;
8960 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8961 op_type, ®ion_conf);
8968 printf("function not implemented or supported\n");
8971 printf("queue region config error: (%s)\n", strerror(-ret));
8975 cmdline_parse_token_string_t cmd_queue_region_set =
8976 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8978 cmdline_parse_token_string_t cmd_queue_region_port =
8979 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
8980 cmdline_parse_token_num_t cmd_queue_region_port_id =
8981 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8983 cmdline_parse_token_string_t cmd_queue_region_cmd =
8984 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8985 cmd, "queue-region");
8986 cmdline_parse_token_string_t cmd_queue_region_id =
8987 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8988 region, "region_id");
8989 cmdline_parse_token_num_t cmd_queue_region_index =
8990 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8992 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
8993 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8994 queue_start_index, "queue_start_index");
8995 cmdline_parse_token_num_t cmd_queue_region_queue_id =
8996 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8998 cmdline_parse_token_string_t cmd_queue_region_queue_num =
8999 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9000 queue_num, "queue_num");
9001 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9002 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9003 queue_num_value, UINT8);
9005 cmdline_parse_inst_t cmd_queue_region = {
9006 .f = cmd_queue_region_parsed,
9008 .help_str = "set port <port_id> queue-region region_id <value> "
9009 "queue_start_index <value> queue_num <value>: Set a queue region",
9011 (void *)&cmd_queue_region_set,
9012 (void *)&cmd_queue_region_port,
9013 (void *)&cmd_queue_region_port_id,
9014 (void *)&cmd_queue_region_cmd,
9015 (void *)&cmd_queue_region_id,
9016 (void *)&cmd_queue_region_index,
9017 (void *)&cmd_queue_region_queue_start_index,
9018 (void *)&cmd_queue_region_queue_id,
9019 (void *)&cmd_queue_region_queue_num,
9020 (void *)&cmd_queue_region_queue_num_value,
9025 /* *** queue region and flowtype set *** */
9026 struct cmd_region_flowtype_result {
9027 cmdline_fixed_string_t set;
9028 cmdline_fixed_string_t port;
9030 cmdline_fixed_string_t cmd;
9031 cmdline_fixed_string_t region;
9033 cmdline_fixed_string_t flowtype;
9034 uint8_t flowtype_id;
9038 cmd_region_flowtype_parsed(void *parsed_result,
9039 __attribute__((unused)) struct cmdline *cl,
9040 __attribute__((unused)) void *data)
9042 struct cmd_region_flowtype_result *res = parsed_result;
9044 #ifdef RTE_LIBRTE_I40E_PMD
9045 struct rte_pmd_i40e_queue_region_conf region_conf;
9046 enum rte_pmd_i40e_queue_region_op op_type;
9049 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9052 #ifdef RTE_LIBRTE_I40E_PMD
9053 memset(®ion_conf, 0, sizeof(region_conf));
9055 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9056 region_conf.region_id = res->region_id;
9057 region_conf.hw_flowtype = res->flowtype_id;
9059 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9060 op_type, ®ion_conf);
9067 printf("function not implemented or supported\n");
9070 printf("region flowtype config error: (%s)\n", strerror(-ret));
9074 cmdline_parse_token_string_t cmd_region_flowtype_set =
9075 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9077 cmdline_parse_token_string_t cmd_region_flowtype_port =
9078 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9080 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9081 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9083 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9084 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9085 cmd, "queue-region");
9086 cmdline_parse_token_string_t cmd_region_flowtype_index =
9087 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9088 region, "region_id");
9089 cmdline_parse_token_num_t cmd_region_flowtype_id =
9090 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9092 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
9093 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9094 flowtype, "flowtype");
9095 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
9096 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9097 flowtype_id, UINT8);
9098 cmdline_parse_inst_t cmd_region_flowtype = {
9099 .f = cmd_region_flowtype_parsed,
9101 .help_str = "set port <port_id> queue-region region_id <value> "
9102 "flowtype <value>: Set a flowtype region index",
9104 (void *)&cmd_region_flowtype_set,
9105 (void *)&cmd_region_flowtype_port,
9106 (void *)&cmd_region_flowtype_port_index,
9107 (void *)&cmd_region_flowtype_cmd,
9108 (void *)&cmd_region_flowtype_index,
9109 (void *)&cmd_region_flowtype_id,
9110 (void *)&cmd_region_flowtype_flow_index,
9111 (void *)&cmd_region_flowtype_flow_id,
9116 /* *** User Priority (UP) to queue region (region_id) set *** */
9117 struct cmd_user_priority_region_result {
9118 cmdline_fixed_string_t set;
9119 cmdline_fixed_string_t port;
9121 cmdline_fixed_string_t cmd;
9122 cmdline_fixed_string_t user_priority;
9123 uint8_t user_priority_id;
9124 cmdline_fixed_string_t region;
9129 cmd_user_priority_region_parsed(void *parsed_result,
9130 __attribute__((unused)) struct cmdline *cl,
9131 __attribute__((unused)) void *data)
9133 struct cmd_user_priority_region_result *res = parsed_result;
9135 #ifdef RTE_LIBRTE_I40E_PMD
9136 struct rte_pmd_i40e_queue_region_conf region_conf;
9137 enum rte_pmd_i40e_queue_region_op op_type;
9140 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9143 #ifdef RTE_LIBRTE_I40E_PMD
9144 memset(®ion_conf, 0, sizeof(region_conf));
9145 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
9146 region_conf.user_priority = res->user_priority_id;
9147 region_conf.region_id = res->region_id;
9149 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9150 op_type, ®ion_conf);
9157 printf("function not implemented or supported\n");
9160 printf("user_priority region config error: (%s)\n",
9165 cmdline_parse_token_string_t cmd_user_priority_region_set =
9166 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9168 cmdline_parse_token_string_t cmd_user_priority_region_port =
9169 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9171 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
9172 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9174 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
9175 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9176 cmd, "queue-region");
9177 cmdline_parse_token_string_t cmd_user_priority_region_UP =
9178 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9179 user_priority, "UP");
9180 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
9181 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9182 user_priority_id, UINT8);
9183 cmdline_parse_token_string_t cmd_user_priority_region_region =
9184 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9185 region, "region_id");
9186 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
9187 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9190 cmdline_parse_inst_t cmd_user_priority_region = {
9191 .f = cmd_user_priority_region_parsed,
9193 .help_str = "set port <port_id> queue-region UP <value> "
9194 "region_id <value>: Set the mapping of User Priority (UP) "
9195 "to queue region (region_id) ",
9197 (void *)&cmd_user_priority_region_set,
9198 (void *)&cmd_user_priority_region_port,
9199 (void *)&cmd_user_priority_region_port_index,
9200 (void *)&cmd_user_priority_region_cmd,
9201 (void *)&cmd_user_priority_region_UP,
9202 (void *)&cmd_user_priority_region_UP_id,
9203 (void *)&cmd_user_priority_region_region,
9204 (void *)&cmd_user_priority_region_region_id,
9209 /* *** flush all queue region related configuration *** */
9210 struct cmd_flush_queue_region_result {
9211 cmdline_fixed_string_t set;
9212 cmdline_fixed_string_t port;
9214 cmdline_fixed_string_t cmd;
9215 cmdline_fixed_string_t flush;
9216 cmdline_fixed_string_t what;
9220 cmd_flush_queue_region_parsed(void *parsed_result,
9221 __attribute__((unused)) struct cmdline *cl,
9222 __attribute__((unused)) void *data)
9224 struct cmd_flush_queue_region_result *res = parsed_result;
9226 #ifdef RTE_LIBRTE_I40E_PMD
9227 struct rte_pmd_i40e_queue_region_conf region_conf;
9228 enum rte_pmd_i40e_queue_region_op op_type;
9231 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9234 #ifdef RTE_LIBRTE_I40E_PMD
9235 memset(®ion_conf, 0, sizeof(region_conf));
9237 if (strcmp(res->what, "on") == 0)
9238 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
9240 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
9242 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9243 op_type, ®ion_conf);
9250 printf("function not implemented or supported\n");
9253 printf("queue region config flush error: (%s)\n",
9258 cmdline_parse_token_string_t cmd_flush_queue_region_set =
9259 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9261 cmdline_parse_token_string_t cmd_flush_queue_region_port =
9262 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9264 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
9265 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
9267 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
9268 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9269 cmd, "queue-region");
9270 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
9271 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9273 cmdline_parse_token_string_t cmd_flush_queue_region_what =
9274 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9277 cmdline_parse_inst_t cmd_flush_queue_region = {
9278 .f = cmd_flush_queue_region_parsed,
9280 .help_str = "set port <port_id> queue-region flush on|off"
9281 ": flush all queue region related configuration",
9283 (void *)&cmd_flush_queue_region_set,
9284 (void *)&cmd_flush_queue_region_port,
9285 (void *)&cmd_flush_queue_region_port_index,
9286 (void *)&cmd_flush_queue_region_cmd,
9287 (void *)&cmd_flush_queue_region_flush,
9288 (void *)&cmd_flush_queue_region_what,
9293 /* *** get all queue region related configuration info *** */
9294 struct cmd_show_queue_region_info {
9295 cmdline_fixed_string_t show;
9296 cmdline_fixed_string_t port;
9298 cmdline_fixed_string_t cmd;
9302 cmd_show_queue_region_info_parsed(void *parsed_result,
9303 __attribute__((unused)) struct cmdline *cl,
9304 __attribute__((unused)) void *data)
9306 struct cmd_show_queue_region_info *res = parsed_result;
9308 #ifdef RTE_LIBRTE_I40E_PMD
9309 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
9310 enum rte_pmd_i40e_queue_region_op op_type;
9313 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9316 #ifdef RTE_LIBRTE_I40E_PMD
9317 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
9319 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
9321 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9322 op_type, &rte_pmd_regions);
9324 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
9331 printf("function not implemented or supported\n");
9334 printf("queue region config info show error: (%s)\n",
9339 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
9340 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9342 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
9343 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9345 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
9346 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
9348 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
9349 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9350 cmd, "queue-region");
9352 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
9353 .f = cmd_show_queue_region_info_parsed,
9355 .help_str = "show port <port_id> queue-region"
9356 ": show all queue region related configuration info",
9358 (void *)&cmd_show_queue_region_info_get,
9359 (void *)&cmd_show_queue_region_info_port,
9360 (void *)&cmd_show_queue_region_info_port_index,
9361 (void *)&cmd_show_queue_region_info_cmd,
9366 /* *** ADD/REMOVE A 2tuple FILTER *** */
9367 struct cmd_2tuple_filter_result {
9368 cmdline_fixed_string_t filter;
9370 cmdline_fixed_string_t ops;
9371 cmdline_fixed_string_t dst_port;
9372 uint16_t dst_port_value;
9373 cmdline_fixed_string_t protocol;
9374 uint8_t protocol_value;
9375 cmdline_fixed_string_t mask;
9377 cmdline_fixed_string_t tcp_flags;
9378 uint8_t tcp_flags_value;
9379 cmdline_fixed_string_t priority;
9380 uint8_t priority_value;
9381 cmdline_fixed_string_t queue;
9386 cmd_2tuple_filter_parsed(void *parsed_result,
9387 __attribute__((unused)) struct cmdline *cl,
9388 __attribute__((unused)) void *data)
9390 struct rte_eth_ntuple_filter filter;
9391 struct cmd_2tuple_filter_result *res = parsed_result;
9394 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9396 printf("ntuple filter is not supported on port %u.\n",
9401 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9403 filter.flags = RTE_2TUPLE_FLAGS;
9404 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9405 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9406 filter.proto = res->protocol_value;
9407 filter.priority = res->priority_value;
9408 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9409 printf("nonzero tcp_flags is only meaningful"
9410 " when protocol is TCP.\n");
9413 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9414 printf("invalid TCP flags.\n");
9418 if (res->tcp_flags_value != 0) {
9419 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9420 filter.tcp_flags = res->tcp_flags_value;
9423 /* need convert to big endian. */
9424 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9425 filter.queue = res->queue_id;
9427 if (!strcmp(res->ops, "add"))
9428 ret = rte_eth_dev_filter_ctrl(res->port_id,
9429 RTE_ETH_FILTER_NTUPLE,
9433 ret = rte_eth_dev_filter_ctrl(res->port_id,
9434 RTE_ETH_FILTER_NTUPLE,
9435 RTE_ETH_FILTER_DELETE,
9438 printf("2tuple filter programming error: (%s)\n",
9443 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
9444 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9445 filter, "2tuple_filter");
9446 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
9447 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9449 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
9450 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9452 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
9453 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9454 dst_port, "dst_port");
9455 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
9456 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9457 dst_port_value, UINT16);
9458 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
9459 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9460 protocol, "protocol");
9461 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
9462 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9463 protocol_value, UINT8);
9464 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
9465 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9467 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
9468 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9470 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
9471 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9472 tcp_flags, "tcp_flags");
9473 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
9474 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9475 tcp_flags_value, UINT8);
9476 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
9477 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9478 priority, "priority");
9479 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
9480 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9481 priority_value, UINT8);
9482 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
9483 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9485 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
9486 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9489 cmdline_parse_inst_t cmd_2tuple_filter = {
9490 .f = cmd_2tuple_filter_parsed,
9492 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
9493 "<value> mask <value> tcp_flags <value> priority <value> queue "
9494 "<queue_id>: Add a 2tuple filter",
9496 (void *)&cmd_2tuple_filter_filter,
9497 (void *)&cmd_2tuple_filter_port_id,
9498 (void *)&cmd_2tuple_filter_ops,
9499 (void *)&cmd_2tuple_filter_dst_port,
9500 (void *)&cmd_2tuple_filter_dst_port_value,
9501 (void *)&cmd_2tuple_filter_protocol,
9502 (void *)&cmd_2tuple_filter_protocol_value,
9503 (void *)&cmd_2tuple_filter_mask,
9504 (void *)&cmd_2tuple_filter_mask_value,
9505 (void *)&cmd_2tuple_filter_tcp_flags,
9506 (void *)&cmd_2tuple_filter_tcp_flags_value,
9507 (void *)&cmd_2tuple_filter_priority,
9508 (void *)&cmd_2tuple_filter_priority_value,
9509 (void *)&cmd_2tuple_filter_queue,
9510 (void *)&cmd_2tuple_filter_queue_id,
9515 /* *** ADD/REMOVE A 5tuple FILTER *** */
9516 struct cmd_5tuple_filter_result {
9517 cmdline_fixed_string_t filter;
9519 cmdline_fixed_string_t ops;
9520 cmdline_fixed_string_t dst_ip;
9521 cmdline_ipaddr_t dst_ip_value;
9522 cmdline_fixed_string_t src_ip;
9523 cmdline_ipaddr_t src_ip_value;
9524 cmdline_fixed_string_t dst_port;
9525 uint16_t dst_port_value;
9526 cmdline_fixed_string_t src_port;
9527 uint16_t src_port_value;
9528 cmdline_fixed_string_t protocol;
9529 uint8_t protocol_value;
9530 cmdline_fixed_string_t mask;
9532 cmdline_fixed_string_t tcp_flags;
9533 uint8_t tcp_flags_value;
9534 cmdline_fixed_string_t priority;
9535 uint8_t priority_value;
9536 cmdline_fixed_string_t queue;
9541 cmd_5tuple_filter_parsed(void *parsed_result,
9542 __attribute__((unused)) struct cmdline *cl,
9543 __attribute__((unused)) void *data)
9545 struct rte_eth_ntuple_filter filter;
9546 struct cmd_5tuple_filter_result *res = parsed_result;
9549 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9551 printf("ntuple filter is not supported on port %u.\n",
9556 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9558 filter.flags = RTE_5TUPLE_FLAGS;
9559 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
9560 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
9561 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
9562 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9563 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9564 filter.proto = res->protocol_value;
9565 filter.priority = res->priority_value;
9566 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9567 printf("nonzero tcp_flags is only meaningful"
9568 " when protocol is TCP.\n");
9571 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9572 printf("invalid TCP flags.\n");
9576 if (res->tcp_flags_value != 0) {
9577 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9578 filter.tcp_flags = res->tcp_flags_value;
9581 if (res->dst_ip_value.family == AF_INET)
9582 /* no need to convert, already big endian. */
9583 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
9585 if (filter.dst_ip_mask == 0) {
9586 printf("can not support ipv6 involved compare.\n");
9592 if (res->src_ip_value.family == AF_INET)
9593 /* no need to convert, already big endian. */
9594 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
9596 if (filter.src_ip_mask == 0) {
9597 printf("can not support ipv6 involved compare.\n");
9602 /* need convert to big endian. */
9603 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9604 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
9605 filter.queue = res->queue_id;
9607 if (!strcmp(res->ops, "add"))
9608 ret = rte_eth_dev_filter_ctrl(res->port_id,
9609 RTE_ETH_FILTER_NTUPLE,
9613 ret = rte_eth_dev_filter_ctrl(res->port_id,
9614 RTE_ETH_FILTER_NTUPLE,
9615 RTE_ETH_FILTER_DELETE,
9618 printf("5tuple filter programming error: (%s)\n",
9622 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
9623 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9624 filter, "5tuple_filter");
9625 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
9626 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9628 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
9629 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9631 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
9632 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9634 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
9635 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9637 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
9638 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9640 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
9641 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9643 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
9644 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9645 dst_port, "dst_port");
9646 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
9647 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9648 dst_port_value, UINT16);
9649 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
9650 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9651 src_port, "src_port");
9652 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
9653 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9654 src_port_value, UINT16);
9655 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
9656 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9657 protocol, "protocol");
9658 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
9659 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9660 protocol_value, UINT8);
9661 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
9662 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9664 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
9665 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9667 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
9668 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9669 tcp_flags, "tcp_flags");
9670 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
9671 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9672 tcp_flags_value, UINT8);
9673 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
9674 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9675 priority, "priority");
9676 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
9677 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9678 priority_value, UINT8);
9679 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
9680 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9682 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
9683 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9686 cmdline_parse_inst_t cmd_5tuple_filter = {
9687 .f = cmd_5tuple_filter_parsed,
9689 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
9690 "src_ip <value> dst_port <value> src_port <value> "
9691 "protocol <value> mask <value> tcp_flags <value> "
9692 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
9694 (void *)&cmd_5tuple_filter_filter,
9695 (void *)&cmd_5tuple_filter_port_id,
9696 (void *)&cmd_5tuple_filter_ops,
9697 (void *)&cmd_5tuple_filter_dst_ip,
9698 (void *)&cmd_5tuple_filter_dst_ip_value,
9699 (void *)&cmd_5tuple_filter_src_ip,
9700 (void *)&cmd_5tuple_filter_src_ip_value,
9701 (void *)&cmd_5tuple_filter_dst_port,
9702 (void *)&cmd_5tuple_filter_dst_port_value,
9703 (void *)&cmd_5tuple_filter_src_port,
9704 (void *)&cmd_5tuple_filter_src_port_value,
9705 (void *)&cmd_5tuple_filter_protocol,
9706 (void *)&cmd_5tuple_filter_protocol_value,
9707 (void *)&cmd_5tuple_filter_mask,
9708 (void *)&cmd_5tuple_filter_mask_value,
9709 (void *)&cmd_5tuple_filter_tcp_flags,
9710 (void *)&cmd_5tuple_filter_tcp_flags_value,
9711 (void *)&cmd_5tuple_filter_priority,
9712 (void *)&cmd_5tuple_filter_priority_value,
9713 (void *)&cmd_5tuple_filter_queue,
9714 (void *)&cmd_5tuple_filter_queue_id,
9719 /* *** ADD/REMOVE A flex FILTER *** */
9720 struct cmd_flex_filter_result {
9721 cmdline_fixed_string_t filter;
9722 cmdline_fixed_string_t ops;
9724 cmdline_fixed_string_t len;
9726 cmdline_fixed_string_t bytes;
9727 cmdline_fixed_string_t bytes_value;
9728 cmdline_fixed_string_t mask;
9729 cmdline_fixed_string_t mask_value;
9730 cmdline_fixed_string_t priority;
9731 uint8_t priority_value;
9732 cmdline_fixed_string_t queue;
9736 static int xdigit2val(unsigned char c)
9741 else if (isupper(c))
9749 cmd_flex_filter_parsed(void *parsed_result,
9750 __attribute__((unused)) struct cmdline *cl,
9751 __attribute__((unused)) void *data)
9754 struct rte_eth_flex_filter filter;
9755 struct cmd_flex_filter_result *res = parsed_result;
9756 char *bytes_ptr, *mask_ptr;
9757 uint16_t len, i, j = 0;
9762 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
9763 printf("the len exceed the max length 128\n");
9766 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
9767 filter.len = res->len_value;
9768 filter.priority = res->priority_value;
9769 filter.queue = res->queue_id;
9770 bytes_ptr = res->bytes_value;
9771 mask_ptr = res->mask_value;
9773 /* translate bytes string to array. */
9774 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
9775 (bytes_ptr[1] == 'X')))
9777 len = strnlen(bytes_ptr, res->len_value * 2);
9778 if (len == 0 || (len % 8 != 0)) {
9779 printf("please check len and bytes input\n");
9782 for (i = 0; i < len; i++) {
9784 if (isxdigit(c) == 0) {
9785 /* invalid characters. */
9786 printf("invalid input\n");
9789 val = xdigit2val(c);
9792 filter.bytes[j] = byte;
9793 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
9800 /* translate mask string to uint8_t array. */
9801 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
9802 (mask_ptr[1] == 'X')))
9804 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
9806 printf("invalid input\n");
9811 for (i = 0; i < len; i++) {
9813 if (isxdigit(c) == 0) {
9814 /* invalid characters. */
9815 printf("invalid input\n");
9818 val = xdigit2val(c);
9821 filter.mask[j] = byte;
9822 printf("mask[%d]:%02x ", j, filter.mask[j]);
9830 if (!strcmp(res->ops, "add"))
9831 ret = rte_eth_dev_filter_ctrl(res->port_id,
9832 RTE_ETH_FILTER_FLEXIBLE,
9836 ret = rte_eth_dev_filter_ctrl(res->port_id,
9837 RTE_ETH_FILTER_FLEXIBLE,
9838 RTE_ETH_FILTER_DELETE,
9842 printf("flex filter setting error: (%s)\n", strerror(-ret));
9845 cmdline_parse_token_string_t cmd_flex_filter_filter =
9846 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9847 filter, "flex_filter");
9848 cmdline_parse_token_num_t cmd_flex_filter_port_id =
9849 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9851 cmdline_parse_token_string_t cmd_flex_filter_ops =
9852 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9854 cmdline_parse_token_string_t cmd_flex_filter_len =
9855 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9857 cmdline_parse_token_num_t cmd_flex_filter_len_value =
9858 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9860 cmdline_parse_token_string_t cmd_flex_filter_bytes =
9861 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9863 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
9864 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9866 cmdline_parse_token_string_t cmd_flex_filter_mask =
9867 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9869 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
9870 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9872 cmdline_parse_token_string_t cmd_flex_filter_priority =
9873 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9874 priority, "priority");
9875 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
9876 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9877 priority_value, UINT8);
9878 cmdline_parse_token_string_t cmd_flex_filter_queue =
9879 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9881 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
9882 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9884 cmdline_parse_inst_t cmd_flex_filter = {
9885 .f = cmd_flex_filter_parsed,
9887 .help_str = "flex_filter <port_id> add|del len <value> bytes "
9888 "<value> mask <value> priority <value> queue <queue_id>: "
9889 "Add/Del a flex filter",
9891 (void *)&cmd_flex_filter_filter,
9892 (void *)&cmd_flex_filter_port_id,
9893 (void *)&cmd_flex_filter_ops,
9894 (void *)&cmd_flex_filter_len,
9895 (void *)&cmd_flex_filter_len_value,
9896 (void *)&cmd_flex_filter_bytes,
9897 (void *)&cmd_flex_filter_bytes_value,
9898 (void *)&cmd_flex_filter_mask,
9899 (void *)&cmd_flex_filter_mask_value,
9900 (void *)&cmd_flex_filter_priority,
9901 (void *)&cmd_flex_filter_priority_value,
9902 (void *)&cmd_flex_filter_queue,
9903 (void *)&cmd_flex_filter_queue_id,
9908 /* *** Filters Control *** */
9910 /* *** deal with ethertype filter *** */
9911 struct cmd_ethertype_filter_result {
9912 cmdline_fixed_string_t filter;
9914 cmdline_fixed_string_t ops;
9915 cmdline_fixed_string_t mac;
9916 struct ether_addr mac_addr;
9917 cmdline_fixed_string_t ethertype;
9918 uint16_t ethertype_value;
9919 cmdline_fixed_string_t drop;
9920 cmdline_fixed_string_t queue;
9924 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
9925 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9926 filter, "ethertype_filter");
9927 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
9928 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9930 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
9931 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9933 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
9934 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9935 mac, "mac_addr#mac_ignr");
9936 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
9937 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
9939 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
9940 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9941 ethertype, "ethertype");
9942 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
9943 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9944 ethertype_value, UINT16);
9945 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
9946 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9948 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
9949 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9951 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
9952 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9956 cmd_ethertype_filter_parsed(void *parsed_result,
9957 __attribute__((unused)) struct cmdline *cl,
9958 __attribute__((unused)) void *data)
9960 struct cmd_ethertype_filter_result *res = parsed_result;
9961 struct rte_eth_ethertype_filter filter;
9964 ret = rte_eth_dev_filter_supported(res->port_id,
9965 RTE_ETH_FILTER_ETHERTYPE);
9967 printf("ethertype filter is not supported on port %u.\n",
9972 memset(&filter, 0, sizeof(filter));
9973 if (!strcmp(res->mac, "mac_addr")) {
9974 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
9975 rte_memcpy(&filter.mac_addr, &res->mac_addr,
9976 sizeof(struct ether_addr));
9978 if (!strcmp(res->drop, "drop"))
9979 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
9980 filter.ether_type = res->ethertype_value;
9981 filter.queue = res->queue_id;
9983 if (!strcmp(res->ops, "add"))
9984 ret = rte_eth_dev_filter_ctrl(res->port_id,
9985 RTE_ETH_FILTER_ETHERTYPE,
9989 ret = rte_eth_dev_filter_ctrl(res->port_id,
9990 RTE_ETH_FILTER_ETHERTYPE,
9991 RTE_ETH_FILTER_DELETE,
9994 printf("ethertype filter programming error: (%s)\n",
9998 cmdline_parse_inst_t cmd_ethertype_filter = {
9999 .f = cmd_ethertype_filter_parsed,
10001 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
10002 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
10003 "Add or delete an ethertype filter entry",
10005 (void *)&cmd_ethertype_filter_filter,
10006 (void *)&cmd_ethertype_filter_port_id,
10007 (void *)&cmd_ethertype_filter_ops,
10008 (void *)&cmd_ethertype_filter_mac,
10009 (void *)&cmd_ethertype_filter_mac_addr,
10010 (void *)&cmd_ethertype_filter_ethertype,
10011 (void *)&cmd_ethertype_filter_ethertype_value,
10012 (void *)&cmd_ethertype_filter_drop,
10013 (void *)&cmd_ethertype_filter_queue,
10014 (void *)&cmd_ethertype_filter_queue_id,
10019 /* *** deal with flow director filter *** */
10020 struct cmd_flow_director_result {
10021 cmdline_fixed_string_t flow_director_filter;
10023 cmdline_fixed_string_t mode;
10024 cmdline_fixed_string_t mode_value;
10025 cmdline_fixed_string_t ops;
10026 cmdline_fixed_string_t flow;
10027 cmdline_fixed_string_t flow_type;
10028 cmdline_fixed_string_t ether;
10029 uint16_t ether_type;
10030 cmdline_fixed_string_t src;
10031 cmdline_ipaddr_t ip_src;
10033 cmdline_fixed_string_t dst;
10034 cmdline_ipaddr_t ip_dst;
10036 cmdline_fixed_string_t verify_tag;
10037 uint32_t verify_tag_value;
10038 cmdline_fixed_string_t tos;
10040 cmdline_fixed_string_t proto;
10041 uint8_t proto_value;
10042 cmdline_fixed_string_t ttl;
10044 cmdline_fixed_string_t vlan;
10045 uint16_t vlan_value;
10046 cmdline_fixed_string_t flexbytes;
10047 cmdline_fixed_string_t flexbytes_value;
10048 cmdline_fixed_string_t pf_vf;
10049 cmdline_fixed_string_t drop;
10050 cmdline_fixed_string_t queue;
10052 cmdline_fixed_string_t fd_id;
10053 uint32_t fd_id_value;
10054 cmdline_fixed_string_t mac;
10055 struct ether_addr mac_addr;
10056 cmdline_fixed_string_t tunnel;
10057 cmdline_fixed_string_t tunnel_type;
10058 cmdline_fixed_string_t tunnel_id;
10059 uint32_t tunnel_id_value;
10060 cmdline_fixed_string_t packet;
10065 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
10068 const char *p, *p0 = q_arg;
10070 unsigned long int_fld;
10071 char *str_fld[max_num];
10076 p = strchr(p0, '(');
10080 p0 = strchr(p, ')');
10085 if (size >= sizeof(s))
10088 snprintf(s, sizeof(s), "%.*s", size, p);
10089 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10090 if (ret < 0 || ret > max_num)
10092 for (i = 0; i < ret; i++) {
10094 int_fld = strtoul(str_fld[i], &end, 0);
10095 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
10097 flexbytes[i] = (uint8_t)int_fld;
10103 str2flowtype(char *string)
10106 static const struct {
10109 } flowtype_str[] = {
10110 {"raw", RTE_ETH_FLOW_RAW},
10111 {"ipv4", RTE_ETH_FLOW_IPV4},
10112 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10113 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10114 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10115 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10116 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10117 {"ipv6", RTE_ETH_FLOW_IPV6},
10118 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10119 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10120 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10121 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10122 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10123 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10126 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10127 if (!strcmp(flowtype_str[i].str, string))
10128 return flowtype_str[i].type;
10131 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10132 return (uint16_t)atoi(string);
10134 return RTE_ETH_FLOW_UNKNOWN;
10137 static enum rte_eth_fdir_tunnel_type
10138 str2fdir_tunneltype(char *string)
10142 static const struct {
10144 enum rte_eth_fdir_tunnel_type type;
10145 } tunneltype_str[] = {
10146 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
10147 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
10150 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
10151 if (!strcmp(tunneltype_str[i].str, string))
10152 return tunneltype_str[i].type;
10154 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
10157 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10159 if ((ip_addr).family == AF_INET) \
10160 (ip) = (ip_addr).addr.ipv4.s_addr; \
10162 printf("invalid parameter.\n"); \
10167 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10169 if ((ip_addr).family == AF_INET6) \
10170 rte_memcpy(&(ip), \
10171 &((ip_addr).addr.ipv6), \
10172 sizeof(struct in6_addr)); \
10174 printf("invalid parameter.\n"); \
10180 cmd_flow_director_filter_parsed(void *parsed_result,
10181 __attribute__((unused)) struct cmdline *cl,
10182 __attribute__((unused)) void *data)
10184 struct cmd_flow_director_result *res = parsed_result;
10185 struct rte_eth_fdir_filter entry;
10186 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
10188 unsigned long vf_id;
10191 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10193 printf("flow director is not supported on port %u.\n",
10197 memset(flexbytes, 0, sizeof(flexbytes));
10198 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
10200 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10201 if (strcmp(res->mode_value, "MAC-VLAN")) {
10202 printf("Please set mode to MAC-VLAN.\n");
10205 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10206 if (strcmp(res->mode_value, "Tunnel")) {
10207 printf("Please set mode to Tunnel.\n");
10211 if (!strcmp(res->mode_value, "raw")) {
10212 #ifdef RTE_LIBRTE_I40E_PMD
10213 struct rte_pmd_i40e_flow_type_mapping
10214 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10215 struct rte_pmd_i40e_pkt_template_conf conf;
10216 uint16_t flow_type = str2flowtype(res->flow_type);
10217 uint16_t i, port = res->port_id;
10220 memset(&conf, 0, sizeof(conf));
10222 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10223 printf("Invalid flow type specified.\n");
10226 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10230 if (mapping[flow_type].pctype == 0ULL) {
10231 printf("Invalid flow type specified.\n");
10234 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10235 if (mapping[flow_type].pctype & (1ULL << i)) {
10236 conf.input.pctype = i;
10241 conf.input.packet = open_file(res->filepath,
10242 &conf.input.length);
10243 if (!conf.input.packet)
10245 if (!strcmp(res->drop, "drop"))
10246 conf.action.behavior =
10247 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10249 conf.action.behavior =
10250 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10251 conf.action.report_status =
10252 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10253 conf.action.rx_queue = res->queue_id;
10254 conf.soft_id = res->fd_id_value;
10255 add = strcmp(res->ops, "del") ? 1 : 0;
10256 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10260 printf("flow director config error: (%s)\n",
10262 close_file(conf.input.packet);
10265 } else if (strcmp(res->mode_value, "IP")) {
10266 printf("Please set mode to IP or raw.\n");
10269 entry.input.flow_type = str2flowtype(res->flow_type);
10272 ret = parse_flexbytes(res->flexbytes_value,
10274 RTE_ETH_FDIR_MAX_FLEXLEN);
10276 printf("error: Cannot parse flexbytes input.\n");
10280 switch (entry.input.flow_type) {
10281 case RTE_ETH_FLOW_FRAG_IPV4:
10282 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
10283 entry.input.flow.ip4_flow.proto = res->proto_value;
10285 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
10286 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
10287 IPV4_ADDR_TO_UINT(res->ip_dst,
10288 entry.input.flow.ip4_flow.dst_ip);
10289 IPV4_ADDR_TO_UINT(res->ip_src,
10290 entry.input.flow.ip4_flow.src_ip);
10291 entry.input.flow.ip4_flow.tos = res->tos_value;
10292 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10293 /* need convert to big endian. */
10294 entry.input.flow.udp4_flow.dst_port =
10295 rte_cpu_to_be_16(res->port_dst);
10296 entry.input.flow.udp4_flow.src_port =
10297 rte_cpu_to_be_16(res->port_src);
10299 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
10300 IPV4_ADDR_TO_UINT(res->ip_dst,
10301 entry.input.flow.sctp4_flow.ip.dst_ip);
10302 IPV4_ADDR_TO_UINT(res->ip_src,
10303 entry.input.flow.sctp4_flow.ip.src_ip);
10304 entry.input.flow.ip4_flow.tos = res->tos_value;
10305 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10306 /* need convert to big endian. */
10307 entry.input.flow.sctp4_flow.dst_port =
10308 rte_cpu_to_be_16(res->port_dst);
10309 entry.input.flow.sctp4_flow.src_port =
10310 rte_cpu_to_be_16(res->port_src);
10311 entry.input.flow.sctp4_flow.verify_tag =
10312 rte_cpu_to_be_32(res->verify_tag_value);
10314 case RTE_ETH_FLOW_FRAG_IPV6:
10315 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
10316 entry.input.flow.ipv6_flow.proto = res->proto_value;
10318 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
10319 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
10320 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10321 entry.input.flow.ipv6_flow.dst_ip);
10322 IPV6_ADDR_TO_ARRAY(res->ip_src,
10323 entry.input.flow.ipv6_flow.src_ip);
10324 entry.input.flow.ipv6_flow.tc = res->tos_value;
10325 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10326 /* need convert to big endian. */
10327 entry.input.flow.udp6_flow.dst_port =
10328 rte_cpu_to_be_16(res->port_dst);
10329 entry.input.flow.udp6_flow.src_port =
10330 rte_cpu_to_be_16(res->port_src);
10332 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
10333 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10334 entry.input.flow.sctp6_flow.ip.dst_ip);
10335 IPV6_ADDR_TO_ARRAY(res->ip_src,
10336 entry.input.flow.sctp6_flow.ip.src_ip);
10337 entry.input.flow.ipv6_flow.tc = res->tos_value;
10338 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10339 /* need convert to big endian. */
10340 entry.input.flow.sctp6_flow.dst_port =
10341 rte_cpu_to_be_16(res->port_dst);
10342 entry.input.flow.sctp6_flow.src_port =
10343 rte_cpu_to_be_16(res->port_src);
10344 entry.input.flow.sctp6_flow.verify_tag =
10345 rte_cpu_to_be_32(res->verify_tag_value);
10347 case RTE_ETH_FLOW_L2_PAYLOAD:
10348 entry.input.flow.l2_flow.ether_type =
10349 rte_cpu_to_be_16(res->ether_type);
10355 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
10356 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
10358 sizeof(struct ether_addr));
10360 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10361 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
10363 sizeof(struct ether_addr));
10364 entry.input.flow.tunnel_flow.tunnel_type =
10365 str2fdir_tunneltype(res->tunnel_type);
10366 entry.input.flow.tunnel_flow.tunnel_id =
10367 rte_cpu_to_be_32(res->tunnel_id_value);
10370 rte_memcpy(entry.input.flow_ext.flexbytes,
10372 RTE_ETH_FDIR_MAX_FLEXLEN);
10374 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
10376 entry.action.flex_off = 0; /*use 0 by default */
10377 if (!strcmp(res->drop, "drop"))
10378 entry.action.behavior = RTE_ETH_FDIR_REJECT;
10380 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
10382 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
10383 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
10384 if (!strcmp(res->pf_vf, "pf"))
10385 entry.input.flow_ext.is_vf = 0;
10386 else if (!strncmp(res->pf_vf, "vf", 2)) {
10387 struct rte_eth_dev_info dev_info;
10389 memset(&dev_info, 0, sizeof(dev_info));
10390 rte_eth_dev_info_get(res->port_id, &dev_info);
10392 vf_id = strtoul(res->pf_vf + 2, &end, 10);
10393 if (errno != 0 || *end != '\0' ||
10394 vf_id >= dev_info.max_vfs) {
10395 printf("invalid parameter %s.\n", res->pf_vf);
10398 entry.input.flow_ext.is_vf = 1;
10399 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
10401 printf("invalid parameter %s.\n", res->pf_vf);
10406 /* set to report FD ID by default */
10407 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
10408 entry.action.rx_queue = res->queue_id;
10409 entry.soft_id = res->fd_id_value;
10410 if (!strcmp(res->ops, "add"))
10411 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10412 RTE_ETH_FILTER_ADD, &entry);
10413 else if (!strcmp(res->ops, "del"))
10414 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10415 RTE_ETH_FILTER_DELETE, &entry);
10417 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10418 RTE_ETH_FILTER_UPDATE, &entry);
10420 printf("flow director programming error: (%s)\n",
10424 cmdline_parse_token_string_t cmd_flow_director_filter =
10425 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10426 flow_director_filter, "flow_director_filter");
10427 cmdline_parse_token_num_t cmd_flow_director_port_id =
10428 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10430 cmdline_parse_token_string_t cmd_flow_director_ops =
10431 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10432 ops, "add#del#update");
10433 cmdline_parse_token_string_t cmd_flow_director_flow =
10434 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10436 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10437 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10439 cmdline_parse_token_string_t cmd_flow_director_ether =
10440 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10442 cmdline_parse_token_num_t cmd_flow_director_ether_type =
10443 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10444 ether_type, UINT16);
10445 cmdline_parse_token_string_t cmd_flow_director_src =
10446 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10448 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
10449 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10451 cmdline_parse_token_num_t cmd_flow_director_port_src =
10452 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10454 cmdline_parse_token_string_t cmd_flow_director_dst =
10455 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10457 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
10458 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10460 cmdline_parse_token_num_t cmd_flow_director_port_dst =
10461 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10463 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
10464 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10465 verify_tag, "verify_tag");
10466 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
10467 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10468 verify_tag_value, UINT32);
10469 cmdline_parse_token_string_t cmd_flow_director_tos =
10470 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10472 cmdline_parse_token_num_t cmd_flow_director_tos_value =
10473 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10475 cmdline_parse_token_string_t cmd_flow_director_proto =
10476 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10478 cmdline_parse_token_num_t cmd_flow_director_proto_value =
10479 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10480 proto_value, UINT8);
10481 cmdline_parse_token_string_t cmd_flow_director_ttl =
10482 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10484 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
10485 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10487 cmdline_parse_token_string_t cmd_flow_director_vlan =
10488 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10490 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
10491 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10492 vlan_value, UINT16);
10493 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
10494 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10495 flexbytes, "flexbytes");
10496 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
10497 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10498 flexbytes_value, NULL);
10499 cmdline_parse_token_string_t cmd_flow_director_drop =
10500 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10502 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
10503 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10505 cmdline_parse_token_string_t cmd_flow_director_queue =
10506 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10508 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10509 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10511 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10512 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10514 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10515 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10516 fd_id_value, UINT32);
10518 cmdline_parse_token_string_t cmd_flow_director_mode =
10519 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10521 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
10522 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10524 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
10525 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10526 mode_value, "MAC-VLAN");
10527 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
10528 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10529 mode_value, "Tunnel");
10530 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
10531 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10532 mode_value, "raw");
10533 cmdline_parse_token_string_t cmd_flow_director_mac =
10534 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10536 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
10537 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
10539 cmdline_parse_token_string_t cmd_flow_director_tunnel =
10540 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10542 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
10543 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10544 tunnel_type, "NVGRE#VxLAN");
10545 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
10546 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10547 tunnel_id, "tunnel-id");
10548 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
10549 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10550 tunnel_id_value, UINT32);
10551 cmdline_parse_token_string_t cmd_flow_director_packet =
10552 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10554 cmdline_parse_token_string_t cmd_flow_director_filepath =
10555 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10558 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
10559 .f = cmd_flow_director_filter_parsed,
10561 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
10562 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
10563 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
10564 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
10565 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
10566 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
10567 "fd_id <fd_id_value>: "
10568 "Add or delete an ip flow director entry on NIC",
10570 (void *)&cmd_flow_director_filter,
10571 (void *)&cmd_flow_director_port_id,
10572 (void *)&cmd_flow_director_mode,
10573 (void *)&cmd_flow_director_mode_ip,
10574 (void *)&cmd_flow_director_ops,
10575 (void *)&cmd_flow_director_flow,
10576 (void *)&cmd_flow_director_flow_type,
10577 (void *)&cmd_flow_director_src,
10578 (void *)&cmd_flow_director_ip_src,
10579 (void *)&cmd_flow_director_dst,
10580 (void *)&cmd_flow_director_ip_dst,
10581 (void *)&cmd_flow_director_tos,
10582 (void *)&cmd_flow_director_tos_value,
10583 (void *)&cmd_flow_director_proto,
10584 (void *)&cmd_flow_director_proto_value,
10585 (void *)&cmd_flow_director_ttl,
10586 (void *)&cmd_flow_director_ttl_value,
10587 (void *)&cmd_flow_director_vlan,
10588 (void *)&cmd_flow_director_vlan_value,
10589 (void *)&cmd_flow_director_flexbytes,
10590 (void *)&cmd_flow_director_flexbytes_value,
10591 (void *)&cmd_flow_director_drop,
10592 (void *)&cmd_flow_director_pf_vf,
10593 (void *)&cmd_flow_director_queue,
10594 (void *)&cmd_flow_director_queue_id,
10595 (void *)&cmd_flow_director_fd_id,
10596 (void *)&cmd_flow_director_fd_id_value,
10601 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
10602 .f = cmd_flow_director_filter_parsed,
10604 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
10605 "director entry on NIC",
10607 (void *)&cmd_flow_director_filter,
10608 (void *)&cmd_flow_director_port_id,
10609 (void *)&cmd_flow_director_mode,
10610 (void *)&cmd_flow_director_mode_ip,
10611 (void *)&cmd_flow_director_ops,
10612 (void *)&cmd_flow_director_flow,
10613 (void *)&cmd_flow_director_flow_type,
10614 (void *)&cmd_flow_director_src,
10615 (void *)&cmd_flow_director_ip_src,
10616 (void *)&cmd_flow_director_port_src,
10617 (void *)&cmd_flow_director_dst,
10618 (void *)&cmd_flow_director_ip_dst,
10619 (void *)&cmd_flow_director_port_dst,
10620 (void *)&cmd_flow_director_tos,
10621 (void *)&cmd_flow_director_tos_value,
10622 (void *)&cmd_flow_director_ttl,
10623 (void *)&cmd_flow_director_ttl_value,
10624 (void *)&cmd_flow_director_vlan,
10625 (void *)&cmd_flow_director_vlan_value,
10626 (void *)&cmd_flow_director_flexbytes,
10627 (void *)&cmd_flow_director_flexbytes_value,
10628 (void *)&cmd_flow_director_drop,
10629 (void *)&cmd_flow_director_pf_vf,
10630 (void *)&cmd_flow_director_queue,
10631 (void *)&cmd_flow_director_queue_id,
10632 (void *)&cmd_flow_director_fd_id,
10633 (void *)&cmd_flow_director_fd_id_value,
10638 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
10639 .f = cmd_flow_director_filter_parsed,
10641 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
10642 "director entry on NIC",
10644 (void *)&cmd_flow_director_filter,
10645 (void *)&cmd_flow_director_port_id,
10646 (void *)&cmd_flow_director_mode,
10647 (void *)&cmd_flow_director_mode_ip,
10648 (void *)&cmd_flow_director_ops,
10649 (void *)&cmd_flow_director_flow,
10650 (void *)&cmd_flow_director_flow_type,
10651 (void *)&cmd_flow_director_src,
10652 (void *)&cmd_flow_director_ip_src,
10653 (void *)&cmd_flow_director_port_src,
10654 (void *)&cmd_flow_director_dst,
10655 (void *)&cmd_flow_director_ip_dst,
10656 (void *)&cmd_flow_director_port_dst,
10657 (void *)&cmd_flow_director_verify_tag,
10658 (void *)&cmd_flow_director_verify_tag_value,
10659 (void *)&cmd_flow_director_tos,
10660 (void *)&cmd_flow_director_tos_value,
10661 (void *)&cmd_flow_director_ttl,
10662 (void *)&cmd_flow_director_ttl_value,
10663 (void *)&cmd_flow_director_vlan,
10664 (void *)&cmd_flow_director_vlan_value,
10665 (void *)&cmd_flow_director_flexbytes,
10666 (void *)&cmd_flow_director_flexbytes_value,
10667 (void *)&cmd_flow_director_drop,
10668 (void *)&cmd_flow_director_pf_vf,
10669 (void *)&cmd_flow_director_queue,
10670 (void *)&cmd_flow_director_queue_id,
10671 (void *)&cmd_flow_director_fd_id,
10672 (void *)&cmd_flow_director_fd_id_value,
10677 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
10678 .f = cmd_flow_director_filter_parsed,
10680 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
10681 "director entry on NIC",
10683 (void *)&cmd_flow_director_filter,
10684 (void *)&cmd_flow_director_port_id,
10685 (void *)&cmd_flow_director_mode,
10686 (void *)&cmd_flow_director_mode_ip,
10687 (void *)&cmd_flow_director_ops,
10688 (void *)&cmd_flow_director_flow,
10689 (void *)&cmd_flow_director_flow_type,
10690 (void *)&cmd_flow_director_ether,
10691 (void *)&cmd_flow_director_ether_type,
10692 (void *)&cmd_flow_director_flexbytes,
10693 (void *)&cmd_flow_director_flexbytes_value,
10694 (void *)&cmd_flow_director_drop,
10695 (void *)&cmd_flow_director_pf_vf,
10696 (void *)&cmd_flow_director_queue,
10697 (void *)&cmd_flow_director_queue_id,
10698 (void *)&cmd_flow_director_fd_id,
10699 (void *)&cmd_flow_director_fd_id_value,
10704 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
10705 .f = cmd_flow_director_filter_parsed,
10707 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
10708 "director entry on NIC",
10710 (void *)&cmd_flow_director_filter,
10711 (void *)&cmd_flow_director_port_id,
10712 (void *)&cmd_flow_director_mode,
10713 (void *)&cmd_flow_director_mode_mac_vlan,
10714 (void *)&cmd_flow_director_ops,
10715 (void *)&cmd_flow_director_mac,
10716 (void *)&cmd_flow_director_mac_addr,
10717 (void *)&cmd_flow_director_vlan,
10718 (void *)&cmd_flow_director_vlan_value,
10719 (void *)&cmd_flow_director_flexbytes,
10720 (void *)&cmd_flow_director_flexbytes_value,
10721 (void *)&cmd_flow_director_drop,
10722 (void *)&cmd_flow_director_queue,
10723 (void *)&cmd_flow_director_queue_id,
10724 (void *)&cmd_flow_director_fd_id,
10725 (void *)&cmd_flow_director_fd_id_value,
10730 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
10731 .f = cmd_flow_director_filter_parsed,
10733 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
10734 "director entry on NIC",
10736 (void *)&cmd_flow_director_filter,
10737 (void *)&cmd_flow_director_port_id,
10738 (void *)&cmd_flow_director_mode,
10739 (void *)&cmd_flow_director_mode_tunnel,
10740 (void *)&cmd_flow_director_ops,
10741 (void *)&cmd_flow_director_mac,
10742 (void *)&cmd_flow_director_mac_addr,
10743 (void *)&cmd_flow_director_vlan,
10744 (void *)&cmd_flow_director_vlan_value,
10745 (void *)&cmd_flow_director_tunnel,
10746 (void *)&cmd_flow_director_tunnel_type,
10747 (void *)&cmd_flow_director_tunnel_id,
10748 (void *)&cmd_flow_director_tunnel_id_value,
10749 (void *)&cmd_flow_director_flexbytes,
10750 (void *)&cmd_flow_director_flexbytes_value,
10751 (void *)&cmd_flow_director_drop,
10752 (void *)&cmd_flow_director_queue,
10753 (void *)&cmd_flow_director_queue_id,
10754 (void *)&cmd_flow_director_fd_id,
10755 (void *)&cmd_flow_director_fd_id_value,
10760 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
10761 .f = cmd_flow_director_filter_parsed,
10763 .help_str = "flow_director_filter ... : Add or delete a raw flow "
10764 "director entry on NIC",
10766 (void *)&cmd_flow_director_filter,
10767 (void *)&cmd_flow_director_port_id,
10768 (void *)&cmd_flow_director_mode,
10769 (void *)&cmd_flow_director_mode_raw,
10770 (void *)&cmd_flow_director_ops,
10771 (void *)&cmd_flow_director_flow,
10772 (void *)&cmd_flow_director_flow_type,
10773 (void *)&cmd_flow_director_drop,
10774 (void *)&cmd_flow_director_queue,
10775 (void *)&cmd_flow_director_queue_id,
10776 (void *)&cmd_flow_director_fd_id,
10777 (void *)&cmd_flow_director_fd_id_value,
10778 (void *)&cmd_flow_director_packet,
10779 (void *)&cmd_flow_director_filepath,
10784 struct cmd_flush_flow_director_result {
10785 cmdline_fixed_string_t flush_flow_director;
10789 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
10790 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
10791 flush_flow_director, "flush_flow_director");
10792 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
10793 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
10797 cmd_flush_flow_director_parsed(void *parsed_result,
10798 __attribute__((unused)) struct cmdline *cl,
10799 __attribute__((unused)) void *data)
10801 struct cmd_flow_director_result *res = parsed_result;
10804 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10806 printf("flow director is not supported on port %u.\n",
10811 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10812 RTE_ETH_FILTER_FLUSH, NULL);
10814 printf("flow director table flushing error: (%s)\n",
10818 cmdline_parse_inst_t cmd_flush_flow_director = {
10819 .f = cmd_flush_flow_director_parsed,
10821 .help_str = "flush_flow_director <port_id>: "
10822 "Flush all flow director entries of a device on NIC",
10824 (void *)&cmd_flush_flow_director_flush,
10825 (void *)&cmd_flush_flow_director_port_id,
10830 /* *** deal with flow director mask *** */
10831 struct cmd_flow_director_mask_result {
10832 cmdline_fixed_string_t flow_director_mask;
10834 cmdline_fixed_string_t mode;
10835 cmdline_fixed_string_t mode_value;
10836 cmdline_fixed_string_t vlan;
10837 uint16_t vlan_mask;
10838 cmdline_fixed_string_t src_mask;
10839 cmdline_ipaddr_t ipv4_src;
10840 cmdline_ipaddr_t ipv6_src;
10842 cmdline_fixed_string_t dst_mask;
10843 cmdline_ipaddr_t ipv4_dst;
10844 cmdline_ipaddr_t ipv6_dst;
10846 cmdline_fixed_string_t mac;
10847 uint8_t mac_addr_byte_mask;
10848 cmdline_fixed_string_t tunnel_id;
10849 uint32_t tunnel_id_mask;
10850 cmdline_fixed_string_t tunnel_type;
10851 uint8_t tunnel_type_mask;
10855 cmd_flow_director_mask_parsed(void *parsed_result,
10856 __attribute__((unused)) struct cmdline *cl,
10857 __attribute__((unused)) void *data)
10859 struct cmd_flow_director_mask_result *res = parsed_result;
10860 struct rte_eth_fdir_masks *mask;
10861 struct rte_port *port;
10863 port = &ports[res->port_id];
10864 /** Check if the port is not started **/
10865 if (port->port_status != RTE_PORT_STOPPED) {
10866 printf("Please stop port %d first\n", res->port_id);
10870 mask = &port->dev_conf.fdir_conf.mask;
10872 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10873 if (strcmp(res->mode_value, "MAC-VLAN")) {
10874 printf("Please set mode to MAC-VLAN.\n");
10878 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10879 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10880 if (strcmp(res->mode_value, "Tunnel")) {
10881 printf("Please set mode to Tunnel.\n");
10885 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10886 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
10887 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
10888 mask->tunnel_type_mask = res->tunnel_type_mask;
10890 if (strcmp(res->mode_value, "IP")) {
10891 printf("Please set mode to IP.\n");
10895 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10896 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
10897 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
10898 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
10899 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
10900 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
10901 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
10904 cmd_reconfig_device_queue(res->port_id, 1, 1);
10907 cmdline_parse_token_string_t cmd_flow_director_mask =
10908 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10909 flow_director_mask, "flow_director_mask");
10910 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
10911 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10913 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
10914 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10916 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
10917 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10918 vlan_mask, UINT16);
10919 cmdline_parse_token_string_t cmd_flow_director_mask_src =
10920 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10921 src_mask, "src_mask");
10922 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
10923 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10925 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
10926 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10928 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
10929 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10931 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
10932 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10933 dst_mask, "dst_mask");
10934 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
10935 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10937 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
10938 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10940 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
10941 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10944 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
10945 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10947 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
10948 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10950 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
10951 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10952 mode_value, "MAC-VLAN");
10953 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
10954 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10955 mode_value, "Tunnel");
10956 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
10957 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10959 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
10960 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10961 mac_addr_byte_mask, UINT8);
10962 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
10963 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10964 tunnel_type, "tunnel-type");
10965 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
10966 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10967 tunnel_type_mask, UINT8);
10968 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
10969 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10970 tunnel_id, "tunnel-id");
10971 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
10972 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10973 tunnel_id_mask, UINT32);
10975 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
10976 .f = cmd_flow_director_mask_parsed,
10978 .help_str = "flow_director_mask ... : "
10979 "Set IP mode flow director's mask on NIC",
10981 (void *)&cmd_flow_director_mask,
10982 (void *)&cmd_flow_director_mask_port_id,
10983 (void *)&cmd_flow_director_mask_mode,
10984 (void *)&cmd_flow_director_mask_mode_ip,
10985 (void *)&cmd_flow_director_mask_vlan,
10986 (void *)&cmd_flow_director_mask_vlan_value,
10987 (void *)&cmd_flow_director_mask_src,
10988 (void *)&cmd_flow_director_mask_ipv4_src,
10989 (void *)&cmd_flow_director_mask_ipv6_src,
10990 (void *)&cmd_flow_director_mask_port_src,
10991 (void *)&cmd_flow_director_mask_dst,
10992 (void *)&cmd_flow_director_mask_ipv4_dst,
10993 (void *)&cmd_flow_director_mask_ipv6_dst,
10994 (void *)&cmd_flow_director_mask_port_dst,
10999 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
11000 .f = cmd_flow_director_mask_parsed,
11002 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
11003 "flow director's mask on NIC",
11005 (void *)&cmd_flow_director_mask,
11006 (void *)&cmd_flow_director_mask_port_id,
11007 (void *)&cmd_flow_director_mask_mode,
11008 (void *)&cmd_flow_director_mask_mode_mac_vlan,
11009 (void *)&cmd_flow_director_mask_vlan,
11010 (void *)&cmd_flow_director_mask_vlan_value,
11015 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
11016 .f = cmd_flow_director_mask_parsed,
11018 .help_str = "flow_director_mask ... : Set tunnel mode "
11019 "flow director's mask on NIC",
11021 (void *)&cmd_flow_director_mask,
11022 (void *)&cmd_flow_director_mask_port_id,
11023 (void *)&cmd_flow_director_mask_mode,
11024 (void *)&cmd_flow_director_mask_mode_tunnel,
11025 (void *)&cmd_flow_director_mask_vlan,
11026 (void *)&cmd_flow_director_mask_vlan_value,
11027 (void *)&cmd_flow_director_mask_mac,
11028 (void *)&cmd_flow_director_mask_mac_value,
11029 (void *)&cmd_flow_director_mask_tunnel_type,
11030 (void *)&cmd_flow_director_mask_tunnel_type_value,
11031 (void *)&cmd_flow_director_mask_tunnel_id,
11032 (void *)&cmd_flow_director_mask_tunnel_id_value,
11037 /* *** deal with flow director mask on flexible payload *** */
11038 struct cmd_flow_director_flex_mask_result {
11039 cmdline_fixed_string_t flow_director_flexmask;
11041 cmdline_fixed_string_t flow;
11042 cmdline_fixed_string_t flow_type;
11043 cmdline_fixed_string_t mask;
11047 cmd_flow_director_flex_mask_parsed(void *parsed_result,
11048 __attribute__((unused)) struct cmdline *cl,
11049 __attribute__((unused)) void *data)
11051 struct cmd_flow_director_flex_mask_result *res = parsed_result;
11052 struct rte_eth_fdir_info fdir_info;
11053 struct rte_eth_fdir_flex_mask flex_mask;
11054 struct rte_port *port;
11055 uint64_t flow_type_mask;
11059 port = &ports[res->port_id];
11060 /** Check if the port is not started **/
11061 if (port->port_status != RTE_PORT_STOPPED) {
11062 printf("Please stop port %d first\n", res->port_id);
11066 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
11067 ret = parse_flexbytes(res->mask,
11069 RTE_ETH_FDIR_MAX_FLEXLEN);
11071 printf("error: Cannot parse mask input.\n");
11075 memset(&fdir_info, 0, sizeof(fdir_info));
11076 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11077 RTE_ETH_FILTER_INFO, &fdir_info);
11079 printf("Cannot get FDir filter info\n");
11083 if (!strcmp(res->flow_type, "none")) {
11084 /* means don't specify the flow type */
11085 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
11086 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
11087 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
11088 0, sizeof(struct rte_eth_fdir_flex_mask));
11089 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
11090 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
11092 sizeof(struct rte_eth_fdir_flex_mask));
11093 cmd_reconfig_device_queue(res->port_id, 1, 1);
11096 flow_type_mask = fdir_info.flow_types_mask[0];
11097 if (!strcmp(res->flow_type, "all")) {
11098 if (!flow_type_mask) {
11099 printf("No flow type supported\n");
11102 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
11103 if (flow_type_mask & (1ULL << i)) {
11104 flex_mask.flow_type = i;
11105 fdir_set_flex_mask(res->port_id, &flex_mask);
11108 cmd_reconfig_device_queue(res->port_id, 1, 1);
11111 flex_mask.flow_type = str2flowtype(res->flow_type);
11112 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
11113 printf("Flow type %s not supported on port %d\n",
11114 res->flow_type, res->port_id);
11117 fdir_set_flex_mask(res->port_id, &flex_mask);
11118 cmd_reconfig_device_queue(res->port_id, 1, 1);
11121 cmdline_parse_token_string_t cmd_flow_director_flexmask =
11122 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11123 flow_director_flexmask,
11124 "flow_director_flex_mask");
11125 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
11126 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11128 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
11129 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11131 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
11132 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11133 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
11134 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
11135 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
11136 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11139 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
11140 .f = cmd_flow_director_flex_mask_parsed,
11142 .help_str = "flow_director_flex_mask ... : "
11143 "Set flow director's flex mask on NIC",
11145 (void *)&cmd_flow_director_flexmask,
11146 (void *)&cmd_flow_director_flexmask_port_id,
11147 (void *)&cmd_flow_director_flexmask_flow,
11148 (void *)&cmd_flow_director_flexmask_flow_type,
11149 (void *)&cmd_flow_director_flexmask_mask,
11154 /* *** deal with flow director flexible payload configuration *** */
11155 struct cmd_flow_director_flexpayload_result {
11156 cmdline_fixed_string_t flow_director_flexpayload;
11158 cmdline_fixed_string_t payload_layer;
11159 cmdline_fixed_string_t payload_cfg;
11163 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
11166 const char *p, *p0 = q_arg;
11168 unsigned long int_fld;
11169 char *str_fld[max_num];
11174 p = strchr(p0, '(');
11178 p0 = strchr(p, ')');
11183 if (size >= sizeof(s))
11186 snprintf(s, sizeof(s), "%.*s", size, p);
11187 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
11188 if (ret < 0 || ret > max_num)
11190 for (i = 0; i < ret; i++) {
11192 int_fld = strtoul(str_fld[i], &end, 0);
11193 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
11195 offsets[i] = (uint16_t)int_fld;
11201 cmd_flow_director_flxpld_parsed(void *parsed_result,
11202 __attribute__((unused)) struct cmdline *cl,
11203 __attribute__((unused)) void *data)
11205 struct cmd_flow_director_flexpayload_result *res = parsed_result;
11206 struct rte_eth_flex_payload_cfg flex_cfg;
11207 struct rte_port *port;
11210 port = &ports[res->port_id];
11211 /** Check if the port is not started **/
11212 if (port->port_status != RTE_PORT_STOPPED) {
11213 printf("Please stop port %d first\n", res->port_id);
11217 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
11219 if (!strcmp(res->payload_layer, "raw"))
11220 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
11221 else if (!strcmp(res->payload_layer, "l2"))
11222 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
11223 else if (!strcmp(res->payload_layer, "l3"))
11224 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
11225 else if (!strcmp(res->payload_layer, "l4"))
11226 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
11228 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
11229 RTE_ETH_FDIR_MAX_FLEXLEN);
11231 printf("error: Cannot parse flex payload input.\n");
11235 fdir_set_flex_payload(res->port_id, &flex_cfg);
11236 cmd_reconfig_device_queue(res->port_id, 1, 1);
11239 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
11240 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11241 flow_director_flexpayload,
11242 "flow_director_flex_payload");
11243 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
11244 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11246 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
11247 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11248 payload_layer, "raw#l2#l3#l4");
11249 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
11250 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11251 payload_cfg, NULL);
11253 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
11254 .f = cmd_flow_director_flxpld_parsed,
11256 .help_str = "flow_director_flexpayload ... : "
11257 "Set flow director's flex payload on NIC",
11259 (void *)&cmd_flow_director_flexpayload,
11260 (void *)&cmd_flow_director_flexpayload_port_id,
11261 (void *)&cmd_flow_director_flexpayload_payload_layer,
11262 (void *)&cmd_flow_director_flexpayload_payload_cfg,
11267 /* Generic flow interface command. */
11268 extern cmdline_parse_inst_t cmd_flow;
11270 /* *** Classification Filters Control *** */
11271 /* *** Get symmetric hash enable per port *** */
11272 struct cmd_get_sym_hash_ena_per_port_result {
11273 cmdline_fixed_string_t get_sym_hash_ena_per_port;
11278 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
11279 __rte_unused struct cmdline *cl,
11280 __rte_unused void *data)
11282 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
11283 struct rte_eth_hash_filter_info info;
11286 if (rte_eth_dev_filter_supported(res->port_id,
11287 RTE_ETH_FILTER_HASH) < 0) {
11288 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11293 memset(&info, 0, sizeof(info));
11294 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11295 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11296 RTE_ETH_FILTER_GET, &info);
11299 printf("Cannot get symmetric hash enable per port "
11300 "on port %u\n", res->port_id);
11304 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
11305 "enabled" : "disabled", res->port_id);
11308 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
11309 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11310 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
11311 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
11312 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11315 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
11316 .f = cmd_get_sym_hash_per_port_parsed,
11318 .help_str = "get_sym_hash_ena_per_port <port_id>",
11320 (void *)&cmd_get_sym_hash_ena_per_port_all,
11321 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
11326 /* *** Set symmetric hash enable per port *** */
11327 struct cmd_set_sym_hash_ena_per_port_result {
11328 cmdline_fixed_string_t set_sym_hash_ena_per_port;
11329 cmdline_fixed_string_t enable;
11334 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
11335 __rte_unused struct cmdline *cl,
11336 __rte_unused void *data)
11338 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
11339 struct rte_eth_hash_filter_info info;
11342 if (rte_eth_dev_filter_supported(res->port_id,
11343 RTE_ETH_FILTER_HASH) < 0) {
11344 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11349 memset(&info, 0, sizeof(info));
11350 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11351 if (!strcmp(res->enable, "enable"))
11352 info.info.enable = 1;
11353 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11354 RTE_ETH_FILTER_SET, &info);
11356 printf("Cannot set symmetric hash enable per port on "
11357 "port %u\n", res->port_id);
11360 printf("Symmetric hash has been set to %s on port %u\n",
11361 res->enable, res->port_id);
11364 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
11365 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11366 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
11367 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
11368 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11370 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
11371 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11372 enable, "enable#disable");
11374 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
11375 .f = cmd_set_sym_hash_per_port_parsed,
11377 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
11379 (void *)&cmd_set_sym_hash_ena_per_port_all,
11380 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
11381 (void *)&cmd_set_sym_hash_ena_per_port_enable,
11386 /* Get global config of hash function */
11387 struct cmd_get_hash_global_config_result {
11388 cmdline_fixed_string_t get_hash_global_config;
11393 flowtype_to_str(uint16_t ftype)
11399 } ftype_table[] = {
11400 {"ipv4", RTE_ETH_FLOW_IPV4},
11401 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
11402 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
11403 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
11404 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
11405 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
11406 {"ipv6", RTE_ETH_FLOW_IPV6},
11407 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
11408 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
11409 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
11410 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
11411 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
11412 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
11413 {"port", RTE_ETH_FLOW_PORT},
11414 {"vxlan", RTE_ETH_FLOW_VXLAN},
11415 {"geneve", RTE_ETH_FLOW_GENEVE},
11416 {"nvgre", RTE_ETH_FLOW_NVGRE},
11419 for (i = 0; i < RTE_DIM(ftype_table); i++) {
11420 if (ftype_table[i].ftype == ftype)
11421 return ftype_table[i].str;
11428 cmd_get_hash_global_config_parsed(void *parsed_result,
11429 __rte_unused struct cmdline *cl,
11430 __rte_unused void *data)
11432 struct cmd_get_hash_global_config_result *res = parsed_result;
11433 struct rte_eth_hash_filter_info info;
11434 uint32_t idx, offset;
11439 if (rte_eth_dev_filter_supported(res->port_id,
11440 RTE_ETH_FILTER_HASH) < 0) {
11441 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11446 memset(&info, 0, sizeof(info));
11447 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11448 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11449 RTE_ETH_FILTER_GET, &info);
11451 printf("Cannot get hash global configurations by port %d\n",
11456 switch (info.info.global_conf.hash_func) {
11457 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
11458 printf("Hash function is Toeplitz\n");
11460 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
11461 printf("Hash function is Simple XOR\n");
11464 printf("Unknown hash function\n");
11468 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
11469 idx = i / UINT64_BIT;
11470 offset = i % UINT64_BIT;
11471 if (!(info.info.global_conf.valid_bit_mask[idx] &
11474 str = flowtype_to_str(i);
11477 printf("Symmetric hash is %s globally for flow type %s "
11479 ((info.info.global_conf.sym_hash_enable_mask[idx] &
11480 (1ULL << offset)) ? "enabled" : "disabled"), str,
11485 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
11486 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
11487 get_hash_global_config, "get_hash_global_config");
11488 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
11489 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
11492 cmdline_parse_inst_t cmd_get_hash_global_config = {
11493 .f = cmd_get_hash_global_config_parsed,
11495 .help_str = "get_hash_global_config <port_id>",
11497 (void *)&cmd_get_hash_global_config_all,
11498 (void *)&cmd_get_hash_global_config_port_id,
11503 /* Set global config of hash function */
11504 struct cmd_set_hash_global_config_result {
11505 cmdline_fixed_string_t set_hash_global_config;
11507 cmdline_fixed_string_t hash_func;
11508 cmdline_fixed_string_t flow_type;
11509 cmdline_fixed_string_t enable;
11513 cmd_set_hash_global_config_parsed(void *parsed_result,
11514 __rte_unused struct cmdline *cl,
11515 __rte_unused void *data)
11517 struct cmd_set_hash_global_config_result *res = parsed_result;
11518 struct rte_eth_hash_filter_info info;
11519 uint32_t ftype, idx, offset;
11522 if (rte_eth_dev_filter_supported(res->port_id,
11523 RTE_ETH_FILTER_HASH) < 0) {
11524 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11528 memset(&info, 0, sizeof(info));
11529 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11530 if (!strcmp(res->hash_func, "toeplitz"))
11531 info.info.global_conf.hash_func =
11532 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
11533 else if (!strcmp(res->hash_func, "simple_xor"))
11534 info.info.global_conf.hash_func =
11535 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
11536 else if (!strcmp(res->hash_func, "default"))
11537 info.info.global_conf.hash_func =
11538 RTE_ETH_HASH_FUNCTION_DEFAULT;
11540 ftype = str2flowtype(res->flow_type);
11541 idx = ftype / UINT64_BIT;
11542 offset = ftype % UINT64_BIT;
11543 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
11544 if (!strcmp(res->enable, "enable"))
11545 info.info.global_conf.sym_hash_enable_mask[idx] |=
11547 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11548 RTE_ETH_FILTER_SET, &info);
11550 printf("Cannot set global hash configurations by port %d\n",
11553 printf("Global hash configurations have been set "
11554 "succcessfully by port %d\n", res->port_id);
11557 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
11558 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11559 set_hash_global_config, "set_hash_global_config");
11560 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
11561 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
11563 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
11564 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11565 hash_func, "toeplitz#simple_xor#default");
11566 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
11567 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11569 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
11570 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11571 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
11572 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11573 enable, "enable#disable");
11575 cmdline_parse_inst_t cmd_set_hash_global_config = {
11576 .f = cmd_set_hash_global_config_parsed,
11578 .help_str = "set_hash_global_config <port_id> "
11579 "toeplitz|simple_xor|default "
11580 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11581 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
11582 "l2_payload enable|disable",
11584 (void *)&cmd_set_hash_global_config_all,
11585 (void *)&cmd_set_hash_global_config_port_id,
11586 (void *)&cmd_set_hash_global_config_hash_func,
11587 (void *)&cmd_set_hash_global_config_flow_type,
11588 (void *)&cmd_set_hash_global_config_enable,
11593 /* Set hash input set */
11594 struct cmd_set_hash_input_set_result {
11595 cmdline_fixed_string_t set_hash_input_set;
11597 cmdline_fixed_string_t flow_type;
11598 cmdline_fixed_string_t inset_field;
11599 cmdline_fixed_string_t select;
11602 static enum rte_eth_input_set_field
11603 str2inset(char *string)
11607 static const struct {
11609 enum rte_eth_input_set_field inset;
11610 } inset_table[] = {
11611 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
11612 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
11613 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
11614 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
11615 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
11616 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
11617 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
11618 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
11619 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
11620 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
11621 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
11622 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
11623 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
11624 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
11625 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
11626 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
11627 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
11628 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
11629 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
11630 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
11631 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
11632 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
11633 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
11634 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
11635 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
11636 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
11637 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
11638 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
11639 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
11640 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
11641 {"none", RTE_ETH_INPUT_SET_NONE},
11644 for (i = 0; i < RTE_DIM(inset_table); i++) {
11645 if (!strcmp(string, inset_table[i].str))
11646 return inset_table[i].inset;
11649 return RTE_ETH_INPUT_SET_UNKNOWN;
11653 cmd_set_hash_input_set_parsed(void *parsed_result,
11654 __rte_unused struct cmdline *cl,
11655 __rte_unused void *data)
11657 struct cmd_set_hash_input_set_result *res = parsed_result;
11658 struct rte_eth_hash_filter_info info;
11660 memset(&info, 0, sizeof(info));
11661 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
11662 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
11663 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
11664 info.info.input_set_conf.inset_size = 1;
11665 if (!strcmp(res->select, "select"))
11666 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
11667 else if (!strcmp(res->select, "add"))
11668 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
11669 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11670 RTE_ETH_FILTER_SET, &info);
11673 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
11674 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11675 set_hash_input_set, "set_hash_input_set");
11676 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
11677 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
11679 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
11680 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11682 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
11683 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11685 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
11686 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
11687 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
11688 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
11689 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
11691 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
11692 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11693 select, "select#add");
11695 cmdline_parse_inst_t cmd_set_hash_input_set = {
11696 .f = cmd_set_hash_input_set_parsed,
11698 .help_str = "set_hash_input_set <port_id> "
11699 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11700 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
11701 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
11702 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
11703 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
11704 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
11705 "fld-7th|fld-8th|none select|add",
11707 (void *)&cmd_set_hash_input_set_cmd,
11708 (void *)&cmd_set_hash_input_set_port_id,
11709 (void *)&cmd_set_hash_input_set_flow_type,
11710 (void *)&cmd_set_hash_input_set_field,
11711 (void *)&cmd_set_hash_input_set_select,
11716 /* Set flow director input set */
11717 struct cmd_set_fdir_input_set_result {
11718 cmdline_fixed_string_t set_fdir_input_set;
11720 cmdline_fixed_string_t flow_type;
11721 cmdline_fixed_string_t inset_field;
11722 cmdline_fixed_string_t select;
11726 cmd_set_fdir_input_set_parsed(void *parsed_result,
11727 __rte_unused struct cmdline *cl,
11728 __rte_unused void *data)
11730 struct cmd_set_fdir_input_set_result *res = parsed_result;
11731 struct rte_eth_fdir_filter_info info;
11733 memset(&info, 0, sizeof(info));
11734 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
11735 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
11736 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
11737 info.info.input_set_conf.inset_size = 1;
11738 if (!strcmp(res->select, "select"))
11739 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
11740 else if (!strcmp(res->select, "add"))
11741 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
11742 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11743 RTE_ETH_FILTER_SET, &info);
11746 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
11747 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11748 set_fdir_input_set, "set_fdir_input_set");
11749 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
11750 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
11752 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
11753 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11755 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
11756 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11757 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
11758 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11760 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
11761 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
11762 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
11763 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
11764 "sctp-veri-tag#none");
11765 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
11766 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11767 select, "select#add");
11769 cmdline_parse_inst_t cmd_set_fdir_input_set = {
11770 .f = cmd_set_fdir_input_set_parsed,
11772 .help_str = "set_fdir_input_set <port_id> "
11773 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11774 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
11775 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
11776 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
11777 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
11778 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
11779 "sctp-veri-tag|none select|add",
11781 (void *)&cmd_set_fdir_input_set_cmd,
11782 (void *)&cmd_set_fdir_input_set_port_id,
11783 (void *)&cmd_set_fdir_input_set_flow_type,
11784 (void *)&cmd_set_fdir_input_set_field,
11785 (void *)&cmd_set_fdir_input_set_select,
11790 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
11791 struct cmd_mcast_addr_result {
11792 cmdline_fixed_string_t mcast_addr_cmd;
11793 cmdline_fixed_string_t what;
11795 struct ether_addr mc_addr;
11798 static void cmd_mcast_addr_parsed(void *parsed_result,
11799 __attribute__((unused)) struct cmdline *cl,
11800 __attribute__((unused)) void *data)
11802 struct cmd_mcast_addr_result *res = parsed_result;
11804 if (!is_multicast_ether_addr(&res->mc_addr)) {
11805 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
11806 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
11807 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
11808 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
11811 if (strcmp(res->what, "add") == 0)
11812 mcast_addr_add(res->port_num, &res->mc_addr);
11814 mcast_addr_remove(res->port_num, &res->mc_addr);
11817 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
11818 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
11819 mcast_addr_cmd, "mcast_addr");
11820 cmdline_parse_token_string_t cmd_mcast_addr_what =
11821 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
11823 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
11824 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
11825 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
11826 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
11828 cmdline_parse_inst_t cmd_mcast_addr = {
11829 .f = cmd_mcast_addr_parsed,
11831 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
11832 "Add/Remove multicast MAC address on port_id",
11834 (void *)&cmd_mcast_addr_cmd,
11835 (void *)&cmd_mcast_addr_what,
11836 (void *)&cmd_mcast_addr_portnum,
11837 (void *)&cmd_mcast_addr_addr,
11842 /* l2 tunnel config
11843 * only support E-tag now.
11846 /* Ether type config */
11847 struct cmd_config_l2_tunnel_eth_type_result {
11848 cmdline_fixed_string_t port;
11849 cmdline_fixed_string_t config;
11850 cmdline_fixed_string_t all;
11852 cmdline_fixed_string_t l2_tunnel;
11853 cmdline_fixed_string_t l2_tunnel_type;
11854 cmdline_fixed_string_t eth_type;
11855 uint16_t eth_type_val;
11858 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
11859 TOKEN_STRING_INITIALIZER
11860 (struct cmd_config_l2_tunnel_eth_type_result,
11862 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
11863 TOKEN_STRING_INITIALIZER
11864 (struct cmd_config_l2_tunnel_eth_type_result,
11866 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
11867 TOKEN_STRING_INITIALIZER
11868 (struct cmd_config_l2_tunnel_eth_type_result,
11870 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
11871 TOKEN_NUM_INITIALIZER
11872 (struct cmd_config_l2_tunnel_eth_type_result,
11874 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
11875 TOKEN_STRING_INITIALIZER
11876 (struct cmd_config_l2_tunnel_eth_type_result,
11877 l2_tunnel, "l2-tunnel");
11878 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
11879 TOKEN_STRING_INITIALIZER
11880 (struct cmd_config_l2_tunnel_eth_type_result,
11881 l2_tunnel_type, "E-tag");
11882 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
11883 TOKEN_STRING_INITIALIZER
11884 (struct cmd_config_l2_tunnel_eth_type_result,
11885 eth_type, "ether-type");
11886 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
11887 TOKEN_NUM_INITIALIZER
11888 (struct cmd_config_l2_tunnel_eth_type_result,
11889 eth_type_val, UINT16);
11891 static enum rte_eth_tunnel_type
11892 str2fdir_l2_tunnel_type(char *string)
11896 static const struct {
11898 enum rte_eth_tunnel_type type;
11899 } l2_tunnel_type_str[] = {
11900 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
11903 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
11904 if (!strcmp(l2_tunnel_type_str[i].str, string))
11905 return l2_tunnel_type_str[i].type;
11907 return RTE_TUNNEL_TYPE_NONE;
11910 /* ether type config for all ports */
11912 cmd_config_l2_tunnel_eth_type_all_parsed
11913 (void *parsed_result,
11914 __attribute__((unused)) struct cmdline *cl,
11915 __attribute__((unused)) void *data)
11917 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
11918 struct rte_eth_l2_tunnel_conf entry;
11921 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11922 entry.ether_type = res->eth_type_val;
11924 RTE_ETH_FOREACH_DEV(pid) {
11925 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
11929 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
11930 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
11932 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
11934 (void *)&cmd_config_l2_tunnel_eth_type_port,
11935 (void *)&cmd_config_l2_tunnel_eth_type_config,
11936 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
11937 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
11938 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
11939 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
11940 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
11945 /* ether type config for a specific port */
11947 cmd_config_l2_tunnel_eth_type_specific_parsed(
11948 void *parsed_result,
11949 __attribute__((unused)) struct cmdline *cl,
11950 __attribute__((unused)) void *data)
11952 struct cmd_config_l2_tunnel_eth_type_result *res =
11954 struct rte_eth_l2_tunnel_conf entry;
11956 if (port_id_is_invalid(res->id, ENABLED_WARN))
11959 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11960 entry.ether_type = res->eth_type_val;
11962 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
11965 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
11966 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
11968 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
11970 (void *)&cmd_config_l2_tunnel_eth_type_port,
11971 (void *)&cmd_config_l2_tunnel_eth_type_config,
11972 (void *)&cmd_config_l2_tunnel_eth_type_id,
11973 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
11974 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
11975 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
11976 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
11981 /* Enable/disable l2 tunnel */
11982 struct cmd_config_l2_tunnel_en_dis_result {
11983 cmdline_fixed_string_t port;
11984 cmdline_fixed_string_t config;
11985 cmdline_fixed_string_t all;
11987 cmdline_fixed_string_t l2_tunnel;
11988 cmdline_fixed_string_t l2_tunnel_type;
11989 cmdline_fixed_string_t en_dis;
11992 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
11993 TOKEN_STRING_INITIALIZER
11994 (struct cmd_config_l2_tunnel_en_dis_result,
11996 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
11997 TOKEN_STRING_INITIALIZER
11998 (struct cmd_config_l2_tunnel_en_dis_result,
12000 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
12001 TOKEN_STRING_INITIALIZER
12002 (struct cmd_config_l2_tunnel_en_dis_result,
12004 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
12005 TOKEN_NUM_INITIALIZER
12006 (struct cmd_config_l2_tunnel_en_dis_result,
12008 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
12009 TOKEN_STRING_INITIALIZER
12010 (struct cmd_config_l2_tunnel_en_dis_result,
12011 l2_tunnel, "l2-tunnel");
12012 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
12013 TOKEN_STRING_INITIALIZER
12014 (struct cmd_config_l2_tunnel_en_dis_result,
12015 l2_tunnel_type, "E-tag");
12016 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
12017 TOKEN_STRING_INITIALIZER
12018 (struct cmd_config_l2_tunnel_en_dis_result,
12019 en_dis, "enable#disable");
12021 /* enable/disable l2 tunnel for all ports */
12023 cmd_config_l2_tunnel_en_dis_all_parsed(
12024 void *parsed_result,
12025 __attribute__((unused)) struct cmdline *cl,
12026 __attribute__((unused)) void *data)
12028 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
12029 struct rte_eth_l2_tunnel_conf entry;
12033 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12035 if (!strcmp("enable", res->en_dis))
12040 RTE_ETH_FOREACH_DEV(pid) {
12041 rte_eth_dev_l2_tunnel_offload_set(pid,
12043 ETH_L2_TUNNEL_ENABLE_MASK,
12048 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
12049 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
12051 .help_str = "port config all l2-tunnel E-tag enable|disable",
12053 (void *)&cmd_config_l2_tunnel_en_dis_port,
12054 (void *)&cmd_config_l2_tunnel_en_dis_config,
12055 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
12056 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12057 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12058 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12063 /* enable/disable l2 tunnel for a port */
12065 cmd_config_l2_tunnel_en_dis_specific_parsed(
12066 void *parsed_result,
12067 __attribute__((unused)) struct cmdline *cl,
12068 __attribute__((unused)) void *data)
12070 struct cmd_config_l2_tunnel_en_dis_result *res =
12072 struct rte_eth_l2_tunnel_conf entry;
12074 if (port_id_is_invalid(res->id, ENABLED_WARN))
12077 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12079 if (!strcmp("enable", res->en_dis))
12080 rte_eth_dev_l2_tunnel_offload_set(res->id,
12082 ETH_L2_TUNNEL_ENABLE_MASK,
12085 rte_eth_dev_l2_tunnel_offload_set(res->id,
12087 ETH_L2_TUNNEL_ENABLE_MASK,
12091 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
12092 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
12094 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
12096 (void *)&cmd_config_l2_tunnel_en_dis_port,
12097 (void *)&cmd_config_l2_tunnel_en_dis_config,
12098 (void *)&cmd_config_l2_tunnel_en_dis_id,
12099 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12100 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12101 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12106 /* E-tag configuration */
12108 /* Common result structure for all E-tag configuration */
12109 struct cmd_config_e_tag_result {
12110 cmdline_fixed_string_t e_tag;
12111 cmdline_fixed_string_t set;
12112 cmdline_fixed_string_t insertion;
12113 cmdline_fixed_string_t stripping;
12114 cmdline_fixed_string_t forwarding;
12115 cmdline_fixed_string_t filter;
12116 cmdline_fixed_string_t add;
12117 cmdline_fixed_string_t del;
12118 cmdline_fixed_string_t on;
12119 cmdline_fixed_string_t off;
12120 cmdline_fixed_string_t on_off;
12121 cmdline_fixed_string_t port_tag_id;
12122 uint32_t port_tag_id_val;
12123 cmdline_fixed_string_t e_tag_id;
12124 uint16_t e_tag_id_val;
12125 cmdline_fixed_string_t dst_pool;
12126 uint8_t dst_pool_val;
12127 cmdline_fixed_string_t port;
12129 cmdline_fixed_string_t vf;
12133 /* Common CLI fields for all E-tag configuration */
12134 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
12135 TOKEN_STRING_INITIALIZER
12136 (struct cmd_config_e_tag_result,
12138 cmdline_parse_token_string_t cmd_config_e_tag_set =
12139 TOKEN_STRING_INITIALIZER
12140 (struct cmd_config_e_tag_result,
12142 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
12143 TOKEN_STRING_INITIALIZER
12144 (struct cmd_config_e_tag_result,
12145 insertion, "insertion");
12146 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
12147 TOKEN_STRING_INITIALIZER
12148 (struct cmd_config_e_tag_result,
12149 stripping, "stripping");
12150 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
12151 TOKEN_STRING_INITIALIZER
12152 (struct cmd_config_e_tag_result,
12153 forwarding, "forwarding");
12154 cmdline_parse_token_string_t cmd_config_e_tag_filter =
12155 TOKEN_STRING_INITIALIZER
12156 (struct cmd_config_e_tag_result,
12158 cmdline_parse_token_string_t cmd_config_e_tag_add =
12159 TOKEN_STRING_INITIALIZER
12160 (struct cmd_config_e_tag_result,
12162 cmdline_parse_token_string_t cmd_config_e_tag_del =
12163 TOKEN_STRING_INITIALIZER
12164 (struct cmd_config_e_tag_result,
12166 cmdline_parse_token_string_t cmd_config_e_tag_on =
12167 TOKEN_STRING_INITIALIZER
12168 (struct cmd_config_e_tag_result,
12170 cmdline_parse_token_string_t cmd_config_e_tag_off =
12171 TOKEN_STRING_INITIALIZER
12172 (struct cmd_config_e_tag_result,
12174 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
12175 TOKEN_STRING_INITIALIZER
12176 (struct cmd_config_e_tag_result,
12178 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
12179 TOKEN_STRING_INITIALIZER
12180 (struct cmd_config_e_tag_result,
12181 port_tag_id, "port-tag-id");
12182 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
12183 TOKEN_NUM_INITIALIZER
12184 (struct cmd_config_e_tag_result,
12185 port_tag_id_val, UINT32);
12186 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
12187 TOKEN_STRING_INITIALIZER
12188 (struct cmd_config_e_tag_result,
12189 e_tag_id, "e-tag-id");
12190 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
12191 TOKEN_NUM_INITIALIZER
12192 (struct cmd_config_e_tag_result,
12193 e_tag_id_val, UINT16);
12194 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
12195 TOKEN_STRING_INITIALIZER
12196 (struct cmd_config_e_tag_result,
12197 dst_pool, "dst-pool");
12198 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
12199 TOKEN_NUM_INITIALIZER
12200 (struct cmd_config_e_tag_result,
12201 dst_pool_val, UINT8);
12202 cmdline_parse_token_string_t cmd_config_e_tag_port =
12203 TOKEN_STRING_INITIALIZER
12204 (struct cmd_config_e_tag_result,
12206 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
12207 TOKEN_NUM_INITIALIZER
12208 (struct cmd_config_e_tag_result,
12210 cmdline_parse_token_string_t cmd_config_e_tag_vf =
12211 TOKEN_STRING_INITIALIZER
12212 (struct cmd_config_e_tag_result,
12214 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
12215 TOKEN_NUM_INITIALIZER
12216 (struct cmd_config_e_tag_result,
12219 /* E-tag insertion configuration */
12221 cmd_config_e_tag_insertion_en_parsed(
12222 void *parsed_result,
12223 __attribute__((unused)) struct cmdline *cl,
12224 __attribute__((unused)) void *data)
12226 struct cmd_config_e_tag_result *res =
12228 struct rte_eth_l2_tunnel_conf entry;
12230 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12233 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12234 entry.tunnel_id = res->port_tag_id_val;
12235 entry.vf_id = res->vf_id;
12236 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12238 ETH_L2_TUNNEL_INSERTION_MASK,
12243 cmd_config_e_tag_insertion_dis_parsed(
12244 void *parsed_result,
12245 __attribute__((unused)) struct cmdline *cl,
12246 __attribute__((unused)) void *data)
12248 struct cmd_config_e_tag_result *res =
12250 struct rte_eth_l2_tunnel_conf entry;
12252 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12255 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12256 entry.vf_id = res->vf_id;
12258 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12260 ETH_L2_TUNNEL_INSERTION_MASK,
12264 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
12265 .f = cmd_config_e_tag_insertion_en_parsed,
12267 .help_str = "E-tag ... : E-tag insertion enable",
12269 (void *)&cmd_config_e_tag_e_tag,
12270 (void *)&cmd_config_e_tag_set,
12271 (void *)&cmd_config_e_tag_insertion,
12272 (void *)&cmd_config_e_tag_on,
12273 (void *)&cmd_config_e_tag_port_tag_id,
12274 (void *)&cmd_config_e_tag_port_tag_id_val,
12275 (void *)&cmd_config_e_tag_port,
12276 (void *)&cmd_config_e_tag_port_id,
12277 (void *)&cmd_config_e_tag_vf,
12278 (void *)&cmd_config_e_tag_vf_id,
12283 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
12284 .f = cmd_config_e_tag_insertion_dis_parsed,
12286 .help_str = "E-tag ... : E-tag insertion disable",
12288 (void *)&cmd_config_e_tag_e_tag,
12289 (void *)&cmd_config_e_tag_set,
12290 (void *)&cmd_config_e_tag_insertion,
12291 (void *)&cmd_config_e_tag_off,
12292 (void *)&cmd_config_e_tag_port,
12293 (void *)&cmd_config_e_tag_port_id,
12294 (void *)&cmd_config_e_tag_vf,
12295 (void *)&cmd_config_e_tag_vf_id,
12300 /* E-tag stripping configuration */
12302 cmd_config_e_tag_stripping_parsed(
12303 void *parsed_result,
12304 __attribute__((unused)) struct cmdline *cl,
12305 __attribute__((unused)) void *data)
12307 struct cmd_config_e_tag_result *res =
12309 struct rte_eth_l2_tunnel_conf entry;
12311 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12314 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12316 if (!strcmp(res->on_off, "on"))
12317 rte_eth_dev_l2_tunnel_offload_set
12320 ETH_L2_TUNNEL_STRIPPING_MASK,
12323 rte_eth_dev_l2_tunnel_offload_set
12326 ETH_L2_TUNNEL_STRIPPING_MASK,
12330 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
12331 .f = cmd_config_e_tag_stripping_parsed,
12333 .help_str = "E-tag ... : E-tag stripping enable/disable",
12335 (void *)&cmd_config_e_tag_e_tag,
12336 (void *)&cmd_config_e_tag_set,
12337 (void *)&cmd_config_e_tag_stripping,
12338 (void *)&cmd_config_e_tag_on_off,
12339 (void *)&cmd_config_e_tag_port,
12340 (void *)&cmd_config_e_tag_port_id,
12345 /* E-tag forwarding configuration */
12347 cmd_config_e_tag_forwarding_parsed(
12348 void *parsed_result,
12349 __attribute__((unused)) struct cmdline *cl,
12350 __attribute__((unused)) void *data)
12352 struct cmd_config_e_tag_result *res = parsed_result;
12353 struct rte_eth_l2_tunnel_conf entry;
12355 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12358 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12360 if (!strcmp(res->on_off, "on"))
12361 rte_eth_dev_l2_tunnel_offload_set
12364 ETH_L2_TUNNEL_FORWARDING_MASK,
12367 rte_eth_dev_l2_tunnel_offload_set
12370 ETH_L2_TUNNEL_FORWARDING_MASK,
12374 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
12375 .f = cmd_config_e_tag_forwarding_parsed,
12377 .help_str = "E-tag ... : E-tag forwarding enable/disable",
12379 (void *)&cmd_config_e_tag_e_tag,
12380 (void *)&cmd_config_e_tag_set,
12381 (void *)&cmd_config_e_tag_forwarding,
12382 (void *)&cmd_config_e_tag_on_off,
12383 (void *)&cmd_config_e_tag_port,
12384 (void *)&cmd_config_e_tag_port_id,
12389 /* E-tag filter configuration */
12391 cmd_config_e_tag_filter_add_parsed(
12392 void *parsed_result,
12393 __attribute__((unused)) struct cmdline *cl,
12394 __attribute__((unused)) void *data)
12396 struct cmd_config_e_tag_result *res = parsed_result;
12397 struct rte_eth_l2_tunnel_conf entry;
12400 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12403 if (res->e_tag_id_val > 0x3fff) {
12404 printf("e-tag-id must be equal or less than 0x3fff.\n");
12408 ret = rte_eth_dev_filter_supported(res->port_id,
12409 RTE_ETH_FILTER_L2_TUNNEL);
12411 printf("E-tag filter is not supported on port %u.\n",
12416 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12417 entry.tunnel_id = res->e_tag_id_val;
12418 entry.pool = res->dst_pool_val;
12420 ret = rte_eth_dev_filter_ctrl(res->port_id,
12421 RTE_ETH_FILTER_L2_TUNNEL,
12422 RTE_ETH_FILTER_ADD,
12425 printf("E-tag filter programming error: (%s)\n",
12429 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
12430 .f = cmd_config_e_tag_filter_add_parsed,
12432 .help_str = "E-tag ... : E-tag filter add",
12434 (void *)&cmd_config_e_tag_e_tag,
12435 (void *)&cmd_config_e_tag_set,
12436 (void *)&cmd_config_e_tag_filter,
12437 (void *)&cmd_config_e_tag_add,
12438 (void *)&cmd_config_e_tag_e_tag_id,
12439 (void *)&cmd_config_e_tag_e_tag_id_val,
12440 (void *)&cmd_config_e_tag_dst_pool,
12441 (void *)&cmd_config_e_tag_dst_pool_val,
12442 (void *)&cmd_config_e_tag_port,
12443 (void *)&cmd_config_e_tag_port_id,
12449 cmd_config_e_tag_filter_del_parsed(
12450 void *parsed_result,
12451 __attribute__((unused)) struct cmdline *cl,
12452 __attribute__((unused)) void *data)
12454 struct cmd_config_e_tag_result *res = parsed_result;
12455 struct rte_eth_l2_tunnel_conf entry;
12458 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12461 if (res->e_tag_id_val > 0x3fff) {
12462 printf("e-tag-id must be less than 0x3fff.\n");
12466 ret = rte_eth_dev_filter_supported(res->port_id,
12467 RTE_ETH_FILTER_L2_TUNNEL);
12469 printf("E-tag filter is not supported on port %u.\n",
12474 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12475 entry.tunnel_id = res->e_tag_id_val;
12477 ret = rte_eth_dev_filter_ctrl(res->port_id,
12478 RTE_ETH_FILTER_L2_TUNNEL,
12479 RTE_ETH_FILTER_DELETE,
12482 printf("E-tag filter programming error: (%s)\n",
12486 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
12487 .f = cmd_config_e_tag_filter_del_parsed,
12489 .help_str = "E-tag ... : E-tag filter delete",
12491 (void *)&cmd_config_e_tag_e_tag,
12492 (void *)&cmd_config_e_tag_set,
12493 (void *)&cmd_config_e_tag_filter,
12494 (void *)&cmd_config_e_tag_del,
12495 (void *)&cmd_config_e_tag_e_tag_id,
12496 (void *)&cmd_config_e_tag_e_tag_id_val,
12497 (void *)&cmd_config_e_tag_port,
12498 (void *)&cmd_config_e_tag_port_id,
12503 /* vf vlan anti spoof configuration */
12505 /* Common result structure for vf vlan anti spoof */
12506 struct cmd_vf_vlan_anti_spoof_result {
12507 cmdline_fixed_string_t set;
12508 cmdline_fixed_string_t vf;
12509 cmdline_fixed_string_t vlan;
12510 cmdline_fixed_string_t antispoof;
12513 cmdline_fixed_string_t on_off;
12516 /* Common CLI fields for vf vlan anti spoof enable disable */
12517 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
12518 TOKEN_STRING_INITIALIZER
12519 (struct cmd_vf_vlan_anti_spoof_result,
12521 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
12522 TOKEN_STRING_INITIALIZER
12523 (struct cmd_vf_vlan_anti_spoof_result,
12525 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
12526 TOKEN_STRING_INITIALIZER
12527 (struct cmd_vf_vlan_anti_spoof_result,
12529 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
12530 TOKEN_STRING_INITIALIZER
12531 (struct cmd_vf_vlan_anti_spoof_result,
12532 antispoof, "antispoof");
12533 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
12534 TOKEN_NUM_INITIALIZER
12535 (struct cmd_vf_vlan_anti_spoof_result,
12537 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
12538 TOKEN_NUM_INITIALIZER
12539 (struct cmd_vf_vlan_anti_spoof_result,
12541 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
12542 TOKEN_STRING_INITIALIZER
12543 (struct cmd_vf_vlan_anti_spoof_result,
12547 cmd_set_vf_vlan_anti_spoof_parsed(
12548 void *parsed_result,
12549 __attribute__((unused)) struct cmdline *cl,
12550 __attribute__((unused)) void *data)
12552 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
12553 int ret = -ENOTSUP;
12555 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12557 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12560 #ifdef RTE_LIBRTE_IXGBE_PMD
12561 if (ret == -ENOTSUP)
12562 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
12563 res->vf_id, is_on);
12565 #ifdef RTE_LIBRTE_I40E_PMD
12566 if (ret == -ENOTSUP)
12567 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
12568 res->vf_id, is_on);
12570 #ifdef RTE_LIBRTE_BNXT_PMD
12571 if (ret == -ENOTSUP)
12572 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
12573 res->vf_id, is_on);
12580 printf("invalid vf_id %d\n", res->vf_id);
12583 printf("invalid port_id %d\n", res->port_id);
12586 printf("function not implemented\n");
12589 printf("programming error: (%s)\n", strerror(-ret));
12593 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
12594 .f = cmd_set_vf_vlan_anti_spoof_parsed,
12596 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
12598 (void *)&cmd_vf_vlan_anti_spoof_set,
12599 (void *)&cmd_vf_vlan_anti_spoof_vf,
12600 (void *)&cmd_vf_vlan_anti_spoof_vlan,
12601 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
12602 (void *)&cmd_vf_vlan_anti_spoof_port_id,
12603 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
12604 (void *)&cmd_vf_vlan_anti_spoof_on_off,
12609 /* vf mac anti spoof configuration */
12611 /* Common result structure for vf mac anti spoof */
12612 struct cmd_vf_mac_anti_spoof_result {
12613 cmdline_fixed_string_t set;
12614 cmdline_fixed_string_t vf;
12615 cmdline_fixed_string_t mac;
12616 cmdline_fixed_string_t antispoof;
12619 cmdline_fixed_string_t on_off;
12622 /* Common CLI fields for vf mac anti spoof enable disable */
12623 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
12624 TOKEN_STRING_INITIALIZER
12625 (struct cmd_vf_mac_anti_spoof_result,
12627 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
12628 TOKEN_STRING_INITIALIZER
12629 (struct cmd_vf_mac_anti_spoof_result,
12631 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
12632 TOKEN_STRING_INITIALIZER
12633 (struct cmd_vf_mac_anti_spoof_result,
12635 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
12636 TOKEN_STRING_INITIALIZER
12637 (struct cmd_vf_mac_anti_spoof_result,
12638 antispoof, "antispoof");
12639 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
12640 TOKEN_NUM_INITIALIZER
12641 (struct cmd_vf_mac_anti_spoof_result,
12643 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
12644 TOKEN_NUM_INITIALIZER
12645 (struct cmd_vf_mac_anti_spoof_result,
12647 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
12648 TOKEN_STRING_INITIALIZER
12649 (struct cmd_vf_mac_anti_spoof_result,
12653 cmd_set_vf_mac_anti_spoof_parsed(
12654 void *parsed_result,
12655 __attribute__((unused)) struct cmdline *cl,
12656 __attribute__((unused)) void *data)
12658 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
12659 int ret = -ENOTSUP;
12661 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12663 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12666 #ifdef RTE_LIBRTE_IXGBE_PMD
12667 if (ret == -ENOTSUP)
12668 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
12669 res->vf_id, is_on);
12671 #ifdef RTE_LIBRTE_I40E_PMD
12672 if (ret == -ENOTSUP)
12673 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
12674 res->vf_id, is_on);
12676 #ifdef RTE_LIBRTE_BNXT_PMD
12677 if (ret == -ENOTSUP)
12678 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
12679 res->vf_id, is_on);
12686 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12689 printf("invalid port_id %d\n", res->port_id);
12692 printf("function not implemented\n");
12695 printf("programming error: (%s)\n", strerror(-ret));
12699 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
12700 .f = cmd_set_vf_mac_anti_spoof_parsed,
12702 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
12704 (void *)&cmd_vf_mac_anti_spoof_set,
12705 (void *)&cmd_vf_mac_anti_spoof_vf,
12706 (void *)&cmd_vf_mac_anti_spoof_mac,
12707 (void *)&cmd_vf_mac_anti_spoof_antispoof,
12708 (void *)&cmd_vf_mac_anti_spoof_port_id,
12709 (void *)&cmd_vf_mac_anti_spoof_vf_id,
12710 (void *)&cmd_vf_mac_anti_spoof_on_off,
12715 /* vf vlan strip queue configuration */
12717 /* Common result structure for vf mac anti spoof */
12718 struct cmd_vf_vlan_stripq_result {
12719 cmdline_fixed_string_t set;
12720 cmdline_fixed_string_t vf;
12721 cmdline_fixed_string_t vlan;
12722 cmdline_fixed_string_t stripq;
12725 cmdline_fixed_string_t on_off;
12728 /* Common CLI fields for vf vlan strip enable disable */
12729 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
12730 TOKEN_STRING_INITIALIZER
12731 (struct cmd_vf_vlan_stripq_result,
12733 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
12734 TOKEN_STRING_INITIALIZER
12735 (struct cmd_vf_vlan_stripq_result,
12737 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
12738 TOKEN_STRING_INITIALIZER
12739 (struct cmd_vf_vlan_stripq_result,
12741 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
12742 TOKEN_STRING_INITIALIZER
12743 (struct cmd_vf_vlan_stripq_result,
12745 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
12746 TOKEN_NUM_INITIALIZER
12747 (struct cmd_vf_vlan_stripq_result,
12749 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
12750 TOKEN_NUM_INITIALIZER
12751 (struct cmd_vf_vlan_stripq_result,
12753 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
12754 TOKEN_STRING_INITIALIZER
12755 (struct cmd_vf_vlan_stripq_result,
12759 cmd_set_vf_vlan_stripq_parsed(
12760 void *parsed_result,
12761 __attribute__((unused)) struct cmdline *cl,
12762 __attribute__((unused)) void *data)
12764 struct cmd_vf_vlan_stripq_result *res = parsed_result;
12765 int ret = -ENOTSUP;
12767 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12769 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12772 #ifdef RTE_LIBRTE_IXGBE_PMD
12773 if (ret == -ENOTSUP)
12774 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
12775 res->vf_id, is_on);
12777 #ifdef RTE_LIBRTE_I40E_PMD
12778 if (ret == -ENOTSUP)
12779 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
12780 res->vf_id, is_on);
12782 #ifdef RTE_LIBRTE_BNXT_PMD
12783 if (ret == -ENOTSUP)
12784 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
12785 res->vf_id, is_on);
12792 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12795 printf("invalid port_id %d\n", res->port_id);
12798 printf("function not implemented\n");
12801 printf("programming error: (%s)\n", strerror(-ret));
12805 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
12806 .f = cmd_set_vf_vlan_stripq_parsed,
12808 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
12810 (void *)&cmd_vf_vlan_stripq_set,
12811 (void *)&cmd_vf_vlan_stripq_vf,
12812 (void *)&cmd_vf_vlan_stripq_vlan,
12813 (void *)&cmd_vf_vlan_stripq_stripq,
12814 (void *)&cmd_vf_vlan_stripq_port_id,
12815 (void *)&cmd_vf_vlan_stripq_vf_id,
12816 (void *)&cmd_vf_vlan_stripq_on_off,
12821 /* vf vlan insert configuration */
12823 /* Common result structure for vf vlan insert */
12824 struct cmd_vf_vlan_insert_result {
12825 cmdline_fixed_string_t set;
12826 cmdline_fixed_string_t vf;
12827 cmdline_fixed_string_t vlan;
12828 cmdline_fixed_string_t insert;
12834 /* Common CLI fields for vf vlan insert enable disable */
12835 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
12836 TOKEN_STRING_INITIALIZER
12837 (struct cmd_vf_vlan_insert_result,
12839 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
12840 TOKEN_STRING_INITIALIZER
12841 (struct cmd_vf_vlan_insert_result,
12843 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
12844 TOKEN_STRING_INITIALIZER
12845 (struct cmd_vf_vlan_insert_result,
12847 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
12848 TOKEN_STRING_INITIALIZER
12849 (struct cmd_vf_vlan_insert_result,
12851 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
12852 TOKEN_NUM_INITIALIZER
12853 (struct cmd_vf_vlan_insert_result,
12855 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
12856 TOKEN_NUM_INITIALIZER
12857 (struct cmd_vf_vlan_insert_result,
12859 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
12860 TOKEN_NUM_INITIALIZER
12861 (struct cmd_vf_vlan_insert_result,
12865 cmd_set_vf_vlan_insert_parsed(
12866 void *parsed_result,
12867 __attribute__((unused)) struct cmdline *cl,
12868 __attribute__((unused)) void *data)
12870 struct cmd_vf_vlan_insert_result *res = parsed_result;
12871 int ret = -ENOTSUP;
12873 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12876 #ifdef RTE_LIBRTE_IXGBE_PMD
12877 if (ret == -ENOTSUP)
12878 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
12881 #ifdef RTE_LIBRTE_I40E_PMD
12882 if (ret == -ENOTSUP)
12883 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
12886 #ifdef RTE_LIBRTE_BNXT_PMD
12887 if (ret == -ENOTSUP)
12888 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
12896 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
12899 printf("invalid port_id %d\n", res->port_id);
12902 printf("function not implemented\n");
12905 printf("programming error: (%s)\n", strerror(-ret));
12909 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
12910 .f = cmd_set_vf_vlan_insert_parsed,
12912 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
12914 (void *)&cmd_vf_vlan_insert_set,
12915 (void *)&cmd_vf_vlan_insert_vf,
12916 (void *)&cmd_vf_vlan_insert_vlan,
12917 (void *)&cmd_vf_vlan_insert_insert,
12918 (void *)&cmd_vf_vlan_insert_port_id,
12919 (void *)&cmd_vf_vlan_insert_vf_id,
12920 (void *)&cmd_vf_vlan_insert_vlan_id,
12925 /* tx loopback configuration */
12927 /* Common result structure for tx loopback */
12928 struct cmd_tx_loopback_result {
12929 cmdline_fixed_string_t set;
12930 cmdline_fixed_string_t tx;
12931 cmdline_fixed_string_t loopback;
12933 cmdline_fixed_string_t on_off;
12936 /* Common CLI fields for tx loopback enable disable */
12937 cmdline_parse_token_string_t cmd_tx_loopback_set =
12938 TOKEN_STRING_INITIALIZER
12939 (struct cmd_tx_loopback_result,
12941 cmdline_parse_token_string_t cmd_tx_loopback_tx =
12942 TOKEN_STRING_INITIALIZER
12943 (struct cmd_tx_loopback_result,
12945 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
12946 TOKEN_STRING_INITIALIZER
12947 (struct cmd_tx_loopback_result,
12948 loopback, "loopback");
12949 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
12950 TOKEN_NUM_INITIALIZER
12951 (struct cmd_tx_loopback_result,
12953 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
12954 TOKEN_STRING_INITIALIZER
12955 (struct cmd_tx_loopback_result,
12959 cmd_set_tx_loopback_parsed(
12960 void *parsed_result,
12961 __attribute__((unused)) struct cmdline *cl,
12962 __attribute__((unused)) void *data)
12964 struct cmd_tx_loopback_result *res = parsed_result;
12965 int ret = -ENOTSUP;
12967 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12969 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12972 #ifdef RTE_LIBRTE_IXGBE_PMD
12973 if (ret == -ENOTSUP)
12974 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
12976 #ifdef RTE_LIBRTE_I40E_PMD
12977 if (ret == -ENOTSUP)
12978 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
12980 #ifdef RTE_LIBRTE_BNXT_PMD
12981 if (ret == -ENOTSUP)
12982 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
12984 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
12985 if (ret == -ENOTSUP)
12986 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
12993 printf("invalid is_on %d\n", is_on);
12996 printf("invalid port_id %d\n", res->port_id);
12999 printf("function not implemented\n");
13002 printf("programming error: (%s)\n", strerror(-ret));
13006 cmdline_parse_inst_t cmd_set_tx_loopback = {
13007 .f = cmd_set_tx_loopback_parsed,
13009 .help_str = "set tx loopback <port_id> on|off",
13011 (void *)&cmd_tx_loopback_set,
13012 (void *)&cmd_tx_loopback_tx,
13013 (void *)&cmd_tx_loopback_loopback,
13014 (void *)&cmd_tx_loopback_port_id,
13015 (void *)&cmd_tx_loopback_on_off,
13020 /* all queues drop enable configuration */
13022 /* Common result structure for all queues drop enable */
13023 struct cmd_all_queues_drop_en_result {
13024 cmdline_fixed_string_t set;
13025 cmdline_fixed_string_t all;
13026 cmdline_fixed_string_t queues;
13027 cmdline_fixed_string_t drop;
13029 cmdline_fixed_string_t on_off;
13032 /* Common CLI fields for tx loopback enable disable */
13033 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
13034 TOKEN_STRING_INITIALIZER
13035 (struct cmd_all_queues_drop_en_result,
13037 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
13038 TOKEN_STRING_INITIALIZER
13039 (struct cmd_all_queues_drop_en_result,
13041 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
13042 TOKEN_STRING_INITIALIZER
13043 (struct cmd_all_queues_drop_en_result,
13045 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
13046 TOKEN_STRING_INITIALIZER
13047 (struct cmd_all_queues_drop_en_result,
13049 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
13050 TOKEN_NUM_INITIALIZER
13051 (struct cmd_all_queues_drop_en_result,
13053 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
13054 TOKEN_STRING_INITIALIZER
13055 (struct cmd_all_queues_drop_en_result,
13059 cmd_set_all_queues_drop_en_parsed(
13060 void *parsed_result,
13061 __attribute__((unused)) struct cmdline *cl,
13062 __attribute__((unused)) void *data)
13064 struct cmd_all_queues_drop_en_result *res = parsed_result;
13065 int ret = -ENOTSUP;
13066 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13068 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13071 #ifdef RTE_LIBRTE_IXGBE_PMD
13072 if (ret == -ENOTSUP)
13073 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
13075 #ifdef RTE_LIBRTE_BNXT_PMD
13076 if (ret == -ENOTSUP)
13077 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
13083 printf("invalid is_on %d\n", is_on);
13086 printf("invalid port_id %d\n", res->port_id);
13089 printf("function not implemented\n");
13092 printf("programming error: (%s)\n", strerror(-ret));
13096 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
13097 .f = cmd_set_all_queues_drop_en_parsed,
13099 .help_str = "set all queues drop <port_id> on|off",
13101 (void *)&cmd_all_queues_drop_en_set,
13102 (void *)&cmd_all_queues_drop_en_all,
13103 (void *)&cmd_all_queues_drop_en_queues,
13104 (void *)&cmd_all_queues_drop_en_drop,
13105 (void *)&cmd_all_queues_drop_en_port_id,
13106 (void *)&cmd_all_queues_drop_en_on_off,
13111 /* vf split drop enable configuration */
13113 /* Common result structure for vf split drop enable */
13114 struct cmd_vf_split_drop_en_result {
13115 cmdline_fixed_string_t set;
13116 cmdline_fixed_string_t vf;
13117 cmdline_fixed_string_t split;
13118 cmdline_fixed_string_t drop;
13121 cmdline_fixed_string_t on_off;
13124 /* Common CLI fields for vf split drop enable disable */
13125 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
13126 TOKEN_STRING_INITIALIZER
13127 (struct cmd_vf_split_drop_en_result,
13129 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
13130 TOKEN_STRING_INITIALIZER
13131 (struct cmd_vf_split_drop_en_result,
13133 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
13134 TOKEN_STRING_INITIALIZER
13135 (struct cmd_vf_split_drop_en_result,
13137 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
13138 TOKEN_STRING_INITIALIZER
13139 (struct cmd_vf_split_drop_en_result,
13141 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
13142 TOKEN_NUM_INITIALIZER
13143 (struct cmd_vf_split_drop_en_result,
13145 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
13146 TOKEN_NUM_INITIALIZER
13147 (struct cmd_vf_split_drop_en_result,
13149 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
13150 TOKEN_STRING_INITIALIZER
13151 (struct cmd_vf_split_drop_en_result,
13155 cmd_set_vf_split_drop_en_parsed(
13156 void *parsed_result,
13157 __attribute__((unused)) struct cmdline *cl,
13158 __attribute__((unused)) void *data)
13160 struct cmd_vf_split_drop_en_result *res = parsed_result;
13161 int ret = -ENOTSUP;
13162 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13164 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13167 #ifdef RTE_LIBRTE_IXGBE_PMD
13168 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
13175 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13178 printf("invalid port_id %d\n", res->port_id);
13181 printf("not supported on port %d\n", res->port_id);
13184 printf("programming error: (%s)\n", strerror(-ret));
13188 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
13189 .f = cmd_set_vf_split_drop_en_parsed,
13191 .help_str = "set vf split drop <port_id> <vf_id> on|off",
13193 (void *)&cmd_vf_split_drop_en_set,
13194 (void *)&cmd_vf_split_drop_en_vf,
13195 (void *)&cmd_vf_split_drop_en_split,
13196 (void *)&cmd_vf_split_drop_en_drop,
13197 (void *)&cmd_vf_split_drop_en_port_id,
13198 (void *)&cmd_vf_split_drop_en_vf_id,
13199 (void *)&cmd_vf_split_drop_en_on_off,
13204 /* vf mac address configuration */
13206 /* Common result structure for vf mac address */
13207 struct cmd_set_vf_mac_addr_result {
13208 cmdline_fixed_string_t set;
13209 cmdline_fixed_string_t vf;
13210 cmdline_fixed_string_t mac;
13211 cmdline_fixed_string_t addr;
13214 struct ether_addr mac_addr;
13218 /* Common CLI fields for vf split drop enable disable */
13219 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
13220 TOKEN_STRING_INITIALIZER
13221 (struct cmd_set_vf_mac_addr_result,
13223 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
13224 TOKEN_STRING_INITIALIZER
13225 (struct cmd_set_vf_mac_addr_result,
13227 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
13228 TOKEN_STRING_INITIALIZER
13229 (struct cmd_set_vf_mac_addr_result,
13231 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
13232 TOKEN_STRING_INITIALIZER
13233 (struct cmd_set_vf_mac_addr_result,
13235 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
13236 TOKEN_NUM_INITIALIZER
13237 (struct cmd_set_vf_mac_addr_result,
13239 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
13240 TOKEN_NUM_INITIALIZER
13241 (struct cmd_set_vf_mac_addr_result,
13243 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
13244 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
13248 cmd_set_vf_mac_addr_parsed(
13249 void *parsed_result,
13250 __attribute__((unused)) struct cmdline *cl,
13251 __attribute__((unused)) void *data)
13253 struct cmd_set_vf_mac_addr_result *res = parsed_result;
13254 int ret = -ENOTSUP;
13256 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13259 #ifdef RTE_LIBRTE_IXGBE_PMD
13260 if (ret == -ENOTSUP)
13261 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
13264 #ifdef RTE_LIBRTE_I40E_PMD
13265 if (ret == -ENOTSUP)
13266 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
13269 #ifdef RTE_LIBRTE_BNXT_PMD
13270 if (ret == -ENOTSUP)
13271 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
13279 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
13282 printf("invalid port_id %d\n", res->port_id);
13285 printf("function not implemented\n");
13288 printf("programming error: (%s)\n", strerror(-ret));
13292 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
13293 .f = cmd_set_vf_mac_addr_parsed,
13295 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
13297 (void *)&cmd_set_vf_mac_addr_set,
13298 (void *)&cmd_set_vf_mac_addr_vf,
13299 (void *)&cmd_set_vf_mac_addr_mac,
13300 (void *)&cmd_set_vf_mac_addr_addr,
13301 (void *)&cmd_set_vf_mac_addr_port_id,
13302 (void *)&cmd_set_vf_mac_addr_vf_id,
13303 (void *)&cmd_set_vf_mac_addr_mac_addr,
13308 /* MACsec configuration */
13310 /* Common result structure for MACsec offload enable */
13311 struct cmd_macsec_offload_on_result {
13312 cmdline_fixed_string_t set;
13313 cmdline_fixed_string_t macsec;
13314 cmdline_fixed_string_t offload;
13316 cmdline_fixed_string_t on;
13317 cmdline_fixed_string_t encrypt;
13318 cmdline_fixed_string_t en_on_off;
13319 cmdline_fixed_string_t replay_protect;
13320 cmdline_fixed_string_t rp_on_off;
13323 /* Common CLI fields for MACsec offload disable */
13324 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
13325 TOKEN_STRING_INITIALIZER
13326 (struct cmd_macsec_offload_on_result,
13328 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
13329 TOKEN_STRING_INITIALIZER
13330 (struct cmd_macsec_offload_on_result,
13332 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
13333 TOKEN_STRING_INITIALIZER
13334 (struct cmd_macsec_offload_on_result,
13335 offload, "offload");
13336 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
13337 TOKEN_NUM_INITIALIZER
13338 (struct cmd_macsec_offload_on_result,
13340 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
13341 TOKEN_STRING_INITIALIZER
13342 (struct cmd_macsec_offload_on_result,
13344 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
13345 TOKEN_STRING_INITIALIZER
13346 (struct cmd_macsec_offload_on_result,
13347 encrypt, "encrypt");
13348 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
13349 TOKEN_STRING_INITIALIZER
13350 (struct cmd_macsec_offload_on_result,
13351 en_on_off, "on#off");
13352 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
13353 TOKEN_STRING_INITIALIZER
13354 (struct cmd_macsec_offload_on_result,
13355 replay_protect, "replay-protect");
13356 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
13357 TOKEN_STRING_INITIALIZER
13358 (struct cmd_macsec_offload_on_result,
13359 rp_on_off, "on#off");
13362 cmd_set_macsec_offload_on_parsed(
13363 void *parsed_result,
13364 __attribute__((unused)) struct cmdline *cl,
13365 __attribute__((unused)) void *data)
13367 struct cmd_macsec_offload_on_result *res = parsed_result;
13368 int ret = -ENOTSUP;
13369 portid_t port_id = res->port_id;
13370 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
13371 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
13372 struct rte_eth_dev_info dev_info;
13374 if (port_id_is_invalid(port_id, ENABLED_WARN))
13376 if (!port_is_stopped(port_id)) {
13377 printf("Please stop port %d first\n", port_id);
13381 rte_eth_dev_info_get(port_id, &dev_info);
13382 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13383 #ifdef RTE_LIBRTE_IXGBE_PMD
13384 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
13392 ports[port_id].dev_conf.txmode.offloads |=
13393 DEV_TX_OFFLOAD_MACSEC_INSERT;
13394 cmd_reconfig_device_queue(port_id, 1, 1);
13397 printf("invalid port_id %d\n", port_id);
13400 printf("not supported on port %d\n", port_id);
13403 printf("programming error: (%s)\n", strerror(-ret));
13407 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
13408 .f = cmd_set_macsec_offload_on_parsed,
13410 .help_str = "set macsec offload <port_id> on "
13411 "encrypt on|off replay-protect on|off",
13413 (void *)&cmd_macsec_offload_on_set,
13414 (void *)&cmd_macsec_offload_on_macsec,
13415 (void *)&cmd_macsec_offload_on_offload,
13416 (void *)&cmd_macsec_offload_on_port_id,
13417 (void *)&cmd_macsec_offload_on_on,
13418 (void *)&cmd_macsec_offload_on_encrypt,
13419 (void *)&cmd_macsec_offload_on_en_on_off,
13420 (void *)&cmd_macsec_offload_on_replay_protect,
13421 (void *)&cmd_macsec_offload_on_rp_on_off,
13426 /* Common result structure for MACsec offload disable */
13427 struct cmd_macsec_offload_off_result {
13428 cmdline_fixed_string_t set;
13429 cmdline_fixed_string_t macsec;
13430 cmdline_fixed_string_t offload;
13432 cmdline_fixed_string_t off;
13435 /* Common CLI fields for MACsec offload disable */
13436 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
13437 TOKEN_STRING_INITIALIZER
13438 (struct cmd_macsec_offload_off_result,
13440 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
13441 TOKEN_STRING_INITIALIZER
13442 (struct cmd_macsec_offload_off_result,
13444 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
13445 TOKEN_STRING_INITIALIZER
13446 (struct cmd_macsec_offload_off_result,
13447 offload, "offload");
13448 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
13449 TOKEN_NUM_INITIALIZER
13450 (struct cmd_macsec_offload_off_result,
13452 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
13453 TOKEN_STRING_INITIALIZER
13454 (struct cmd_macsec_offload_off_result,
13458 cmd_set_macsec_offload_off_parsed(
13459 void *parsed_result,
13460 __attribute__((unused)) struct cmdline *cl,
13461 __attribute__((unused)) void *data)
13463 struct cmd_macsec_offload_off_result *res = parsed_result;
13464 int ret = -ENOTSUP;
13465 struct rte_eth_dev_info dev_info;
13466 portid_t port_id = res->port_id;
13468 if (port_id_is_invalid(port_id, ENABLED_WARN))
13470 if (!port_is_stopped(port_id)) {
13471 printf("Please stop port %d first\n", port_id);
13475 rte_eth_dev_info_get(port_id, &dev_info);
13476 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13477 #ifdef RTE_LIBRTE_IXGBE_PMD
13478 ret = rte_pmd_ixgbe_macsec_disable(port_id);
13483 ports[port_id].dev_conf.txmode.offloads &=
13484 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
13485 cmd_reconfig_device_queue(port_id, 1, 1);
13488 printf("invalid port_id %d\n", port_id);
13491 printf("not supported on port %d\n", port_id);
13494 printf("programming error: (%s)\n", strerror(-ret));
13498 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
13499 .f = cmd_set_macsec_offload_off_parsed,
13501 .help_str = "set macsec offload <port_id> off",
13503 (void *)&cmd_macsec_offload_off_set,
13504 (void *)&cmd_macsec_offload_off_macsec,
13505 (void *)&cmd_macsec_offload_off_offload,
13506 (void *)&cmd_macsec_offload_off_port_id,
13507 (void *)&cmd_macsec_offload_off_off,
13512 /* Common result structure for MACsec secure connection configure */
13513 struct cmd_macsec_sc_result {
13514 cmdline_fixed_string_t set;
13515 cmdline_fixed_string_t macsec;
13516 cmdline_fixed_string_t sc;
13517 cmdline_fixed_string_t tx_rx;
13519 struct ether_addr mac;
13523 /* Common CLI fields for MACsec secure connection configure */
13524 cmdline_parse_token_string_t cmd_macsec_sc_set =
13525 TOKEN_STRING_INITIALIZER
13526 (struct cmd_macsec_sc_result,
13528 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
13529 TOKEN_STRING_INITIALIZER
13530 (struct cmd_macsec_sc_result,
13532 cmdline_parse_token_string_t cmd_macsec_sc_sc =
13533 TOKEN_STRING_INITIALIZER
13534 (struct cmd_macsec_sc_result,
13536 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
13537 TOKEN_STRING_INITIALIZER
13538 (struct cmd_macsec_sc_result,
13540 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
13541 TOKEN_NUM_INITIALIZER
13542 (struct cmd_macsec_sc_result,
13544 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
13545 TOKEN_ETHERADDR_INITIALIZER
13546 (struct cmd_macsec_sc_result,
13548 cmdline_parse_token_num_t cmd_macsec_sc_pi =
13549 TOKEN_NUM_INITIALIZER
13550 (struct cmd_macsec_sc_result,
13554 cmd_set_macsec_sc_parsed(
13555 void *parsed_result,
13556 __attribute__((unused)) struct cmdline *cl,
13557 __attribute__((unused)) void *data)
13559 struct cmd_macsec_sc_result *res = parsed_result;
13560 int ret = -ENOTSUP;
13561 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13563 #ifdef RTE_LIBRTE_IXGBE_PMD
13565 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
13566 res->mac.addr_bytes) :
13567 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
13568 res->mac.addr_bytes, res->pi);
13570 RTE_SET_USED(is_tx);
13576 printf("invalid port_id %d\n", res->port_id);
13579 printf("not supported on port %d\n", res->port_id);
13582 printf("programming error: (%s)\n", strerror(-ret));
13586 cmdline_parse_inst_t cmd_set_macsec_sc = {
13587 .f = cmd_set_macsec_sc_parsed,
13589 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
13591 (void *)&cmd_macsec_sc_set,
13592 (void *)&cmd_macsec_sc_macsec,
13593 (void *)&cmd_macsec_sc_sc,
13594 (void *)&cmd_macsec_sc_tx_rx,
13595 (void *)&cmd_macsec_sc_port_id,
13596 (void *)&cmd_macsec_sc_mac,
13597 (void *)&cmd_macsec_sc_pi,
13602 /* Common result structure for MACsec secure connection configure */
13603 struct cmd_macsec_sa_result {
13604 cmdline_fixed_string_t set;
13605 cmdline_fixed_string_t macsec;
13606 cmdline_fixed_string_t sa;
13607 cmdline_fixed_string_t tx_rx;
13612 cmdline_fixed_string_t key;
13615 /* Common CLI fields for MACsec secure connection configure */
13616 cmdline_parse_token_string_t cmd_macsec_sa_set =
13617 TOKEN_STRING_INITIALIZER
13618 (struct cmd_macsec_sa_result,
13620 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
13621 TOKEN_STRING_INITIALIZER
13622 (struct cmd_macsec_sa_result,
13624 cmdline_parse_token_string_t cmd_macsec_sa_sa =
13625 TOKEN_STRING_INITIALIZER
13626 (struct cmd_macsec_sa_result,
13628 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
13629 TOKEN_STRING_INITIALIZER
13630 (struct cmd_macsec_sa_result,
13632 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
13633 TOKEN_NUM_INITIALIZER
13634 (struct cmd_macsec_sa_result,
13636 cmdline_parse_token_num_t cmd_macsec_sa_idx =
13637 TOKEN_NUM_INITIALIZER
13638 (struct cmd_macsec_sa_result,
13640 cmdline_parse_token_num_t cmd_macsec_sa_an =
13641 TOKEN_NUM_INITIALIZER
13642 (struct cmd_macsec_sa_result,
13644 cmdline_parse_token_num_t cmd_macsec_sa_pn =
13645 TOKEN_NUM_INITIALIZER
13646 (struct cmd_macsec_sa_result,
13648 cmdline_parse_token_string_t cmd_macsec_sa_key =
13649 TOKEN_STRING_INITIALIZER
13650 (struct cmd_macsec_sa_result,
13654 cmd_set_macsec_sa_parsed(
13655 void *parsed_result,
13656 __attribute__((unused)) struct cmdline *cl,
13657 __attribute__((unused)) void *data)
13659 struct cmd_macsec_sa_result *res = parsed_result;
13660 int ret = -ENOTSUP;
13661 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13662 uint8_t key[16] = { 0 };
13668 key_len = strlen(res->key) / 2;
13672 for (i = 0; i < key_len; i++) {
13673 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
13676 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
13679 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
13682 #ifdef RTE_LIBRTE_IXGBE_PMD
13684 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
13685 res->idx, res->an, res->pn, key) :
13686 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
13687 res->idx, res->an, res->pn, key);
13689 RTE_SET_USED(is_tx);
13696 printf("invalid idx %d or an %d\n", res->idx, res->an);
13699 printf("invalid port_id %d\n", res->port_id);
13702 printf("not supported on port %d\n", res->port_id);
13705 printf("programming error: (%s)\n", strerror(-ret));
13709 cmdline_parse_inst_t cmd_set_macsec_sa = {
13710 .f = cmd_set_macsec_sa_parsed,
13712 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
13714 (void *)&cmd_macsec_sa_set,
13715 (void *)&cmd_macsec_sa_macsec,
13716 (void *)&cmd_macsec_sa_sa,
13717 (void *)&cmd_macsec_sa_tx_rx,
13718 (void *)&cmd_macsec_sa_port_id,
13719 (void *)&cmd_macsec_sa_idx,
13720 (void *)&cmd_macsec_sa_an,
13721 (void *)&cmd_macsec_sa_pn,
13722 (void *)&cmd_macsec_sa_key,
13727 /* VF unicast promiscuous mode configuration */
13729 /* Common result structure for VF unicast promiscuous mode */
13730 struct cmd_vf_promisc_result {
13731 cmdline_fixed_string_t set;
13732 cmdline_fixed_string_t vf;
13733 cmdline_fixed_string_t promisc;
13736 cmdline_fixed_string_t on_off;
13739 /* Common CLI fields for VF unicast promiscuous mode enable disable */
13740 cmdline_parse_token_string_t cmd_vf_promisc_set =
13741 TOKEN_STRING_INITIALIZER
13742 (struct cmd_vf_promisc_result,
13744 cmdline_parse_token_string_t cmd_vf_promisc_vf =
13745 TOKEN_STRING_INITIALIZER
13746 (struct cmd_vf_promisc_result,
13748 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
13749 TOKEN_STRING_INITIALIZER
13750 (struct cmd_vf_promisc_result,
13751 promisc, "promisc");
13752 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
13753 TOKEN_NUM_INITIALIZER
13754 (struct cmd_vf_promisc_result,
13756 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
13757 TOKEN_NUM_INITIALIZER
13758 (struct cmd_vf_promisc_result,
13760 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
13761 TOKEN_STRING_INITIALIZER
13762 (struct cmd_vf_promisc_result,
13766 cmd_set_vf_promisc_parsed(
13767 void *parsed_result,
13768 __attribute__((unused)) struct cmdline *cl,
13769 __attribute__((unused)) void *data)
13771 struct cmd_vf_promisc_result *res = parsed_result;
13772 int ret = -ENOTSUP;
13774 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13776 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13779 #ifdef RTE_LIBRTE_I40E_PMD
13780 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
13781 res->vf_id, is_on);
13788 printf("invalid vf_id %d\n", res->vf_id);
13791 printf("invalid port_id %d\n", res->port_id);
13794 printf("function not implemented\n");
13797 printf("programming error: (%s)\n", strerror(-ret));
13801 cmdline_parse_inst_t cmd_set_vf_promisc = {
13802 .f = cmd_set_vf_promisc_parsed,
13804 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
13805 "Set unicast promiscuous mode for a VF from the PF",
13807 (void *)&cmd_vf_promisc_set,
13808 (void *)&cmd_vf_promisc_vf,
13809 (void *)&cmd_vf_promisc_promisc,
13810 (void *)&cmd_vf_promisc_port_id,
13811 (void *)&cmd_vf_promisc_vf_id,
13812 (void *)&cmd_vf_promisc_on_off,
13817 /* VF multicast promiscuous mode configuration */
13819 /* Common result structure for VF multicast promiscuous mode */
13820 struct cmd_vf_allmulti_result {
13821 cmdline_fixed_string_t set;
13822 cmdline_fixed_string_t vf;
13823 cmdline_fixed_string_t allmulti;
13826 cmdline_fixed_string_t on_off;
13829 /* Common CLI fields for VF multicast promiscuous mode enable disable */
13830 cmdline_parse_token_string_t cmd_vf_allmulti_set =
13831 TOKEN_STRING_INITIALIZER
13832 (struct cmd_vf_allmulti_result,
13834 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
13835 TOKEN_STRING_INITIALIZER
13836 (struct cmd_vf_allmulti_result,
13838 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
13839 TOKEN_STRING_INITIALIZER
13840 (struct cmd_vf_allmulti_result,
13841 allmulti, "allmulti");
13842 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
13843 TOKEN_NUM_INITIALIZER
13844 (struct cmd_vf_allmulti_result,
13846 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
13847 TOKEN_NUM_INITIALIZER
13848 (struct cmd_vf_allmulti_result,
13850 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
13851 TOKEN_STRING_INITIALIZER
13852 (struct cmd_vf_allmulti_result,
13856 cmd_set_vf_allmulti_parsed(
13857 void *parsed_result,
13858 __attribute__((unused)) struct cmdline *cl,
13859 __attribute__((unused)) void *data)
13861 struct cmd_vf_allmulti_result *res = parsed_result;
13862 int ret = -ENOTSUP;
13864 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13866 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13869 #ifdef RTE_LIBRTE_I40E_PMD
13870 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
13871 res->vf_id, is_on);
13878 printf("invalid vf_id %d\n", res->vf_id);
13881 printf("invalid port_id %d\n", res->port_id);
13884 printf("function not implemented\n");
13887 printf("programming error: (%s)\n", strerror(-ret));
13891 cmdline_parse_inst_t cmd_set_vf_allmulti = {
13892 .f = cmd_set_vf_allmulti_parsed,
13894 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
13895 "Set multicast promiscuous mode for a VF from the PF",
13897 (void *)&cmd_vf_allmulti_set,
13898 (void *)&cmd_vf_allmulti_vf,
13899 (void *)&cmd_vf_allmulti_allmulti,
13900 (void *)&cmd_vf_allmulti_port_id,
13901 (void *)&cmd_vf_allmulti_vf_id,
13902 (void *)&cmd_vf_allmulti_on_off,
13907 /* vf broadcast mode configuration */
13909 /* Common result structure for vf broadcast */
13910 struct cmd_set_vf_broadcast_result {
13911 cmdline_fixed_string_t set;
13912 cmdline_fixed_string_t vf;
13913 cmdline_fixed_string_t broadcast;
13916 cmdline_fixed_string_t on_off;
13919 /* Common CLI fields for vf broadcast enable disable */
13920 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
13921 TOKEN_STRING_INITIALIZER
13922 (struct cmd_set_vf_broadcast_result,
13924 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
13925 TOKEN_STRING_INITIALIZER
13926 (struct cmd_set_vf_broadcast_result,
13928 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
13929 TOKEN_STRING_INITIALIZER
13930 (struct cmd_set_vf_broadcast_result,
13931 broadcast, "broadcast");
13932 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
13933 TOKEN_NUM_INITIALIZER
13934 (struct cmd_set_vf_broadcast_result,
13936 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
13937 TOKEN_NUM_INITIALIZER
13938 (struct cmd_set_vf_broadcast_result,
13940 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
13941 TOKEN_STRING_INITIALIZER
13942 (struct cmd_set_vf_broadcast_result,
13946 cmd_set_vf_broadcast_parsed(
13947 void *parsed_result,
13948 __attribute__((unused)) struct cmdline *cl,
13949 __attribute__((unused)) void *data)
13951 struct cmd_set_vf_broadcast_result *res = parsed_result;
13952 int ret = -ENOTSUP;
13954 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13956 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13959 #ifdef RTE_LIBRTE_I40E_PMD
13960 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
13961 res->vf_id, is_on);
13968 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13971 printf("invalid port_id %d\n", res->port_id);
13974 printf("function not implemented\n");
13977 printf("programming error: (%s)\n", strerror(-ret));
13981 cmdline_parse_inst_t cmd_set_vf_broadcast = {
13982 .f = cmd_set_vf_broadcast_parsed,
13984 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
13986 (void *)&cmd_set_vf_broadcast_set,
13987 (void *)&cmd_set_vf_broadcast_vf,
13988 (void *)&cmd_set_vf_broadcast_broadcast,
13989 (void *)&cmd_set_vf_broadcast_port_id,
13990 (void *)&cmd_set_vf_broadcast_vf_id,
13991 (void *)&cmd_set_vf_broadcast_on_off,
13996 /* vf vlan tag configuration */
13998 /* Common result structure for vf vlan tag */
13999 struct cmd_set_vf_vlan_tag_result {
14000 cmdline_fixed_string_t set;
14001 cmdline_fixed_string_t vf;
14002 cmdline_fixed_string_t vlan;
14003 cmdline_fixed_string_t tag;
14006 cmdline_fixed_string_t on_off;
14009 /* Common CLI fields for vf vlan tag enable disable */
14010 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
14011 TOKEN_STRING_INITIALIZER
14012 (struct cmd_set_vf_vlan_tag_result,
14014 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
14015 TOKEN_STRING_INITIALIZER
14016 (struct cmd_set_vf_vlan_tag_result,
14018 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
14019 TOKEN_STRING_INITIALIZER
14020 (struct cmd_set_vf_vlan_tag_result,
14022 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
14023 TOKEN_STRING_INITIALIZER
14024 (struct cmd_set_vf_vlan_tag_result,
14026 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
14027 TOKEN_NUM_INITIALIZER
14028 (struct cmd_set_vf_vlan_tag_result,
14030 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
14031 TOKEN_NUM_INITIALIZER
14032 (struct cmd_set_vf_vlan_tag_result,
14034 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
14035 TOKEN_STRING_INITIALIZER
14036 (struct cmd_set_vf_vlan_tag_result,
14040 cmd_set_vf_vlan_tag_parsed(
14041 void *parsed_result,
14042 __attribute__((unused)) struct cmdline *cl,
14043 __attribute__((unused)) void *data)
14045 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
14046 int ret = -ENOTSUP;
14048 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14050 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14053 #ifdef RTE_LIBRTE_I40E_PMD
14054 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
14055 res->vf_id, is_on);
14062 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14065 printf("invalid port_id %d\n", res->port_id);
14068 printf("function not implemented\n");
14071 printf("programming error: (%s)\n", strerror(-ret));
14075 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
14076 .f = cmd_set_vf_vlan_tag_parsed,
14078 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
14080 (void *)&cmd_set_vf_vlan_tag_set,
14081 (void *)&cmd_set_vf_vlan_tag_vf,
14082 (void *)&cmd_set_vf_vlan_tag_vlan,
14083 (void *)&cmd_set_vf_vlan_tag_tag,
14084 (void *)&cmd_set_vf_vlan_tag_port_id,
14085 (void *)&cmd_set_vf_vlan_tag_vf_id,
14086 (void *)&cmd_set_vf_vlan_tag_on_off,
14091 /* Common definition of VF and TC TX bandwidth configuration */
14092 struct cmd_vf_tc_bw_result {
14093 cmdline_fixed_string_t set;
14094 cmdline_fixed_string_t vf;
14095 cmdline_fixed_string_t tc;
14096 cmdline_fixed_string_t tx;
14097 cmdline_fixed_string_t min_bw;
14098 cmdline_fixed_string_t max_bw;
14099 cmdline_fixed_string_t strict_link_prio;
14104 cmdline_fixed_string_t bw_list;
14108 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
14109 TOKEN_STRING_INITIALIZER
14110 (struct cmd_vf_tc_bw_result,
14112 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
14113 TOKEN_STRING_INITIALIZER
14114 (struct cmd_vf_tc_bw_result,
14116 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
14117 TOKEN_STRING_INITIALIZER
14118 (struct cmd_vf_tc_bw_result,
14120 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
14121 TOKEN_STRING_INITIALIZER
14122 (struct cmd_vf_tc_bw_result,
14124 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
14125 TOKEN_STRING_INITIALIZER
14126 (struct cmd_vf_tc_bw_result,
14127 strict_link_prio, "strict-link-priority");
14128 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
14129 TOKEN_STRING_INITIALIZER
14130 (struct cmd_vf_tc_bw_result,
14131 min_bw, "min-bandwidth");
14132 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
14133 TOKEN_STRING_INITIALIZER
14134 (struct cmd_vf_tc_bw_result,
14135 max_bw, "max-bandwidth");
14136 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
14137 TOKEN_NUM_INITIALIZER
14138 (struct cmd_vf_tc_bw_result,
14140 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
14141 TOKEN_NUM_INITIALIZER
14142 (struct cmd_vf_tc_bw_result,
14144 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
14145 TOKEN_NUM_INITIALIZER
14146 (struct cmd_vf_tc_bw_result,
14148 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
14149 TOKEN_NUM_INITIALIZER
14150 (struct cmd_vf_tc_bw_result,
14152 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
14153 TOKEN_STRING_INITIALIZER
14154 (struct cmd_vf_tc_bw_result,
14156 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
14157 TOKEN_NUM_INITIALIZER
14158 (struct cmd_vf_tc_bw_result,
14161 /* VF max bandwidth setting */
14163 cmd_vf_max_bw_parsed(
14164 void *parsed_result,
14165 __attribute__((unused)) struct cmdline *cl,
14166 __attribute__((unused)) void *data)
14168 struct cmd_vf_tc_bw_result *res = parsed_result;
14169 int ret = -ENOTSUP;
14171 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14174 #ifdef RTE_LIBRTE_I40E_PMD
14175 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
14176 res->vf_id, res->bw);
14183 printf("invalid vf_id %d or bandwidth %d\n",
14184 res->vf_id, res->bw);
14187 printf("invalid port_id %d\n", res->port_id);
14190 printf("function not implemented\n");
14193 printf("programming error: (%s)\n", strerror(-ret));
14197 cmdline_parse_inst_t cmd_vf_max_bw = {
14198 .f = cmd_vf_max_bw_parsed,
14200 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
14202 (void *)&cmd_vf_tc_bw_set,
14203 (void *)&cmd_vf_tc_bw_vf,
14204 (void *)&cmd_vf_tc_bw_tx,
14205 (void *)&cmd_vf_tc_bw_max_bw,
14206 (void *)&cmd_vf_tc_bw_port_id,
14207 (void *)&cmd_vf_tc_bw_vf_id,
14208 (void *)&cmd_vf_tc_bw_bw,
14214 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
14219 const char *p, *p0 = str;
14226 p = strchr(p0, '(');
14228 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14232 p0 = strchr(p, ')');
14234 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14238 if (size >= sizeof(s)) {
14239 printf("The string size exceeds the internal buffer size\n");
14242 snprintf(s, sizeof(s), "%.*s", size, p);
14243 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
14245 printf("Failed to get the bandwidth list. ");
14249 for (i = 0; i < ret; i++)
14250 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
14255 /* TC min bandwidth setting */
14257 cmd_vf_tc_min_bw_parsed(
14258 void *parsed_result,
14259 __attribute__((unused)) struct cmdline *cl,
14260 __attribute__((unused)) void *data)
14262 struct cmd_vf_tc_bw_result *res = parsed_result;
14265 int ret = -ENOTSUP;
14267 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14270 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14274 #ifdef RTE_LIBRTE_I40E_PMD
14275 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
14283 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
14286 printf("invalid port_id %d\n", res->port_id);
14289 printf("function not implemented\n");
14292 printf("programming error: (%s)\n", strerror(-ret));
14296 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
14297 .f = cmd_vf_tc_min_bw_parsed,
14299 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
14300 " <bw1, bw2, ...>",
14302 (void *)&cmd_vf_tc_bw_set,
14303 (void *)&cmd_vf_tc_bw_vf,
14304 (void *)&cmd_vf_tc_bw_tc,
14305 (void *)&cmd_vf_tc_bw_tx,
14306 (void *)&cmd_vf_tc_bw_min_bw,
14307 (void *)&cmd_vf_tc_bw_port_id,
14308 (void *)&cmd_vf_tc_bw_vf_id,
14309 (void *)&cmd_vf_tc_bw_bw_list,
14315 cmd_tc_min_bw_parsed(
14316 void *parsed_result,
14317 __attribute__((unused)) struct cmdline *cl,
14318 __attribute__((unused)) void *data)
14320 struct cmd_vf_tc_bw_result *res = parsed_result;
14321 struct rte_port *port;
14324 int ret = -ENOTSUP;
14326 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14329 port = &ports[res->port_id];
14330 /** Check if the port is not started **/
14331 if (port->port_status != RTE_PORT_STOPPED) {
14332 printf("Please stop port %d first\n", res->port_id);
14336 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14340 #ifdef RTE_LIBRTE_IXGBE_PMD
14341 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
14348 printf("invalid bandwidth\n");
14351 printf("invalid port_id %d\n", res->port_id);
14354 printf("function not implemented\n");
14357 printf("programming error: (%s)\n", strerror(-ret));
14361 cmdline_parse_inst_t cmd_tc_min_bw = {
14362 .f = cmd_tc_min_bw_parsed,
14364 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
14366 (void *)&cmd_vf_tc_bw_set,
14367 (void *)&cmd_vf_tc_bw_tc,
14368 (void *)&cmd_vf_tc_bw_tx,
14369 (void *)&cmd_vf_tc_bw_min_bw,
14370 (void *)&cmd_vf_tc_bw_port_id,
14371 (void *)&cmd_vf_tc_bw_bw_list,
14376 /* TC max bandwidth setting */
14378 cmd_vf_tc_max_bw_parsed(
14379 void *parsed_result,
14380 __attribute__((unused)) struct cmdline *cl,
14381 __attribute__((unused)) void *data)
14383 struct cmd_vf_tc_bw_result *res = parsed_result;
14384 int ret = -ENOTSUP;
14386 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14389 #ifdef RTE_LIBRTE_I40E_PMD
14390 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
14391 res->tc_no, res->bw);
14398 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
14399 res->vf_id, res->tc_no, res->bw);
14402 printf("invalid port_id %d\n", res->port_id);
14405 printf("function not implemented\n");
14408 printf("programming error: (%s)\n", strerror(-ret));
14412 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
14413 .f = cmd_vf_tc_max_bw_parsed,
14415 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
14418 (void *)&cmd_vf_tc_bw_set,
14419 (void *)&cmd_vf_tc_bw_vf,
14420 (void *)&cmd_vf_tc_bw_tc,
14421 (void *)&cmd_vf_tc_bw_tx,
14422 (void *)&cmd_vf_tc_bw_max_bw,
14423 (void *)&cmd_vf_tc_bw_port_id,
14424 (void *)&cmd_vf_tc_bw_vf_id,
14425 (void *)&cmd_vf_tc_bw_tc_no,
14426 (void *)&cmd_vf_tc_bw_bw,
14432 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
14434 /* *** Set Port default Traffic Management Hierarchy *** */
14435 struct cmd_set_port_tm_hierarchy_default_result {
14436 cmdline_fixed_string_t set;
14437 cmdline_fixed_string_t port;
14438 cmdline_fixed_string_t tm;
14439 cmdline_fixed_string_t hierarchy;
14440 cmdline_fixed_string_t def;
14444 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
14445 TOKEN_STRING_INITIALIZER(
14446 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
14447 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
14448 TOKEN_STRING_INITIALIZER(
14449 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
14450 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
14451 TOKEN_STRING_INITIALIZER(
14452 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
14453 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
14454 TOKEN_STRING_INITIALIZER(
14455 struct cmd_set_port_tm_hierarchy_default_result,
14456 hierarchy, "hierarchy");
14457 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
14458 TOKEN_STRING_INITIALIZER(
14459 struct cmd_set_port_tm_hierarchy_default_result,
14461 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
14462 TOKEN_NUM_INITIALIZER(
14463 struct cmd_set_port_tm_hierarchy_default_result,
14466 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
14467 __attribute__((unused)) struct cmdline *cl,
14468 __attribute__((unused)) void *data)
14470 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
14471 struct rte_port *p;
14472 portid_t port_id = res->port_id;
14474 if (port_id_is_invalid(port_id, ENABLED_WARN))
14477 p = &ports[port_id];
14480 if (p->softport.tm_flag == 0) {
14481 printf(" tm not enabled on port %u (error)\n", port_id);
14485 /* Forward mode: tm */
14486 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "tm")) {
14487 printf(" tm mode not enabled(error)\n");
14491 /* Set the default tm hierarchy */
14492 p->softport.tm.default_hierarchy_enable = 1;
14495 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
14496 .f = cmd_set_port_tm_hierarchy_default_parsed,
14498 .help_str = "set port tm hierarchy default <port_id>",
14500 (void *)&cmd_set_port_tm_hierarchy_default_set,
14501 (void *)&cmd_set_port_tm_hierarchy_default_port,
14502 (void *)&cmd_set_port_tm_hierarchy_default_tm,
14503 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
14504 (void *)&cmd_set_port_tm_hierarchy_default_default,
14505 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
14511 /* Strict link priority scheduling mode setting */
14513 cmd_strict_link_prio_parsed(
14514 void *parsed_result,
14515 __attribute__((unused)) struct cmdline *cl,
14516 __attribute__((unused)) void *data)
14518 struct cmd_vf_tc_bw_result *res = parsed_result;
14519 int ret = -ENOTSUP;
14521 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14524 #ifdef RTE_LIBRTE_I40E_PMD
14525 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
14532 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
14535 printf("invalid port_id %d\n", res->port_id);
14538 printf("function not implemented\n");
14541 printf("programming error: (%s)\n", strerror(-ret));
14545 cmdline_parse_inst_t cmd_strict_link_prio = {
14546 .f = cmd_strict_link_prio_parsed,
14548 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
14550 (void *)&cmd_vf_tc_bw_set,
14551 (void *)&cmd_vf_tc_bw_tx,
14552 (void *)&cmd_vf_tc_bw_strict_link_prio,
14553 (void *)&cmd_vf_tc_bw_port_id,
14554 (void *)&cmd_vf_tc_bw_tc_map,
14559 /* Load dynamic device personalization*/
14560 struct cmd_ddp_add_result {
14561 cmdline_fixed_string_t ddp;
14562 cmdline_fixed_string_t add;
14567 cmdline_parse_token_string_t cmd_ddp_add_ddp =
14568 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
14569 cmdline_parse_token_string_t cmd_ddp_add_add =
14570 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
14571 cmdline_parse_token_num_t cmd_ddp_add_port_id =
14572 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
14573 cmdline_parse_token_string_t cmd_ddp_add_filepath =
14574 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
14577 cmd_ddp_add_parsed(
14578 void *parsed_result,
14579 __attribute__((unused)) struct cmdline *cl,
14580 __attribute__((unused)) void *data)
14582 struct cmd_ddp_add_result *res = parsed_result;
14588 int ret = -ENOTSUP;
14590 if (!all_ports_stopped()) {
14591 printf("Please stop all ports first\n");
14595 filepath = strdup(res->filepath);
14596 if (filepath == NULL) {
14597 printf("Failed to allocate memory\n");
14600 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
14602 buff = open_file(file_fld[0], &size);
14604 free((void *)filepath);
14608 #ifdef RTE_LIBRTE_I40E_PMD
14609 if (ret == -ENOTSUP)
14610 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14612 RTE_PMD_I40E_PKG_OP_WR_ADD);
14615 if (ret == -EEXIST)
14616 printf("Profile has already existed.\n");
14618 printf("Failed to load profile.\n");
14619 else if (file_num == 2)
14620 save_file(file_fld[1], buff, size);
14623 free((void *)filepath);
14626 cmdline_parse_inst_t cmd_ddp_add = {
14627 .f = cmd_ddp_add_parsed,
14629 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
14631 (void *)&cmd_ddp_add_ddp,
14632 (void *)&cmd_ddp_add_add,
14633 (void *)&cmd_ddp_add_port_id,
14634 (void *)&cmd_ddp_add_filepath,
14639 /* Delete dynamic device personalization*/
14640 struct cmd_ddp_del_result {
14641 cmdline_fixed_string_t ddp;
14642 cmdline_fixed_string_t del;
14647 cmdline_parse_token_string_t cmd_ddp_del_ddp =
14648 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
14649 cmdline_parse_token_string_t cmd_ddp_del_del =
14650 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
14651 cmdline_parse_token_num_t cmd_ddp_del_port_id =
14652 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
14653 cmdline_parse_token_string_t cmd_ddp_del_filepath =
14654 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
14657 cmd_ddp_del_parsed(
14658 void *parsed_result,
14659 __attribute__((unused)) struct cmdline *cl,
14660 __attribute__((unused)) void *data)
14662 struct cmd_ddp_del_result *res = parsed_result;
14665 int ret = -ENOTSUP;
14667 if (!all_ports_stopped()) {
14668 printf("Please stop all ports first\n");
14672 buff = open_file(res->filepath, &size);
14676 #ifdef RTE_LIBRTE_I40E_PMD
14677 if (ret == -ENOTSUP)
14678 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14680 RTE_PMD_I40E_PKG_OP_WR_DEL);
14683 if (ret == -EACCES)
14684 printf("Profile does not exist.\n");
14686 printf("Failed to delete profile.\n");
14691 cmdline_parse_inst_t cmd_ddp_del = {
14692 .f = cmd_ddp_del_parsed,
14694 .help_str = "ddp del <port_id> <backup_profile_path>",
14696 (void *)&cmd_ddp_del_ddp,
14697 (void *)&cmd_ddp_del_del,
14698 (void *)&cmd_ddp_del_port_id,
14699 (void *)&cmd_ddp_del_filepath,
14704 /* Get dynamic device personalization profile info */
14705 struct cmd_ddp_info_result {
14706 cmdline_fixed_string_t ddp;
14707 cmdline_fixed_string_t get;
14708 cmdline_fixed_string_t info;
14712 cmdline_parse_token_string_t cmd_ddp_info_ddp =
14713 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
14714 cmdline_parse_token_string_t cmd_ddp_info_get =
14715 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
14716 cmdline_parse_token_string_t cmd_ddp_info_info =
14717 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
14718 cmdline_parse_token_string_t cmd_ddp_info_filepath =
14719 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
14722 cmd_ddp_info_parsed(
14723 void *parsed_result,
14724 __attribute__((unused)) struct cmdline *cl,
14725 __attribute__((unused)) void *data)
14727 struct cmd_ddp_info_result *res = parsed_result;
14730 int ret = -ENOTSUP;
14731 #ifdef RTE_LIBRTE_I40E_PMD
14734 uint32_t buff_size = 0;
14735 struct rte_pmd_i40e_profile_info info;
14736 uint32_t dev_num = 0;
14737 struct rte_pmd_i40e_ddp_device_id *devs;
14738 uint32_t proto_num = 0;
14739 struct rte_pmd_i40e_proto_info *proto = NULL;
14740 uint32_t pctype_num = 0;
14741 struct rte_pmd_i40e_ptype_info *pctype;
14742 uint32_t ptype_num = 0;
14743 struct rte_pmd_i40e_ptype_info *ptype;
14748 pkg = open_file(res->filepath, &pkg_size);
14752 #ifdef RTE_LIBRTE_I40E_PMD
14753 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14754 (uint8_t *)&info, sizeof(info),
14755 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
14757 printf("Global Track id: 0x%x\n", info.track_id);
14758 printf("Global Version: %d.%d.%d.%d\n",
14759 info.version.major,
14760 info.version.minor,
14761 info.version.update,
14762 info.version.draft);
14763 printf("Global Package name: %s\n\n", info.name);
14766 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14767 (uint8_t *)&info, sizeof(info),
14768 RTE_PMD_I40E_PKG_INFO_HEADER);
14770 printf("i40e Profile Track id: 0x%x\n", info.track_id);
14771 printf("i40e Profile Version: %d.%d.%d.%d\n",
14772 info.version.major,
14773 info.version.minor,
14774 info.version.update,
14775 info.version.draft);
14776 printf("i40e Profile name: %s\n\n", info.name);
14779 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14780 (uint8_t *)&buff_size, sizeof(buff_size),
14781 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
14782 if (!ret && buff_size) {
14783 buff = (uint8_t *)malloc(buff_size);
14785 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14787 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
14789 printf("Package Notes:\n%s\n\n", buff);
14794 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14795 (uint8_t *)&dev_num, sizeof(dev_num),
14796 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
14797 if (!ret && dev_num) {
14798 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
14799 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
14801 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14802 (uint8_t *)devs, buff_size,
14803 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
14805 printf("List of supported devices:\n");
14806 for (i = 0; i < dev_num; i++) {
14807 printf(" %04X:%04X %04X:%04X\n",
14808 devs[i].vendor_dev_id >> 16,
14809 devs[i].vendor_dev_id & 0xFFFF,
14810 devs[i].sub_vendor_dev_id >> 16,
14811 devs[i].sub_vendor_dev_id & 0xFFFF);
14819 /* get information about protocols and packet types */
14820 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14821 (uint8_t *)&proto_num, sizeof(proto_num),
14822 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
14823 if (ret || !proto_num)
14824 goto no_print_return;
14826 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
14827 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
14829 goto no_print_return;
14831 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
14833 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
14835 printf("List of used protocols:\n");
14836 for (i = 0; i < proto_num; i++)
14837 printf(" %2u: %s\n", proto[i].proto_id,
14841 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14842 (uint8_t *)&pctype_num, sizeof(pctype_num),
14843 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
14844 if (ret || !pctype_num)
14845 goto no_print_pctypes;
14847 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14848 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14850 goto no_print_pctypes;
14852 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
14854 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
14857 goto no_print_pctypes;
14860 printf("List of defined packet classification types:\n");
14861 for (i = 0; i < pctype_num; i++) {
14862 printf(" %2u:", pctype[i].ptype_id);
14863 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14864 proto_id = pctype[i].protocols[j];
14865 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14866 for (n = 0; n < proto_num; n++) {
14867 if (proto[n].proto_id == proto_id) {
14868 printf(" %s", proto[n].name);
14881 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
14883 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
14884 if (ret || !ptype_num)
14885 goto no_print_return;
14887 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14888 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14890 goto no_print_return;
14892 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
14894 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
14897 goto no_print_return;
14899 printf("List of defined packet types:\n");
14900 for (i = 0; i < ptype_num; i++) {
14901 printf(" %2u:", ptype[i].ptype_id);
14902 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14903 proto_id = ptype[i].protocols[j];
14904 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14905 for (n = 0; n < proto_num; n++) {
14906 if (proto[n].proto_id == proto_id) {
14907 printf(" %s", proto[n].name);
14923 if (ret == -ENOTSUP)
14924 printf("Function not supported in PMD driver\n");
14928 cmdline_parse_inst_t cmd_ddp_get_info = {
14929 .f = cmd_ddp_info_parsed,
14931 .help_str = "ddp get info <profile_path>",
14933 (void *)&cmd_ddp_info_ddp,
14934 (void *)&cmd_ddp_info_get,
14935 (void *)&cmd_ddp_info_info,
14936 (void *)&cmd_ddp_info_filepath,
14941 /* Get dynamic device personalization profile info list*/
14942 #define PROFILE_INFO_SIZE 48
14943 #define MAX_PROFILE_NUM 16
14945 struct cmd_ddp_get_list_result {
14946 cmdline_fixed_string_t ddp;
14947 cmdline_fixed_string_t get;
14948 cmdline_fixed_string_t list;
14952 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
14953 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
14954 cmdline_parse_token_string_t cmd_ddp_get_list_get =
14955 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
14956 cmdline_parse_token_string_t cmd_ddp_get_list_list =
14957 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
14958 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
14959 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
14962 cmd_ddp_get_list_parsed(
14963 __attribute__((unused)) void *parsed_result,
14964 __attribute__((unused)) struct cmdline *cl,
14965 __attribute__((unused)) void *data)
14967 #ifdef RTE_LIBRTE_I40E_PMD
14968 struct cmd_ddp_get_list_result *res = parsed_result;
14969 struct rte_pmd_i40e_profile_list *p_list;
14970 struct rte_pmd_i40e_profile_info *p_info;
14975 int ret = -ENOTSUP;
14977 #ifdef RTE_LIBRTE_I40E_PMD
14978 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
14979 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
14981 printf("%s: Failed to malloc buffer\n", __func__);
14983 if (ret == -ENOTSUP)
14984 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
14985 (uint8_t *)p_list, size);
14988 p_num = p_list->p_count;
14989 printf("Profile number is: %d\n\n", p_num);
14991 for (i = 0; i < p_num; i++) {
14992 p_info = &p_list->p_info[i];
14993 printf("Profile %d:\n", i);
14994 printf("Track id: 0x%x\n", p_info->track_id);
14995 printf("Version: %d.%d.%d.%d\n",
14996 p_info->version.major,
14997 p_info->version.minor,
14998 p_info->version.update,
14999 p_info->version.draft);
15000 printf("Profile name: %s\n\n", p_info->name);
15008 printf("Failed to get ddp list\n");
15011 cmdline_parse_inst_t cmd_ddp_get_list = {
15012 .f = cmd_ddp_get_list_parsed,
15014 .help_str = "ddp get list <port_id>",
15016 (void *)&cmd_ddp_get_list_ddp,
15017 (void *)&cmd_ddp_get_list_get,
15018 (void *)&cmd_ddp_get_list_list,
15019 (void *)&cmd_ddp_get_list_port_id,
15024 /* Configure input set */
15025 struct cmd_cfg_input_set_result {
15026 cmdline_fixed_string_t port;
15027 cmdline_fixed_string_t cfg;
15029 cmdline_fixed_string_t pctype;
15031 cmdline_fixed_string_t inset_type;
15032 cmdline_fixed_string_t opt;
15033 cmdline_fixed_string_t field;
15038 cmd_cfg_input_set_parsed(
15039 __attribute__((unused)) void *parsed_result,
15040 __attribute__((unused)) struct cmdline *cl,
15041 __attribute__((unused)) void *data)
15043 #ifdef RTE_LIBRTE_I40E_PMD
15044 struct cmd_cfg_input_set_result *res = parsed_result;
15045 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
15046 struct rte_pmd_i40e_inset inset;
15048 int ret = -ENOTSUP;
15050 if (!all_ports_stopped()) {
15051 printf("Please stop all ports first\n");
15055 #ifdef RTE_LIBRTE_I40E_PMD
15056 if (!strcmp(res->inset_type, "hash_inset"))
15057 inset_type = INSET_HASH;
15058 else if (!strcmp(res->inset_type, "fdir_inset"))
15059 inset_type = INSET_FDIR;
15060 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
15061 inset_type = INSET_FDIR_FLX;
15062 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
15063 &inset, inset_type);
15065 printf("Failed to get input set.\n");
15069 if (!strcmp(res->opt, "get")) {
15070 ret = rte_pmd_i40e_inset_field_get(inset.inset,
15073 printf("Field index %d is enabled.\n", res->field_idx);
15075 printf("Field index %d is disabled.\n", res->field_idx);
15077 } else if (!strcmp(res->opt, "set"))
15078 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
15080 else if (!strcmp(res->opt, "clear"))
15081 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
15084 printf("Failed to configure input set field.\n");
15088 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15089 &inset, inset_type);
15091 printf("Failed to set input set.\n");
15096 if (ret == -ENOTSUP)
15097 printf("Function not supported\n");
15100 cmdline_parse_token_string_t cmd_cfg_input_set_port =
15101 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15103 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
15104 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15106 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
15107 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15109 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
15110 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15112 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
15113 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15115 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
15116 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15118 "hash_inset#fdir_inset#fdir_flx_inset");
15119 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
15120 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15121 opt, "get#set#clear");
15122 cmdline_parse_token_string_t cmd_cfg_input_set_field =
15123 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15125 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
15126 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15129 cmdline_parse_inst_t cmd_cfg_input_set = {
15130 .f = cmd_cfg_input_set_parsed,
15132 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15133 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
15135 (void *)&cmd_cfg_input_set_port,
15136 (void *)&cmd_cfg_input_set_cfg,
15137 (void *)&cmd_cfg_input_set_port_id,
15138 (void *)&cmd_cfg_input_set_pctype,
15139 (void *)&cmd_cfg_input_set_pctype_id,
15140 (void *)&cmd_cfg_input_set_inset_type,
15141 (void *)&cmd_cfg_input_set_opt,
15142 (void *)&cmd_cfg_input_set_field,
15143 (void *)&cmd_cfg_input_set_field_idx,
15148 /* Clear input set */
15149 struct cmd_clear_input_set_result {
15150 cmdline_fixed_string_t port;
15151 cmdline_fixed_string_t cfg;
15153 cmdline_fixed_string_t pctype;
15155 cmdline_fixed_string_t inset_type;
15156 cmdline_fixed_string_t clear;
15157 cmdline_fixed_string_t all;
15161 cmd_clear_input_set_parsed(
15162 __attribute__((unused)) void *parsed_result,
15163 __attribute__((unused)) struct cmdline *cl,
15164 __attribute__((unused)) void *data)
15166 #ifdef RTE_LIBRTE_I40E_PMD
15167 struct cmd_clear_input_set_result *res = parsed_result;
15168 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
15169 struct rte_pmd_i40e_inset inset;
15171 int ret = -ENOTSUP;
15173 if (!all_ports_stopped()) {
15174 printf("Please stop all ports first\n");
15178 #ifdef RTE_LIBRTE_I40E_PMD
15179 if (!strcmp(res->inset_type, "hash_inset"))
15180 inset_type = INSET_HASH;
15181 else if (!strcmp(res->inset_type, "fdir_inset"))
15182 inset_type = INSET_FDIR;
15183 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
15184 inset_type = INSET_FDIR_FLX;
15186 memset(&inset, 0, sizeof(inset));
15188 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15189 &inset, inset_type);
15191 printf("Failed to clear input set.\n");
15197 if (ret == -ENOTSUP)
15198 printf("Function not supported\n");
15201 cmdline_parse_token_string_t cmd_clear_input_set_port =
15202 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15204 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
15205 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15207 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
15208 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15210 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
15211 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15213 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
15214 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15216 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
15217 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15219 "hash_inset#fdir_inset#fdir_flx_inset");
15220 cmdline_parse_token_string_t cmd_clear_input_set_clear =
15221 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15223 cmdline_parse_token_string_t cmd_clear_input_set_all =
15224 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15227 cmdline_parse_inst_t cmd_clear_input_set = {
15228 .f = cmd_clear_input_set_parsed,
15230 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15231 "fdir_inset|fdir_flx_inset clear all",
15233 (void *)&cmd_clear_input_set_port,
15234 (void *)&cmd_clear_input_set_cfg,
15235 (void *)&cmd_clear_input_set_port_id,
15236 (void *)&cmd_clear_input_set_pctype,
15237 (void *)&cmd_clear_input_set_pctype_id,
15238 (void *)&cmd_clear_input_set_inset_type,
15239 (void *)&cmd_clear_input_set_clear,
15240 (void *)&cmd_clear_input_set_all,
15245 /* show vf stats */
15247 /* Common result structure for show vf stats */
15248 struct cmd_show_vf_stats_result {
15249 cmdline_fixed_string_t show;
15250 cmdline_fixed_string_t vf;
15251 cmdline_fixed_string_t stats;
15256 /* Common CLI fields show vf stats*/
15257 cmdline_parse_token_string_t cmd_show_vf_stats_show =
15258 TOKEN_STRING_INITIALIZER
15259 (struct cmd_show_vf_stats_result,
15261 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
15262 TOKEN_STRING_INITIALIZER
15263 (struct cmd_show_vf_stats_result,
15265 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
15266 TOKEN_STRING_INITIALIZER
15267 (struct cmd_show_vf_stats_result,
15269 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
15270 TOKEN_NUM_INITIALIZER
15271 (struct cmd_show_vf_stats_result,
15273 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
15274 TOKEN_NUM_INITIALIZER
15275 (struct cmd_show_vf_stats_result,
15279 cmd_show_vf_stats_parsed(
15280 void *parsed_result,
15281 __attribute__((unused)) struct cmdline *cl,
15282 __attribute__((unused)) void *data)
15284 struct cmd_show_vf_stats_result *res = parsed_result;
15285 struct rte_eth_stats stats;
15286 int ret = -ENOTSUP;
15287 static const char *nic_stats_border = "########################";
15289 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15292 memset(&stats, 0, sizeof(stats));
15294 #ifdef RTE_LIBRTE_I40E_PMD
15295 if (ret == -ENOTSUP)
15296 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
15300 #ifdef RTE_LIBRTE_BNXT_PMD
15301 if (ret == -ENOTSUP)
15302 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
15311 printf("invalid vf_id %d\n", res->vf_id);
15314 printf("invalid port_id %d\n", res->port_id);
15317 printf("function not implemented\n");
15320 printf("programming error: (%s)\n", strerror(-ret));
15323 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
15324 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
15326 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
15328 stats.ipackets, stats.imissed, stats.ibytes);
15329 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
15330 printf(" RX-nombuf: %-10"PRIu64"\n",
15332 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
15334 stats.opackets, stats.oerrors, stats.obytes);
15336 printf(" %s############################%s\n",
15337 nic_stats_border, nic_stats_border);
15340 cmdline_parse_inst_t cmd_show_vf_stats = {
15341 .f = cmd_show_vf_stats_parsed,
15343 .help_str = "show vf stats <port_id> <vf_id>",
15345 (void *)&cmd_show_vf_stats_show,
15346 (void *)&cmd_show_vf_stats_vf,
15347 (void *)&cmd_show_vf_stats_stats,
15348 (void *)&cmd_show_vf_stats_port_id,
15349 (void *)&cmd_show_vf_stats_vf_id,
15354 /* clear vf stats */
15356 /* Common result structure for clear vf stats */
15357 struct cmd_clear_vf_stats_result {
15358 cmdline_fixed_string_t clear;
15359 cmdline_fixed_string_t vf;
15360 cmdline_fixed_string_t stats;
15365 /* Common CLI fields clear vf stats*/
15366 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
15367 TOKEN_STRING_INITIALIZER
15368 (struct cmd_clear_vf_stats_result,
15370 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
15371 TOKEN_STRING_INITIALIZER
15372 (struct cmd_clear_vf_stats_result,
15374 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
15375 TOKEN_STRING_INITIALIZER
15376 (struct cmd_clear_vf_stats_result,
15378 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
15379 TOKEN_NUM_INITIALIZER
15380 (struct cmd_clear_vf_stats_result,
15382 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
15383 TOKEN_NUM_INITIALIZER
15384 (struct cmd_clear_vf_stats_result,
15388 cmd_clear_vf_stats_parsed(
15389 void *parsed_result,
15390 __attribute__((unused)) struct cmdline *cl,
15391 __attribute__((unused)) void *data)
15393 struct cmd_clear_vf_stats_result *res = parsed_result;
15394 int ret = -ENOTSUP;
15396 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15399 #ifdef RTE_LIBRTE_I40E_PMD
15400 if (ret == -ENOTSUP)
15401 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
15404 #ifdef RTE_LIBRTE_BNXT_PMD
15405 if (ret == -ENOTSUP)
15406 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
15414 printf("invalid vf_id %d\n", res->vf_id);
15417 printf("invalid port_id %d\n", res->port_id);
15420 printf("function not implemented\n");
15423 printf("programming error: (%s)\n", strerror(-ret));
15427 cmdline_parse_inst_t cmd_clear_vf_stats = {
15428 .f = cmd_clear_vf_stats_parsed,
15430 .help_str = "clear vf stats <port_id> <vf_id>",
15432 (void *)&cmd_clear_vf_stats_clear,
15433 (void *)&cmd_clear_vf_stats_vf,
15434 (void *)&cmd_clear_vf_stats_stats,
15435 (void *)&cmd_clear_vf_stats_port_id,
15436 (void *)&cmd_clear_vf_stats_vf_id,
15441 /* port config pctype mapping reset */
15443 /* Common result structure for port config pctype mapping reset */
15444 struct cmd_pctype_mapping_reset_result {
15445 cmdline_fixed_string_t port;
15446 cmdline_fixed_string_t config;
15448 cmdline_fixed_string_t pctype;
15449 cmdline_fixed_string_t mapping;
15450 cmdline_fixed_string_t reset;
15453 /* Common CLI fields for port config pctype mapping reset*/
15454 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
15455 TOKEN_STRING_INITIALIZER
15456 (struct cmd_pctype_mapping_reset_result,
15458 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
15459 TOKEN_STRING_INITIALIZER
15460 (struct cmd_pctype_mapping_reset_result,
15462 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
15463 TOKEN_NUM_INITIALIZER
15464 (struct cmd_pctype_mapping_reset_result,
15466 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
15467 TOKEN_STRING_INITIALIZER
15468 (struct cmd_pctype_mapping_reset_result,
15470 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
15471 TOKEN_STRING_INITIALIZER
15472 (struct cmd_pctype_mapping_reset_result,
15473 mapping, "mapping");
15474 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
15475 TOKEN_STRING_INITIALIZER
15476 (struct cmd_pctype_mapping_reset_result,
15480 cmd_pctype_mapping_reset_parsed(
15481 void *parsed_result,
15482 __attribute__((unused)) struct cmdline *cl,
15483 __attribute__((unused)) void *data)
15485 struct cmd_pctype_mapping_reset_result *res = parsed_result;
15486 int ret = -ENOTSUP;
15488 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15491 #ifdef RTE_LIBRTE_I40E_PMD
15492 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
15499 printf("invalid port_id %d\n", res->port_id);
15502 printf("function not implemented\n");
15505 printf("programming error: (%s)\n", strerror(-ret));
15509 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
15510 .f = cmd_pctype_mapping_reset_parsed,
15512 .help_str = "port config <port_id> pctype mapping reset",
15514 (void *)&cmd_pctype_mapping_reset_port,
15515 (void *)&cmd_pctype_mapping_reset_config,
15516 (void *)&cmd_pctype_mapping_reset_port_id,
15517 (void *)&cmd_pctype_mapping_reset_pctype,
15518 (void *)&cmd_pctype_mapping_reset_mapping,
15519 (void *)&cmd_pctype_mapping_reset_reset,
15524 /* show port pctype mapping */
15526 /* Common result structure for show port pctype mapping */
15527 struct cmd_pctype_mapping_get_result {
15528 cmdline_fixed_string_t show;
15529 cmdline_fixed_string_t port;
15531 cmdline_fixed_string_t pctype;
15532 cmdline_fixed_string_t mapping;
15535 /* Common CLI fields for pctype mapping get */
15536 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
15537 TOKEN_STRING_INITIALIZER
15538 (struct cmd_pctype_mapping_get_result,
15540 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
15541 TOKEN_STRING_INITIALIZER
15542 (struct cmd_pctype_mapping_get_result,
15544 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
15545 TOKEN_NUM_INITIALIZER
15546 (struct cmd_pctype_mapping_get_result,
15548 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
15549 TOKEN_STRING_INITIALIZER
15550 (struct cmd_pctype_mapping_get_result,
15552 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
15553 TOKEN_STRING_INITIALIZER
15554 (struct cmd_pctype_mapping_get_result,
15555 mapping, "mapping");
15558 cmd_pctype_mapping_get_parsed(
15559 void *parsed_result,
15560 __attribute__((unused)) struct cmdline *cl,
15561 __attribute__((unused)) void *data)
15563 struct cmd_pctype_mapping_get_result *res = parsed_result;
15564 int ret = -ENOTSUP;
15565 #ifdef RTE_LIBRTE_I40E_PMD
15566 struct rte_pmd_i40e_flow_type_mapping
15567 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
15568 int i, j, first_pctype;
15571 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15574 #ifdef RTE_LIBRTE_I40E_PMD
15575 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
15582 printf("invalid port_id %d\n", res->port_id);
15585 printf("function not implemented\n");
15588 printf("programming error: (%s)\n", strerror(-ret));
15592 #ifdef RTE_LIBRTE_I40E_PMD
15593 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
15594 if (mapping[i].pctype != 0ULL) {
15597 printf("pctype: ");
15598 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
15599 if (mapping[i].pctype & (1ULL << j)) {
15600 printf(first_pctype ?
15601 "%02d" : ",%02d", j);
15605 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
15611 cmdline_parse_inst_t cmd_pctype_mapping_get = {
15612 .f = cmd_pctype_mapping_get_parsed,
15614 .help_str = "show port <port_id> pctype mapping",
15616 (void *)&cmd_pctype_mapping_get_show,
15617 (void *)&cmd_pctype_mapping_get_port,
15618 (void *)&cmd_pctype_mapping_get_port_id,
15619 (void *)&cmd_pctype_mapping_get_pctype,
15620 (void *)&cmd_pctype_mapping_get_mapping,
15625 /* port config pctype mapping update */
15627 /* Common result structure for port config pctype mapping update */
15628 struct cmd_pctype_mapping_update_result {
15629 cmdline_fixed_string_t port;
15630 cmdline_fixed_string_t config;
15632 cmdline_fixed_string_t pctype;
15633 cmdline_fixed_string_t mapping;
15634 cmdline_fixed_string_t update;
15635 cmdline_fixed_string_t pctype_list;
15636 uint16_t flow_type;
15639 /* Common CLI fields for pctype mapping update*/
15640 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
15641 TOKEN_STRING_INITIALIZER
15642 (struct cmd_pctype_mapping_update_result,
15644 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
15645 TOKEN_STRING_INITIALIZER
15646 (struct cmd_pctype_mapping_update_result,
15648 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
15649 TOKEN_NUM_INITIALIZER
15650 (struct cmd_pctype_mapping_update_result,
15652 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
15653 TOKEN_STRING_INITIALIZER
15654 (struct cmd_pctype_mapping_update_result,
15656 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
15657 TOKEN_STRING_INITIALIZER
15658 (struct cmd_pctype_mapping_update_result,
15659 mapping, "mapping");
15660 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
15661 TOKEN_STRING_INITIALIZER
15662 (struct cmd_pctype_mapping_update_result,
15664 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
15665 TOKEN_STRING_INITIALIZER
15666 (struct cmd_pctype_mapping_update_result,
15667 pctype_list, NULL);
15668 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
15669 TOKEN_NUM_INITIALIZER
15670 (struct cmd_pctype_mapping_update_result,
15671 flow_type, UINT16);
15674 cmd_pctype_mapping_update_parsed(
15675 void *parsed_result,
15676 __attribute__((unused)) struct cmdline *cl,
15677 __attribute__((unused)) void *data)
15679 struct cmd_pctype_mapping_update_result *res = parsed_result;
15680 int ret = -ENOTSUP;
15681 #ifdef RTE_LIBRTE_I40E_PMD
15682 struct rte_pmd_i40e_flow_type_mapping mapping;
15684 unsigned int nb_item;
15685 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
15688 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15691 #ifdef RTE_LIBRTE_I40E_PMD
15692 nb_item = parse_item_list(res->pctype_list, "pctypes",
15693 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
15694 mapping.flow_type = res->flow_type;
15695 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
15696 mapping.pctype |= (1ULL << pctype_list[i]);
15697 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
15707 printf("invalid pctype or flow type\n");
15710 printf("invalid port_id %d\n", res->port_id);
15713 printf("function not implemented\n");
15716 printf("programming error: (%s)\n", strerror(-ret));
15720 cmdline_parse_inst_t cmd_pctype_mapping_update = {
15721 .f = cmd_pctype_mapping_update_parsed,
15723 .help_str = "port config <port_id> pctype mapping update"
15724 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
15726 (void *)&cmd_pctype_mapping_update_port,
15727 (void *)&cmd_pctype_mapping_update_config,
15728 (void *)&cmd_pctype_mapping_update_port_id,
15729 (void *)&cmd_pctype_mapping_update_pctype,
15730 (void *)&cmd_pctype_mapping_update_mapping,
15731 (void *)&cmd_pctype_mapping_update_update,
15732 (void *)&cmd_pctype_mapping_update_pc_type,
15733 (void *)&cmd_pctype_mapping_update_flow_type,
15738 /* ptype mapping get */
15740 /* Common result structure for ptype mapping get */
15741 struct cmd_ptype_mapping_get_result {
15742 cmdline_fixed_string_t ptype;
15743 cmdline_fixed_string_t mapping;
15744 cmdline_fixed_string_t get;
15746 uint8_t valid_only;
15749 /* Common CLI fields for ptype mapping get */
15750 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
15751 TOKEN_STRING_INITIALIZER
15752 (struct cmd_ptype_mapping_get_result,
15754 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
15755 TOKEN_STRING_INITIALIZER
15756 (struct cmd_ptype_mapping_get_result,
15757 mapping, "mapping");
15758 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
15759 TOKEN_STRING_INITIALIZER
15760 (struct cmd_ptype_mapping_get_result,
15762 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
15763 TOKEN_NUM_INITIALIZER
15764 (struct cmd_ptype_mapping_get_result,
15766 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
15767 TOKEN_NUM_INITIALIZER
15768 (struct cmd_ptype_mapping_get_result,
15769 valid_only, UINT8);
15772 cmd_ptype_mapping_get_parsed(
15773 void *parsed_result,
15774 __attribute__((unused)) struct cmdline *cl,
15775 __attribute__((unused)) void *data)
15777 struct cmd_ptype_mapping_get_result *res = parsed_result;
15778 int ret = -ENOTSUP;
15779 #ifdef RTE_LIBRTE_I40E_PMD
15780 int max_ptype_num = 256;
15781 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
15786 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15789 #ifdef RTE_LIBRTE_I40E_PMD
15790 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
15801 printf("invalid port_id %d\n", res->port_id);
15804 printf("function not implemented\n");
15807 printf("programming error: (%s)\n", strerror(-ret));
15810 #ifdef RTE_LIBRTE_I40E_PMD
15812 for (i = 0; i < count; i++)
15813 printf("%3d\t0x%08x\n",
15814 mapping[i].hw_ptype, mapping[i].sw_ptype);
15819 cmdline_parse_inst_t cmd_ptype_mapping_get = {
15820 .f = cmd_ptype_mapping_get_parsed,
15822 .help_str = "ptype mapping get <port_id> <valid_only>",
15824 (void *)&cmd_ptype_mapping_get_ptype,
15825 (void *)&cmd_ptype_mapping_get_mapping,
15826 (void *)&cmd_ptype_mapping_get_get,
15827 (void *)&cmd_ptype_mapping_get_port_id,
15828 (void *)&cmd_ptype_mapping_get_valid_only,
15833 /* ptype mapping replace */
15835 /* Common result structure for ptype mapping replace */
15836 struct cmd_ptype_mapping_replace_result {
15837 cmdline_fixed_string_t ptype;
15838 cmdline_fixed_string_t mapping;
15839 cmdline_fixed_string_t replace;
15846 /* Common CLI fields for ptype mapping replace */
15847 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
15848 TOKEN_STRING_INITIALIZER
15849 (struct cmd_ptype_mapping_replace_result,
15851 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
15852 TOKEN_STRING_INITIALIZER
15853 (struct cmd_ptype_mapping_replace_result,
15854 mapping, "mapping");
15855 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
15856 TOKEN_STRING_INITIALIZER
15857 (struct cmd_ptype_mapping_replace_result,
15858 replace, "replace");
15859 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
15860 TOKEN_NUM_INITIALIZER
15861 (struct cmd_ptype_mapping_replace_result,
15863 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
15864 TOKEN_NUM_INITIALIZER
15865 (struct cmd_ptype_mapping_replace_result,
15867 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
15868 TOKEN_NUM_INITIALIZER
15869 (struct cmd_ptype_mapping_replace_result,
15871 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
15872 TOKEN_NUM_INITIALIZER
15873 (struct cmd_ptype_mapping_replace_result,
15877 cmd_ptype_mapping_replace_parsed(
15878 void *parsed_result,
15879 __attribute__((unused)) struct cmdline *cl,
15880 __attribute__((unused)) void *data)
15882 struct cmd_ptype_mapping_replace_result *res = parsed_result;
15883 int ret = -ENOTSUP;
15885 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15888 #ifdef RTE_LIBRTE_I40E_PMD
15889 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
15899 printf("invalid ptype 0x%8x or 0x%8x\n",
15900 res->target, res->pkt_type);
15903 printf("invalid port_id %d\n", res->port_id);
15906 printf("function not implemented\n");
15909 printf("programming error: (%s)\n", strerror(-ret));
15913 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
15914 .f = cmd_ptype_mapping_replace_parsed,
15917 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
15919 (void *)&cmd_ptype_mapping_replace_ptype,
15920 (void *)&cmd_ptype_mapping_replace_mapping,
15921 (void *)&cmd_ptype_mapping_replace_replace,
15922 (void *)&cmd_ptype_mapping_replace_port_id,
15923 (void *)&cmd_ptype_mapping_replace_target,
15924 (void *)&cmd_ptype_mapping_replace_mask,
15925 (void *)&cmd_ptype_mapping_replace_pkt_type,
15930 /* ptype mapping reset */
15932 /* Common result structure for ptype mapping reset */
15933 struct cmd_ptype_mapping_reset_result {
15934 cmdline_fixed_string_t ptype;
15935 cmdline_fixed_string_t mapping;
15936 cmdline_fixed_string_t reset;
15940 /* Common CLI fields for ptype mapping reset*/
15941 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
15942 TOKEN_STRING_INITIALIZER
15943 (struct cmd_ptype_mapping_reset_result,
15945 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
15946 TOKEN_STRING_INITIALIZER
15947 (struct cmd_ptype_mapping_reset_result,
15948 mapping, "mapping");
15949 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
15950 TOKEN_STRING_INITIALIZER
15951 (struct cmd_ptype_mapping_reset_result,
15953 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
15954 TOKEN_NUM_INITIALIZER
15955 (struct cmd_ptype_mapping_reset_result,
15959 cmd_ptype_mapping_reset_parsed(
15960 void *parsed_result,
15961 __attribute__((unused)) struct cmdline *cl,
15962 __attribute__((unused)) void *data)
15964 struct cmd_ptype_mapping_reset_result *res = parsed_result;
15965 int ret = -ENOTSUP;
15967 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15970 #ifdef RTE_LIBRTE_I40E_PMD
15971 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
15978 printf("invalid port_id %d\n", res->port_id);
15981 printf("function not implemented\n");
15984 printf("programming error: (%s)\n", strerror(-ret));
15988 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
15989 .f = cmd_ptype_mapping_reset_parsed,
15991 .help_str = "ptype mapping reset <port_id>",
15993 (void *)&cmd_ptype_mapping_reset_ptype,
15994 (void *)&cmd_ptype_mapping_reset_mapping,
15995 (void *)&cmd_ptype_mapping_reset_reset,
15996 (void *)&cmd_ptype_mapping_reset_port_id,
16001 /* ptype mapping update */
16003 /* Common result structure for ptype mapping update */
16004 struct cmd_ptype_mapping_update_result {
16005 cmdline_fixed_string_t ptype;
16006 cmdline_fixed_string_t mapping;
16007 cmdline_fixed_string_t reset;
16013 /* Common CLI fields for ptype mapping update*/
16014 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
16015 TOKEN_STRING_INITIALIZER
16016 (struct cmd_ptype_mapping_update_result,
16018 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
16019 TOKEN_STRING_INITIALIZER
16020 (struct cmd_ptype_mapping_update_result,
16021 mapping, "mapping");
16022 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
16023 TOKEN_STRING_INITIALIZER
16024 (struct cmd_ptype_mapping_update_result,
16026 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
16027 TOKEN_NUM_INITIALIZER
16028 (struct cmd_ptype_mapping_update_result,
16030 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
16031 TOKEN_NUM_INITIALIZER
16032 (struct cmd_ptype_mapping_update_result,
16034 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
16035 TOKEN_NUM_INITIALIZER
16036 (struct cmd_ptype_mapping_update_result,
16040 cmd_ptype_mapping_update_parsed(
16041 void *parsed_result,
16042 __attribute__((unused)) struct cmdline *cl,
16043 __attribute__((unused)) void *data)
16045 struct cmd_ptype_mapping_update_result *res = parsed_result;
16046 int ret = -ENOTSUP;
16047 #ifdef RTE_LIBRTE_I40E_PMD
16048 struct rte_pmd_i40e_ptype_mapping mapping;
16050 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16053 #ifdef RTE_LIBRTE_I40E_PMD
16054 mapping.hw_ptype = res->hw_ptype;
16055 mapping.sw_ptype = res->sw_ptype;
16056 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
16066 printf("invalid ptype 0x%8x\n", res->sw_ptype);
16069 printf("invalid port_id %d\n", res->port_id);
16072 printf("function not implemented\n");
16075 printf("programming error: (%s)\n", strerror(-ret));
16079 cmdline_parse_inst_t cmd_ptype_mapping_update = {
16080 .f = cmd_ptype_mapping_update_parsed,
16082 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
16084 (void *)&cmd_ptype_mapping_update_ptype,
16085 (void *)&cmd_ptype_mapping_update_mapping,
16086 (void *)&cmd_ptype_mapping_update_update,
16087 (void *)&cmd_ptype_mapping_update_port_id,
16088 (void *)&cmd_ptype_mapping_update_hw_ptype,
16089 (void *)&cmd_ptype_mapping_update_sw_ptype,
16094 /* Common result structure for file commands */
16095 struct cmd_cmdfile_result {
16096 cmdline_fixed_string_t load;
16097 cmdline_fixed_string_t filename;
16100 /* Common CLI fields for file commands */
16101 cmdline_parse_token_string_t cmd_load_cmdfile =
16102 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
16103 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
16104 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
16107 cmd_load_from_file_parsed(
16108 void *parsed_result,
16109 __attribute__((unused)) struct cmdline *cl,
16110 __attribute__((unused)) void *data)
16112 struct cmd_cmdfile_result *res = parsed_result;
16114 cmdline_read_from_file(res->filename);
16117 cmdline_parse_inst_t cmd_load_from_file = {
16118 .f = cmd_load_from_file_parsed,
16120 .help_str = "load <filename>",
16122 (void *)&cmd_load_cmdfile,
16123 (void *)&cmd_load_cmdfile_filename,
16128 /* ******************************************************************************** */
16130 /* list of instructions */
16131 cmdline_parse_ctx_t main_ctx[] = {
16132 (cmdline_parse_inst_t *)&cmd_help_brief,
16133 (cmdline_parse_inst_t *)&cmd_help_long,
16134 (cmdline_parse_inst_t *)&cmd_quit,
16135 (cmdline_parse_inst_t *)&cmd_load_from_file,
16136 (cmdline_parse_inst_t *)&cmd_showport,
16137 (cmdline_parse_inst_t *)&cmd_showqueue,
16138 (cmdline_parse_inst_t *)&cmd_showportall,
16139 (cmdline_parse_inst_t *)&cmd_showcfg,
16140 (cmdline_parse_inst_t *)&cmd_start,
16141 (cmdline_parse_inst_t *)&cmd_start_tx_first,
16142 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
16143 (cmdline_parse_inst_t *)&cmd_set_link_up,
16144 (cmdline_parse_inst_t *)&cmd_set_link_down,
16145 (cmdline_parse_inst_t *)&cmd_reset,
16146 (cmdline_parse_inst_t *)&cmd_set_numbers,
16147 (cmdline_parse_inst_t *)&cmd_set_log,
16148 (cmdline_parse_inst_t *)&cmd_set_txpkts,
16149 (cmdline_parse_inst_t *)&cmd_set_txsplit,
16150 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
16151 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
16152 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
16153 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
16154 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
16155 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
16156 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
16157 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
16158 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
16159 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
16160 (cmdline_parse_inst_t *)&cmd_set_link_check,
16161 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
16162 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
16163 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
16164 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
16165 #ifdef RTE_LIBRTE_PMD_BOND
16166 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
16167 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
16168 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
16169 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
16170 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
16171 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
16172 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
16173 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
16174 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
16175 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
16176 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
16178 (cmdline_parse_inst_t *)&cmd_vlan_offload,
16179 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
16180 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
16181 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
16182 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
16183 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
16184 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
16185 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
16186 (cmdline_parse_inst_t *)&cmd_csum_set,
16187 (cmdline_parse_inst_t *)&cmd_csum_show,
16188 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
16189 (cmdline_parse_inst_t *)&cmd_tso_set,
16190 (cmdline_parse_inst_t *)&cmd_tso_show,
16191 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
16192 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
16193 (cmdline_parse_inst_t *)&cmd_gro_enable,
16194 (cmdline_parse_inst_t *)&cmd_gro_flush,
16195 (cmdline_parse_inst_t *)&cmd_gro_show,
16196 (cmdline_parse_inst_t *)&cmd_gso_enable,
16197 (cmdline_parse_inst_t *)&cmd_gso_size,
16198 (cmdline_parse_inst_t *)&cmd_gso_show,
16199 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
16200 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
16201 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
16202 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
16203 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
16204 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
16205 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
16206 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
16207 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
16208 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
16209 (cmdline_parse_inst_t *)&cmd_config_dcb,
16210 (cmdline_parse_inst_t *)&cmd_read_reg,
16211 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
16212 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
16213 (cmdline_parse_inst_t *)&cmd_write_reg,
16214 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
16215 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
16216 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
16217 (cmdline_parse_inst_t *)&cmd_stop,
16218 (cmdline_parse_inst_t *)&cmd_mac_addr,
16219 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
16220 (cmdline_parse_inst_t *)&cmd_set_qmap,
16221 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
16222 (cmdline_parse_inst_t *)&cmd_operate_port,
16223 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
16224 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
16225 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
16226 (cmdline_parse_inst_t *)&cmd_config_speed_all,
16227 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
16228 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
16229 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
16230 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
16231 (cmdline_parse_inst_t *)&cmd_config_mtu,
16232 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
16233 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
16234 (cmdline_parse_inst_t *)&cmd_config_rss,
16235 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
16236 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
16237 (cmdline_parse_inst_t *)&cmd_showport_reta,
16238 (cmdline_parse_inst_t *)&cmd_config_burst,
16239 (cmdline_parse_inst_t *)&cmd_config_thresh,
16240 (cmdline_parse_inst_t *)&cmd_config_threshold,
16241 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
16242 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
16243 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
16244 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
16245 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
16246 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
16247 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
16248 (cmdline_parse_inst_t *)&cmd_global_config,
16249 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
16250 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
16251 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
16252 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
16253 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
16254 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
16255 (cmdline_parse_inst_t *)&cmd_dump,
16256 (cmdline_parse_inst_t *)&cmd_dump_one,
16257 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
16258 (cmdline_parse_inst_t *)&cmd_syn_filter,
16259 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
16260 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
16261 (cmdline_parse_inst_t *)&cmd_flex_filter,
16262 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
16263 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
16264 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
16265 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
16266 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
16267 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
16268 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
16269 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
16270 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
16271 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
16272 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
16273 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
16274 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
16275 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
16276 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
16277 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
16278 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
16279 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
16280 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
16281 (cmdline_parse_inst_t *)&cmd_flow,
16282 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
16283 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
16284 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
16285 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
16286 (cmdline_parse_inst_t *)&cmd_create_port_meter,
16287 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
16288 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
16289 (cmdline_parse_inst_t *)&cmd_del_port_meter,
16290 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
16291 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
16292 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
16293 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
16294 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
16295 (cmdline_parse_inst_t *)&cmd_mcast_addr,
16296 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
16297 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
16298 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
16299 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
16300 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
16301 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
16302 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
16303 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
16304 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
16305 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
16306 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
16307 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
16308 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
16309 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
16310 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
16311 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
16312 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
16313 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
16314 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
16315 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
16316 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
16317 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
16318 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
16319 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
16320 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
16321 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
16322 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
16323 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
16324 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
16325 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
16326 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
16327 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
16328 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
16329 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
16330 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
16331 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
16332 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
16334 (cmdline_parse_inst_t *)&cmd_ddp_add,
16335 (cmdline_parse_inst_t *)&cmd_ddp_del,
16336 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
16337 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
16338 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
16339 (cmdline_parse_inst_t *)&cmd_clear_input_set,
16340 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
16341 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
16342 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
16343 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
16344 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
16345 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
16347 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
16348 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
16349 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
16350 (cmdline_parse_inst_t *)&cmd_queue_region,
16351 (cmdline_parse_inst_t *)&cmd_region_flowtype,
16352 (cmdline_parse_inst_t *)&cmd_user_priority_region,
16353 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
16354 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
16355 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
16356 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
16357 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
16358 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
16359 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
16360 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
16361 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
16362 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
16363 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
16364 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
16365 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
16366 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
16367 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
16368 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
16369 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
16370 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
16371 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
16375 /* read cmdline commands from file */
16377 cmdline_read_from_file(const char *filename)
16379 struct cmdline *cl;
16381 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
16383 printf("Failed to create file based cmdline context: %s\n",
16388 cmdline_interact(cl);
16393 printf("Read CLI commands from %s\n", filename);
16396 /* prompt function, called from main on MASTER lcore */
16400 /* initialize non-constant commands */
16401 cmd_set_fwd_mode_init();
16402 cmd_set_fwd_retry_mode_init();
16404 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
16405 if (testpmd_cl == NULL)
16407 cmdline_interact(testpmd_cl);
16408 cmdline_stdin_exit(testpmd_cl);
16414 if (testpmd_cl != NULL)
16415 cmdline_quit(testpmd_cl);
16419 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
16421 if (id == (portid_t)RTE_PORT_ALL) {
16424 RTE_ETH_FOREACH_DEV(pid) {
16425 /* check if need_reconfig has been set to 1 */
16426 if (ports[pid].need_reconfig == 0)
16427 ports[pid].need_reconfig = dev;
16428 /* check if need_reconfig_queues has been set to 1 */
16429 if (ports[pid].need_reconfig_queues == 0)
16430 ports[pid].need_reconfig_queues = queue;
16432 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
16433 /* check if need_reconfig has been set to 1 */
16434 if (ports[id].need_reconfig == 0)
16435 ports[id].need_reconfig = dev;
16436 /* check if need_reconfig_queues has been set to 1 */
16437 if (ports[id].need_reconfig_queues == 0)
16438 ports[id].need_reconfig_queues = queue;