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 RTE_ETH_FOREACH_DEV(i) {
2037 diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
2039 printf("Configuration of RSS hash at ethernet port %d "
2040 "failed with error (%d): %s.\n",
2041 i, -diag, strerror(-diag));
2045 cmdline_parse_token_string_t cmd_config_rss_port =
2046 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2047 cmdline_parse_token_string_t cmd_config_rss_keyword =
2048 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2049 cmdline_parse_token_string_t cmd_config_rss_all =
2050 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2051 cmdline_parse_token_string_t cmd_config_rss_name =
2052 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2053 cmdline_parse_token_string_t cmd_config_rss_value =
2054 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2056 cmdline_parse_inst_t cmd_config_rss = {
2057 .f = cmd_config_rss_parsed,
2059 .help_str = "port config all rss "
2060 "all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none|<flowtype_id>",
2062 (void *)&cmd_config_rss_port,
2063 (void *)&cmd_config_rss_keyword,
2064 (void *)&cmd_config_rss_all,
2065 (void *)&cmd_config_rss_name,
2066 (void *)&cmd_config_rss_value,
2071 /* *** configure rss hash key *** */
2072 struct cmd_config_rss_hash_key {
2073 cmdline_fixed_string_t port;
2074 cmdline_fixed_string_t config;
2076 cmdline_fixed_string_t rss_hash_key;
2077 cmdline_fixed_string_t rss_type;
2078 cmdline_fixed_string_t key;
2082 hexa_digit_to_value(char hexa_digit)
2084 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2085 return (uint8_t) (hexa_digit - '0');
2086 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2087 return (uint8_t) ((hexa_digit - 'a') + 10);
2088 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2089 return (uint8_t) ((hexa_digit - 'A') + 10);
2090 /* Invalid hexa digit */
2095 parse_and_check_key_hexa_digit(char *key, int idx)
2099 hexa_v = hexa_digit_to_value(key[idx]);
2101 printf("invalid key: character %c at position %d is not a "
2102 "valid hexa digit\n", key[idx], idx);
2107 cmd_config_rss_hash_key_parsed(void *parsed_result,
2108 __attribute__((unused)) struct cmdline *cl,
2109 __attribute__((unused)) void *data)
2111 struct cmd_config_rss_hash_key *res = parsed_result;
2112 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2116 struct rte_eth_dev_info dev_info;
2117 uint8_t hash_key_size;
2120 memset(&dev_info, 0, sizeof(dev_info));
2121 rte_eth_dev_info_get(res->port_id, &dev_info);
2122 if (dev_info.hash_key_size > 0 &&
2123 dev_info.hash_key_size <= sizeof(hash_key))
2124 hash_key_size = dev_info.hash_key_size;
2126 printf("dev_info did not provide a valid hash key size\n");
2129 /* Check the length of the RSS hash key */
2130 key_len = strlen(res->key);
2131 if (key_len != (hash_key_size * 2)) {
2132 printf("key length: %d invalid - key must be a string of %d"
2133 " hexa-decimal numbers\n",
2134 (int) key_len, hash_key_size * 2);
2137 /* Translate RSS hash key into binary representation */
2138 for (i = 0; i < hash_key_size; i++) {
2139 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2142 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2145 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2147 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2151 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2152 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2153 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2154 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2156 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2157 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2158 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2159 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2160 rss_hash_key, "rss-hash-key");
2161 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2162 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2163 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2164 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2165 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2166 "ipv6-tcp-ex#ipv6-udp-ex");
2167 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2168 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2170 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2171 .f = cmd_config_rss_hash_key_parsed,
2173 .help_str = "port config <port_id> rss-hash-key "
2174 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2175 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2176 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
2177 "<string of hex digits (variable length, NIC dependent)>",
2179 (void *)&cmd_config_rss_hash_key_port,
2180 (void *)&cmd_config_rss_hash_key_config,
2181 (void *)&cmd_config_rss_hash_key_port_id,
2182 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2183 (void *)&cmd_config_rss_hash_key_rss_type,
2184 (void *)&cmd_config_rss_hash_key_value,
2189 /* *** configure port rxq/txq start/stop *** */
2190 struct cmd_config_rxtx_queue {
2191 cmdline_fixed_string_t port;
2193 cmdline_fixed_string_t rxtxq;
2195 cmdline_fixed_string_t opname;
2199 cmd_config_rxtx_queue_parsed(void *parsed_result,
2200 __attribute__((unused)) struct cmdline *cl,
2201 __attribute__((unused)) void *data)
2203 struct cmd_config_rxtx_queue *res = parsed_result;
2208 if (test_done == 0) {
2209 printf("Please stop forwarding first\n");
2213 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2216 if (port_is_started(res->portid) != 1) {
2217 printf("Please start port %u first\n", res->portid);
2221 if (!strcmp(res->rxtxq, "rxq"))
2223 else if (!strcmp(res->rxtxq, "txq"))
2226 printf("Unknown parameter\n");
2230 if (isrx && rx_queue_id_is_invalid(res->qid))
2232 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2235 if (!strcmp(res->opname, "start"))
2237 else if (!strcmp(res->opname, "stop"))
2240 printf("Unknown parameter\n");
2244 if (isstart && isrx)
2245 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2246 else if (!isstart && isrx)
2247 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2248 else if (isstart && !isrx)
2249 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2251 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2253 if (ret == -ENOTSUP)
2254 printf("Function not supported in PMD driver\n");
2257 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2258 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2259 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2260 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2261 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2262 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2263 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2264 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2265 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2266 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2269 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2270 .f = cmd_config_rxtx_queue_parsed,
2272 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2274 (void *)&cmd_config_speed_all_port,
2275 (void *)&cmd_config_rxtx_queue_portid,
2276 (void *)&cmd_config_rxtx_queue_rxtxq,
2277 (void *)&cmd_config_rxtx_queue_qid,
2278 (void *)&cmd_config_rxtx_queue_opname,
2283 /* *** Configure RSS RETA *** */
2284 struct cmd_config_rss_reta {
2285 cmdline_fixed_string_t port;
2286 cmdline_fixed_string_t keyword;
2288 cmdline_fixed_string_t name;
2289 cmdline_fixed_string_t list_name;
2290 cmdline_fixed_string_t list_of_items;
2294 parse_reta_config(const char *str,
2295 struct rte_eth_rss_reta_entry64 *reta_conf,
2296 uint16_t nb_entries)
2300 uint16_t hash_index, idx, shift;
2303 const char *p, *p0 = str;
2310 unsigned long int_fld[_NUM_FLD];
2311 char *str_fld[_NUM_FLD];
2313 while ((p = strchr(p0,'(')) != NULL) {
2315 if((p0 = strchr(p,')')) == NULL)
2319 if(size >= sizeof(s))
2322 snprintf(s, sizeof(s), "%.*s", size, p);
2323 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2325 for (i = 0; i < _NUM_FLD; i++) {
2327 int_fld[i] = strtoul(str_fld[i], &end, 0);
2328 if (errno != 0 || end == str_fld[i] ||
2333 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2334 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2336 if (hash_index >= nb_entries) {
2337 printf("Invalid RETA hash index=%d\n", hash_index);
2341 idx = hash_index / RTE_RETA_GROUP_SIZE;
2342 shift = hash_index % RTE_RETA_GROUP_SIZE;
2343 reta_conf[idx].mask |= (1ULL << shift);
2344 reta_conf[idx].reta[shift] = nb_queue;
2351 cmd_set_rss_reta_parsed(void *parsed_result,
2352 __attribute__((unused)) struct cmdline *cl,
2353 __attribute__((unused)) void *data)
2356 struct rte_eth_dev_info dev_info;
2357 struct rte_eth_rss_reta_entry64 reta_conf[8];
2358 struct cmd_config_rss_reta *res = parsed_result;
2360 memset(&dev_info, 0, sizeof(dev_info));
2361 rte_eth_dev_info_get(res->port_id, &dev_info);
2362 if (dev_info.reta_size == 0) {
2363 printf("Redirection table size is 0 which is "
2364 "invalid for RSS\n");
2367 printf("The reta size of port %d is %u\n",
2368 res->port_id, dev_info.reta_size);
2369 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2370 printf("Currently do not support more than %u entries of "
2371 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2375 memset(reta_conf, 0, sizeof(reta_conf));
2376 if (!strcmp(res->list_name, "reta")) {
2377 if (parse_reta_config(res->list_of_items, reta_conf,
2378 dev_info.reta_size)) {
2379 printf("Invalid RSS Redirection Table "
2380 "config entered\n");
2383 ret = rte_eth_dev_rss_reta_update(res->port_id,
2384 reta_conf, dev_info.reta_size);
2386 printf("Bad redirection table parameter, "
2387 "return code = %d \n", ret);
2391 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2392 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2393 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2394 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2395 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2396 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
2397 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2398 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2399 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2400 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2401 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2402 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2404 cmdline_parse_inst_t cmd_config_rss_reta = {
2405 .f = cmd_set_rss_reta_parsed,
2407 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2409 (void *)&cmd_config_rss_reta_port,
2410 (void *)&cmd_config_rss_reta_keyword,
2411 (void *)&cmd_config_rss_reta_port_id,
2412 (void *)&cmd_config_rss_reta_name,
2413 (void *)&cmd_config_rss_reta_list_name,
2414 (void *)&cmd_config_rss_reta_list_of_items,
2419 /* *** SHOW PORT RETA INFO *** */
2420 struct cmd_showport_reta {
2421 cmdline_fixed_string_t show;
2422 cmdline_fixed_string_t port;
2424 cmdline_fixed_string_t rss;
2425 cmdline_fixed_string_t reta;
2427 cmdline_fixed_string_t list_of_items;
2431 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2432 uint16_t nb_entries,
2436 const char *p, *p0 = str;
2441 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2442 RTE_RETA_GROUP_SIZE;
2445 p = strchr(p0, '(');
2449 p0 = strchr(p, ')');
2453 if (size >= sizeof(s)) {
2454 printf("The string size exceeds the internal buffer size\n");
2457 snprintf(s, sizeof(s), "%.*s", size, p);
2458 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2459 if (ret <= 0 || ret != num) {
2460 printf("The bits of masks do not match the number of "
2461 "reta entries: %u\n", num);
2464 for (i = 0; i < ret; i++)
2465 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2471 cmd_showport_reta_parsed(void *parsed_result,
2472 __attribute__((unused)) struct cmdline *cl,
2473 __attribute__((unused)) void *data)
2475 struct cmd_showport_reta *res = parsed_result;
2476 struct rte_eth_rss_reta_entry64 reta_conf[8];
2477 struct rte_eth_dev_info dev_info;
2478 uint16_t max_reta_size;
2480 memset(&dev_info, 0, sizeof(dev_info));
2481 rte_eth_dev_info_get(res->port_id, &dev_info);
2482 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
2483 if (res->size == 0 || res->size > max_reta_size) {
2484 printf("Invalid redirection table size: %u (1-%u)\n",
2485 res->size, max_reta_size);
2489 memset(reta_conf, 0, sizeof(reta_conf));
2490 if (showport_parse_reta_config(reta_conf, res->size,
2491 res->list_of_items) < 0) {
2492 printf("Invalid string: %s for reta masks\n",
2493 res->list_of_items);
2496 port_rss_reta_info(res->port_id, reta_conf, res->size);
2499 cmdline_parse_token_string_t cmd_showport_reta_show =
2500 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2501 cmdline_parse_token_string_t cmd_showport_reta_port =
2502 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2503 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2504 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
2505 cmdline_parse_token_string_t cmd_showport_reta_rss =
2506 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2507 cmdline_parse_token_string_t cmd_showport_reta_reta =
2508 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2509 cmdline_parse_token_num_t cmd_showport_reta_size =
2510 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2511 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2512 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2513 list_of_items, NULL);
2515 cmdline_parse_inst_t cmd_showport_reta = {
2516 .f = cmd_showport_reta_parsed,
2518 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2520 (void *)&cmd_showport_reta_show,
2521 (void *)&cmd_showport_reta_port,
2522 (void *)&cmd_showport_reta_port_id,
2523 (void *)&cmd_showport_reta_rss,
2524 (void *)&cmd_showport_reta_reta,
2525 (void *)&cmd_showport_reta_size,
2526 (void *)&cmd_showport_reta_list_of_items,
2531 /* *** Show RSS hash configuration *** */
2532 struct cmd_showport_rss_hash {
2533 cmdline_fixed_string_t show;
2534 cmdline_fixed_string_t port;
2536 cmdline_fixed_string_t rss_hash;
2537 cmdline_fixed_string_t rss_type;
2538 cmdline_fixed_string_t key; /* optional argument */
2541 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2542 __attribute__((unused)) struct cmdline *cl,
2545 struct cmd_showport_rss_hash *res = parsed_result;
2547 port_rss_hash_conf_show(res->port_id, res->rss_type,
2548 show_rss_key != NULL);
2551 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2552 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2553 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2554 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2555 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2556 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
2557 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2558 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2560 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2561 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2562 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2563 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2564 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2565 "ipv6-tcp-ex#ipv6-udp-ex");
2566 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2567 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2569 cmdline_parse_inst_t cmd_showport_rss_hash = {
2570 .f = cmd_showport_rss_hash_parsed,
2572 .help_str = "show port <port_id> rss-hash "
2573 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2574 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2575 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex",
2577 (void *)&cmd_showport_rss_hash_show,
2578 (void *)&cmd_showport_rss_hash_port,
2579 (void *)&cmd_showport_rss_hash_port_id,
2580 (void *)&cmd_showport_rss_hash_rss_hash,
2581 (void *)&cmd_showport_rss_hash_rss_hash_info,
2586 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2587 .f = cmd_showport_rss_hash_parsed,
2589 .help_str = "show port <port_id> rss-hash "
2590 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2591 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2592 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key",
2594 (void *)&cmd_showport_rss_hash_show,
2595 (void *)&cmd_showport_rss_hash_port,
2596 (void *)&cmd_showport_rss_hash_port_id,
2597 (void *)&cmd_showport_rss_hash_rss_hash,
2598 (void *)&cmd_showport_rss_hash_rss_hash_info,
2599 (void *)&cmd_showport_rss_hash_rss_key,
2604 /* *** Configure DCB *** */
2605 struct cmd_config_dcb {
2606 cmdline_fixed_string_t port;
2607 cmdline_fixed_string_t config;
2609 cmdline_fixed_string_t dcb;
2610 cmdline_fixed_string_t vt;
2611 cmdline_fixed_string_t vt_en;
2613 cmdline_fixed_string_t pfc;
2614 cmdline_fixed_string_t pfc_en;
2618 cmd_config_dcb_parsed(void *parsed_result,
2619 __attribute__((unused)) struct cmdline *cl,
2620 __attribute__((unused)) void *data)
2622 struct cmd_config_dcb *res = parsed_result;
2623 portid_t port_id = res->port_id;
2624 struct rte_port *port;
2628 port = &ports[port_id];
2629 /** Check if the port is not started **/
2630 if (port->port_status != RTE_PORT_STOPPED) {
2631 printf("Please stop port %d first\n", port_id);
2635 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2636 printf("The invalid number of traffic class,"
2637 " only 4 or 8 allowed.\n");
2641 if (nb_fwd_lcores < res->num_tcs) {
2642 printf("nb_cores shouldn't be less than number of TCs.\n");
2645 if (!strncmp(res->pfc_en, "on", 2))
2650 /* DCB in VT mode */
2651 if (!strncmp(res->vt_en, "on", 2))
2652 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2653 (enum rte_eth_nb_tcs)res->num_tcs,
2656 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2657 (enum rte_eth_nb_tcs)res->num_tcs,
2662 printf("Cannot initialize network ports.\n");
2666 cmd_reconfig_device_queue(port_id, 1, 1);
2669 cmdline_parse_token_string_t cmd_config_dcb_port =
2670 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2671 cmdline_parse_token_string_t cmd_config_dcb_config =
2672 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2673 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2674 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
2675 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2676 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2677 cmdline_parse_token_string_t cmd_config_dcb_vt =
2678 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2679 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2680 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2681 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2682 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2683 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2684 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2685 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2686 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2688 cmdline_parse_inst_t cmd_config_dcb = {
2689 .f = cmd_config_dcb_parsed,
2691 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
2693 (void *)&cmd_config_dcb_port,
2694 (void *)&cmd_config_dcb_config,
2695 (void *)&cmd_config_dcb_port_id,
2696 (void *)&cmd_config_dcb_dcb,
2697 (void *)&cmd_config_dcb_vt,
2698 (void *)&cmd_config_dcb_vt_en,
2699 (void *)&cmd_config_dcb_num_tcs,
2700 (void *)&cmd_config_dcb_pfc,
2701 (void *)&cmd_config_dcb_pfc_en,
2706 /* *** configure number of packets per burst *** */
2707 struct cmd_config_burst {
2708 cmdline_fixed_string_t port;
2709 cmdline_fixed_string_t keyword;
2710 cmdline_fixed_string_t all;
2711 cmdline_fixed_string_t name;
2716 cmd_config_burst_parsed(void *parsed_result,
2717 __attribute__((unused)) struct cmdline *cl,
2718 __attribute__((unused)) void *data)
2720 struct cmd_config_burst *res = parsed_result;
2721 struct rte_eth_dev_info dev_info;
2722 uint16_t rec_nb_pkts;
2724 if (!all_ports_stopped()) {
2725 printf("Please stop all ports first\n");
2729 if (!strcmp(res->name, "burst")) {
2730 if (res->value == 0) {
2731 /* If user gives a value of zero, query the PMD for
2732 * its recommended Rx burst size. Testpmd uses a single
2733 * size for all ports, so assume all ports are the same
2734 * NIC model and use the values from Port 0.
2736 rte_eth_dev_info_get(0, &dev_info);
2737 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
2739 if (rec_nb_pkts == 0) {
2740 printf("PMD does not recommend a burst size.\n"
2741 "User provided value must be between"
2742 " 1 and %d\n", MAX_PKT_BURST);
2744 } else if (rec_nb_pkts > MAX_PKT_BURST) {
2745 printf("PMD recommended burst size of %d"
2746 " exceeds maximum value of %d\n",
2747 rec_nb_pkts, MAX_PKT_BURST);
2750 printf("Using PMD-provided burst value of %d\n",
2752 nb_pkt_per_burst = rec_nb_pkts;
2753 } else if (res->value > MAX_PKT_BURST) {
2754 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2757 nb_pkt_per_burst = res->value;
2759 printf("Unknown parameter\n");
2765 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2768 cmdline_parse_token_string_t cmd_config_burst_port =
2769 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2770 cmdline_parse_token_string_t cmd_config_burst_keyword =
2771 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2772 cmdline_parse_token_string_t cmd_config_burst_all =
2773 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2774 cmdline_parse_token_string_t cmd_config_burst_name =
2775 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2776 cmdline_parse_token_num_t cmd_config_burst_value =
2777 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2779 cmdline_parse_inst_t cmd_config_burst = {
2780 .f = cmd_config_burst_parsed,
2782 .help_str = "port config all burst <value>",
2784 (void *)&cmd_config_burst_port,
2785 (void *)&cmd_config_burst_keyword,
2786 (void *)&cmd_config_burst_all,
2787 (void *)&cmd_config_burst_name,
2788 (void *)&cmd_config_burst_value,
2793 /* *** configure rx/tx queues *** */
2794 struct cmd_config_thresh {
2795 cmdline_fixed_string_t port;
2796 cmdline_fixed_string_t keyword;
2797 cmdline_fixed_string_t all;
2798 cmdline_fixed_string_t name;
2803 cmd_config_thresh_parsed(void *parsed_result,
2804 __attribute__((unused)) struct cmdline *cl,
2805 __attribute__((unused)) void *data)
2807 struct cmd_config_thresh *res = parsed_result;
2809 if (!all_ports_stopped()) {
2810 printf("Please stop all ports first\n");
2814 if (!strcmp(res->name, "txpt"))
2815 tx_pthresh = res->value;
2816 else if(!strcmp(res->name, "txht"))
2817 tx_hthresh = res->value;
2818 else if(!strcmp(res->name, "txwt"))
2819 tx_wthresh = res->value;
2820 else if(!strcmp(res->name, "rxpt"))
2821 rx_pthresh = res->value;
2822 else if(!strcmp(res->name, "rxht"))
2823 rx_hthresh = res->value;
2824 else if(!strcmp(res->name, "rxwt"))
2825 rx_wthresh = res->value;
2827 printf("Unknown parameter\n");
2833 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2836 cmdline_parse_token_string_t cmd_config_thresh_port =
2837 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2838 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2839 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2840 cmdline_parse_token_string_t cmd_config_thresh_all =
2841 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2842 cmdline_parse_token_string_t cmd_config_thresh_name =
2843 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2844 "txpt#txht#txwt#rxpt#rxht#rxwt");
2845 cmdline_parse_token_num_t cmd_config_thresh_value =
2846 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2848 cmdline_parse_inst_t cmd_config_thresh = {
2849 .f = cmd_config_thresh_parsed,
2851 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
2853 (void *)&cmd_config_thresh_port,
2854 (void *)&cmd_config_thresh_keyword,
2855 (void *)&cmd_config_thresh_all,
2856 (void *)&cmd_config_thresh_name,
2857 (void *)&cmd_config_thresh_value,
2862 /* *** configure free/rs threshold *** */
2863 struct cmd_config_threshold {
2864 cmdline_fixed_string_t port;
2865 cmdline_fixed_string_t keyword;
2866 cmdline_fixed_string_t all;
2867 cmdline_fixed_string_t name;
2872 cmd_config_threshold_parsed(void *parsed_result,
2873 __attribute__((unused)) struct cmdline *cl,
2874 __attribute__((unused)) void *data)
2876 struct cmd_config_threshold *res = parsed_result;
2878 if (!all_ports_stopped()) {
2879 printf("Please stop all ports first\n");
2883 if (!strcmp(res->name, "txfreet"))
2884 tx_free_thresh = res->value;
2885 else if (!strcmp(res->name, "txrst"))
2886 tx_rs_thresh = res->value;
2887 else if (!strcmp(res->name, "rxfreet"))
2888 rx_free_thresh = res->value;
2890 printf("Unknown parameter\n");
2896 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2899 cmdline_parse_token_string_t cmd_config_threshold_port =
2900 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2901 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2902 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2904 cmdline_parse_token_string_t cmd_config_threshold_all =
2905 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2906 cmdline_parse_token_string_t cmd_config_threshold_name =
2907 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2908 "txfreet#txrst#rxfreet");
2909 cmdline_parse_token_num_t cmd_config_threshold_value =
2910 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2912 cmdline_parse_inst_t cmd_config_threshold = {
2913 .f = cmd_config_threshold_parsed,
2915 .help_str = "port config all txfreet|txrst|rxfreet <value>",
2917 (void *)&cmd_config_threshold_port,
2918 (void *)&cmd_config_threshold_keyword,
2919 (void *)&cmd_config_threshold_all,
2920 (void *)&cmd_config_threshold_name,
2921 (void *)&cmd_config_threshold_value,
2927 struct cmd_stop_result {
2928 cmdline_fixed_string_t stop;
2931 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2932 __attribute__((unused)) struct cmdline *cl,
2933 __attribute__((unused)) void *data)
2935 stop_packet_forwarding();
2938 cmdline_parse_token_string_t cmd_stop_stop =
2939 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2941 cmdline_parse_inst_t cmd_stop = {
2942 .f = cmd_stop_parsed,
2944 .help_str = "stop: Stop packet forwarding",
2946 (void *)&cmd_stop_stop,
2951 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2954 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2955 unsigned int *parsed_items, int check_unique_values)
2957 unsigned int nb_item;
2965 * First parse all items in the list and store their value.
2970 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2972 if ((c >= '0') && (c <= '9')) {
2973 value = (unsigned int) (value * 10 + (c - '0'));
2978 printf("character %c is not a decimal digit\n", c);
2982 printf("No valid value before comma\n");
2985 if (nb_item < max_items) {
2986 parsed_items[nb_item] = value;
2992 if (nb_item >= max_items) {
2993 printf("Number of %s = %u > %u (maximum items)\n",
2994 item_name, nb_item + 1, max_items);
2997 parsed_items[nb_item++] = value;
2998 if (! check_unique_values)
3002 * Then, check that all values in the list are differents.
3003 * No optimization here...
3005 for (i = 0; i < nb_item; i++) {
3006 for (j = i + 1; j < nb_item; j++) {
3007 if (parsed_items[j] == parsed_items[i]) {
3008 printf("duplicated %s %u at index %u and %u\n",
3009 item_name, parsed_items[i], i, j);
3017 struct cmd_set_list_result {
3018 cmdline_fixed_string_t cmd_keyword;
3019 cmdline_fixed_string_t list_name;
3020 cmdline_fixed_string_t list_of_items;
3023 static void cmd_set_list_parsed(void *parsed_result,
3024 __attribute__((unused)) struct cmdline *cl,
3025 __attribute__((unused)) void *data)
3027 struct cmd_set_list_result *res;
3029 unsigned int lcorelist[RTE_MAX_LCORE];
3030 unsigned int portlist[RTE_MAX_ETHPORTS];
3032 unsigned int nb_item;
3034 if (test_done == 0) {
3035 printf("Please stop forwarding first\n");
3039 res = parsed_result;
3040 if (!strcmp(res->list_name, "corelist")) {
3041 nb_item = parse_item_list(res->list_of_items, "core",
3043 parsed_items.lcorelist, 1);
3045 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3050 if (!strcmp(res->list_name, "portlist")) {
3051 nb_item = parse_item_list(res->list_of_items, "port",
3053 parsed_items.portlist, 1);
3055 set_fwd_ports_list(parsed_items.portlist, nb_item);
3061 cmdline_parse_token_string_t cmd_set_list_keyword =
3062 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3064 cmdline_parse_token_string_t cmd_set_list_name =
3065 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3066 "corelist#portlist");
3067 cmdline_parse_token_string_t cmd_set_list_of_items =
3068 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3071 cmdline_parse_inst_t cmd_set_fwd_list = {
3072 .f = cmd_set_list_parsed,
3074 .help_str = "set corelist|portlist <list0[,list1]*>",
3076 (void *)&cmd_set_list_keyword,
3077 (void *)&cmd_set_list_name,
3078 (void *)&cmd_set_list_of_items,
3083 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3085 struct cmd_setmask_result {
3086 cmdline_fixed_string_t set;
3087 cmdline_fixed_string_t mask;
3091 static void cmd_set_mask_parsed(void *parsed_result,
3092 __attribute__((unused)) struct cmdline *cl,
3093 __attribute__((unused)) void *data)
3095 struct cmd_setmask_result *res = parsed_result;
3097 if (test_done == 0) {
3098 printf("Please stop forwarding first\n");
3101 if (!strcmp(res->mask, "coremask")) {
3102 set_fwd_lcores_mask(res->hexavalue);
3104 } else if (!strcmp(res->mask, "portmask")) {
3105 set_fwd_ports_mask(res->hexavalue);
3110 cmdline_parse_token_string_t cmd_setmask_set =
3111 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3112 cmdline_parse_token_string_t cmd_setmask_mask =
3113 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3114 "coremask#portmask");
3115 cmdline_parse_token_num_t cmd_setmask_value =
3116 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3118 cmdline_parse_inst_t cmd_set_fwd_mask = {
3119 .f = cmd_set_mask_parsed,
3121 .help_str = "set coremask|portmask <hexadecimal value>",
3123 (void *)&cmd_setmask_set,
3124 (void *)&cmd_setmask_mask,
3125 (void *)&cmd_setmask_value,
3131 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3133 struct cmd_set_result {
3134 cmdline_fixed_string_t set;
3135 cmdline_fixed_string_t what;
3139 static void cmd_set_parsed(void *parsed_result,
3140 __attribute__((unused)) struct cmdline *cl,
3141 __attribute__((unused)) void *data)
3143 struct cmd_set_result *res = parsed_result;
3144 if (!strcmp(res->what, "nbport")) {
3145 set_fwd_ports_number(res->value);
3147 } else if (!strcmp(res->what, "nbcore")) {
3148 set_fwd_lcores_number(res->value);
3150 } else if (!strcmp(res->what, "burst"))
3151 set_nb_pkt_per_burst(res->value);
3152 else if (!strcmp(res->what, "verbose"))
3153 set_verbose_level(res->value);
3156 cmdline_parse_token_string_t cmd_set_set =
3157 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3158 cmdline_parse_token_string_t cmd_set_what =
3159 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3160 "nbport#nbcore#burst#verbose");
3161 cmdline_parse_token_num_t cmd_set_value =
3162 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3164 cmdline_parse_inst_t cmd_set_numbers = {
3165 .f = cmd_set_parsed,
3167 .help_str = "set nbport|nbcore|burst|verbose <value>",
3169 (void *)&cmd_set_set,
3170 (void *)&cmd_set_what,
3171 (void *)&cmd_set_value,
3176 /* *** SET LOG LEVEL CONFIGURATION *** */
3178 struct cmd_set_log_result {
3179 cmdline_fixed_string_t set;
3180 cmdline_fixed_string_t log;
3181 cmdline_fixed_string_t type;
3186 cmd_set_log_parsed(void *parsed_result,
3187 __attribute__((unused)) struct cmdline *cl,
3188 __attribute__((unused)) void *data)
3190 struct cmd_set_log_result *res;
3193 res = parsed_result;
3194 if (!strcmp(res->type, "global"))
3195 rte_log_set_global_level(res->level);
3197 ret = rte_log_set_level_regexp(res->type, res->level);
3199 printf("Unable to set log level\n");
3203 cmdline_parse_token_string_t cmd_set_log_set =
3204 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3205 cmdline_parse_token_string_t cmd_set_log_log =
3206 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3207 cmdline_parse_token_string_t cmd_set_log_type =
3208 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3209 cmdline_parse_token_num_t cmd_set_log_level =
3210 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3212 cmdline_parse_inst_t cmd_set_log = {
3213 .f = cmd_set_log_parsed,
3215 .help_str = "set log global|<type> <level>",
3217 (void *)&cmd_set_log_set,
3218 (void *)&cmd_set_log_log,
3219 (void *)&cmd_set_log_type,
3220 (void *)&cmd_set_log_level,
3225 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3227 struct cmd_set_txpkts_result {
3228 cmdline_fixed_string_t cmd_keyword;
3229 cmdline_fixed_string_t txpkts;
3230 cmdline_fixed_string_t seg_lengths;
3234 cmd_set_txpkts_parsed(void *parsed_result,
3235 __attribute__((unused)) struct cmdline *cl,
3236 __attribute__((unused)) void *data)
3238 struct cmd_set_txpkts_result *res;
3239 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3240 unsigned int nb_segs;
3242 res = parsed_result;
3243 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3244 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3246 set_tx_pkt_segments(seg_lengths, nb_segs);
3249 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3250 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3251 cmd_keyword, "set");
3252 cmdline_parse_token_string_t cmd_set_txpkts_name =
3253 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3255 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3256 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3259 cmdline_parse_inst_t cmd_set_txpkts = {
3260 .f = cmd_set_txpkts_parsed,
3262 .help_str = "set txpkts <len0[,len1]*>",
3264 (void *)&cmd_set_txpkts_keyword,
3265 (void *)&cmd_set_txpkts_name,
3266 (void *)&cmd_set_txpkts_lengths,
3271 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3273 struct cmd_set_txsplit_result {
3274 cmdline_fixed_string_t cmd_keyword;
3275 cmdline_fixed_string_t txsplit;
3276 cmdline_fixed_string_t mode;
3280 cmd_set_txsplit_parsed(void *parsed_result,
3281 __attribute__((unused)) struct cmdline *cl,
3282 __attribute__((unused)) void *data)
3284 struct cmd_set_txsplit_result *res;
3286 res = parsed_result;
3287 set_tx_pkt_split(res->mode);
3290 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3291 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3292 cmd_keyword, "set");
3293 cmdline_parse_token_string_t cmd_set_txsplit_name =
3294 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3295 txsplit, "txsplit");
3296 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3297 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3300 cmdline_parse_inst_t cmd_set_txsplit = {
3301 .f = cmd_set_txsplit_parsed,
3303 .help_str = "set txsplit on|off|rand",
3305 (void *)&cmd_set_txsplit_keyword,
3306 (void *)&cmd_set_txsplit_name,
3307 (void *)&cmd_set_txsplit_mode,
3312 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3313 struct cmd_rx_vlan_filter_all_result {
3314 cmdline_fixed_string_t rx_vlan;
3315 cmdline_fixed_string_t what;
3316 cmdline_fixed_string_t all;
3321 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3322 __attribute__((unused)) struct cmdline *cl,
3323 __attribute__((unused)) void *data)
3325 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3327 if (!strcmp(res->what, "add"))
3328 rx_vlan_all_filter_set(res->port_id, 1);
3330 rx_vlan_all_filter_set(res->port_id, 0);
3333 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3334 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3335 rx_vlan, "rx_vlan");
3336 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3337 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3339 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3340 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3342 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3343 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3346 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3347 .f = cmd_rx_vlan_filter_all_parsed,
3349 .help_str = "rx_vlan add|rm all <port_id>: "
3350 "Add/Remove all identifiers to/from the set of VLAN "
3351 "identifiers filtered by a port",
3353 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3354 (void *)&cmd_rx_vlan_filter_all_what,
3355 (void *)&cmd_rx_vlan_filter_all_all,
3356 (void *)&cmd_rx_vlan_filter_all_portid,
3361 /* *** VLAN OFFLOAD SET ON A PORT *** */
3362 struct cmd_vlan_offload_result {
3363 cmdline_fixed_string_t vlan;
3364 cmdline_fixed_string_t set;
3365 cmdline_fixed_string_t vlan_type;
3366 cmdline_fixed_string_t what;
3367 cmdline_fixed_string_t on;
3368 cmdline_fixed_string_t port_id;
3372 cmd_vlan_offload_parsed(void *parsed_result,
3373 __attribute__((unused)) struct cmdline *cl,
3374 __attribute__((unused)) void *data)
3377 struct cmd_vlan_offload_result *res = parsed_result;
3380 portid_t port_id = 0;
3384 len = strnlen(str, STR_TOKEN_SIZE);
3386 /* Get port_id first */
3394 tmp = strtoul(str, NULL, 0);
3395 /* If port_id greater that what portid_t can represent, return */
3396 if(tmp >= RTE_MAX_ETHPORTS)
3398 port_id = (portid_t)tmp;
3400 if (!strcmp(res->on, "on"))
3405 if (!strcmp(res->what, "strip"))
3406 rx_vlan_strip_set(port_id, on);
3407 else if(!strcmp(res->what, "stripq")){
3408 uint16_t queue_id = 0;
3410 /* No queue_id, return */
3412 printf("must specify (port,queue_id)\n");
3415 tmp = strtoul(str + i + 1, NULL, 0);
3416 /* If queue_id greater that what 16-bits can represent, return */
3420 queue_id = (uint16_t)tmp;
3421 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3423 else if (!strcmp(res->what, "filter"))
3424 rx_vlan_filter_set(port_id, on);
3426 vlan_extend_set(port_id, on);
3431 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3432 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3434 cmdline_parse_token_string_t cmd_vlan_offload_set =
3435 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3437 cmdline_parse_token_string_t cmd_vlan_offload_what =
3438 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3439 what, "strip#filter#qinq#stripq");
3440 cmdline_parse_token_string_t cmd_vlan_offload_on =
3441 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3443 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3444 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3447 cmdline_parse_inst_t cmd_vlan_offload = {
3448 .f = cmd_vlan_offload_parsed,
3450 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3451 "<port_id[,queue_id]>: "
3452 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3454 (void *)&cmd_vlan_offload_vlan,
3455 (void *)&cmd_vlan_offload_set,
3456 (void *)&cmd_vlan_offload_what,
3457 (void *)&cmd_vlan_offload_on,
3458 (void *)&cmd_vlan_offload_portid,
3463 /* *** VLAN TPID SET ON A PORT *** */
3464 struct cmd_vlan_tpid_result {
3465 cmdline_fixed_string_t vlan;
3466 cmdline_fixed_string_t set;
3467 cmdline_fixed_string_t vlan_type;
3468 cmdline_fixed_string_t what;
3474 cmd_vlan_tpid_parsed(void *parsed_result,
3475 __attribute__((unused)) struct cmdline *cl,
3476 __attribute__((unused)) void *data)
3478 struct cmd_vlan_tpid_result *res = parsed_result;
3479 enum rte_vlan_type vlan_type;
3481 if (!strcmp(res->vlan_type, "inner"))
3482 vlan_type = ETH_VLAN_TYPE_INNER;
3483 else if (!strcmp(res->vlan_type, "outer"))
3484 vlan_type = ETH_VLAN_TYPE_OUTER;
3486 printf("Unknown vlan type\n");
3489 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3492 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3493 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3495 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3496 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3498 cmdline_parse_token_string_t cmd_vlan_type =
3499 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3500 vlan_type, "inner#outer");
3501 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3502 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3504 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3505 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3507 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3508 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3511 cmdline_parse_inst_t cmd_vlan_tpid = {
3512 .f = cmd_vlan_tpid_parsed,
3514 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3515 "Set the VLAN Ether type",
3517 (void *)&cmd_vlan_tpid_vlan,
3518 (void *)&cmd_vlan_tpid_set,
3519 (void *)&cmd_vlan_type,
3520 (void *)&cmd_vlan_tpid_what,
3521 (void *)&cmd_vlan_tpid_tpid,
3522 (void *)&cmd_vlan_tpid_portid,
3527 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3528 struct cmd_rx_vlan_filter_result {
3529 cmdline_fixed_string_t rx_vlan;
3530 cmdline_fixed_string_t what;
3536 cmd_rx_vlan_filter_parsed(void *parsed_result,
3537 __attribute__((unused)) struct cmdline *cl,
3538 __attribute__((unused)) void *data)
3540 struct cmd_rx_vlan_filter_result *res = parsed_result;
3542 if (!strcmp(res->what, "add"))
3543 rx_vft_set(res->port_id, res->vlan_id, 1);
3545 rx_vft_set(res->port_id, res->vlan_id, 0);
3548 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3549 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3550 rx_vlan, "rx_vlan");
3551 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3552 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3554 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3555 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3557 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3558 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3561 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3562 .f = cmd_rx_vlan_filter_parsed,
3564 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3565 "Add/Remove a VLAN identifier to/from the set of VLAN "
3566 "identifiers filtered by a port",
3568 (void *)&cmd_rx_vlan_filter_rx_vlan,
3569 (void *)&cmd_rx_vlan_filter_what,
3570 (void *)&cmd_rx_vlan_filter_vlanid,
3571 (void *)&cmd_rx_vlan_filter_portid,
3576 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3577 struct cmd_tx_vlan_set_result {
3578 cmdline_fixed_string_t tx_vlan;
3579 cmdline_fixed_string_t set;
3585 cmd_tx_vlan_set_parsed(void *parsed_result,
3586 __attribute__((unused)) struct cmdline *cl,
3587 __attribute__((unused)) void *data)
3589 struct cmd_tx_vlan_set_result *res = parsed_result;
3591 if (!port_is_stopped(res->port_id)) {
3592 printf("Please stop port %d first\n", res->port_id);
3596 tx_vlan_set(res->port_id, res->vlan_id);
3598 cmd_reconfig_device_queue(res->port_id, 1, 1);
3601 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3602 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3603 tx_vlan, "tx_vlan");
3604 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3605 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3607 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3608 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3610 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3611 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3614 cmdline_parse_inst_t cmd_tx_vlan_set = {
3615 .f = cmd_tx_vlan_set_parsed,
3617 .help_str = "tx_vlan set <port_id> <vlan_id>: "
3618 "Enable hardware insertion of a single VLAN header "
3619 "with a given TAG Identifier in packets sent on a port",
3621 (void *)&cmd_tx_vlan_set_tx_vlan,
3622 (void *)&cmd_tx_vlan_set_set,
3623 (void *)&cmd_tx_vlan_set_portid,
3624 (void *)&cmd_tx_vlan_set_vlanid,
3629 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3630 struct cmd_tx_vlan_set_qinq_result {
3631 cmdline_fixed_string_t tx_vlan;
3632 cmdline_fixed_string_t set;
3635 uint16_t vlan_id_outer;
3639 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3640 __attribute__((unused)) struct cmdline *cl,
3641 __attribute__((unused)) void *data)
3643 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3645 if (!port_is_stopped(res->port_id)) {
3646 printf("Please stop port %d first\n", res->port_id);
3650 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3652 cmd_reconfig_device_queue(res->port_id, 1, 1);
3655 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3656 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3657 tx_vlan, "tx_vlan");
3658 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3659 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3661 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3662 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3664 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3665 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3667 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3668 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3669 vlan_id_outer, UINT16);
3671 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3672 .f = cmd_tx_vlan_set_qinq_parsed,
3674 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3675 "Enable hardware insertion of double VLAN header "
3676 "with given TAG Identifiers in packets sent on a port",
3678 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3679 (void *)&cmd_tx_vlan_set_qinq_set,
3680 (void *)&cmd_tx_vlan_set_qinq_portid,
3681 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3682 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3687 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3688 struct cmd_tx_vlan_set_pvid_result {
3689 cmdline_fixed_string_t tx_vlan;
3690 cmdline_fixed_string_t set;
3691 cmdline_fixed_string_t pvid;
3694 cmdline_fixed_string_t mode;
3698 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3699 __attribute__((unused)) struct cmdline *cl,
3700 __attribute__((unused)) void *data)
3702 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3704 if (strcmp(res->mode, "on") == 0)
3705 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3707 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3710 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3711 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3712 tx_vlan, "tx_vlan");
3713 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3714 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3716 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3717 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3719 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3720 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3722 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3723 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3725 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3726 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3729 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3730 .f = cmd_tx_vlan_set_pvid_parsed,
3732 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
3734 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3735 (void *)&cmd_tx_vlan_set_pvid_set,
3736 (void *)&cmd_tx_vlan_set_pvid_pvid,
3737 (void *)&cmd_tx_vlan_set_pvid_port_id,
3738 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3739 (void *)&cmd_tx_vlan_set_pvid_mode,
3744 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3745 struct cmd_tx_vlan_reset_result {
3746 cmdline_fixed_string_t tx_vlan;
3747 cmdline_fixed_string_t reset;
3752 cmd_tx_vlan_reset_parsed(void *parsed_result,
3753 __attribute__((unused)) struct cmdline *cl,
3754 __attribute__((unused)) void *data)
3756 struct cmd_tx_vlan_reset_result *res = parsed_result;
3758 if (!port_is_stopped(res->port_id)) {
3759 printf("Please stop port %d first\n", res->port_id);
3763 tx_vlan_reset(res->port_id);
3765 cmd_reconfig_device_queue(res->port_id, 1, 1);
3768 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3769 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3770 tx_vlan, "tx_vlan");
3771 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3772 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3774 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3775 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3778 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3779 .f = cmd_tx_vlan_reset_parsed,
3781 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
3782 "VLAN header in packets sent on a port",
3784 (void *)&cmd_tx_vlan_reset_tx_vlan,
3785 (void *)&cmd_tx_vlan_reset_reset,
3786 (void *)&cmd_tx_vlan_reset_portid,
3792 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3793 struct cmd_csum_result {
3794 cmdline_fixed_string_t csum;
3795 cmdline_fixed_string_t mode;
3796 cmdline_fixed_string_t proto;
3797 cmdline_fixed_string_t hwsw;
3802 csum_show(int port_id)
3804 struct rte_eth_dev_info dev_info;
3805 uint64_t tx_offloads;
3807 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
3808 printf("Parse tunnel is %s\n",
3809 (ports[port_id].parse_tunnel) ? "on" : "off");
3810 printf("IP checksum offload is %s\n",
3811 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
3812 printf("UDP checksum offload is %s\n",
3813 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3814 printf("TCP checksum offload is %s\n",
3815 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3816 printf("SCTP checksum offload is %s\n",
3817 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3818 printf("Outer-Ip checksum offload is %s\n",
3819 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
3821 /* display warnings if configuration is not supported by the NIC */
3822 rte_eth_dev_info_get(port_id, &dev_info);
3823 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
3824 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3825 printf("Warning: hardware IP checksum enabled but not "
3826 "supported by port %d\n", port_id);
3828 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
3829 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3830 printf("Warning: hardware UDP checksum enabled but not "
3831 "supported by port %d\n", port_id);
3833 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
3834 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3835 printf("Warning: hardware TCP checksum enabled but not "
3836 "supported by port %d\n", port_id);
3838 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
3839 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3840 printf("Warning: hardware SCTP checksum enabled but not "
3841 "supported by port %d\n", port_id);
3843 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
3844 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3845 printf("Warning: hardware outer IP checksum enabled but not "
3846 "supported by port %d\n", port_id);
3851 cmd_csum_parsed(void *parsed_result,
3852 __attribute__((unused)) struct cmdline *cl,
3853 __attribute__((unused)) void *data)
3855 struct cmd_csum_result *res = parsed_result;
3857 uint64_t csum_offloads = 0;
3858 struct rte_eth_dev_info dev_info;
3860 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3861 printf("invalid port %d\n", res->port_id);
3864 if (!port_is_stopped(res->port_id)) {
3865 printf("Please stop port %d first\n", res->port_id);
3869 rte_eth_dev_info_get(res->port_id, &dev_info);
3870 if (!strcmp(res->mode, "set")) {
3872 if (!strcmp(res->hwsw, "hw"))
3875 if (!strcmp(res->proto, "ip")) {
3876 if (hw == 0 || (dev_info.tx_offload_capa &
3877 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
3878 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
3880 printf("IP checksum offload is not supported "
3881 "by port %u\n", res->port_id);
3883 } else if (!strcmp(res->proto, "udp")) {
3884 if (hw == 0 || (dev_info.tx_offload_capa &
3885 DEV_TX_OFFLOAD_UDP_CKSUM)) {
3886 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
3888 printf("UDP checksum offload is not supported "
3889 "by port %u\n", res->port_id);
3891 } else if (!strcmp(res->proto, "tcp")) {
3892 if (hw == 0 || (dev_info.tx_offload_capa &
3893 DEV_TX_OFFLOAD_TCP_CKSUM)) {
3894 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
3896 printf("TCP checksum offload is not supported "
3897 "by port %u\n", res->port_id);
3899 } else if (!strcmp(res->proto, "sctp")) {
3900 if (hw == 0 || (dev_info.tx_offload_capa &
3901 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
3902 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
3904 printf("SCTP checksum offload is not supported "
3905 "by port %u\n", res->port_id);
3907 } else if (!strcmp(res->proto, "outer-ip")) {
3908 if (hw == 0 || (dev_info.tx_offload_capa &
3909 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
3911 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
3913 printf("Outer IP checksum offload is not "
3914 "supported by port %u\n", res->port_id);
3919 ports[res->port_id].dev_conf.txmode.offloads |=
3922 ports[res->port_id].dev_conf.txmode.offloads &=
3926 csum_show(res->port_id);
3928 cmd_reconfig_device_queue(res->port_id, 1, 1);
3931 cmdline_parse_token_string_t cmd_csum_csum =
3932 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3934 cmdline_parse_token_string_t cmd_csum_mode =
3935 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3937 cmdline_parse_token_string_t cmd_csum_proto =
3938 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3939 proto, "ip#tcp#udp#sctp#outer-ip");
3940 cmdline_parse_token_string_t cmd_csum_hwsw =
3941 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3943 cmdline_parse_token_num_t cmd_csum_portid =
3944 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3947 cmdline_parse_inst_t cmd_csum_set = {
3948 .f = cmd_csum_parsed,
3950 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
3951 "Enable/Disable hardware calculation of L3/L4 checksum when "
3952 "using csum forward engine",
3954 (void *)&cmd_csum_csum,
3955 (void *)&cmd_csum_mode,
3956 (void *)&cmd_csum_proto,
3957 (void *)&cmd_csum_hwsw,
3958 (void *)&cmd_csum_portid,
3963 cmdline_parse_token_string_t cmd_csum_mode_show =
3964 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3967 cmdline_parse_inst_t cmd_csum_show = {
3968 .f = cmd_csum_parsed,
3970 .help_str = "csum show <port_id>: Show checksum offload configuration",
3972 (void *)&cmd_csum_csum,
3973 (void *)&cmd_csum_mode_show,
3974 (void *)&cmd_csum_portid,
3979 /* Enable/disable tunnel parsing */
3980 struct cmd_csum_tunnel_result {
3981 cmdline_fixed_string_t csum;
3982 cmdline_fixed_string_t parse;
3983 cmdline_fixed_string_t onoff;
3988 cmd_csum_tunnel_parsed(void *parsed_result,
3989 __attribute__((unused)) struct cmdline *cl,
3990 __attribute__((unused)) void *data)
3992 struct cmd_csum_tunnel_result *res = parsed_result;
3994 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3997 if (!strcmp(res->onoff, "on"))
3998 ports[res->port_id].parse_tunnel = 1;
4000 ports[res->port_id].parse_tunnel = 0;
4002 csum_show(res->port_id);
4005 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4006 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4008 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4009 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4010 parse, "parse_tunnel");
4011 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4012 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4014 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4015 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4018 cmdline_parse_inst_t cmd_csum_tunnel = {
4019 .f = cmd_csum_tunnel_parsed,
4021 .help_str = "csum parse_tunnel on|off <port_id>: "
4022 "Enable/Disable parsing of tunnels for csum engine",
4024 (void *)&cmd_csum_tunnel_csum,
4025 (void *)&cmd_csum_tunnel_parse,
4026 (void *)&cmd_csum_tunnel_onoff,
4027 (void *)&cmd_csum_tunnel_portid,
4032 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4033 struct cmd_tso_set_result {
4034 cmdline_fixed_string_t tso;
4035 cmdline_fixed_string_t mode;
4041 cmd_tso_set_parsed(void *parsed_result,
4042 __attribute__((unused)) struct cmdline *cl,
4043 __attribute__((unused)) void *data)
4045 struct cmd_tso_set_result *res = parsed_result;
4046 struct rte_eth_dev_info dev_info;
4048 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4050 if (!port_is_stopped(res->port_id)) {
4051 printf("Please stop port %d first\n", res->port_id);
4055 if (!strcmp(res->mode, "set"))
4056 ports[res->port_id].tso_segsz = res->tso_segsz;
4058 rte_eth_dev_info_get(res->port_id, &dev_info);
4059 if ((ports[res->port_id].tso_segsz != 0) &&
4060 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4061 printf("Error: TSO is not supported by port %d\n",
4066 if (ports[res->port_id].tso_segsz == 0) {
4067 ports[res->port_id].dev_conf.txmode.offloads &=
4068 ~DEV_TX_OFFLOAD_TCP_TSO;
4069 printf("TSO for non-tunneled packets is disabled\n");
4071 ports[res->port_id].dev_conf.txmode.offloads |=
4072 DEV_TX_OFFLOAD_TCP_TSO;
4073 printf("TSO segment size for non-tunneled packets is %d\n",
4074 ports[res->port_id].tso_segsz);
4077 /* display warnings if configuration is not supported by the NIC */
4078 rte_eth_dev_info_get(res->port_id, &dev_info);
4079 if ((ports[res->port_id].tso_segsz != 0) &&
4080 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4081 printf("Warning: TSO enabled but not "
4082 "supported by port %d\n", res->port_id);
4085 cmd_reconfig_device_queue(res->port_id, 1, 1);
4088 cmdline_parse_token_string_t cmd_tso_set_tso =
4089 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4091 cmdline_parse_token_string_t cmd_tso_set_mode =
4092 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4094 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4095 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4097 cmdline_parse_token_num_t cmd_tso_set_portid =
4098 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4101 cmdline_parse_inst_t cmd_tso_set = {
4102 .f = cmd_tso_set_parsed,
4104 .help_str = "tso set <tso_segsz> <port_id>: "
4105 "Set TSO segment size of non-tunneled packets for csum engine "
4108 (void *)&cmd_tso_set_tso,
4109 (void *)&cmd_tso_set_mode,
4110 (void *)&cmd_tso_set_tso_segsz,
4111 (void *)&cmd_tso_set_portid,
4116 cmdline_parse_token_string_t cmd_tso_show_mode =
4117 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4121 cmdline_parse_inst_t cmd_tso_show = {
4122 .f = cmd_tso_set_parsed,
4124 .help_str = "tso show <port_id>: "
4125 "Show TSO segment size of non-tunneled packets for csum engine",
4127 (void *)&cmd_tso_set_tso,
4128 (void *)&cmd_tso_show_mode,
4129 (void *)&cmd_tso_set_portid,
4134 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4135 struct cmd_tunnel_tso_set_result {
4136 cmdline_fixed_string_t tso;
4137 cmdline_fixed_string_t mode;
4142 static struct rte_eth_dev_info
4143 check_tunnel_tso_nic_support(portid_t port_id)
4145 struct rte_eth_dev_info dev_info;
4147 rte_eth_dev_info_get(port_id, &dev_info);
4148 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4149 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4150 "not enabled for port %d\n", port_id);
4151 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4152 printf("Warning: GRE TUNNEL TSO not supported therefore "
4153 "not enabled for port %d\n", port_id);
4154 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4155 printf("Warning: IPIP TUNNEL TSO not supported therefore "
4156 "not enabled for port %d\n", port_id);
4157 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4158 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4159 "not enabled for port %d\n", port_id);
4164 cmd_tunnel_tso_set_parsed(void *parsed_result,
4165 __attribute__((unused)) struct cmdline *cl,
4166 __attribute__((unused)) void *data)
4168 struct cmd_tunnel_tso_set_result *res = parsed_result;
4169 struct rte_eth_dev_info dev_info;
4171 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4173 if (!port_is_stopped(res->port_id)) {
4174 printf("Please stop port %d first\n", res->port_id);
4178 if (!strcmp(res->mode, "set"))
4179 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4181 dev_info = check_tunnel_tso_nic_support(res->port_id);
4182 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4183 ports[res->port_id].dev_conf.txmode.offloads &=
4184 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4185 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4186 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4187 DEV_TX_OFFLOAD_GENEVE_TNL_TSO);
4188 printf("TSO for tunneled packets is disabled\n");
4190 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4191 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4192 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4193 DEV_TX_OFFLOAD_GENEVE_TNL_TSO);
4195 ports[res->port_id].dev_conf.txmode.offloads |=
4196 (tso_offloads & dev_info.tx_offload_capa);
4197 printf("TSO segment size for tunneled packets is %d\n",
4198 ports[res->port_id].tunnel_tso_segsz);
4200 /* Below conditions are needed to make it work:
4201 * (1) tunnel TSO is supported by the NIC;
4202 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4204 * (3) for tunneled pkts with outer L3 of IPv4,
4205 * "csum set outer-ip" must be set to hw, because after tso,
4206 * total_len of outer IP header is changed, and the checksum
4207 * of outer IP header calculated by sw should be wrong; that
4208 * is not necessary for IPv6 tunneled pkts because there's no
4209 * checksum in IP header anymore.
4212 if (!ports[res->port_id].parse_tunnel)
4213 printf("Warning: csum parse_tunnel must be set "
4214 "so that tunneled packets are recognized\n");
4215 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4216 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4217 printf("Warning: csum set outer-ip must be set to hw "
4218 "if outer L3 is IPv4; not necessary for IPv6\n");
4221 cmd_reconfig_device_queue(res->port_id, 1, 1);
4224 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4225 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4227 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4228 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4230 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4231 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4233 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4234 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4237 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4238 .f = cmd_tunnel_tso_set_parsed,
4240 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4241 "Set TSO segment size of tunneled packets for csum engine "
4244 (void *)&cmd_tunnel_tso_set_tso,
4245 (void *)&cmd_tunnel_tso_set_mode,
4246 (void *)&cmd_tunnel_tso_set_tso_segsz,
4247 (void *)&cmd_tunnel_tso_set_portid,
4252 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4253 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4257 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4258 .f = cmd_tunnel_tso_set_parsed,
4260 .help_str = "tunnel_tso show <port_id> "
4261 "Show TSO segment size of tunneled packets for csum engine",
4263 (void *)&cmd_tunnel_tso_set_tso,
4264 (void *)&cmd_tunnel_tso_show_mode,
4265 (void *)&cmd_tunnel_tso_set_portid,
4270 /* *** SET GRO FOR A PORT *** */
4271 struct cmd_gro_enable_result {
4272 cmdline_fixed_string_t cmd_set;
4273 cmdline_fixed_string_t cmd_port;
4274 cmdline_fixed_string_t cmd_keyword;
4275 cmdline_fixed_string_t cmd_onoff;
4280 cmd_gro_enable_parsed(void *parsed_result,
4281 __attribute__((unused)) struct cmdline *cl,
4282 __attribute__((unused)) void *data)
4284 struct cmd_gro_enable_result *res;
4286 res = parsed_result;
4287 if (!strcmp(res->cmd_keyword, "gro"))
4288 setup_gro(res->cmd_onoff, res->cmd_pid);
4291 cmdline_parse_token_string_t cmd_gro_enable_set =
4292 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4294 cmdline_parse_token_string_t cmd_gro_enable_port =
4295 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4296 cmd_keyword, "port");
4297 cmdline_parse_token_num_t cmd_gro_enable_pid =
4298 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4300 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4301 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4302 cmd_keyword, "gro");
4303 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4304 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4305 cmd_onoff, "on#off");
4307 cmdline_parse_inst_t cmd_gro_enable = {
4308 .f = cmd_gro_enable_parsed,
4310 .help_str = "set port <port_id> gro on|off",
4312 (void *)&cmd_gro_enable_set,
4313 (void *)&cmd_gro_enable_port,
4314 (void *)&cmd_gro_enable_pid,
4315 (void *)&cmd_gro_enable_keyword,
4316 (void *)&cmd_gro_enable_onoff,
4321 /* *** DISPLAY GRO CONFIGURATION *** */
4322 struct cmd_gro_show_result {
4323 cmdline_fixed_string_t cmd_show;
4324 cmdline_fixed_string_t cmd_port;
4325 cmdline_fixed_string_t cmd_keyword;
4330 cmd_gro_show_parsed(void *parsed_result,
4331 __attribute__((unused)) struct cmdline *cl,
4332 __attribute__((unused)) void *data)
4334 struct cmd_gro_show_result *res;
4336 res = parsed_result;
4337 if (!strcmp(res->cmd_keyword, "gro"))
4338 show_gro(res->cmd_pid);
4341 cmdline_parse_token_string_t cmd_gro_show_show =
4342 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4344 cmdline_parse_token_string_t cmd_gro_show_port =
4345 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4347 cmdline_parse_token_num_t cmd_gro_show_pid =
4348 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
4350 cmdline_parse_token_string_t cmd_gro_show_keyword =
4351 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4352 cmd_keyword, "gro");
4354 cmdline_parse_inst_t cmd_gro_show = {
4355 .f = cmd_gro_show_parsed,
4357 .help_str = "show port <port_id> gro",
4359 (void *)&cmd_gro_show_show,
4360 (void *)&cmd_gro_show_port,
4361 (void *)&cmd_gro_show_pid,
4362 (void *)&cmd_gro_show_keyword,
4367 /* *** SET FLUSH CYCLES FOR GRO *** */
4368 struct cmd_gro_flush_result {
4369 cmdline_fixed_string_t cmd_set;
4370 cmdline_fixed_string_t cmd_keyword;
4371 cmdline_fixed_string_t cmd_flush;
4376 cmd_gro_flush_parsed(void *parsed_result,
4377 __attribute__((unused)) struct cmdline *cl,
4378 __attribute__((unused)) void *data)
4380 struct cmd_gro_flush_result *res;
4382 res = parsed_result;
4383 if ((!strcmp(res->cmd_keyword, "gro")) &&
4384 (!strcmp(res->cmd_flush, "flush")))
4385 setup_gro_flush_cycles(res->cmd_cycles);
4388 cmdline_parse_token_string_t cmd_gro_flush_set =
4389 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4391 cmdline_parse_token_string_t cmd_gro_flush_keyword =
4392 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4393 cmd_keyword, "gro");
4394 cmdline_parse_token_string_t cmd_gro_flush_flush =
4395 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4396 cmd_flush, "flush");
4397 cmdline_parse_token_num_t cmd_gro_flush_cycles =
4398 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
4401 cmdline_parse_inst_t cmd_gro_flush = {
4402 .f = cmd_gro_flush_parsed,
4404 .help_str = "set gro flush <cycles>",
4406 (void *)&cmd_gro_flush_set,
4407 (void *)&cmd_gro_flush_keyword,
4408 (void *)&cmd_gro_flush_flush,
4409 (void *)&cmd_gro_flush_cycles,
4414 /* *** ENABLE/DISABLE GSO *** */
4415 struct cmd_gso_enable_result {
4416 cmdline_fixed_string_t cmd_set;
4417 cmdline_fixed_string_t cmd_port;
4418 cmdline_fixed_string_t cmd_keyword;
4419 cmdline_fixed_string_t cmd_mode;
4424 cmd_gso_enable_parsed(void *parsed_result,
4425 __attribute__((unused)) struct cmdline *cl,
4426 __attribute__((unused)) void *data)
4428 struct cmd_gso_enable_result *res;
4430 res = parsed_result;
4431 if (!strcmp(res->cmd_keyword, "gso"))
4432 setup_gso(res->cmd_mode, res->cmd_pid);
4435 cmdline_parse_token_string_t cmd_gso_enable_set =
4436 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4438 cmdline_parse_token_string_t cmd_gso_enable_port =
4439 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4441 cmdline_parse_token_string_t cmd_gso_enable_keyword =
4442 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4443 cmd_keyword, "gso");
4444 cmdline_parse_token_string_t cmd_gso_enable_mode =
4445 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4446 cmd_mode, "on#off");
4447 cmdline_parse_token_num_t cmd_gso_enable_pid =
4448 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
4451 cmdline_parse_inst_t cmd_gso_enable = {
4452 .f = cmd_gso_enable_parsed,
4454 .help_str = "set port <port_id> gso on|off",
4456 (void *)&cmd_gso_enable_set,
4457 (void *)&cmd_gso_enable_port,
4458 (void *)&cmd_gso_enable_pid,
4459 (void *)&cmd_gso_enable_keyword,
4460 (void *)&cmd_gso_enable_mode,
4465 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
4466 struct cmd_gso_size_result {
4467 cmdline_fixed_string_t cmd_set;
4468 cmdline_fixed_string_t cmd_keyword;
4469 cmdline_fixed_string_t cmd_segsz;
4474 cmd_gso_size_parsed(void *parsed_result,
4475 __attribute__((unused)) struct cmdline *cl,
4476 __attribute__((unused)) void *data)
4478 struct cmd_gso_size_result *res = parsed_result;
4480 if (test_done == 0) {
4481 printf("Before setting GSO segsz, please first"
4482 " stop fowarding\n");
4486 if (!strcmp(res->cmd_keyword, "gso") &&
4487 !strcmp(res->cmd_segsz, "segsz")) {
4488 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
4489 printf("gso_size should be larger than %zu."
4490 " Please input a legal value\n",
4491 RTE_GSO_SEG_SIZE_MIN);
4493 gso_max_segment_size = res->cmd_size;
4497 cmdline_parse_token_string_t cmd_gso_size_set =
4498 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4500 cmdline_parse_token_string_t cmd_gso_size_keyword =
4501 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4502 cmd_keyword, "gso");
4503 cmdline_parse_token_string_t cmd_gso_size_segsz =
4504 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4505 cmd_segsz, "segsz");
4506 cmdline_parse_token_num_t cmd_gso_size_size =
4507 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
4510 cmdline_parse_inst_t cmd_gso_size = {
4511 .f = cmd_gso_size_parsed,
4513 .help_str = "set gso segsz <length>",
4515 (void *)&cmd_gso_size_set,
4516 (void *)&cmd_gso_size_keyword,
4517 (void *)&cmd_gso_size_segsz,
4518 (void *)&cmd_gso_size_size,
4523 /* *** SHOW GSO CONFIGURATION *** */
4524 struct cmd_gso_show_result {
4525 cmdline_fixed_string_t cmd_show;
4526 cmdline_fixed_string_t cmd_port;
4527 cmdline_fixed_string_t cmd_keyword;
4532 cmd_gso_show_parsed(void *parsed_result,
4533 __attribute__((unused)) struct cmdline *cl,
4534 __attribute__((unused)) void *data)
4536 struct cmd_gso_show_result *res = parsed_result;
4538 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
4539 printf("invalid port id %u\n", res->cmd_pid);
4542 if (!strcmp(res->cmd_keyword, "gso")) {
4543 if (gso_ports[res->cmd_pid].enable) {
4544 printf("Max GSO'd packet size: %uB\n"
4545 "Supported GSO types: TCP/IPv4, "
4546 "VxLAN with inner TCP/IPv4 packet, "
4547 "GRE with inner TCP/IPv4 packet\n",
4548 gso_max_segment_size);
4550 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
4554 cmdline_parse_token_string_t cmd_gso_show_show =
4555 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4557 cmdline_parse_token_string_t cmd_gso_show_port =
4558 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4560 cmdline_parse_token_string_t cmd_gso_show_keyword =
4561 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4562 cmd_keyword, "gso");
4563 cmdline_parse_token_num_t cmd_gso_show_pid =
4564 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
4567 cmdline_parse_inst_t cmd_gso_show = {
4568 .f = cmd_gso_show_parsed,
4570 .help_str = "show port <port_id> gso",
4572 (void *)&cmd_gso_show_show,
4573 (void *)&cmd_gso_show_port,
4574 (void *)&cmd_gso_show_pid,
4575 (void *)&cmd_gso_show_keyword,
4580 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
4581 struct cmd_set_flush_rx {
4582 cmdline_fixed_string_t set;
4583 cmdline_fixed_string_t flush_rx;
4584 cmdline_fixed_string_t mode;
4588 cmd_set_flush_rx_parsed(void *parsed_result,
4589 __attribute__((unused)) struct cmdline *cl,
4590 __attribute__((unused)) void *data)
4592 struct cmd_set_flush_rx *res = parsed_result;
4593 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4596 cmdline_parse_token_string_t cmd_setflushrx_set =
4597 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4599 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
4600 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4601 flush_rx, "flush_rx");
4602 cmdline_parse_token_string_t cmd_setflushrx_mode =
4603 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4607 cmdline_parse_inst_t cmd_set_flush_rx = {
4608 .f = cmd_set_flush_rx_parsed,
4609 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
4612 (void *)&cmd_setflushrx_set,
4613 (void *)&cmd_setflushrx_flush_rx,
4614 (void *)&cmd_setflushrx_mode,
4619 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
4620 struct cmd_set_link_check {
4621 cmdline_fixed_string_t set;
4622 cmdline_fixed_string_t link_check;
4623 cmdline_fixed_string_t mode;
4627 cmd_set_link_check_parsed(void *parsed_result,
4628 __attribute__((unused)) struct cmdline *cl,
4629 __attribute__((unused)) void *data)
4631 struct cmd_set_link_check *res = parsed_result;
4632 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4635 cmdline_parse_token_string_t cmd_setlinkcheck_set =
4636 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4638 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
4639 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4640 link_check, "link_check");
4641 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
4642 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4646 cmdline_parse_inst_t cmd_set_link_check = {
4647 .f = cmd_set_link_check_parsed,
4648 .help_str = "set link_check on|off: Enable/Disable link status check "
4649 "when starting/stopping a port",
4652 (void *)&cmd_setlinkcheck_set,
4653 (void *)&cmd_setlinkcheck_link_check,
4654 (void *)&cmd_setlinkcheck_mode,
4659 /* *** SET NIC BYPASS MODE *** */
4660 struct cmd_set_bypass_mode_result {
4661 cmdline_fixed_string_t set;
4662 cmdline_fixed_string_t bypass;
4663 cmdline_fixed_string_t mode;
4664 cmdline_fixed_string_t value;
4669 cmd_set_bypass_mode_parsed(void *parsed_result,
4670 __attribute__((unused)) struct cmdline *cl,
4671 __attribute__((unused)) void *data)
4673 struct cmd_set_bypass_mode_result *res = parsed_result;
4674 portid_t port_id = res->port_id;
4675 int32_t rc = -EINVAL;
4677 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4678 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4680 if (!strcmp(res->value, "bypass"))
4681 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4682 else if (!strcmp(res->value, "isolate"))
4683 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4685 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4687 /* Set the bypass mode for the relevant port. */
4688 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
4691 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
4694 cmdline_parse_token_string_t cmd_setbypass_mode_set =
4695 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4697 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
4698 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4700 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
4701 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4703 cmdline_parse_token_string_t cmd_setbypass_mode_value =
4704 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4705 value, "normal#bypass#isolate");
4706 cmdline_parse_token_num_t cmd_setbypass_mode_port =
4707 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
4710 cmdline_parse_inst_t cmd_set_bypass_mode = {
4711 .f = cmd_set_bypass_mode_parsed,
4712 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
4713 "Set the NIC bypass mode for port_id",
4716 (void *)&cmd_setbypass_mode_set,
4717 (void *)&cmd_setbypass_mode_bypass,
4718 (void *)&cmd_setbypass_mode_mode,
4719 (void *)&cmd_setbypass_mode_value,
4720 (void *)&cmd_setbypass_mode_port,
4725 /* *** SET NIC BYPASS EVENT *** */
4726 struct cmd_set_bypass_event_result {
4727 cmdline_fixed_string_t set;
4728 cmdline_fixed_string_t bypass;
4729 cmdline_fixed_string_t event;
4730 cmdline_fixed_string_t event_value;
4731 cmdline_fixed_string_t mode;
4732 cmdline_fixed_string_t mode_value;
4737 cmd_set_bypass_event_parsed(void *parsed_result,
4738 __attribute__((unused)) struct cmdline *cl,
4739 __attribute__((unused)) void *data)
4741 int32_t rc = -EINVAL;
4742 struct cmd_set_bypass_event_result *res = parsed_result;
4743 portid_t port_id = res->port_id;
4745 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4746 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4747 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4749 if (!strcmp(res->event_value, "timeout"))
4750 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
4751 else if (!strcmp(res->event_value, "os_on"))
4752 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
4753 else if (!strcmp(res->event_value, "os_off"))
4754 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
4755 else if (!strcmp(res->event_value, "power_on"))
4756 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
4757 else if (!strcmp(res->event_value, "power_off"))
4758 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
4760 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4762 if (!strcmp(res->mode_value, "bypass"))
4763 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4764 else if (!strcmp(res->mode_value, "isolate"))
4765 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4767 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4769 /* Set the watchdog timeout. */
4770 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
4773 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
4774 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
4778 printf("Failed to set timeout value %u "
4779 "for port %d, errto code: %d.\n",
4780 bypass_timeout, port_id, rc);
4784 /* Set the bypass event to transition to bypass mode. */
4785 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
4790 printf("\t Failed to set bypass event for port = %d.\n",
4794 cmdline_parse_token_string_t cmd_setbypass_event_set =
4795 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4797 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
4798 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4800 cmdline_parse_token_string_t cmd_setbypass_event_event =
4801 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4803 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
4804 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4805 event_value, "none#timeout#os_off#os_on#power_on#power_off");
4806 cmdline_parse_token_string_t cmd_setbypass_event_mode =
4807 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4809 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
4810 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4811 mode_value, "normal#bypass#isolate");
4812 cmdline_parse_token_num_t cmd_setbypass_event_port =
4813 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
4816 cmdline_parse_inst_t cmd_set_bypass_event = {
4817 .f = cmd_set_bypass_event_parsed,
4818 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
4819 "power_off mode normal|bypass|isolate <port_id>: "
4820 "Set the NIC bypass event mode for port_id",
4823 (void *)&cmd_setbypass_event_set,
4824 (void *)&cmd_setbypass_event_bypass,
4825 (void *)&cmd_setbypass_event_event,
4826 (void *)&cmd_setbypass_event_event_value,
4827 (void *)&cmd_setbypass_event_mode,
4828 (void *)&cmd_setbypass_event_mode_value,
4829 (void *)&cmd_setbypass_event_port,
4835 /* *** SET NIC BYPASS TIMEOUT *** */
4836 struct cmd_set_bypass_timeout_result {
4837 cmdline_fixed_string_t set;
4838 cmdline_fixed_string_t bypass;
4839 cmdline_fixed_string_t timeout;
4840 cmdline_fixed_string_t value;
4844 cmd_set_bypass_timeout_parsed(void *parsed_result,
4845 __attribute__((unused)) struct cmdline *cl,
4846 __attribute__((unused)) void *data)
4848 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
4850 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4851 if (!strcmp(res->value, "1.5"))
4852 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
4853 else if (!strcmp(res->value, "2"))
4854 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
4855 else if (!strcmp(res->value, "3"))
4856 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
4857 else if (!strcmp(res->value, "4"))
4858 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
4859 else if (!strcmp(res->value, "8"))
4860 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
4861 else if (!strcmp(res->value, "16"))
4862 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
4863 else if (!strcmp(res->value, "32"))
4864 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
4866 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4870 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
4871 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4873 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
4874 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4876 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
4877 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4878 timeout, "timeout");
4879 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
4880 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4881 value, "0#1.5#2#3#4#8#16#32");
4883 cmdline_parse_inst_t cmd_set_bypass_timeout = {
4884 .f = cmd_set_bypass_timeout_parsed,
4885 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
4886 "Set the NIC bypass watchdog timeout in seconds",
4889 (void *)&cmd_setbypass_timeout_set,
4890 (void *)&cmd_setbypass_timeout_bypass,
4891 (void *)&cmd_setbypass_timeout_timeout,
4892 (void *)&cmd_setbypass_timeout_value,
4897 /* *** SHOW NIC BYPASS MODE *** */
4898 struct cmd_show_bypass_config_result {
4899 cmdline_fixed_string_t show;
4900 cmdline_fixed_string_t bypass;
4901 cmdline_fixed_string_t config;
4906 cmd_show_bypass_config_parsed(void *parsed_result,
4907 __attribute__((unused)) struct cmdline *cl,
4908 __attribute__((unused)) void *data)
4910 struct cmd_show_bypass_config_result *res = parsed_result;
4911 portid_t port_id = res->port_id;
4913 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4914 uint32_t event_mode;
4915 uint32_t bypass_mode;
4916 uint32_t timeout = bypass_timeout;
4919 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
4920 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
4921 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
4922 {"UNKNOWN", "normal", "bypass", "isolate"};
4923 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
4930 int num_events = (sizeof events) / (sizeof events[0]);
4932 /* Display the bypass mode.*/
4933 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
4934 printf("\tFailed to get bypass mode for port = %d\n", port_id);
4938 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
4939 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4941 printf("\tbypass mode = %s\n", modes[bypass_mode]);
4944 /* Display the bypass timeout.*/
4945 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
4946 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4948 printf("\tbypass timeout = %s\n", timeouts[timeout]);
4950 /* Display the bypass events and associated modes. */
4951 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
4953 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
4954 printf("\tFailed to get bypass mode for event = %s\n",
4957 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
4958 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4960 printf("\tbypass event: %-16s = %s\n", events[i],
4966 printf("\tFailed to get bypass configuration for port = %d\n",
4970 cmdline_parse_token_string_t cmd_showbypass_config_show =
4971 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4973 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
4974 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4976 cmdline_parse_token_string_t cmd_showbypass_config_config =
4977 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4979 cmdline_parse_token_num_t cmd_showbypass_config_port =
4980 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
4983 cmdline_parse_inst_t cmd_show_bypass_config = {
4984 .f = cmd_show_bypass_config_parsed,
4985 .help_str = "show bypass config <port_id>: "
4986 "Show the NIC bypass config for port_id",
4989 (void *)&cmd_showbypass_config_show,
4990 (void *)&cmd_showbypass_config_bypass,
4991 (void *)&cmd_showbypass_config_config,
4992 (void *)&cmd_showbypass_config_port,
4997 #ifdef RTE_LIBRTE_PMD_BOND
4998 /* *** SET BONDING MODE *** */
4999 struct cmd_set_bonding_mode_result {
5000 cmdline_fixed_string_t set;
5001 cmdline_fixed_string_t bonding;
5002 cmdline_fixed_string_t mode;
5007 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5008 __attribute__((unused)) struct cmdline *cl,
5009 __attribute__((unused)) void *data)
5011 struct cmd_set_bonding_mode_result *res = parsed_result;
5012 portid_t port_id = res->port_id;
5014 /* Set the bonding mode for the relevant port. */
5015 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5016 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5019 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5020 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5022 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5023 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5024 bonding, "bonding");
5025 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5026 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5028 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5029 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5031 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5032 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5035 cmdline_parse_inst_t cmd_set_bonding_mode = {
5036 .f = cmd_set_bonding_mode_parsed,
5037 .help_str = "set bonding mode <mode_value> <port_id>: "
5038 "Set the bonding mode for port_id",
5041 (void *) &cmd_setbonding_mode_set,
5042 (void *) &cmd_setbonding_mode_bonding,
5043 (void *) &cmd_setbonding_mode_mode,
5044 (void *) &cmd_setbonding_mode_value,
5045 (void *) &cmd_setbonding_mode_port,
5050 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5051 struct cmd_set_bonding_lacp_dedicated_queues_result {
5052 cmdline_fixed_string_t set;
5053 cmdline_fixed_string_t bonding;
5054 cmdline_fixed_string_t lacp;
5055 cmdline_fixed_string_t dedicated_queues;
5057 cmdline_fixed_string_t mode;
5060 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5061 __attribute__((unused)) struct cmdline *cl,
5062 __attribute__((unused)) void *data)
5064 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5065 portid_t port_id = res->port_id;
5066 struct rte_port *port;
5068 port = &ports[port_id];
5070 /** Check if the port is not started **/
5071 if (port->port_status != RTE_PORT_STOPPED) {
5072 printf("Please stop port %d first\n", port_id);
5076 if (!strcmp(res->mode, "enable")) {
5077 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5078 printf("Dedicate queues for LACP control packets"
5081 printf("Enabling dedicate queues for LACP control "
5082 "packets on port %d failed\n", port_id);
5083 } else if (!strcmp(res->mode, "disable")) {
5084 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5085 printf("Dedicated queues for LACP control packets "
5088 printf("Disabling dedicated queues for LACP control "
5089 "traffic on port %d failed\n", port_id);
5093 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5094 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5096 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5097 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5098 bonding, "bonding");
5099 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5100 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5102 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5103 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5104 dedicated_queues, "dedicated_queues");
5105 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5106 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5108 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5109 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5110 mode, "enable#disable");
5112 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5113 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5114 .help_str = "set bonding lacp dedicated_queues <port_id> "
5116 "Enable/disable dedicated queues for LACP control traffic for port_id",
5119 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5120 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5121 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5122 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5123 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5124 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5129 /* *** SET BALANCE XMIT POLICY *** */
5130 struct cmd_set_bonding_balance_xmit_policy_result {
5131 cmdline_fixed_string_t set;
5132 cmdline_fixed_string_t bonding;
5133 cmdline_fixed_string_t balance_xmit_policy;
5135 cmdline_fixed_string_t policy;
5138 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5139 __attribute__((unused)) struct cmdline *cl,
5140 __attribute__((unused)) void *data)
5142 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5143 portid_t port_id = res->port_id;
5146 if (!strcmp(res->policy, "l2")) {
5147 policy = BALANCE_XMIT_POLICY_LAYER2;
5148 } else if (!strcmp(res->policy, "l23")) {
5149 policy = BALANCE_XMIT_POLICY_LAYER23;
5150 } else if (!strcmp(res->policy, "l34")) {
5151 policy = BALANCE_XMIT_POLICY_LAYER34;
5153 printf("\t Invalid xmit policy selection");
5157 /* Set the bonding mode for the relevant port. */
5158 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5159 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5164 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5165 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5167 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5168 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5169 bonding, "bonding");
5170 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5171 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5172 balance_xmit_policy, "balance_xmit_policy");
5173 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5174 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5176 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5177 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5178 policy, "l2#l23#l34");
5180 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5181 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5182 .help_str = "set bonding balance_xmit_policy <port_id> "
5184 "Set the bonding balance_xmit_policy for port_id",
5187 (void *)&cmd_setbonding_balance_xmit_policy_set,
5188 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5189 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5190 (void *)&cmd_setbonding_balance_xmit_policy_port,
5191 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5196 /* *** SHOW NIC BONDING CONFIGURATION *** */
5197 struct cmd_show_bonding_config_result {
5198 cmdline_fixed_string_t show;
5199 cmdline_fixed_string_t bonding;
5200 cmdline_fixed_string_t config;
5204 static void cmd_show_bonding_config_parsed(void *parsed_result,
5205 __attribute__((unused)) struct cmdline *cl,
5206 __attribute__((unused)) void *data)
5208 struct cmd_show_bonding_config_result *res = parsed_result;
5209 int bonding_mode, agg_mode;
5210 portid_t slaves[RTE_MAX_ETHPORTS];
5211 int num_slaves, num_active_slaves;
5214 portid_t port_id = res->port_id;
5216 /* Display the bonding mode.*/
5217 bonding_mode = rte_eth_bond_mode_get(port_id);
5218 if (bonding_mode < 0) {
5219 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5222 printf("\tBonding mode: %d\n", bonding_mode);
5224 if (bonding_mode == BONDING_MODE_BALANCE) {
5225 int balance_xmit_policy;
5227 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5228 if (balance_xmit_policy < 0) {
5229 printf("\tFailed to get balance xmit policy for port = %d\n",
5233 printf("\tBalance Xmit Policy: ");
5235 switch (balance_xmit_policy) {
5236 case BALANCE_XMIT_POLICY_LAYER2:
5237 printf("BALANCE_XMIT_POLICY_LAYER2");
5239 case BALANCE_XMIT_POLICY_LAYER23:
5240 printf("BALANCE_XMIT_POLICY_LAYER23");
5242 case BALANCE_XMIT_POLICY_LAYER34:
5243 printf("BALANCE_XMIT_POLICY_LAYER34");
5250 if (bonding_mode == BONDING_MODE_8023AD) {
5251 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5252 printf("\tIEEE802.3AD Aggregator Mode: ");
5255 printf("bandwidth");
5267 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5269 if (num_slaves < 0) {
5270 printf("\tFailed to get slave list for port = %d\n", port_id);
5273 if (num_slaves > 0) {
5274 printf("\tSlaves (%d): [", num_slaves);
5275 for (i = 0; i < num_slaves - 1; i++)
5276 printf("%d ", slaves[i]);
5278 printf("%d]\n", slaves[num_slaves - 1]);
5280 printf("\tSlaves: []\n");
5284 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5287 if (num_active_slaves < 0) {
5288 printf("\tFailed to get active slave list for port = %d\n", port_id);
5291 if (num_active_slaves > 0) {
5292 printf("\tActive Slaves (%d): [", num_active_slaves);
5293 for (i = 0; i < num_active_slaves - 1; i++)
5294 printf("%d ", slaves[i]);
5296 printf("%d]\n", slaves[num_active_slaves - 1]);
5299 printf("\tActive Slaves: []\n");
5303 primary_id = rte_eth_bond_primary_get(port_id);
5304 if (primary_id < 0) {
5305 printf("\tFailed to get primary slave for port = %d\n", port_id);
5308 printf("\tPrimary: [%d]\n", primary_id);
5312 cmdline_parse_token_string_t cmd_showbonding_config_show =
5313 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5315 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5316 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5317 bonding, "bonding");
5318 cmdline_parse_token_string_t cmd_showbonding_config_config =
5319 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5321 cmdline_parse_token_num_t cmd_showbonding_config_port =
5322 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
5325 cmdline_parse_inst_t cmd_show_bonding_config = {
5326 .f = cmd_show_bonding_config_parsed,
5327 .help_str = "show bonding config <port_id>: "
5328 "Show the bonding config for port_id",
5331 (void *)&cmd_showbonding_config_show,
5332 (void *)&cmd_showbonding_config_bonding,
5333 (void *)&cmd_showbonding_config_config,
5334 (void *)&cmd_showbonding_config_port,
5339 /* *** SET BONDING PRIMARY *** */
5340 struct cmd_set_bonding_primary_result {
5341 cmdline_fixed_string_t set;
5342 cmdline_fixed_string_t bonding;
5343 cmdline_fixed_string_t primary;
5348 static void cmd_set_bonding_primary_parsed(void *parsed_result,
5349 __attribute__((unused)) struct cmdline *cl,
5350 __attribute__((unused)) void *data)
5352 struct cmd_set_bonding_primary_result *res = parsed_result;
5353 portid_t master_port_id = res->port_id;
5354 portid_t slave_port_id = res->slave_id;
5356 /* Set the primary slave for a bonded device. */
5357 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
5358 printf("\t Failed to set primary slave for port = %d.\n",
5365 cmdline_parse_token_string_t cmd_setbonding_primary_set =
5366 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5368 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
5369 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5370 bonding, "bonding");
5371 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
5372 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5373 primary, "primary");
5374 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
5375 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5377 cmdline_parse_token_num_t cmd_setbonding_primary_port =
5378 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5381 cmdline_parse_inst_t cmd_set_bonding_primary = {
5382 .f = cmd_set_bonding_primary_parsed,
5383 .help_str = "set bonding primary <slave_id> <port_id>: "
5384 "Set the primary slave for port_id",
5387 (void *)&cmd_setbonding_primary_set,
5388 (void *)&cmd_setbonding_primary_bonding,
5389 (void *)&cmd_setbonding_primary_primary,
5390 (void *)&cmd_setbonding_primary_slave,
5391 (void *)&cmd_setbonding_primary_port,
5396 /* *** ADD SLAVE *** */
5397 struct cmd_add_bonding_slave_result {
5398 cmdline_fixed_string_t add;
5399 cmdline_fixed_string_t bonding;
5400 cmdline_fixed_string_t slave;
5405 static void cmd_add_bonding_slave_parsed(void *parsed_result,
5406 __attribute__((unused)) struct cmdline *cl,
5407 __attribute__((unused)) void *data)
5409 struct cmd_add_bonding_slave_result *res = parsed_result;
5410 portid_t master_port_id = res->port_id;
5411 portid_t slave_port_id = res->slave_id;
5413 /* add the slave for a bonded device. */
5414 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
5415 printf("\t Failed to add slave %d to master port = %d.\n",
5416 slave_port_id, master_port_id);
5420 set_port_slave_flag(slave_port_id);
5423 cmdline_parse_token_string_t cmd_addbonding_slave_add =
5424 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5426 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
5427 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5428 bonding, "bonding");
5429 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
5430 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5432 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
5433 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5435 cmdline_parse_token_num_t cmd_addbonding_slave_port =
5436 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5439 cmdline_parse_inst_t cmd_add_bonding_slave = {
5440 .f = cmd_add_bonding_slave_parsed,
5441 .help_str = "add bonding slave <slave_id> <port_id>: "
5442 "Add a slave device to a bonded device",
5445 (void *)&cmd_addbonding_slave_add,
5446 (void *)&cmd_addbonding_slave_bonding,
5447 (void *)&cmd_addbonding_slave_slave,
5448 (void *)&cmd_addbonding_slave_slaveid,
5449 (void *)&cmd_addbonding_slave_port,
5454 /* *** REMOVE SLAVE *** */
5455 struct cmd_remove_bonding_slave_result {
5456 cmdline_fixed_string_t remove;
5457 cmdline_fixed_string_t bonding;
5458 cmdline_fixed_string_t slave;
5463 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
5464 __attribute__((unused)) struct cmdline *cl,
5465 __attribute__((unused)) void *data)
5467 struct cmd_remove_bonding_slave_result *res = parsed_result;
5468 portid_t master_port_id = res->port_id;
5469 portid_t slave_port_id = res->slave_id;
5471 /* remove the slave from a bonded device. */
5472 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
5473 printf("\t Failed to remove slave %d from master port = %d.\n",
5474 slave_port_id, master_port_id);
5478 clear_port_slave_flag(slave_port_id);
5481 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
5482 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5484 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
5485 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5486 bonding, "bonding");
5487 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
5488 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5490 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
5491 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5493 cmdline_parse_token_num_t cmd_removebonding_slave_port =
5494 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5497 cmdline_parse_inst_t cmd_remove_bonding_slave = {
5498 .f = cmd_remove_bonding_slave_parsed,
5499 .help_str = "remove bonding slave <slave_id> <port_id>: "
5500 "Remove a slave device from a bonded device",
5503 (void *)&cmd_removebonding_slave_remove,
5504 (void *)&cmd_removebonding_slave_bonding,
5505 (void *)&cmd_removebonding_slave_slave,
5506 (void *)&cmd_removebonding_slave_slaveid,
5507 (void *)&cmd_removebonding_slave_port,
5512 /* *** CREATE BONDED DEVICE *** */
5513 struct cmd_create_bonded_device_result {
5514 cmdline_fixed_string_t create;
5515 cmdline_fixed_string_t bonded;
5516 cmdline_fixed_string_t device;
5521 static int bond_dev_num = 0;
5523 static void cmd_create_bonded_device_parsed(void *parsed_result,
5524 __attribute__((unused)) struct cmdline *cl,
5525 __attribute__((unused)) void *data)
5527 struct cmd_create_bonded_device_result *res = parsed_result;
5528 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
5531 if (test_done == 0) {
5532 printf("Please stop forwarding first\n");
5536 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
5539 /* Create a new bonded device. */
5540 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
5542 printf("\t Failed to create bonded device.\n");
5545 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
5548 /* Update number of ports */
5549 nb_ports = rte_eth_dev_count();
5550 reconfig(port_id, res->socket);
5551 rte_eth_promiscuous_enable(port_id);
5556 cmdline_parse_token_string_t cmd_createbonded_device_create =
5557 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5559 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
5560 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5562 cmdline_parse_token_string_t cmd_createbonded_device_device =
5563 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5565 cmdline_parse_token_num_t cmd_createbonded_device_mode =
5566 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5568 cmdline_parse_token_num_t cmd_createbonded_device_socket =
5569 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5572 cmdline_parse_inst_t cmd_create_bonded_device = {
5573 .f = cmd_create_bonded_device_parsed,
5574 .help_str = "create bonded device <mode> <socket>: "
5575 "Create a new bonded device with specific bonding mode and socket",
5578 (void *)&cmd_createbonded_device_create,
5579 (void *)&cmd_createbonded_device_bonded,
5580 (void *)&cmd_createbonded_device_device,
5581 (void *)&cmd_createbonded_device_mode,
5582 (void *)&cmd_createbonded_device_socket,
5587 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
5588 struct cmd_set_bond_mac_addr_result {
5589 cmdline_fixed_string_t set;
5590 cmdline_fixed_string_t bonding;
5591 cmdline_fixed_string_t mac_addr;
5593 struct ether_addr address;
5596 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
5597 __attribute__((unused)) struct cmdline *cl,
5598 __attribute__((unused)) void *data)
5600 struct cmd_set_bond_mac_addr_result *res = parsed_result;
5603 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
5606 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
5608 /* check the return value and print it if is < 0 */
5610 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5613 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
5614 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
5615 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
5616 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
5618 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
5619 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
5621 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
5622 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
5624 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
5625 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
5627 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
5628 .f = cmd_set_bond_mac_addr_parsed,
5630 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
5632 (void *)&cmd_set_bond_mac_addr_set,
5633 (void *)&cmd_set_bond_mac_addr_bonding,
5634 (void *)&cmd_set_bond_mac_addr_mac,
5635 (void *)&cmd_set_bond_mac_addr_portnum,
5636 (void *)&cmd_set_bond_mac_addr_addr,
5642 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
5643 struct cmd_set_bond_mon_period_result {
5644 cmdline_fixed_string_t set;
5645 cmdline_fixed_string_t bonding;
5646 cmdline_fixed_string_t mon_period;
5651 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
5652 __attribute__((unused)) struct cmdline *cl,
5653 __attribute__((unused)) void *data)
5655 struct cmd_set_bond_mon_period_result *res = parsed_result;
5658 if (res->port_num >= nb_ports) {
5659 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
5663 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
5665 /* check the return value and print it if is < 0 */
5667 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5670 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
5671 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5673 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
5674 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5675 bonding, "bonding");
5676 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
5677 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5678 mon_period, "mon_period");
5679 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
5680 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5682 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
5683 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5686 cmdline_parse_inst_t cmd_set_bond_mon_period = {
5687 .f = cmd_set_bond_mon_period_parsed,
5689 .help_str = "set bonding mon_period <port_id> <period_ms>",
5691 (void *)&cmd_set_bond_mon_period_set,
5692 (void *)&cmd_set_bond_mon_period_bonding,
5693 (void *)&cmd_set_bond_mon_period_mon_period,
5694 (void *)&cmd_set_bond_mon_period_portnum,
5695 (void *)&cmd_set_bond_mon_period_period_ms,
5702 struct cmd_set_bonding_agg_mode_policy_result {
5703 cmdline_fixed_string_t set;
5704 cmdline_fixed_string_t bonding;
5705 cmdline_fixed_string_t agg_mode;
5707 cmdline_fixed_string_t policy;
5712 cmd_set_bonding_agg_mode(void *parsed_result,
5713 __attribute__((unused)) struct cmdline *cl,
5714 __attribute__((unused)) void *data)
5716 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
5717 uint8_t policy = AGG_BANDWIDTH;
5719 if (res->port_num >= nb_ports) {
5720 printf("Port id %d must be less than %d\n",
5721 res->port_num, nb_ports);
5725 if (!strcmp(res->policy, "bandwidth"))
5726 policy = AGG_BANDWIDTH;
5727 else if (!strcmp(res->policy, "stable"))
5728 policy = AGG_STABLE;
5729 else if (!strcmp(res->policy, "count"))
5732 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
5736 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
5737 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5739 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
5740 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5741 bonding, "bonding");
5743 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
5744 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5745 agg_mode, "agg_mode");
5747 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
5748 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5751 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
5752 TOKEN_STRING_INITIALIZER(
5753 struct cmd_set_bonding_balance_xmit_policy_result,
5754 policy, "stable#bandwidth#count");
5756 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
5757 .f = cmd_set_bonding_agg_mode,
5759 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
5761 (void *)&cmd_set_bonding_agg_mode_set,
5762 (void *)&cmd_set_bonding_agg_mode_bonding,
5763 (void *)&cmd_set_bonding_agg_mode_agg_mode,
5764 (void *)&cmd_set_bonding_agg_mode_portnum,
5765 (void *)&cmd_set_bonding_agg_mode_policy_string,
5771 #endif /* RTE_LIBRTE_PMD_BOND */
5773 /* *** SET FORWARDING MODE *** */
5774 struct cmd_set_fwd_mode_result {
5775 cmdline_fixed_string_t set;
5776 cmdline_fixed_string_t fwd;
5777 cmdline_fixed_string_t mode;
5780 static void cmd_set_fwd_mode_parsed(void *parsed_result,
5781 __attribute__((unused)) struct cmdline *cl,
5782 __attribute__((unused)) void *data)
5784 struct cmd_set_fwd_mode_result *res = parsed_result;
5787 set_pkt_forwarding_mode(res->mode);
5790 cmdline_parse_token_string_t cmd_setfwd_set =
5791 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
5792 cmdline_parse_token_string_t cmd_setfwd_fwd =
5793 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
5794 cmdline_parse_token_string_t cmd_setfwd_mode =
5795 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
5796 "" /* defined at init */);
5798 cmdline_parse_inst_t cmd_set_fwd_mode = {
5799 .f = cmd_set_fwd_mode_parsed,
5801 .help_str = NULL, /* defined at init */
5803 (void *)&cmd_setfwd_set,
5804 (void *)&cmd_setfwd_fwd,
5805 (void *)&cmd_setfwd_mode,
5810 static void cmd_set_fwd_mode_init(void)
5813 static char token[128];
5814 static char help[256];
5815 cmdline_parse_token_string_t *token_struct;
5817 modes = list_pkt_forwarding_modes();
5818 snprintf(help, sizeof(help), "set fwd %s: "
5819 "Set packet forwarding mode", modes);
5820 cmd_set_fwd_mode.help_str = help;
5822 /* string token separator is # */
5823 for (c = token; *modes != '\0'; modes++)
5828 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
5829 token_struct->string_data.str = token;
5832 /* *** SET RETRY FORWARDING MODE *** */
5833 struct cmd_set_fwd_retry_mode_result {
5834 cmdline_fixed_string_t set;
5835 cmdline_fixed_string_t fwd;
5836 cmdline_fixed_string_t mode;
5837 cmdline_fixed_string_t retry;
5840 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
5841 __attribute__((unused)) struct cmdline *cl,
5842 __attribute__((unused)) void *data)
5844 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
5847 set_pkt_forwarding_mode(res->mode);
5850 cmdline_parse_token_string_t cmd_setfwd_retry_set =
5851 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5853 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
5854 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5856 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
5857 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5859 "" /* defined at init */);
5860 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
5861 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5864 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
5865 .f = cmd_set_fwd_retry_mode_parsed,
5867 .help_str = NULL, /* defined at init */
5869 (void *)&cmd_setfwd_retry_set,
5870 (void *)&cmd_setfwd_retry_fwd,
5871 (void *)&cmd_setfwd_retry_mode,
5872 (void *)&cmd_setfwd_retry_retry,
5877 static void cmd_set_fwd_retry_mode_init(void)
5880 static char token[128];
5881 static char help[256];
5882 cmdline_parse_token_string_t *token_struct;
5884 modes = list_pkt_forwarding_retry_modes();
5885 snprintf(help, sizeof(help), "set fwd %s retry: "
5886 "Set packet forwarding mode with retry", modes);
5887 cmd_set_fwd_retry_mode.help_str = help;
5889 /* string token separator is # */
5890 for (c = token; *modes != '\0'; modes++)
5895 token_struct = (cmdline_parse_token_string_t *)
5896 cmd_set_fwd_retry_mode.tokens[2];
5897 token_struct->string_data.str = token;
5900 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
5901 struct cmd_set_burst_tx_retry_result {
5902 cmdline_fixed_string_t set;
5903 cmdline_fixed_string_t burst;
5904 cmdline_fixed_string_t tx;
5905 cmdline_fixed_string_t delay;
5907 cmdline_fixed_string_t retry;
5911 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
5912 __attribute__((unused)) struct cmdline *cl,
5913 __attribute__((unused)) void *data)
5915 struct cmd_set_burst_tx_retry_result *res = parsed_result;
5917 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
5918 && !strcmp(res->tx, "tx")) {
5919 if (!strcmp(res->delay, "delay"))
5920 burst_tx_delay_time = res->time;
5921 if (!strcmp(res->retry, "retry"))
5922 burst_tx_retry_num = res->retry_num;
5927 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
5928 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
5929 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
5930 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
5932 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
5933 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
5934 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
5935 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
5936 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
5937 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
5938 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
5939 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
5940 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
5941 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
5943 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
5944 .f = cmd_set_burst_tx_retry_parsed,
5945 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
5947 (void *)&cmd_set_burst_tx_retry_set,
5948 (void *)&cmd_set_burst_tx_retry_burst,
5949 (void *)&cmd_set_burst_tx_retry_tx,
5950 (void *)&cmd_set_burst_tx_retry_delay,
5951 (void *)&cmd_set_burst_tx_retry_time,
5952 (void *)&cmd_set_burst_tx_retry_retry,
5953 (void *)&cmd_set_burst_tx_retry_retry_num,
5958 /* *** SET PROMISC MODE *** */
5959 struct cmd_set_promisc_mode_result {
5960 cmdline_fixed_string_t set;
5961 cmdline_fixed_string_t promisc;
5962 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5963 uint16_t port_num; /* valid if "allports" argument == 0 */
5964 cmdline_fixed_string_t mode;
5967 static void cmd_set_promisc_mode_parsed(void *parsed_result,
5968 __attribute__((unused)) struct cmdline *cl,
5971 struct cmd_set_promisc_mode_result *res = parsed_result;
5975 if (!strcmp(res->mode, "on"))
5982 RTE_ETH_FOREACH_DEV(i) {
5984 rte_eth_promiscuous_enable(i);
5986 rte_eth_promiscuous_disable(i);
5991 rte_eth_promiscuous_enable(res->port_num);
5993 rte_eth_promiscuous_disable(res->port_num);
5997 cmdline_parse_token_string_t cmd_setpromisc_set =
5998 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
5999 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6000 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6002 cmdline_parse_token_string_t cmd_setpromisc_portall =
6003 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6005 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6006 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6008 cmdline_parse_token_string_t cmd_setpromisc_mode =
6009 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6012 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6013 .f = cmd_set_promisc_mode_parsed,
6015 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6017 (void *)&cmd_setpromisc_set,
6018 (void *)&cmd_setpromisc_promisc,
6019 (void *)&cmd_setpromisc_portall,
6020 (void *)&cmd_setpromisc_mode,
6025 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6026 .f = cmd_set_promisc_mode_parsed,
6028 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6030 (void *)&cmd_setpromisc_set,
6031 (void *)&cmd_setpromisc_promisc,
6032 (void *)&cmd_setpromisc_portnum,
6033 (void *)&cmd_setpromisc_mode,
6038 /* *** SET ALLMULTI MODE *** */
6039 struct cmd_set_allmulti_mode_result {
6040 cmdline_fixed_string_t set;
6041 cmdline_fixed_string_t allmulti;
6042 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6043 uint16_t port_num; /* valid if "allports" argument == 0 */
6044 cmdline_fixed_string_t mode;
6047 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6048 __attribute__((unused)) struct cmdline *cl,
6051 struct cmd_set_allmulti_mode_result *res = parsed_result;
6055 if (!strcmp(res->mode, "on"))
6062 RTE_ETH_FOREACH_DEV(i) {
6064 rte_eth_allmulticast_enable(i);
6066 rte_eth_allmulticast_disable(i);
6071 rte_eth_allmulticast_enable(res->port_num);
6073 rte_eth_allmulticast_disable(res->port_num);
6077 cmdline_parse_token_string_t cmd_setallmulti_set =
6078 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6079 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6080 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6082 cmdline_parse_token_string_t cmd_setallmulti_portall =
6083 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6085 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6086 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6088 cmdline_parse_token_string_t cmd_setallmulti_mode =
6089 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6092 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6093 .f = cmd_set_allmulti_mode_parsed,
6095 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6097 (void *)&cmd_setallmulti_set,
6098 (void *)&cmd_setallmulti_allmulti,
6099 (void *)&cmd_setallmulti_portall,
6100 (void *)&cmd_setallmulti_mode,
6105 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6106 .f = cmd_set_allmulti_mode_parsed,
6108 .help_str = "set allmulti <port_id> on|off: "
6109 "Set allmulti mode on port_id",
6111 (void *)&cmd_setallmulti_set,
6112 (void *)&cmd_setallmulti_allmulti,
6113 (void *)&cmd_setallmulti_portnum,
6114 (void *)&cmd_setallmulti_mode,
6119 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6120 struct cmd_link_flow_ctrl_set_result {
6121 cmdline_fixed_string_t set;
6122 cmdline_fixed_string_t flow_ctrl;
6123 cmdline_fixed_string_t rx;
6124 cmdline_fixed_string_t rx_lfc_mode;
6125 cmdline_fixed_string_t tx;
6126 cmdline_fixed_string_t tx_lfc_mode;
6127 cmdline_fixed_string_t mac_ctrl_frame_fwd;
6128 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6129 cmdline_fixed_string_t autoneg_str;
6130 cmdline_fixed_string_t autoneg;
6131 cmdline_fixed_string_t hw_str;
6132 uint32_t high_water;
6133 cmdline_fixed_string_t lw_str;
6135 cmdline_fixed_string_t pt_str;
6136 uint16_t pause_time;
6137 cmdline_fixed_string_t xon_str;
6142 cmdline_parse_token_string_t cmd_lfc_set_set =
6143 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6145 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6146 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6147 flow_ctrl, "flow_ctrl");
6148 cmdline_parse_token_string_t cmd_lfc_set_rx =
6149 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6151 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6152 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6153 rx_lfc_mode, "on#off");
6154 cmdline_parse_token_string_t cmd_lfc_set_tx =
6155 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6157 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6158 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6159 tx_lfc_mode, "on#off");
6160 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6161 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6162 hw_str, "high_water");
6163 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6164 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6165 high_water, UINT32);
6166 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6167 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6168 lw_str, "low_water");
6169 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6170 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6172 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6173 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6174 pt_str, "pause_time");
6175 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6176 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6177 pause_time, UINT16);
6178 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6179 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6180 xon_str, "send_xon");
6181 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6182 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6184 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6185 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6186 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6187 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6188 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6189 mac_ctrl_frame_fwd_mode, "on#off");
6190 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6191 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6192 autoneg_str, "autoneg");
6193 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6194 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6196 cmdline_parse_token_num_t cmd_lfc_set_portid =
6197 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6200 /* forward declaration */
6202 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6205 cmdline_parse_inst_t cmd_link_flow_control_set = {
6206 .f = cmd_link_flow_ctrl_set_parsed,
6208 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6209 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6210 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6212 (void *)&cmd_lfc_set_set,
6213 (void *)&cmd_lfc_set_flow_ctrl,
6214 (void *)&cmd_lfc_set_rx,
6215 (void *)&cmd_lfc_set_rx_mode,
6216 (void *)&cmd_lfc_set_tx,
6217 (void *)&cmd_lfc_set_tx_mode,
6218 (void *)&cmd_lfc_set_high_water,
6219 (void *)&cmd_lfc_set_low_water,
6220 (void *)&cmd_lfc_set_pause_time,
6221 (void *)&cmd_lfc_set_send_xon,
6222 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6223 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6224 (void *)&cmd_lfc_set_autoneg_str,
6225 (void *)&cmd_lfc_set_autoneg,
6226 (void *)&cmd_lfc_set_portid,
6231 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6232 .f = cmd_link_flow_ctrl_set_parsed,
6233 .data = (void *)&cmd_link_flow_control_set_rx,
6234 .help_str = "set flow_ctrl rx on|off <port_id>: "
6235 "Change rx flow control parameter",
6237 (void *)&cmd_lfc_set_set,
6238 (void *)&cmd_lfc_set_flow_ctrl,
6239 (void *)&cmd_lfc_set_rx,
6240 (void *)&cmd_lfc_set_rx_mode,
6241 (void *)&cmd_lfc_set_portid,
6246 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6247 .f = cmd_link_flow_ctrl_set_parsed,
6248 .data = (void *)&cmd_link_flow_control_set_tx,
6249 .help_str = "set flow_ctrl tx on|off <port_id>: "
6250 "Change tx flow control parameter",
6252 (void *)&cmd_lfc_set_set,
6253 (void *)&cmd_lfc_set_flow_ctrl,
6254 (void *)&cmd_lfc_set_tx,
6255 (void *)&cmd_lfc_set_tx_mode,
6256 (void *)&cmd_lfc_set_portid,
6261 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6262 .f = cmd_link_flow_ctrl_set_parsed,
6263 .data = (void *)&cmd_link_flow_control_set_hw,
6264 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6265 "Change high water flow control parameter",
6267 (void *)&cmd_lfc_set_set,
6268 (void *)&cmd_lfc_set_flow_ctrl,
6269 (void *)&cmd_lfc_set_high_water_str,
6270 (void *)&cmd_lfc_set_high_water,
6271 (void *)&cmd_lfc_set_portid,
6276 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6277 .f = cmd_link_flow_ctrl_set_parsed,
6278 .data = (void *)&cmd_link_flow_control_set_lw,
6279 .help_str = "set flow_ctrl low_water <value> <port_id>: "
6280 "Change low water flow control parameter",
6282 (void *)&cmd_lfc_set_set,
6283 (void *)&cmd_lfc_set_flow_ctrl,
6284 (void *)&cmd_lfc_set_low_water_str,
6285 (void *)&cmd_lfc_set_low_water,
6286 (void *)&cmd_lfc_set_portid,
6291 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6292 .f = cmd_link_flow_ctrl_set_parsed,
6293 .data = (void *)&cmd_link_flow_control_set_pt,
6294 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6295 "Change pause time flow control parameter",
6297 (void *)&cmd_lfc_set_set,
6298 (void *)&cmd_lfc_set_flow_ctrl,
6299 (void *)&cmd_lfc_set_pause_time_str,
6300 (void *)&cmd_lfc_set_pause_time,
6301 (void *)&cmd_lfc_set_portid,
6306 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6307 .f = cmd_link_flow_ctrl_set_parsed,
6308 .data = (void *)&cmd_link_flow_control_set_xon,
6309 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6310 "Change send_xon flow control parameter",
6312 (void *)&cmd_lfc_set_set,
6313 (void *)&cmd_lfc_set_flow_ctrl,
6314 (void *)&cmd_lfc_set_send_xon_str,
6315 (void *)&cmd_lfc_set_send_xon,
6316 (void *)&cmd_lfc_set_portid,
6321 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6322 .f = cmd_link_flow_ctrl_set_parsed,
6323 .data = (void *)&cmd_link_flow_control_set_macfwd,
6324 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6325 "Change mac ctrl fwd flow control parameter",
6327 (void *)&cmd_lfc_set_set,
6328 (void *)&cmd_lfc_set_flow_ctrl,
6329 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6330 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6331 (void *)&cmd_lfc_set_portid,
6336 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6337 .f = cmd_link_flow_ctrl_set_parsed,
6338 .data = (void *)&cmd_link_flow_control_set_autoneg,
6339 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6340 "Change autoneg flow control parameter",
6342 (void *)&cmd_lfc_set_set,
6343 (void *)&cmd_lfc_set_flow_ctrl,
6344 (void *)&cmd_lfc_set_autoneg_str,
6345 (void *)&cmd_lfc_set_autoneg,
6346 (void *)&cmd_lfc_set_portid,
6352 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6353 __attribute__((unused)) struct cmdline *cl,
6356 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6357 cmdline_parse_inst_t *cmd = data;
6358 struct rte_eth_fc_conf fc_conf;
6364 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6365 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6366 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6367 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6369 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6370 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
6373 /* Partial command line, retrieve current configuration */
6375 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6377 printf("cannot get current flow ctrl parameters, return"
6378 "code = %d\n", ret);
6382 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
6383 (fc_conf.mode == RTE_FC_FULL))
6385 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
6386 (fc_conf.mode == RTE_FC_FULL))
6390 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6391 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6393 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6394 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6396 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6398 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6399 fc_conf.high_water = res->high_water;
6401 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6402 fc_conf.low_water = res->low_water;
6404 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6405 fc_conf.pause_time = res->pause_time;
6407 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6408 fc_conf.send_xon = res->send_xon;
6410 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6411 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6412 fc_conf.mac_ctrl_frame_fwd = 1;
6414 fc_conf.mac_ctrl_frame_fwd = 0;
6417 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6418 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6420 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6422 printf("bad flow contrl parameter, return code = %d \n", ret);
6425 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6426 struct cmd_priority_flow_ctrl_set_result {
6427 cmdline_fixed_string_t set;
6428 cmdline_fixed_string_t pfc_ctrl;
6429 cmdline_fixed_string_t rx;
6430 cmdline_fixed_string_t rx_pfc_mode;
6431 cmdline_fixed_string_t tx;
6432 cmdline_fixed_string_t tx_pfc_mode;
6433 uint32_t high_water;
6435 uint16_t pause_time;
6441 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6442 __attribute__((unused)) struct cmdline *cl,
6443 __attribute__((unused)) void *data)
6445 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
6446 struct rte_eth_pfc_conf pfc_conf;
6447 int rx_fc_enable, tx_fc_enable;
6451 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6452 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6453 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6454 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6456 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
6457 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
6460 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
6461 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
6462 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
6463 pfc_conf.fc.high_water = res->high_water;
6464 pfc_conf.fc.low_water = res->low_water;
6465 pfc_conf.fc.pause_time = res->pause_time;
6466 pfc_conf.priority = res->priority;
6468 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
6470 printf("bad priority flow contrl parameter, return code = %d \n", ret);
6473 cmdline_parse_token_string_t cmd_pfc_set_set =
6474 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6476 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
6477 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6478 pfc_ctrl, "pfc_ctrl");
6479 cmdline_parse_token_string_t cmd_pfc_set_rx =
6480 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6482 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
6483 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6484 rx_pfc_mode, "on#off");
6485 cmdline_parse_token_string_t cmd_pfc_set_tx =
6486 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6488 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
6489 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6490 tx_pfc_mode, "on#off");
6491 cmdline_parse_token_num_t cmd_pfc_set_high_water =
6492 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6493 high_water, UINT32);
6494 cmdline_parse_token_num_t cmd_pfc_set_low_water =
6495 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6497 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
6498 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6499 pause_time, UINT16);
6500 cmdline_parse_token_num_t cmd_pfc_set_priority =
6501 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6503 cmdline_parse_token_num_t cmd_pfc_set_portid =
6504 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6507 cmdline_parse_inst_t cmd_priority_flow_control_set = {
6508 .f = cmd_priority_flow_ctrl_set_parsed,
6510 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
6511 "<pause_time> <priority> <port_id>: "
6512 "Configure the Ethernet priority flow control",
6514 (void *)&cmd_pfc_set_set,
6515 (void *)&cmd_pfc_set_flow_ctrl,
6516 (void *)&cmd_pfc_set_rx,
6517 (void *)&cmd_pfc_set_rx_mode,
6518 (void *)&cmd_pfc_set_tx,
6519 (void *)&cmd_pfc_set_tx_mode,
6520 (void *)&cmd_pfc_set_high_water,
6521 (void *)&cmd_pfc_set_low_water,
6522 (void *)&cmd_pfc_set_pause_time,
6523 (void *)&cmd_pfc_set_priority,
6524 (void *)&cmd_pfc_set_portid,
6529 /* *** RESET CONFIGURATION *** */
6530 struct cmd_reset_result {
6531 cmdline_fixed_string_t reset;
6532 cmdline_fixed_string_t def;
6535 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
6537 __attribute__((unused)) void *data)
6539 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
6540 set_def_fwd_config();
6543 cmdline_parse_token_string_t cmd_reset_set =
6544 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
6545 cmdline_parse_token_string_t cmd_reset_def =
6546 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
6549 cmdline_parse_inst_t cmd_reset = {
6550 .f = cmd_reset_parsed,
6552 .help_str = "set default: Reset default forwarding configuration",
6554 (void *)&cmd_reset_set,
6555 (void *)&cmd_reset_def,
6560 /* *** START FORWARDING *** */
6561 struct cmd_start_result {
6562 cmdline_fixed_string_t start;
6565 cmdline_parse_token_string_t cmd_start_start =
6566 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
6568 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
6569 __attribute__((unused)) struct cmdline *cl,
6570 __attribute__((unused)) void *data)
6572 start_packet_forwarding(0);
6575 cmdline_parse_inst_t cmd_start = {
6576 .f = cmd_start_parsed,
6578 .help_str = "start: Start packet forwarding",
6580 (void *)&cmd_start_start,
6585 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
6586 struct cmd_start_tx_first_result {
6587 cmdline_fixed_string_t start;
6588 cmdline_fixed_string_t tx_first;
6592 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
6593 __attribute__((unused)) struct cmdline *cl,
6594 __attribute__((unused)) void *data)
6596 start_packet_forwarding(1);
6599 cmdline_parse_token_string_t cmd_start_tx_first_start =
6600 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
6602 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
6603 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
6604 tx_first, "tx_first");
6606 cmdline_parse_inst_t cmd_start_tx_first = {
6607 .f = cmd_start_tx_first_parsed,
6609 .help_str = "start tx_first: Start packet forwarding, "
6610 "after sending 1 burst of packets",
6612 (void *)&cmd_start_tx_first_start,
6613 (void *)&cmd_start_tx_first_tx_first,
6618 /* *** START FORWARDING WITH N TX BURST FIRST *** */
6619 struct cmd_start_tx_first_n_result {
6620 cmdline_fixed_string_t start;
6621 cmdline_fixed_string_t tx_first;
6626 cmd_start_tx_first_n_parsed(void *parsed_result,
6627 __attribute__((unused)) struct cmdline *cl,
6628 __attribute__((unused)) void *data)
6630 struct cmd_start_tx_first_n_result *res = parsed_result;
6632 start_packet_forwarding(res->tx_num);
6635 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
6636 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6638 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
6639 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6640 tx_first, "tx_first");
6641 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
6642 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
6645 cmdline_parse_inst_t cmd_start_tx_first_n = {
6646 .f = cmd_start_tx_first_n_parsed,
6648 .help_str = "start tx_first <num>: "
6649 "packet forwarding, after sending <num> bursts of packets",
6651 (void *)&cmd_start_tx_first_n_start,
6652 (void *)&cmd_start_tx_first_n_tx_first,
6653 (void *)&cmd_start_tx_first_n_tx_num,
6658 /* *** SET LINK UP *** */
6659 struct cmd_set_link_up_result {
6660 cmdline_fixed_string_t set;
6661 cmdline_fixed_string_t link_up;
6662 cmdline_fixed_string_t port;
6666 cmdline_parse_token_string_t cmd_set_link_up_set =
6667 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
6668 cmdline_parse_token_string_t cmd_set_link_up_link_up =
6669 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
6671 cmdline_parse_token_string_t cmd_set_link_up_port =
6672 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
6673 cmdline_parse_token_num_t cmd_set_link_up_port_id =
6674 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
6676 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
6677 __attribute__((unused)) struct cmdline *cl,
6678 __attribute__((unused)) void *data)
6680 struct cmd_set_link_up_result *res = parsed_result;
6681 dev_set_link_up(res->port_id);
6684 cmdline_parse_inst_t cmd_set_link_up = {
6685 .f = cmd_set_link_up_parsed,
6687 .help_str = "set link-up port <port id>",
6689 (void *)&cmd_set_link_up_set,
6690 (void *)&cmd_set_link_up_link_up,
6691 (void *)&cmd_set_link_up_port,
6692 (void *)&cmd_set_link_up_port_id,
6697 /* *** SET LINK DOWN *** */
6698 struct cmd_set_link_down_result {
6699 cmdline_fixed_string_t set;
6700 cmdline_fixed_string_t link_down;
6701 cmdline_fixed_string_t port;
6705 cmdline_parse_token_string_t cmd_set_link_down_set =
6706 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
6707 cmdline_parse_token_string_t cmd_set_link_down_link_down =
6708 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
6710 cmdline_parse_token_string_t cmd_set_link_down_port =
6711 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
6712 cmdline_parse_token_num_t cmd_set_link_down_port_id =
6713 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
6715 static void cmd_set_link_down_parsed(
6716 __attribute__((unused)) void *parsed_result,
6717 __attribute__((unused)) struct cmdline *cl,
6718 __attribute__((unused)) void *data)
6720 struct cmd_set_link_down_result *res = parsed_result;
6721 dev_set_link_down(res->port_id);
6724 cmdline_parse_inst_t cmd_set_link_down = {
6725 .f = cmd_set_link_down_parsed,
6727 .help_str = "set link-down port <port id>",
6729 (void *)&cmd_set_link_down_set,
6730 (void *)&cmd_set_link_down_link_down,
6731 (void *)&cmd_set_link_down_port,
6732 (void *)&cmd_set_link_down_port_id,
6737 /* *** SHOW CFG *** */
6738 struct cmd_showcfg_result {
6739 cmdline_fixed_string_t show;
6740 cmdline_fixed_string_t cfg;
6741 cmdline_fixed_string_t what;
6744 static void cmd_showcfg_parsed(void *parsed_result,
6745 __attribute__((unused)) struct cmdline *cl,
6746 __attribute__((unused)) void *data)
6748 struct cmd_showcfg_result *res = parsed_result;
6749 if (!strcmp(res->what, "rxtx"))
6750 rxtx_config_display();
6751 else if (!strcmp(res->what, "cores"))
6752 fwd_lcores_config_display();
6753 else if (!strcmp(res->what, "fwd"))
6754 pkt_fwd_config_display(&cur_fwd_config);
6755 else if (!strcmp(res->what, "txpkts"))
6756 show_tx_pkt_segments();
6759 cmdline_parse_token_string_t cmd_showcfg_show =
6760 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
6761 cmdline_parse_token_string_t cmd_showcfg_port =
6762 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
6763 cmdline_parse_token_string_t cmd_showcfg_what =
6764 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
6765 "rxtx#cores#fwd#txpkts");
6767 cmdline_parse_inst_t cmd_showcfg = {
6768 .f = cmd_showcfg_parsed,
6770 .help_str = "show config rxtx|cores|fwd|txpkts",
6772 (void *)&cmd_showcfg_show,
6773 (void *)&cmd_showcfg_port,
6774 (void *)&cmd_showcfg_what,
6779 /* *** SHOW ALL PORT INFO *** */
6780 struct cmd_showportall_result {
6781 cmdline_fixed_string_t show;
6782 cmdline_fixed_string_t port;
6783 cmdline_fixed_string_t what;
6784 cmdline_fixed_string_t all;
6787 static void cmd_showportall_parsed(void *parsed_result,
6788 __attribute__((unused)) struct cmdline *cl,
6789 __attribute__((unused)) void *data)
6793 struct cmd_showportall_result *res = parsed_result;
6794 if (!strcmp(res->show, "clear")) {
6795 if (!strcmp(res->what, "stats"))
6796 RTE_ETH_FOREACH_DEV(i)
6798 else if (!strcmp(res->what, "xstats"))
6799 RTE_ETH_FOREACH_DEV(i)
6800 nic_xstats_clear(i);
6801 } else if (!strcmp(res->what, "info"))
6802 RTE_ETH_FOREACH_DEV(i)
6803 port_infos_display(i);
6804 else if (!strcmp(res->what, "stats"))
6805 RTE_ETH_FOREACH_DEV(i)
6806 nic_stats_display(i);
6807 else if (!strcmp(res->what, "xstats"))
6808 RTE_ETH_FOREACH_DEV(i)
6809 nic_xstats_display(i);
6810 else if (!strcmp(res->what, "fdir"))
6811 RTE_ETH_FOREACH_DEV(i)
6813 else if (!strcmp(res->what, "stat_qmap"))
6814 RTE_ETH_FOREACH_DEV(i)
6815 nic_stats_mapping_display(i);
6816 else if (!strcmp(res->what, "dcb_tc"))
6817 RTE_ETH_FOREACH_DEV(i)
6818 port_dcb_info_display(i);
6819 else if (!strcmp(res->what, "cap"))
6820 RTE_ETH_FOREACH_DEV(i)
6821 port_offload_cap_display(i);
6824 cmdline_parse_token_string_t cmd_showportall_show =
6825 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
6827 cmdline_parse_token_string_t cmd_showportall_port =
6828 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
6829 cmdline_parse_token_string_t cmd_showportall_what =
6830 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
6831 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
6832 cmdline_parse_token_string_t cmd_showportall_all =
6833 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
6834 cmdline_parse_inst_t cmd_showportall = {
6835 .f = cmd_showportall_parsed,
6837 .help_str = "show|clear port "
6838 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
6840 (void *)&cmd_showportall_show,
6841 (void *)&cmd_showportall_port,
6842 (void *)&cmd_showportall_what,
6843 (void *)&cmd_showportall_all,
6848 /* *** SHOW PORT INFO *** */
6849 struct cmd_showport_result {
6850 cmdline_fixed_string_t show;
6851 cmdline_fixed_string_t port;
6852 cmdline_fixed_string_t what;
6856 static void cmd_showport_parsed(void *parsed_result,
6857 __attribute__((unused)) struct cmdline *cl,
6858 __attribute__((unused)) void *data)
6860 struct cmd_showport_result *res = parsed_result;
6861 if (!strcmp(res->show, "clear")) {
6862 if (!strcmp(res->what, "stats"))
6863 nic_stats_clear(res->portnum);
6864 else if (!strcmp(res->what, "xstats"))
6865 nic_xstats_clear(res->portnum);
6866 } else if (!strcmp(res->what, "info"))
6867 port_infos_display(res->portnum);
6868 else if (!strcmp(res->what, "stats"))
6869 nic_stats_display(res->portnum);
6870 else if (!strcmp(res->what, "xstats"))
6871 nic_xstats_display(res->portnum);
6872 else if (!strcmp(res->what, "fdir"))
6873 fdir_get_infos(res->portnum);
6874 else if (!strcmp(res->what, "stat_qmap"))
6875 nic_stats_mapping_display(res->portnum);
6876 else if (!strcmp(res->what, "dcb_tc"))
6877 port_dcb_info_display(res->portnum);
6878 else if (!strcmp(res->what, "cap"))
6879 port_offload_cap_display(res->portnum);
6882 cmdline_parse_token_string_t cmd_showport_show =
6883 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
6885 cmdline_parse_token_string_t cmd_showport_port =
6886 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
6887 cmdline_parse_token_string_t cmd_showport_what =
6888 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
6889 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
6890 cmdline_parse_token_num_t cmd_showport_portnum =
6891 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
6893 cmdline_parse_inst_t cmd_showport = {
6894 .f = cmd_showport_parsed,
6896 .help_str = "show|clear port "
6897 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
6900 (void *)&cmd_showport_show,
6901 (void *)&cmd_showport_port,
6902 (void *)&cmd_showport_what,
6903 (void *)&cmd_showport_portnum,
6908 /* *** SHOW QUEUE INFO *** */
6909 struct cmd_showqueue_result {
6910 cmdline_fixed_string_t show;
6911 cmdline_fixed_string_t type;
6912 cmdline_fixed_string_t what;
6918 cmd_showqueue_parsed(void *parsed_result,
6919 __attribute__((unused)) struct cmdline *cl,
6920 __attribute__((unused)) void *data)
6922 struct cmd_showqueue_result *res = parsed_result;
6924 if (!strcmp(res->type, "rxq"))
6925 rx_queue_infos_display(res->portnum, res->queuenum);
6926 else if (!strcmp(res->type, "txq"))
6927 tx_queue_infos_display(res->portnum, res->queuenum);
6930 cmdline_parse_token_string_t cmd_showqueue_show =
6931 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
6932 cmdline_parse_token_string_t cmd_showqueue_type =
6933 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
6934 cmdline_parse_token_string_t cmd_showqueue_what =
6935 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
6936 cmdline_parse_token_num_t cmd_showqueue_portnum =
6937 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
6938 cmdline_parse_token_num_t cmd_showqueue_queuenum =
6939 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
6941 cmdline_parse_inst_t cmd_showqueue = {
6942 .f = cmd_showqueue_parsed,
6944 .help_str = "show rxq|txq info <port_id> <queue_id>",
6946 (void *)&cmd_showqueue_show,
6947 (void *)&cmd_showqueue_type,
6948 (void *)&cmd_showqueue_what,
6949 (void *)&cmd_showqueue_portnum,
6950 (void *)&cmd_showqueue_queuenum,
6955 /* *** READ PORT REGISTER *** */
6956 struct cmd_read_reg_result {
6957 cmdline_fixed_string_t read;
6958 cmdline_fixed_string_t reg;
6964 cmd_read_reg_parsed(void *parsed_result,
6965 __attribute__((unused)) struct cmdline *cl,
6966 __attribute__((unused)) void *data)
6968 struct cmd_read_reg_result *res = parsed_result;
6969 port_reg_display(res->port_id, res->reg_off);
6972 cmdline_parse_token_string_t cmd_read_reg_read =
6973 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
6974 cmdline_parse_token_string_t cmd_read_reg_reg =
6975 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
6976 cmdline_parse_token_num_t cmd_read_reg_port_id =
6977 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
6978 cmdline_parse_token_num_t cmd_read_reg_reg_off =
6979 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
6981 cmdline_parse_inst_t cmd_read_reg = {
6982 .f = cmd_read_reg_parsed,
6984 .help_str = "read reg <port_id> <reg_off>",
6986 (void *)&cmd_read_reg_read,
6987 (void *)&cmd_read_reg_reg,
6988 (void *)&cmd_read_reg_port_id,
6989 (void *)&cmd_read_reg_reg_off,
6994 /* *** READ PORT REGISTER BIT FIELD *** */
6995 struct cmd_read_reg_bit_field_result {
6996 cmdline_fixed_string_t read;
6997 cmdline_fixed_string_t regfield;
7005 cmd_read_reg_bit_field_parsed(void *parsed_result,
7006 __attribute__((unused)) struct cmdline *cl,
7007 __attribute__((unused)) void *data)
7009 struct cmd_read_reg_bit_field_result *res = parsed_result;
7010 port_reg_bit_field_display(res->port_id, res->reg_off,
7011 res->bit1_pos, res->bit2_pos);
7014 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7015 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7017 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7018 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7019 regfield, "regfield");
7020 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7021 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7023 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7024 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7026 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7027 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7029 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7030 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7033 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7034 .f = cmd_read_reg_bit_field_parsed,
7036 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7037 "Read register bit field between bit_x and bit_y included",
7039 (void *)&cmd_read_reg_bit_field_read,
7040 (void *)&cmd_read_reg_bit_field_regfield,
7041 (void *)&cmd_read_reg_bit_field_port_id,
7042 (void *)&cmd_read_reg_bit_field_reg_off,
7043 (void *)&cmd_read_reg_bit_field_bit1_pos,
7044 (void *)&cmd_read_reg_bit_field_bit2_pos,
7049 /* *** READ PORT REGISTER BIT *** */
7050 struct cmd_read_reg_bit_result {
7051 cmdline_fixed_string_t read;
7052 cmdline_fixed_string_t regbit;
7059 cmd_read_reg_bit_parsed(void *parsed_result,
7060 __attribute__((unused)) struct cmdline *cl,
7061 __attribute__((unused)) void *data)
7063 struct cmd_read_reg_bit_result *res = parsed_result;
7064 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7067 cmdline_parse_token_string_t cmd_read_reg_bit_read =
7068 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
7069 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
7070 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
7072 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
7073 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
7074 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
7075 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
7076 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
7077 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
7079 cmdline_parse_inst_t cmd_read_reg_bit = {
7080 .f = cmd_read_reg_bit_parsed,
7082 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7084 (void *)&cmd_read_reg_bit_read,
7085 (void *)&cmd_read_reg_bit_regbit,
7086 (void *)&cmd_read_reg_bit_port_id,
7087 (void *)&cmd_read_reg_bit_reg_off,
7088 (void *)&cmd_read_reg_bit_bit_pos,
7093 /* *** WRITE PORT REGISTER *** */
7094 struct cmd_write_reg_result {
7095 cmdline_fixed_string_t write;
7096 cmdline_fixed_string_t reg;
7103 cmd_write_reg_parsed(void *parsed_result,
7104 __attribute__((unused)) struct cmdline *cl,
7105 __attribute__((unused)) void *data)
7107 struct cmd_write_reg_result *res = parsed_result;
7108 port_reg_set(res->port_id, res->reg_off, res->value);
7111 cmdline_parse_token_string_t cmd_write_reg_write =
7112 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
7113 cmdline_parse_token_string_t cmd_write_reg_reg =
7114 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
7115 cmdline_parse_token_num_t cmd_write_reg_port_id =
7116 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
7117 cmdline_parse_token_num_t cmd_write_reg_reg_off =
7118 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
7119 cmdline_parse_token_num_t cmd_write_reg_value =
7120 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
7122 cmdline_parse_inst_t cmd_write_reg = {
7123 .f = cmd_write_reg_parsed,
7125 .help_str = "write reg <port_id> <reg_off> <reg_value>",
7127 (void *)&cmd_write_reg_write,
7128 (void *)&cmd_write_reg_reg,
7129 (void *)&cmd_write_reg_port_id,
7130 (void *)&cmd_write_reg_reg_off,
7131 (void *)&cmd_write_reg_value,
7136 /* *** WRITE PORT REGISTER BIT FIELD *** */
7137 struct cmd_write_reg_bit_field_result {
7138 cmdline_fixed_string_t write;
7139 cmdline_fixed_string_t regfield;
7148 cmd_write_reg_bit_field_parsed(void *parsed_result,
7149 __attribute__((unused)) struct cmdline *cl,
7150 __attribute__((unused)) void *data)
7152 struct cmd_write_reg_bit_field_result *res = parsed_result;
7153 port_reg_bit_field_set(res->port_id, res->reg_off,
7154 res->bit1_pos, res->bit2_pos, res->value);
7157 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
7158 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
7160 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
7161 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
7162 regfield, "regfield");
7163 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
7164 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
7166 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
7167 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
7169 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
7170 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
7172 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
7173 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
7175 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
7176 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
7179 cmdline_parse_inst_t cmd_write_reg_bit_field = {
7180 .f = cmd_write_reg_bit_field_parsed,
7182 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
7184 "Set register bit field between bit_x and bit_y included",
7186 (void *)&cmd_write_reg_bit_field_write,
7187 (void *)&cmd_write_reg_bit_field_regfield,
7188 (void *)&cmd_write_reg_bit_field_port_id,
7189 (void *)&cmd_write_reg_bit_field_reg_off,
7190 (void *)&cmd_write_reg_bit_field_bit1_pos,
7191 (void *)&cmd_write_reg_bit_field_bit2_pos,
7192 (void *)&cmd_write_reg_bit_field_value,
7197 /* *** WRITE PORT REGISTER BIT *** */
7198 struct cmd_write_reg_bit_result {
7199 cmdline_fixed_string_t write;
7200 cmdline_fixed_string_t regbit;
7208 cmd_write_reg_bit_parsed(void *parsed_result,
7209 __attribute__((unused)) struct cmdline *cl,
7210 __attribute__((unused)) void *data)
7212 struct cmd_write_reg_bit_result *res = parsed_result;
7213 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
7216 cmdline_parse_token_string_t cmd_write_reg_bit_write =
7217 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
7219 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
7220 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
7222 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
7223 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
7224 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
7225 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
7226 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
7227 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
7228 cmdline_parse_token_num_t cmd_write_reg_bit_value =
7229 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
7231 cmdline_parse_inst_t cmd_write_reg_bit = {
7232 .f = cmd_write_reg_bit_parsed,
7234 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
7237 (void *)&cmd_write_reg_bit_write,
7238 (void *)&cmd_write_reg_bit_regbit,
7239 (void *)&cmd_write_reg_bit_port_id,
7240 (void *)&cmd_write_reg_bit_reg_off,
7241 (void *)&cmd_write_reg_bit_bit_pos,
7242 (void *)&cmd_write_reg_bit_value,
7247 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7248 struct cmd_read_rxd_txd_result {
7249 cmdline_fixed_string_t read;
7250 cmdline_fixed_string_t rxd_txd;
7257 cmd_read_rxd_txd_parsed(void *parsed_result,
7258 __attribute__((unused)) struct cmdline *cl,
7259 __attribute__((unused)) void *data)
7261 struct cmd_read_rxd_txd_result *res = parsed_result;
7263 if (!strcmp(res->rxd_txd, "rxd"))
7264 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7265 else if (!strcmp(res->rxd_txd, "txd"))
7266 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7269 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
7270 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
7271 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
7272 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
7274 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
7275 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
7276 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
7277 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
7278 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
7279 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
7281 cmdline_parse_inst_t cmd_read_rxd_txd = {
7282 .f = cmd_read_rxd_txd_parsed,
7284 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
7286 (void *)&cmd_read_rxd_txd_read,
7287 (void *)&cmd_read_rxd_txd_rxd_txd,
7288 (void *)&cmd_read_rxd_txd_port_id,
7289 (void *)&cmd_read_rxd_txd_queue_id,
7290 (void *)&cmd_read_rxd_txd_desc_id,
7296 struct cmd_quit_result {
7297 cmdline_fixed_string_t quit;
7300 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
7302 __attribute__((unused)) void *data)
7308 cmdline_parse_token_string_t cmd_quit_quit =
7309 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
7311 cmdline_parse_inst_t cmd_quit = {
7312 .f = cmd_quit_parsed,
7314 .help_str = "quit: Exit application",
7316 (void *)&cmd_quit_quit,
7321 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
7322 struct cmd_mac_addr_result {
7323 cmdline_fixed_string_t mac_addr_cmd;
7324 cmdline_fixed_string_t what;
7326 struct ether_addr address;
7329 static void cmd_mac_addr_parsed(void *parsed_result,
7330 __attribute__((unused)) struct cmdline *cl,
7331 __attribute__((unused)) void *data)
7333 struct cmd_mac_addr_result *res = parsed_result;
7336 if (strcmp(res->what, "add") == 0)
7337 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
7338 else if (strcmp(res->what, "set") == 0)
7339 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
7342 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
7344 /* check the return value and print it if is < 0 */
7346 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
7350 cmdline_parse_token_string_t cmd_mac_addr_cmd =
7351 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
7353 cmdline_parse_token_string_t cmd_mac_addr_what =
7354 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
7356 cmdline_parse_token_num_t cmd_mac_addr_portnum =
7357 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
7359 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
7360 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
7362 cmdline_parse_inst_t cmd_mac_addr = {
7363 .f = cmd_mac_addr_parsed,
7365 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
7366 "Add/Remove/Set MAC address on port_id",
7368 (void *)&cmd_mac_addr_cmd,
7369 (void *)&cmd_mac_addr_what,
7370 (void *)&cmd_mac_addr_portnum,
7371 (void *)&cmd_mac_addr_addr,
7376 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
7377 struct cmd_eth_peer_result {
7378 cmdline_fixed_string_t set;
7379 cmdline_fixed_string_t eth_peer;
7381 cmdline_fixed_string_t peer_addr;
7384 static void cmd_set_eth_peer_parsed(void *parsed_result,
7385 __attribute__((unused)) struct cmdline *cl,
7386 __attribute__((unused)) void *data)
7388 struct cmd_eth_peer_result *res = parsed_result;
7390 if (test_done == 0) {
7391 printf("Please stop forwarding first\n");
7394 if (!strcmp(res->eth_peer, "eth-peer")) {
7395 set_fwd_eth_peer(res->port_id, res->peer_addr);
7399 cmdline_parse_token_string_t cmd_eth_peer_set =
7400 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
7401 cmdline_parse_token_string_t cmd_eth_peer =
7402 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
7403 cmdline_parse_token_num_t cmd_eth_peer_port_id =
7404 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
7405 cmdline_parse_token_string_t cmd_eth_peer_addr =
7406 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
7408 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
7409 .f = cmd_set_eth_peer_parsed,
7411 .help_str = "set eth-peer <port_id> <peer_mac>",
7413 (void *)&cmd_eth_peer_set,
7414 (void *)&cmd_eth_peer,
7415 (void *)&cmd_eth_peer_port_id,
7416 (void *)&cmd_eth_peer_addr,
7421 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
7422 struct cmd_set_qmap_result {
7423 cmdline_fixed_string_t set;
7424 cmdline_fixed_string_t qmap;
7425 cmdline_fixed_string_t what;
7432 cmd_set_qmap_parsed(void *parsed_result,
7433 __attribute__((unused)) struct cmdline *cl,
7434 __attribute__((unused)) void *data)
7436 struct cmd_set_qmap_result *res = parsed_result;
7437 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
7439 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
7442 cmdline_parse_token_string_t cmd_setqmap_set =
7443 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7445 cmdline_parse_token_string_t cmd_setqmap_qmap =
7446 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7448 cmdline_parse_token_string_t cmd_setqmap_what =
7449 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7451 cmdline_parse_token_num_t cmd_setqmap_portid =
7452 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7454 cmdline_parse_token_num_t cmd_setqmap_queueid =
7455 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7457 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
7458 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7461 cmdline_parse_inst_t cmd_set_qmap = {
7462 .f = cmd_set_qmap_parsed,
7464 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
7465 "Set statistics mapping value on tx|rx queue_id of port_id",
7467 (void *)&cmd_setqmap_set,
7468 (void *)&cmd_setqmap_qmap,
7469 (void *)&cmd_setqmap_what,
7470 (void *)&cmd_setqmap_portid,
7471 (void *)&cmd_setqmap_queueid,
7472 (void *)&cmd_setqmap_mapvalue,
7477 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
7478 struct cmd_set_xstats_hide_zero_result {
7479 cmdline_fixed_string_t keyword;
7480 cmdline_fixed_string_t name;
7481 cmdline_fixed_string_t on_off;
7485 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
7486 __attribute__((unused)) struct cmdline *cl,
7487 __attribute__((unused)) void *data)
7489 struct cmd_set_xstats_hide_zero_result *res;
7490 uint16_t on_off = 0;
7492 res = parsed_result;
7493 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
7494 set_xstats_hide_zero(on_off);
7497 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
7498 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7500 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
7501 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7502 name, "xstats-hide-zero");
7503 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
7504 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7507 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
7508 .f = cmd_set_xstats_hide_zero_parsed,
7510 .help_str = "set xstats-hide-zero on|off",
7512 (void *)&cmd_set_xstats_hide_zero_keyword,
7513 (void *)&cmd_set_xstats_hide_zero_name,
7514 (void *)&cmd_set_xstats_hide_zero_on_off,
7519 /* *** CONFIGURE UNICAST HASH TABLE *** */
7520 struct cmd_set_uc_hash_table {
7521 cmdline_fixed_string_t set;
7522 cmdline_fixed_string_t port;
7524 cmdline_fixed_string_t what;
7525 struct ether_addr address;
7526 cmdline_fixed_string_t mode;
7530 cmd_set_uc_hash_parsed(void *parsed_result,
7531 __attribute__((unused)) struct cmdline *cl,
7532 __attribute__((unused)) void *data)
7535 struct cmd_set_uc_hash_table *res = parsed_result;
7537 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7539 if (strcmp(res->what, "uta") == 0)
7540 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
7541 &res->address,(uint8_t)is_on);
7543 printf("bad unicast hash table parameter, return code = %d \n", ret);
7547 cmdline_parse_token_string_t cmd_set_uc_hash_set =
7548 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7550 cmdline_parse_token_string_t cmd_set_uc_hash_port =
7551 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7553 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
7554 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
7556 cmdline_parse_token_string_t cmd_set_uc_hash_what =
7557 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7559 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
7560 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
7562 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
7563 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7566 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
7567 .f = cmd_set_uc_hash_parsed,
7569 .help_str = "set port <port_id> uta <mac_addr> on|off)",
7571 (void *)&cmd_set_uc_hash_set,
7572 (void *)&cmd_set_uc_hash_port,
7573 (void *)&cmd_set_uc_hash_portid,
7574 (void *)&cmd_set_uc_hash_what,
7575 (void *)&cmd_set_uc_hash_mac,
7576 (void *)&cmd_set_uc_hash_mode,
7581 struct cmd_set_uc_all_hash_table {
7582 cmdline_fixed_string_t set;
7583 cmdline_fixed_string_t port;
7585 cmdline_fixed_string_t what;
7586 cmdline_fixed_string_t value;
7587 cmdline_fixed_string_t mode;
7591 cmd_set_uc_all_hash_parsed(void *parsed_result,
7592 __attribute__((unused)) struct cmdline *cl,
7593 __attribute__((unused)) void *data)
7596 struct cmd_set_uc_all_hash_table *res = parsed_result;
7598 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7600 if ((strcmp(res->what, "uta") == 0) &&
7601 (strcmp(res->value, "all") == 0))
7602 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
7604 printf("bad unicast hash table parameter,"
7605 "return code = %d \n", ret);
7608 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
7609 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7611 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
7612 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7614 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
7615 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
7617 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
7618 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7620 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
7621 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7623 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
7624 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7627 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
7628 .f = cmd_set_uc_all_hash_parsed,
7630 .help_str = "set port <port_id> uta all on|off",
7632 (void *)&cmd_set_uc_all_hash_set,
7633 (void *)&cmd_set_uc_all_hash_port,
7634 (void *)&cmd_set_uc_all_hash_portid,
7635 (void *)&cmd_set_uc_all_hash_what,
7636 (void *)&cmd_set_uc_all_hash_value,
7637 (void *)&cmd_set_uc_all_hash_mode,
7642 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
7643 struct cmd_set_vf_macvlan_filter {
7644 cmdline_fixed_string_t set;
7645 cmdline_fixed_string_t port;
7647 cmdline_fixed_string_t vf;
7649 struct ether_addr address;
7650 cmdline_fixed_string_t filter_type;
7651 cmdline_fixed_string_t mode;
7655 cmd_set_vf_macvlan_parsed(void *parsed_result,
7656 __attribute__((unused)) struct cmdline *cl,
7657 __attribute__((unused)) void *data)
7660 struct cmd_set_vf_macvlan_filter *res = parsed_result;
7661 struct rte_eth_mac_filter filter;
7663 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
7665 rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
7667 /* set VF MAC filter */
7671 filter.dst_id = res->vf_id;
7673 if (!strcmp(res->filter_type, "exact-mac"))
7674 filter.filter_type = RTE_MAC_PERFECT_MATCH;
7675 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
7676 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
7677 else if (!strcmp(res->filter_type, "hashmac"))
7678 filter.filter_type = RTE_MAC_HASH_MATCH;
7679 else if (!strcmp(res->filter_type, "hashmac-vlan"))
7680 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
7682 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7685 ret = rte_eth_dev_filter_ctrl(res->port_id,
7686 RTE_ETH_FILTER_MACVLAN,
7690 ret = rte_eth_dev_filter_ctrl(res->port_id,
7691 RTE_ETH_FILTER_MACVLAN,
7692 RTE_ETH_FILTER_DELETE,
7696 printf("bad set MAC hash parameter, return code = %d\n", ret);
7700 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
7701 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7703 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
7704 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7706 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
7707 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7709 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
7710 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7712 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
7713 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7715 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
7716 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7718 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
7719 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7720 filter_type, "exact-mac#exact-mac-vlan"
7721 "#hashmac#hashmac-vlan");
7722 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
7723 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7726 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
7727 .f = cmd_set_vf_macvlan_parsed,
7729 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
7730 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
7731 "Exact match rule: exact match of MAC or MAC and VLAN; "
7732 "hash match rule: hash match of MAC and exact match of VLAN",
7734 (void *)&cmd_set_vf_macvlan_set,
7735 (void *)&cmd_set_vf_macvlan_port,
7736 (void *)&cmd_set_vf_macvlan_portid,
7737 (void *)&cmd_set_vf_macvlan_vf,
7738 (void *)&cmd_set_vf_macvlan_vf_id,
7739 (void *)&cmd_set_vf_macvlan_mac,
7740 (void *)&cmd_set_vf_macvlan_filter_type,
7741 (void *)&cmd_set_vf_macvlan_mode,
7746 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
7747 struct cmd_set_vf_traffic {
7748 cmdline_fixed_string_t set;
7749 cmdline_fixed_string_t port;
7751 cmdline_fixed_string_t vf;
7753 cmdline_fixed_string_t what;
7754 cmdline_fixed_string_t mode;
7758 cmd_set_vf_traffic_parsed(void *parsed_result,
7759 __attribute__((unused)) struct cmdline *cl,
7760 __attribute__((unused)) void *data)
7762 struct cmd_set_vf_traffic *res = parsed_result;
7763 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
7764 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7766 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
7769 cmdline_parse_token_string_t cmd_setvf_traffic_set =
7770 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7772 cmdline_parse_token_string_t cmd_setvf_traffic_port =
7773 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7775 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
7776 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7778 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
7779 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7781 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
7782 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7784 cmdline_parse_token_string_t cmd_setvf_traffic_what =
7785 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7787 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
7788 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7791 cmdline_parse_inst_t cmd_set_vf_traffic = {
7792 .f = cmd_set_vf_traffic_parsed,
7794 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
7796 (void *)&cmd_setvf_traffic_set,
7797 (void *)&cmd_setvf_traffic_port,
7798 (void *)&cmd_setvf_traffic_portid,
7799 (void *)&cmd_setvf_traffic_vf,
7800 (void *)&cmd_setvf_traffic_vfid,
7801 (void *)&cmd_setvf_traffic_what,
7802 (void *)&cmd_setvf_traffic_mode,
7807 /* *** CONFIGURE VF RECEIVE MODE *** */
7808 struct cmd_set_vf_rxmode {
7809 cmdline_fixed_string_t set;
7810 cmdline_fixed_string_t port;
7812 cmdline_fixed_string_t vf;
7814 cmdline_fixed_string_t what;
7815 cmdline_fixed_string_t mode;
7816 cmdline_fixed_string_t on;
7820 cmd_set_vf_rxmode_parsed(void *parsed_result,
7821 __attribute__((unused)) struct cmdline *cl,
7822 __attribute__((unused)) void *data)
7825 uint16_t rx_mode = 0;
7826 struct cmd_set_vf_rxmode *res = parsed_result;
7828 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
7829 if (!strcmp(res->what,"rxmode")) {
7830 if (!strcmp(res->mode, "AUPE"))
7831 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
7832 else if (!strcmp(res->mode, "ROPE"))
7833 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
7834 else if (!strcmp(res->mode, "BAM"))
7835 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
7836 else if (!strncmp(res->mode, "MPE",3))
7837 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
7840 RTE_SET_USED(is_on);
7842 #ifdef RTE_LIBRTE_IXGBE_PMD
7843 if (ret == -ENOTSUP)
7844 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
7845 rx_mode, (uint8_t)is_on);
7847 #ifdef RTE_LIBRTE_BNXT_PMD
7848 if (ret == -ENOTSUP)
7849 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
7850 rx_mode, (uint8_t)is_on);
7853 printf("bad VF receive mode parameter, return code = %d \n",
7857 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
7858 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7860 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
7861 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7863 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
7864 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7866 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
7867 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7869 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
7870 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7872 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
7873 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7875 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
7876 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7877 mode, "AUPE#ROPE#BAM#MPE");
7878 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
7879 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7882 cmdline_parse_inst_t cmd_set_vf_rxmode = {
7883 .f = cmd_set_vf_rxmode_parsed,
7885 .help_str = "set port <port_id> vf <vf_id> rxmode "
7886 "AUPE|ROPE|BAM|MPE on|off",
7888 (void *)&cmd_set_vf_rxmode_set,
7889 (void *)&cmd_set_vf_rxmode_port,
7890 (void *)&cmd_set_vf_rxmode_portid,
7891 (void *)&cmd_set_vf_rxmode_vf,
7892 (void *)&cmd_set_vf_rxmode_vfid,
7893 (void *)&cmd_set_vf_rxmode_what,
7894 (void *)&cmd_set_vf_rxmode_mode,
7895 (void *)&cmd_set_vf_rxmode_on,
7900 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
7901 struct cmd_vf_mac_addr_result {
7902 cmdline_fixed_string_t mac_addr_cmd;
7903 cmdline_fixed_string_t what;
7904 cmdline_fixed_string_t port;
7906 cmdline_fixed_string_t vf;
7908 struct ether_addr address;
7911 static void cmd_vf_mac_addr_parsed(void *parsed_result,
7912 __attribute__((unused)) struct cmdline *cl,
7913 __attribute__((unused)) void *data)
7915 struct cmd_vf_mac_addr_result *res = parsed_result;
7918 if (strcmp(res->what, "add") != 0)
7921 #ifdef RTE_LIBRTE_I40E_PMD
7922 if (ret == -ENOTSUP)
7923 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
7926 #ifdef RTE_LIBRTE_BNXT_PMD
7927 if (ret == -ENOTSUP)
7928 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
7933 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
7937 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
7938 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7939 mac_addr_cmd,"mac_addr");
7940 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
7941 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7943 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
7944 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7946 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
7947 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7949 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
7950 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7952 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
7953 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7955 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
7956 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
7959 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
7960 .f = cmd_vf_mac_addr_parsed,
7962 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
7963 "Add MAC address filtering for a VF on port_id",
7965 (void *)&cmd_vf_mac_addr_cmd,
7966 (void *)&cmd_vf_mac_addr_what,
7967 (void *)&cmd_vf_mac_addr_port,
7968 (void *)&cmd_vf_mac_addr_portnum,
7969 (void *)&cmd_vf_mac_addr_vf,
7970 (void *)&cmd_vf_mac_addr_vfnum,
7971 (void *)&cmd_vf_mac_addr_addr,
7976 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
7977 struct cmd_vf_rx_vlan_filter {
7978 cmdline_fixed_string_t rx_vlan;
7979 cmdline_fixed_string_t what;
7981 cmdline_fixed_string_t port;
7983 cmdline_fixed_string_t vf;
7988 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
7989 __attribute__((unused)) struct cmdline *cl,
7990 __attribute__((unused)) void *data)
7992 struct cmd_vf_rx_vlan_filter *res = parsed_result;
7995 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
7997 #ifdef RTE_LIBRTE_IXGBE_PMD
7998 if (ret == -ENOTSUP)
7999 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8000 res->vlan_id, res->vf_mask, is_add);
8002 #ifdef RTE_LIBRTE_I40E_PMD
8003 if (ret == -ENOTSUP)
8004 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8005 res->vlan_id, res->vf_mask, is_add);
8007 #ifdef RTE_LIBRTE_BNXT_PMD
8008 if (ret == -ENOTSUP)
8009 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8010 res->vlan_id, res->vf_mask, is_add);
8017 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8018 res->vlan_id, res->vf_mask);
8021 printf("invalid port_id %d\n", res->port_id);
8024 printf("function not implemented or supported\n");
8027 printf("programming error: (%s)\n", strerror(-ret));
8031 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8032 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8033 rx_vlan, "rx_vlan");
8034 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8035 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8037 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8038 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8040 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8041 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8043 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8044 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8046 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8047 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8049 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8050 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8053 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8054 .f = cmd_vf_rx_vlan_filter_parsed,
8056 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8057 "(vf_mask = hexadecimal VF mask)",
8059 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8060 (void *)&cmd_vf_rx_vlan_filter_what,
8061 (void *)&cmd_vf_rx_vlan_filter_vlanid,
8062 (void *)&cmd_vf_rx_vlan_filter_port,
8063 (void *)&cmd_vf_rx_vlan_filter_portid,
8064 (void *)&cmd_vf_rx_vlan_filter_vf,
8065 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8070 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8071 struct cmd_queue_rate_limit_result {
8072 cmdline_fixed_string_t set;
8073 cmdline_fixed_string_t port;
8075 cmdline_fixed_string_t queue;
8077 cmdline_fixed_string_t rate;
8081 static void cmd_queue_rate_limit_parsed(void *parsed_result,
8082 __attribute__((unused)) struct cmdline *cl,
8083 __attribute__((unused)) void *data)
8085 struct cmd_queue_rate_limit_result *res = parsed_result;
8088 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8089 && (strcmp(res->queue, "queue") == 0)
8090 && (strcmp(res->rate, "rate") == 0))
8091 ret = set_queue_rate_limit(res->port_num, res->queue_num,
8094 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
8098 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8099 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8101 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8102 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8104 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8105 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8107 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8108 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8110 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8111 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8113 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8114 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8116 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8117 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8120 cmdline_parse_inst_t cmd_queue_rate_limit = {
8121 .f = cmd_queue_rate_limit_parsed,
8123 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8124 "Set rate limit for a queue on port_id",
8126 (void *)&cmd_queue_rate_limit_set,
8127 (void *)&cmd_queue_rate_limit_port,
8128 (void *)&cmd_queue_rate_limit_portnum,
8129 (void *)&cmd_queue_rate_limit_queue,
8130 (void *)&cmd_queue_rate_limit_queuenum,
8131 (void *)&cmd_queue_rate_limit_rate,
8132 (void *)&cmd_queue_rate_limit_ratenum,
8137 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
8138 struct cmd_vf_rate_limit_result {
8139 cmdline_fixed_string_t set;
8140 cmdline_fixed_string_t port;
8142 cmdline_fixed_string_t vf;
8144 cmdline_fixed_string_t rate;
8146 cmdline_fixed_string_t q_msk;
8150 static void cmd_vf_rate_limit_parsed(void *parsed_result,
8151 __attribute__((unused)) struct cmdline *cl,
8152 __attribute__((unused)) void *data)
8154 struct cmd_vf_rate_limit_result *res = parsed_result;
8157 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8158 && (strcmp(res->vf, "vf") == 0)
8159 && (strcmp(res->rate, "rate") == 0)
8160 && (strcmp(res->q_msk, "queue_mask") == 0))
8161 ret = set_vf_rate_limit(res->port_num, res->vf_num,
8162 res->rate_num, res->q_msk_val);
8164 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
8168 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
8169 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8171 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
8172 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8174 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
8175 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8177 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
8178 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8180 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
8181 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8183 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
8184 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8186 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
8187 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8189 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
8190 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8191 q_msk, "queue_mask");
8192 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
8193 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8196 cmdline_parse_inst_t cmd_vf_rate_limit = {
8197 .f = cmd_vf_rate_limit_parsed,
8199 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
8200 "queue_mask <queue_mask_value>: "
8201 "Set rate limit for queues of VF on port_id",
8203 (void *)&cmd_vf_rate_limit_set,
8204 (void *)&cmd_vf_rate_limit_port,
8205 (void *)&cmd_vf_rate_limit_portnum,
8206 (void *)&cmd_vf_rate_limit_vf,
8207 (void *)&cmd_vf_rate_limit_vfnum,
8208 (void *)&cmd_vf_rate_limit_rate,
8209 (void *)&cmd_vf_rate_limit_ratenum,
8210 (void *)&cmd_vf_rate_limit_q_msk,
8211 (void *)&cmd_vf_rate_limit_q_msk_val,
8216 /* *** ADD TUNNEL FILTER OF A PORT *** */
8217 struct cmd_tunnel_filter_result {
8218 cmdline_fixed_string_t cmd;
8219 cmdline_fixed_string_t what;
8221 struct ether_addr outer_mac;
8222 struct ether_addr inner_mac;
8223 cmdline_ipaddr_t ip_value;
8224 uint16_t inner_vlan;
8225 cmdline_fixed_string_t tunnel_type;
8226 cmdline_fixed_string_t filter_type;
8232 cmd_tunnel_filter_parsed(void *parsed_result,
8233 __attribute__((unused)) struct cmdline *cl,
8234 __attribute__((unused)) void *data)
8236 struct cmd_tunnel_filter_result *res = parsed_result;
8237 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
8240 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
8242 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
8243 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
8244 tunnel_filter_conf.inner_vlan = res->inner_vlan;
8246 if (res->ip_value.family == AF_INET) {
8247 tunnel_filter_conf.ip_addr.ipv4_addr =
8248 res->ip_value.addr.ipv4.s_addr;
8249 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
8251 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
8252 &(res->ip_value.addr.ipv6),
8253 sizeof(struct in6_addr));
8254 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
8257 if (!strcmp(res->filter_type, "imac-ivlan"))
8258 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
8259 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
8260 tunnel_filter_conf.filter_type =
8261 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
8262 else if (!strcmp(res->filter_type, "imac-tenid"))
8263 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
8264 else if (!strcmp(res->filter_type, "imac"))
8265 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
8266 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
8267 tunnel_filter_conf.filter_type =
8268 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
8269 else if (!strcmp(res->filter_type, "oip"))
8270 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
8271 else if (!strcmp(res->filter_type, "iip"))
8272 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
8274 printf("The filter type is not supported");
8278 if (!strcmp(res->tunnel_type, "vxlan"))
8279 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
8280 else if (!strcmp(res->tunnel_type, "nvgre"))
8281 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
8282 else if (!strcmp(res->tunnel_type, "ipingre"))
8283 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
8285 printf("The tunnel type %s not supported.\n", res->tunnel_type);
8289 tunnel_filter_conf.tenant_id = res->tenant_id;
8290 tunnel_filter_conf.queue_id = res->queue_num;
8291 if (!strcmp(res->what, "add"))
8292 ret = rte_eth_dev_filter_ctrl(res->port_id,
8293 RTE_ETH_FILTER_TUNNEL,
8295 &tunnel_filter_conf);
8297 ret = rte_eth_dev_filter_ctrl(res->port_id,
8298 RTE_ETH_FILTER_TUNNEL,
8299 RTE_ETH_FILTER_DELETE,
8300 &tunnel_filter_conf);
8302 printf("cmd_tunnel_filter_parsed error: (%s)\n",
8306 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
8307 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8308 cmd, "tunnel_filter");
8309 cmdline_parse_token_string_t cmd_tunnel_filter_what =
8310 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8312 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
8313 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8315 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
8316 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8318 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
8319 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8321 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
8322 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8323 inner_vlan, UINT16);
8324 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
8325 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8327 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
8328 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8329 tunnel_type, "vxlan#nvgre#ipingre");
8331 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
8332 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8333 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
8334 "imac#omac-imac-tenid");
8335 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
8336 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8338 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
8339 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8342 cmdline_parse_inst_t cmd_tunnel_filter = {
8343 .f = cmd_tunnel_filter_parsed,
8345 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
8346 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
8347 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
8348 "<queue_id>: Add/Rm tunnel filter of a port",
8350 (void *)&cmd_tunnel_filter_cmd,
8351 (void *)&cmd_tunnel_filter_what,
8352 (void *)&cmd_tunnel_filter_port_id,
8353 (void *)&cmd_tunnel_filter_outer_mac,
8354 (void *)&cmd_tunnel_filter_inner_mac,
8355 (void *)&cmd_tunnel_filter_ip_value,
8356 (void *)&cmd_tunnel_filter_innner_vlan,
8357 (void *)&cmd_tunnel_filter_tunnel_type,
8358 (void *)&cmd_tunnel_filter_filter_type,
8359 (void *)&cmd_tunnel_filter_tenant_id,
8360 (void *)&cmd_tunnel_filter_queue_num,
8365 /* *** CONFIGURE TUNNEL UDP PORT *** */
8366 struct cmd_tunnel_udp_config {
8367 cmdline_fixed_string_t cmd;
8368 cmdline_fixed_string_t what;
8374 cmd_tunnel_udp_config_parsed(void *parsed_result,
8375 __attribute__((unused)) struct cmdline *cl,
8376 __attribute__((unused)) void *data)
8378 struct cmd_tunnel_udp_config *res = parsed_result;
8379 struct rte_eth_udp_tunnel tunnel_udp;
8382 tunnel_udp.udp_port = res->udp_port;
8384 if (!strcmp(res->cmd, "rx_vxlan_port"))
8385 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8387 if (!strcmp(res->what, "add"))
8388 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8391 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8395 printf("udp tunneling add error: (%s)\n", strerror(-ret));
8398 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
8399 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8400 cmd, "rx_vxlan_port");
8401 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
8402 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8404 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
8405 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8407 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
8408 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8411 cmdline_parse_inst_t cmd_tunnel_udp_config = {
8412 .f = cmd_tunnel_udp_config_parsed,
8414 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
8415 "Add/Remove a tunneling UDP port filter",
8417 (void *)&cmd_tunnel_udp_config_cmd,
8418 (void *)&cmd_tunnel_udp_config_what,
8419 (void *)&cmd_tunnel_udp_config_udp_port,
8420 (void *)&cmd_tunnel_udp_config_port_id,
8425 /* *** GLOBAL CONFIG *** */
8426 struct cmd_global_config_result {
8427 cmdline_fixed_string_t cmd;
8429 cmdline_fixed_string_t cfg_type;
8434 cmd_global_config_parsed(void *parsed_result,
8435 __attribute__((unused)) struct cmdline *cl,
8436 __attribute__((unused)) void *data)
8438 struct cmd_global_config_result *res = parsed_result;
8439 struct rte_eth_global_cfg conf;
8442 memset(&conf, 0, sizeof(conf));
8443 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
8444 conf.cfg.gre_key_len = res->len;
8445 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
8446 RTE_ETH_FILTER_SET, &conf);
8448 printf("Global config error\n");
8451 cmdline_parse_token_string_t cmd_global_config_cmd =
8452 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
8454 cmdline_parse_token_num_t cmd_global_config_port_id =
8455 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
8457 cmdline_parse_token_string_t cmd_global_config_type =
8458 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
8459 cfg_type, "gre-key-len");
8460 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
8461 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
8464 cmdline_parse_inst_t cmd_global_config = {
8465 .f = cmd_global_config_parsed,
8466 .data = (void *)NULL,
8467 .help_str = "global_config <port_id> gre-key-len <key_len>",
8469 (void *)&cmd_global_config_cmd,
8470 (void *)&cmd_global_config_port_id,
8471 (void *)&cmd_global_config_type,
8472 (void *)&cmd_global_config_gre_key_len,
8477 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
8478 struct cmd_set_mirror_mask_result {
8479 cmdline_fixed_string_t set;
8480 cmdline_fixed_string_t port;
8482 cmdline_fixed_string_t mirror;
8484 cmdline_fixed_string_t what;
8485 cmdline_fixed_string_t value;
8486 cmdline_fixed_string_t dstpool;
8488 cmdline_fixed_string_t on;
8491 cmdline_parse_token_string_t cmd_mirror_mask_set =
8492 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8494 cmdline_parse_token_string_t cmd_mirror_mask_port =
8495 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8497 cmdline_parse_token_num_t cmd_mirror_mask_portid =
8498 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8500 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
8501 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8502 mirror, "mirror-rule");
8503 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
8504 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8506 cmdline_parse_token_string_t cmd_mirror_mask_what =
8507 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8508 what, "pool-mirror-up#pool-mirror-down"
8510 cmdline_parse_token_string_t cmd_mirror_mask_value =
8511 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8513 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
8514 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8515 dstpool, "dst-pool");
8516 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
8517 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8519 cmdline_parse_token_string_t cmd_mirror_mask_on =
8520 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8524 cmd_set_mirror_mask_parsed(void *parsed_result,
8525 __attribute__((unused)) struct cmdline *cl,
8526 __attribute__((unused)) void *data)
8529 struct cmd_set_mirror_mask_result *res = parsed_result;
8530 struct rte_eth_mirror_conf mr_conf;
8532 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8534 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
8536 mr_conf.dst_pool = res->dstpool_id;
8538 if (!strcmp(res->what, "pool-mirror-up")) {
8539 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8540 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
8541 } else if (!strcmp(res->what, "pool-mirror-down")) {
8542 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8543 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
8544 } else if (!strcmp(res->what, "vlan-mirror")) {
8545 mr_conf.rule_type = ETH_MIRROR_VLAN;
8546 nb_item = parse_item_list(res->value, "vlan",
8547 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
8551 for (i = 0; i < nb_item; i++) {
8552 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
8553 printf("Invalid vlan_id: must be < 4096\n");
8557 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
8558 mr_conf.vlan.vlan_mask |= 1ULL << i;
8562 if (!strcmp(res->on, "on"))
8563 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8566 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8569 printf("mirror rule add error: (%s)\n", strerror(-ret));
8572 cmdline_parse_inst_t cmd_set_mirror_mask = {
8573 .f = cmd_set_mirror_mask_parsed,
8575 .help_str = "set port <port_id> mirror-rule <rule_id> "
8576 "pool-mirror-up|pool-mirror-down|vlan-mirror "
8577 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
8579 (void *)&cmd_mirror_mask_set,
8580 (void *)&cmd_mirror_mask_port,
8581 (void *)&cmd_mirror_mask_portid,
8582 (void *)&cmd_mirror_mask_mirror,
8583 (void *)&cmd_mirror_mask_ruleid,
8584 (void *)&cmd_mirror_mask_what,
8585 (void *)&cmd_mirror_mask_value,
8586 (void *)&cmd_mirror_mask_dstpool,
8587 (void *)&cmd_mirror_mask_poolid,
8588 (void *)&cmd_mirror_mask_on,
8593 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
8594 struct cmd_set_mirror_link_result {
8595 cmdline_fixed_string_t set;
8596 cmdline_fixed_string_t port;
8598 cmdline_fixed_string_t mirror;
8600 cmdline_fixed_string_t what;
8601 cmdline_fixed_string_t dstpool;
8603 cmdline_fixed_string_t on;
8606 cmdline_parse_token_string_t cmd_mirror_link_set =
8607 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8609 cmdline_parse_token_string_t cmd_mirror_link_port =
8610 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8612 cmdline_parse_token_num_t cmd_mirror_link_portid =
8613 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8615 cmdline_parse_token_string_t cmd_mirror_link_mirror =
8616 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8617 mirror, "mirror-rule");
8618 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
8619 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8621 cmdline_parse_token_string_t cmd_mirror_link_what =
8622 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8623 what, "uplink-mirror#downlink-mirror");
8624 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
8625 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8626 dstpool, "dst-pool");
8627 cmdline_parse_token_num_t cmd_mirror_link_poolid =
8628 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8630 cmdline_parse_token_string_t cmd_mirror_link_on =
8631 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8635 cmd_set_mirror_link_parsed(void *parsed_result,
8636 __attribute__((unused)) struct cmdline *cl,
8637 __attribute__((unused)) void *data)
8640 struct cmd_set_mirror_link_result *res = parsed_result;
8641 struct rte_eth_mirror_conf mr_conf;
8643 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8644 if (!strcmp(res->what, "uplink-mirror"))
8645 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
8647 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
8649 mr_conf.dst_pool = res->dstpool_id;
8651 if (!strcmp(res->on, "on"))
8652 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8655 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8658 /* check the return value and print it if is < 0 */
8660 printf("mirror rule add error: (%s)\n", strerror(-ret));
8664 cmdline_parse_inst_t cmd_set_mirror_link = {
8665 .f = cmd_set_mirror_link_parsed,
8667 .help_str = "set port <port_id> mirror-rule <rule_id> "
8668 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
8670 (void *)&cmd_mirror_link_set,
8671 (void *)&cmd_mirror_link_port,
8672 (void *)&cmd_mirror_link_portid,
8673 (void *)&cmd_mirror_link_mirror,
8674 (void *)&cmd_mirror_link_ruleid,
8675 (void *)&cmd_mirror_link_what,
8676 (void *)&cmd_mirror_link_dstpool,
8677 (void *)&cmd_mirror_link_poolid,
8678 (void *)&cmd_mirror_link_on,
8683 /* *** RESET VM MIRROR RULE *** */
8684 struct cmd_rm_mirror_rule_result {
8685 cmdline_fixed_string_t reset;
8686 cmdline_fixed_string_t port;
8688 cmdline_fixed_string_t mirror;
8692 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
8693 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8695 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
8696 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8698 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
8699 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
8701 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
8702 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8703 mirror, "mirror-rule");
8704 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
8705 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
8709 cmd_reset_mirror_rule_parsed(void *parsed_result,
8710 __attribute__((unused)) struct cmdline *cl,
8711 __attribute__((unused)) void *data)
8714 struct cmd_set_mirror_link_result *res = parsed_result;
8716 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
8718 printf("mirror rule remove error: (%s)\n", strerror(-ret));
8721 cmdline_parse_inst_t cmd_reset_mirror_rule = {
8722 .f = cmd_reset_mirror_rule_parsed,
8724 .help_str = "reset port <port_id> mirror-rule <rule_id>",
8726 (void *)&cmd_rm_mirror_rule_reset,
8727 (void *)&cmd_rm_mirror_rule_port,
8728 (void *)&cmd_rm_mirror_rule_portid,
8729 (void *)&cmd_rm_mirror_rule_mirror,
8730 (void *)&cmd_rm_mirror_rule_ruleid,
8735 /* ******************************************************************************** */
8737 struct cmd_dump_result {
8738 cmdline_fixed_string_t dump;
8742 dump_struct_sizes(void)
8744 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
8745 DUMP_SIZE(struct rte_mbuf);
8746 DUMP_SIZE(struct rte_mempool);
8747 DUMP_SIZE(struct rte_ring);
8751 static void cmd_dump_parsed(void *parsed_result,
8752 __attribute__((unused)) struct cmdline *cl,
8753 __attribute__((unused)) void *data)
8755 struct cmd_dump_result *res = parsed_result;
8757 if (!strcmp(res->dump, "dump_physmem"))
8758 rte_dump_physmem_layout(stdout);
8759 else if (!strcmp(res->dump, "dump_memzone"))
8760 rte_memzone_dump(stdout);
8761 else if (!strcmp(res->dump, "dump_struct_sizes"))
8762 dump_struct_sizes();
8763 else if (!strcmp(res->dump, "dump_ring"))
8764 rte_ring_list_dump(stdout);
8765 else if (!strcmp(res->dump, "dump_mempool"))
8766 rte_mempool_list_dump(stdout);
8767 else if (!strcmp(res->dump, "dump_devargs"))
8768 rte_eal_devargs_dump(stdout);
8769 else if (!strcmp(res->dump, "dump_log_types"))
8770 rte_log_dump(stdout);
8773 cmdline_parse_token_string_t cmd_dump_dump =
8774 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
8777 "dump_struct_sizes#"
8783 cmdline_parse_inst_t cmd_dump = {
8784 .f = cmd_dump_parsed, /* function to call */
8785 .data = NULL, /* 2nd arg of func */
8786 .help_str = "Dump status",
8787 .tokens = { /* token list, NULL terminated */
8788 (void *)&cmd_dump_dump,
8793 /* ******************************************************************************** */
8795 struct cmd_dump_one_result {
8796 cmdline_fixed_string_t dump;
8797 cmdline_fixed_string_t name;
8800 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
8801 __attribute__((unused)) void *data)
8803 struct cmd_dump_one_result *res = parsed_result;
8805 if (!strcmp(res->dump, "dump_ring")) {
8807 r = rte_ring_lookup(res->name);
8809 cmdline_printf(cl, "Cannot find ring\n");
8812 rte_ring_dump(stdout, r);
8813 } else if (!strcmp(res->dump, "dump_mempool")) {
8814 struct rte_mempool *mp;
8815 mp = rte_mempool_lookup(res->name);
8817 cmdline_printf(cl, "Cannot find mempool\n");
8820 rte_mempool_dump(stdout, mp);
8824 cmdline_parse_token_string_t cmd_dump_one_dump =
8825 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
8826 "dump_ring#dump_mempool");
8828 cmdline_parse_token_string_t cmd_dump_one_name =
8829 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
8831 cmdline_parse_inst_t cmd_dump_one = {
8832 .f = cmd_dump_one_parsed, /* function to call */
8833 .data = NULL, /* 2nd arg of func */
8834 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
8835 .tokens = { /* token list, NULL terminated */
8836 (void *)&cmd_dump_one_dump,
8837 (void *)&cmd_dump_one_name,
8842 /* *** Add/Del syn filter *** */
8843 struct cmd_syn_filter_result {
8844 cmdline_fixed_string_t filter;
8846 cmdline_fixed_string_t ops;
8847 cmdline_fixed_string_t priority;
8848 cmdline_fixed_string_t high;
8849 cmdline_fixed_string_t queue;
8854 cmd_syn_filter_parsed(void *parsed_result,
8855 __attribute__((unused)) struct cmdline *cl,
8856 __attribute__((unused)) void *data)
8858 struct cmd_syn_filter_result *res = parsed_result;
8859 struct rte_eth_syn_filter syn_filter;
8862 ret = rte_eth_dev_filter_supported(res->port_id,
8863 RTE_ETH_FILTER_SYN);
8865 printf("syn filter is not supported on port %u.\n",
8870 memset(&syn_filter, 0, sizeof(syn_filter));
8872 if (!strcmp(res->ops, "add")) {
8873 if (!strcmp(res->high, "high"))
8874 syn_filter.hig_pri = 1;
8876 syn_filter.hig_pri = 0;
8878 syn_filter.queue = res->queue_id;
8879 ret = rte_eth_dev_filter_ctrl(res->port_id,
8884 ret = rte_eth_dev_filter_ctrl(res->port_id,
8886 RTE_ETH_FILTER_DELETE,
8890 printf("syn filter programming error: (%s)\n",
8894 cmdline_parse_token_string_t cmd_syn_filter_filter =
8895 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8896 filter, "syn_filter");
8897 cmdline_parse_token_num_t cmd_syn_filter_port_id =
8898 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8900 cmdline_parse_token_string_t cmd_syn_filter_ops =
8901 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8903 cmdline_parse_token_string_t cmd_syn_filter_priority =
8904 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8905 priority, "priority");
8906 cmdline_parse_token_string_t cmd_syn_filter_high =
8907 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8909 cmdline_parse_token_string_t cmd_syn_filter_queue =
8910 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8912 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
8913 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8916 cmdline_parse_inst_t cmd_syn_filter = {
8917 .f = cmd_syn_filter_parsed,
8919 .help_str = "syn_filter <port_id> add|del priority high|low queue "
8920 "<queue_id>: Add/Delete syn filter",
8922 (void *)&cmd_syn_filter_filter,
8923 (void *)&cmd_syn_filter_port_id,
8924 (void *)&cmd_syn_filter_ops,
8925 (void *)&cmd_syn_filter_priority,
8926 (void *)&cmd_syn_filter_high,
8927 (void *)&cmd_syn_filter_queue,
8928 (void *)&cmd_syn_filter_queue_id,
8933 /* *** queue region set *** */
8934 struct cmd_queue_region_result {
8935 cmdline_fixed_string_t set;
8936 cmdline_fixed_string_t port;
8938 cmdline_fixed_string_t cmd;
8939 cmdline_fixed_string_t region;
8941 cmdline_fixed_string_t queue_start_index;
8943 cmdline_fixed_string_t queue_num;
8944 uint8_t queue_num_value;
8948 cmd_queue_region_parsed(void *parsed_result,
8949 __attribute__((unused)) struct cmdline *cl,
8950 __attribute__((unused)) void *data)
8952 struct cmd_queue_region_result *res = parsed_result;
8954 #ifdef RTE_LIBRTE_I40E_PMD
8955 struct rte_pmd_i40e_queue_region_conf region_conf;
8956 enum rte_pmd_i40e_queue_region_op op_type;
8959 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8962 #ifdef RTE_LIBRTE_I40E_PMD
8963 memset(®ion_conf, 0, sizeof(region_conf));
8964 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
8965 region_conf.region_id = res->region_id;
8966 region_conf.queue_num = res->queue_num_value;
8967 region_conf.queue_start_index = res->queue_id;
8969 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8970 op_type, ®ion_conf);
8977 printf("function not implemented or supported\n");
8980 printf("queue region config error: (%s)\n", strerror(-ret));
8984 cmdline_parse_token_string_t cmd_queue_region_set =
8985 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8987 cmdline_parse_token_string_t cmd_queue_region_port =
8988 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
8989 cmdline_parse_token_num_t cmd_queue_region_port_id =
8990 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8992 cmdline_parse_token_string_t cmd_queue_region_cmd =
8993 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8994 cmd, "queue-region");
8995 cmdline_parse_token_string_t cmd_queue_region_id =
8996 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8997 region, "region_id");
8998 cmdline_parse_token_num_t cmd_queue_region_index =
8999 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9001 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9002 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9003 queue_start_index, "queue_start_index");
9004 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9005 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9007 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9008 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9009 queue_num, "queue_num");
9010 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9011 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9012 queue_num_value, UINT8);
9014 cmdline_parse_inst_t cmd_queue_region = {
9015 .f = cmd_queue_region_parsed,
9017 .help_str = "set port <port_id> queue-region region_id <value> "
9018 "queue_start_index <value> queue_num <value>: Set a queue region",
9020 (void *)&cmd_queue_region_set,
9021 (void *)&cmd_queue_region_port,
9022 (void *)&cmd_queue_region_port_id,
9023 (void *)&cmd_queue_region_cmd,
9024 (void *)&cmd_queue_region_id,
9025 (void *)&cmd_queue_region_index,
9026 (void *)&cmd_queue_region_queue_start_index,
9027 (void *)&cmd_queue_region_queue_id,
9028 (void *)&cmd_queue_region_queue_num,
9029 (void *)&cmd_queue_region_queue_num_value,
9034 /* *** queue region and flowtype set *** */
9035 struct cmd_region_flowtype_result {
9036 cmdline_fixed_string_t set;
9037 cmdline_fixed_string_t port;
9039 cmdline_fixed_string_t cmd;
9040 cmdline_fixed_string_t region;
9042 cmdline_fixed_string_t flowtype;
9043 uint8_t flowtype_id;
9047 cmd_region_flowtype_parsed(void *parsed_result,
9048 __attribute__((unused)) struct cmdline *cl,
9049 __attribute__((unused)) void *data)
9051 struct cmd_region_flowtype_result *res = parsed_result;
9053 #ifdef RTE_LIBRTE_I40E_PMD
9054 struct rte_pmd_i40e_queue_region_conf region_conf;
9055 enum rte_pmd_i40e_queue_region_op op_type;
9058 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9061 #ifdef RTE_LIBRTE_I40E_PMD
9062 memset(®ion_conf, 0, sizeof(region_conf));
9064 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9065 region_conf.region_id = res->region_id;
9066 region_conf.hw_flowtype = res->flowtype_id;
9068 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9069 op_type, ®ion_conf);
9076 printf("function not implemented or supported\n");
9079 printf("region flowtype config error: (%s)\n", strerror(-ret));
9083 cmdline_parse_token_string_t cmd_region_flowtype_set =
9084 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9086 cmdline_parse_token_string_t cmd_region_flowtype_port =
9087 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9089 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9090 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9092 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9093 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9094 cmd, "queue-region");
9095 cmdline_parse_token_string_t cmd_region_flowtype_index =
9096 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9097 region, "region_id");
9098 cmdline_parse_token_num_t cmd_region_flowtype_id =
9099 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9101 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
9102 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9103 flowtype, "flowtype");
9104 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
9105 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9106 flowtype_id, UINT8);
9107 cmdline_parse_inst_t cmd_region_flowtype = {
9108 .f = cmd_region_flowtype_parsed,
9110 .help_str = "set port <port_id> queue-region region_id <value> "
9111 "flowtype <value>: Set a flowtype region index",
9113 (void *)&cmd_region_flowtype_set,
9114 (void *)&cmd_region_flowtype_port,
9115 (void *)&cmd_region_flowtype_port_index,
9116 (void *)&cmd_region_flowtype_cmd,
9117 (void *)&cmd_region_flowtype_index,
9118 (void *)&cmd_region_flowtype_id,
9119 (void *)&cmd_region_flowtype_flow_index,
9120 (void *)&cmd_region_flowtype_flow_id,
9125 /* *** User Priority (UP) to queue region (region_id) set *** */
9126 struct cmd_user_priority_region_result {
9127 cmdline_fixed_string_t set;
9128 cmdline_fixed_string_t port;
9130 cmdline_fixed_string_t cmd;
9131 cmdline_fixed_string_t user_priority;
9132 uint8_t user_priority_id;
9133 cmdline_fixed_string_t region;
9138 cmd_user_priority_region_parsed(void *parsed_result,
9139 __attribute__((unused)) struct cmdline *cl,
9140 __attribute__((unused)) void *data)
9142 struct cmd_user_priority_region_result *res = parsed_result;
9144 #ifdef RTE_LIBRTE_I40E_PMD
9145 struct rte_pmd_i40e_queue_region_conf region_conf;
9146 enum rte_pmd_i40e_queue_region_op op_type;
9149 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9152 #ifdef RTE_LIBRTE_I40E_PMD
9153 memset(®ion_conf, 0, sizeof(region_conf));
9154 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
9155 region_conf.user_priority = res->user_priority_id;
9156 region_conf.region_id = res->region_id;
9158 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9159 op_type, ®ion_conf);
9166 printf("function not implemented or supported\n");
9169 printf("user_priority region config error: (%s)\n",
9174 cmdline_parse_token_string_t cmd_user_priority_region_set =
9175 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9177 cmdline_parse_token_string_t cmd_user_priority_region_port =
9178 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9180 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
9181 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9183 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
9184 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9185 cmd, "queue-region");
9186 cmdline_parse_token_string_t cmd_user_priority_region_UP =
9187 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9188 user_priority, "UP");
9189 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
9190 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9191 user_priority_id, UINT8);
9192 cmdline_parse_token_string_t cmd_user_priority_region_region =
9193 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9194 region, "region_id");
9195 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
9196 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9199 cmdline_parse_inst_t cmd_user_priority_region = {
9200 .f = cmd_user_priority_region_parsed,
9202 .help_str = "set port <port_id> queue-region UP <value> "
9203 "region_id <value>: Set the mapping of User Priority (UP) "
9204 "to queue region (region_id) ",
9206 (void *)&cmd_user_priority_region_set,
9207 (void *)&cmd_user_priority_region_port,
9208 (void *)&cmd_user_priority_region_port_index,
9209 (void *)&cmd_user_priority_region_cmd,
9210 (void *)&cmd_user_priority_region_UP,
9211 (void *)&cmd_user_priority_region_UP_id,
9212 (void *)&cmd_user_priority_region_region,
9213 (void *)&cmd_user_priority_region_region_id,
9218 /* *** flush all queue region related configuration *** */
9219 struct cmd_flush_queue_region_result {
9220 cmdline_fixed_string_t set;
9221 cmdline_fixed_string_t port;
9223 cmdline_fixed_string_t cmd;
9224 cmdline_fixed_string_t flush;
9225 cmdline_fixed_string_t what;
9229 cmd_flush_queue_region_parsed(void *parsed_result,
9230 __attribute__((unused)) struct cmdline *cl,
9231 __attribute__((unused)) void *data)
9233 struct cmd_flush_queue_region_result *res = parsed_result;
9235 #ifdef RTE_LIBRTE_I40E_PMD
9236 struct rte_pmd_i40e_queue_region_conf region_conf;
9237 enum rte_pmd_i40e_queue_region_op op_type;
9240 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9243 #ifdef RTE_LIBRTE_I40E_PMD
9244 memset(®ion_conf, 0, sizeof(region_conf));
9246 if (strcmp(res->what, "on") == 0)
9247 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
9249 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
9251 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9252 op_type, ®ion_conf);
9259 printf("function not implemented or supported\n");
9262 printf("queue region config flush error: (%s)\n",
9267 cmdline_parse_token_string_t cmd_flush_queue_region_set =
9268 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9270 cmdline_parse_token_string_t cmd_flush_queue_region_port =
9271 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9273 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
9274 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
9276 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
9277 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9278 cmd, "queue-region");
9279 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
9280 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9282 cmdline_parse_token_string_t cmd_flush_queue_region_what =
9283 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9286 cmdline_parse_inst_t cmd_flush_queue_region = {
9287 .f = cmd_flush_queue_region_parsed,
9289 .help_str = "set port <port_id> queue-region flush on|off"
9290 ": flush all queue region related configuration",
9292 (void *)&cmd_flush_queue_region_set,
9293 (void *)&cmd_flush_queue_region_port,
9294 (void *)&cmd_flush_queue_region_port_index,
9295 (void *)&cmd_flush_queue_region_cmd,
9296 (void *)&cmd_flush_queue_region_flush,
9297 (void *)&cmd_flush_queue_region_what,
9302 /* *** get all queue region related configuration info *** */
9303 struct cmd_show_queue_region_info {
9304 cmdline_fixed_string_t show;
9305 cmdline_fixed_string_t port;
9307 cmdline_fixed_string_t cmd;
9311 cmd_show_queue_region_info_parsed(void *parsed_result,
9312 __attribute__((unused)) struct cmdline *cl,
9313 __attribute__((unused)) void *data)
9315 struct cmd_show_queue_region_info *res = parsed_result;
9317 #ifdef RTE_LIBRTE_I40E_PMD
9318 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
9319 enum rte_pmd_i40e_queue_region_op op_type;
9322 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9325 #ifdef RTE_LIBRTE_I40E_PMD
9326 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
9328 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
9330 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9331 op_type, &rte_pmd_regions);
9333 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
9340 printf("function not implemented or supported\n");
9343 printf("queue region config info show error: (%s)\n",
9348 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
9349 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9351 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
9352 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9354 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
9355 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
9357 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
9358 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9359 cmd, "queue-region");
9361 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
9362 .f = cmd_show_queue_region_info_parsed,
9364 .help_str = "show port <port_id> queue-region"
9365 ": show all queue region related configuration info",
9367 (void *)&cmd_show_queue_region_info_get,
9368 (void *)&cmd_show_queue_region_info_port,
9369 (void *)&cmd_show_queue_region_info_port_index,
9370 (void *)&cmd_show_queue_region_info_cmd,
9375 /* *** ADD/REMOVE A 2tuple FILTER *** */
9376 struct cmd_2tuple_filter_result {
9377 cmdline_fixed_string_t filter;
9379 cmdline_fixed_string_t ops;
9380 cmdline_fixed_string_t dst_port;
9381 uint16_t dst_port_value;
9382 cmdline_fixed_string_t protocol;
9383 uint8_t protocol_value;
9384 cmdline_fixed_string_t mask;
9386 cmdline_fixed_string_t tcp_flags;
9387 uint8_t tcp_flags_value;
9388 cmdline_fixed_string_t priority;
9389 uint8_t priority_value;
9390 cmdline_fixed_string_t queue;
9395 cmd_2tuple_filter_parsed(void *parsed_result,
9396 __attribute__((unused)) struct cmdline *cl,
9397 __attribute__((unused)) void *data)
9399 struct rte_eth_ntuple_filter filter;
9400 struct cmd_2tuple_filter_result *res = parsed_result;
9403 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9405 printf("ntuple filter is not supported on port %u.\n",
9410 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9412 filter.flags = RTE_2TUPLE_FLAGS;
9413 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9414 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9415 filter.proto = res->protocol_value;
9416 filter.priority = res->priority_value;
9417 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9418 printf("nonzero tcp_flags is only meaningful"
9419 " when protocol is TCP.\n");
9422 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9423 printf("invalid TCP flags.\n");
9427 if (res->tcp_flags_value != 0) {
9428 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9429 filter.tcp_flags = res->tcp_flags_value;
9432 /* need convert to big endian. */
9433 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9434 filter.queue = res->queue_id;
9436 if (!strcmp(res->ops, "add"))
9437 ret = rte_eth_dev_filter_ctrl(res->port_id,
9438 RTE_ETH_FILTER_NTUPLE,
9442 ret = rte_eth_dev_filter_ctrl(res->port_id,
9443 RTE_ETH_FILTER_NTUPLE,
9444 RTE_ETH_FILTER_DELETE,
9447 printf("2tuple filter programming error: (%s)\n",
9452 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
9453 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9454 filter, "2tuple_filter");
9455 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
9456 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9458 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
9459 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9461 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
9462 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9463 dst_port, "dst_port");
9464 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
9465 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9466 dst_port_value, UINT16);
9467 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
9468 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9469 protocol, "protocol");
9470 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
9471 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9472 protocol_value, UINT8);
9473 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
9474 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9476 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
9477 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9479 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
9480 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9481 tcp_flags, "tcp_flags");
9482 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
9483 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9484 tcp_flags_value, UINT8);
9485 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
9486 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9487 priority, "priority");
9488 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
9489 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9490 priority_value, UINT8);
9491 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
9492 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9494 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
9495 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9498 cmdline_parse_inst_t cmd_2tuple_filter = {
9499 .f = cmd_2tuple_filter_parsed,
9501 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
9502 "<value> mask <value> tcp_flags <value> priority <value> queue "
9503 "<queue_id>: Add a 2tuple filter",
9505 (void *)&cmd_2tuple_filter_filter,
9506 (void *)&cmd_2tuple_filter_port_id,
9507 (void *)&cmd_2tuple_filter_ops,
9508 (void *)&cmd_2tuple_filter_dst_port,
9509 (void *)&cmd_2tuple_filter_dst_port_value,
9510 (void *)&cmd_2tuple_filter_protocol,
9511 (void *)&cmd_2tuple_filter_protocol_value,
9512 (void *)&cmd_2tuple_filter_mask,
9513 (void *)&cmd_2tuple_filter_mask_value,
9514 (void *)&cmd_2tuple_filter_tcp_flags,
9515 (void *)&cmd_2tuple_filter_tcp_flags_value,
9516 (void *)&cmd_2tuple_filter_priority,
9517 (void *)&cmd_2tuple_filter_priority_value,
9518 (void *)&cmd_2tuple_filter_queue,
9519 (void *)&cmd_2tuple_filter_queue_id,
9524 /* *** ADD/REMOVE A 5tuple FILTER *** */
9525 struct cmd_5tuple_filter_result {
9526 cmdline_fixed_string_t filter;
9528 cmdline_fixed_string_t ops;
9529 cmdline_fixed_string_t dst_ip;
9530 cmdline_ipaddr_t dst_ip_value;
9531 cmdline_fixed_string_t src_ip;
9532 cmdline_ipaddr_t src_ip_value;
9533 cmdline_fixed_string_t dst_port;
9534 uint16_t dst_port_value;
9535 cmdline_fixed_string_t src_port;
9536 uint16_t src_port_value;
9537 cmdline_fixed_string_t protocol;
9538 uint8_t protocol_value;
9539 cmdline_fixed_string_t mask;
9541 cmdline_fixed_string_t tcp_flags;
9542 uint8_t tcp_flags_value;
9543 cmdline_fixed_string_t priority;
9544 uint8_t priority_value;
9545 cmdline_fixed_string_t queue;
9550 cmd_5tuple_filter_parsed(void *parsed_result,
9551 __attribute__((unused)) struct cmdline *cl,
9552 __attribute__((unused)) void *data)
9554 struct rte_eth_ntuple_filter filter;
9555 struct cmd_5tuple_filter_result *res = parsed_result;
9558 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9560 printf("ntuple filter is not supported on port %u.\n",
9565 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9567 filter.flags = RTE_5TUPLE_FLAGS;
9568 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
9569 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
9570 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
9571 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9572 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9573 filter.proto = res->protocol_value;
9574 filter.priority = res->priority_value;
9575 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9576 printf("nonzero tcp_flags is only meaningful"
9577 " when protocol is TCP.\n");
9580 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9581 printf("invalid TCP flags.\n");
9585 if (res->tcp_flags_value != 0) {
9586 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9587 filter.tcp_flags = res->tcp_flags_value;
9590 if (res->dst_ip_value.family == AF_INET)
9591 /* no need to convert, already big endian. */
9592 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
9594 if (filter.dst_ip_mask == 0) {
9595 printf("can not support ipv6 involved compare.\n");
9601 if (res->src_ip_value.family == AF_INET)
9602 /* no need to convert, already big endian. */
9603 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
9605 if (filter.src_ip_mask == 0) {
9606 printf("can not support ipv6 involved compare.\n");
9611 /* need convert to big endian. */
9612 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9613 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
9614 filter.queue = res->queue_id;
9616 if (!strcmp(res->ops, "add"))
9617 ret = rte_eth_dev_filter_ctrl(res->port_id,
9618 RTE_ETH_FILTER_NTUPLE,
9622 ret = rte_eth_dev_filter_ctrl(res->port_id,
9623 RTE_ETH_FILTER_NTUPLE,
9624 RTE_ETH_FILTER_DELETE,
9627 printf("5tuple filter programming error: (%s)\n",
9631 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
9632 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9633 filter, "5tuple_filter");
9634 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
9635 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9637 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
9638 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9640 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
9641 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9643 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
9644 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9646 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
9647 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9649 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
9650 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9652 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
9653 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9654 dst_port, "dst_port");
9655 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
9656 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9657 dst_port_value, UINT16);
9658 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
9659 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9660 src_port, "src_port");
9661 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
9662 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9663 src_port_value, UINT16);
9664 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
9665 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9666 protocol, "protocol");
9667 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
9668 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9669 protocol_value, UINT8);
9670 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
9671 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9673 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
9674 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9676 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
9677 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9678 tcp_flags, "tcp_flags");
9679 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
9680 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9681 tcp_flags_value, UINT8);
9682 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
9683 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9684 priority, "priority");
9685 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
9686 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9687 priority_value, UINT8);
9688 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
9689 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9691 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
9692 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9695 cmdline_parse_inst_t cmd_5tuple_filter = {
9696 .f = cmd_5tuple_filter_parsed,
9698 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
9699 "src_ip <value> dst_port <value> src_port <value> "
9700 "protocol <value> mask <value> tcp_flags <value> "
9701 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
9703 (void *)&cmd_5tuple_filter_filter,
9704 (void *)&cmd_5tuple_filter_port_id,
9705 (void *)&cmd_5tuple_filter_ops,
9706 (void *)&cmd_5tuple_filter_dst_ip,
9707 (void *)&cmd_5tuple_filter_dst_ip_value,
9708 (void *)&cmd_5tuple_filter_src_ip,
9709 (void *)&cmd_5tuple_filter_src_ip_value,
9710 (void *)&cmd_5tuple_filter_dst_port,
9711 (void *)&cmd_5tuple_filter_dst_port_value,
9712 (void *)&cmd_5tuple_filter_src_port,
9713 (void *)&cmd_5tuple_filter_src_port_value,
9714 (void *)&cmd_5tuple_filter_protocol,
9715 (void *)&cmd_5tuple_filter_protocol_value,
9716 (void *)&cmd_5tuple_filter_mask,
9717 (void *)&cmd_5tuple_filter_mask_value,
9718 (void *)&cmd_5tuple_filter_tcp_flags,
9719 (void *)&cmd_5tuple_filter_tcp_flags_value,
9720 (void *)&cmd_5tuple_filter_priority,
9721 (void *)&cmd_5tuple_filter_priority_value,
9722 (void *)&cmd_5tuple_filter_queue,
9723 (void *)&cmd_5tuple_filter_queue_id,
9728 /* *** ADD/REMOVE A flex FILTER *** */
9729 struct cmd_flex_filter_result {
9730 cmdline_fixed_string_t filter;
9731 cmdline_fixed_string_t ops;
9733 cmdline_fixed_string_t len;
9735 cmdline_fixed_string_t bytes;
9736 cmdline_fixed_string_t bytes_value;
9737 cmdline_fixed_string_t mask;
9738 cmdline_fixed_string_t mask_value;
9739 cmdline_fixed_string_t priority;
9740 uint8_t priority_value;
9741 cmdline_fixed_string_t queue;
9745 static int xdigit2val(unsigned char c)
9750 else if (isupper(c))
9758 cmd_flex_filter_parsed(void *parsed_result,
9759 __attribute__((unused)) struct cmdline *cl,
9760 __attribute__((unused)) void *data)
9763 struct rte_eth_flex_filter filter;
9764 struct cmd_flex_filter_result *res = parsed_result;
9765 char *bytes_ptr, *mask_ptr;
9766 uint16_t len, i, j = 0;
9771 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
9772 printf("the len exceed the max length 128\n");
9775 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
9776 filter.len = res->len_value;
9777 filter.priority = res->priority_value;
9778 filter.queue = res->queue_id;
9779 bytes_ptr = res->bytes_value;
9780 mask_ptr = res->mask_value;
9782 /* translate bytes string to array. */
9783 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
9784 (bytes_ptr[1] == 'X')))
9786 len = strnlen(bytes_ptr, res->len_value * 2);
9787 if (len == 0 || (len % 8 != 0)) {
9788 printf("please check len and bytes input\n");
9791 for (i = 0; i < len; i++) {
9793 if (isxdigit(c) == 0) {
9794 /* invalid characters. */
9795 printf("invalid input\n");
9798 val = xdigit2val(c);
9801 filter.bytes[j] = byte;
9802 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
9809 /* translate mask string to uint8_t array. */
9810 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
9811 (mask_ptr[1] == 'X')))
9813 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
9815 printf("invalid input\n");
9820 for (i = 0; i < len; i++) {
9822 if (isxdigit(c) == 0) {
9823 /* invalid characters. */
9824 printf("invalid input\n");
9827 val = xdigit2val(c);
9830 filter.mask[j] = byte;
9831 printf("mask[%d]:%02x ", j, filter.mask[j]);
9839 if (!strcmp(res->ops, "add"))
9840 ret = rte_eth_dev_filter_ctrl(res->port_id,
9841 RTE_ETH_FILTER_FLEXIBLE,
9845 ret = rte_eth_dev_filter_ctrl(res->port_id,
9846 RTE_ETH_FILTER_FLEXIBLE,
9847 RTE_ETH_FILTER_DELETE,
9851 printf("flex filter setting error: (%s)\n", strerror(-ret));
9854 cmdline_parse_token_string_t cmd_flex_filter_filter =
9855 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9856 filter, "flex_filter");
9857 cmdline_parse_token_num_t cmd_flex_filter_port_id =
9858 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9860 cmdline_parse_token_string_t cmd_flex_filter_ops =
9861 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9863 cmdline_parse_token_string_t cmd_flex_filter_len =
9864 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9866 cmdline_parse_token_num_t cmd_flex_filter_len_value =
9867 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9869 cmdline_parse_token_string_t cmd_flex_filter_bytes =
9870 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9872 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
9873 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9875 cmdline_parse_token_string_t cmd_flex_filter_mask =
9876 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9878 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
9879 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9881 cmdline_parse_token_string_t cmd_flex_filter_priority =
9882 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9883 priority, "priority");
9884 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
9885 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9886 priority_value, UINT8);
9887 cmdline_parse_token_string_t cmd_flex_filter_queue =
9888 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9890 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
9891 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9893 cmdline_parse_inst_t cmd_flex_filter = {
9894 .f = cmd_flex_filter_parsed,
9896 .help_str = "flex_filter <port_id> add|del len <value> bytes "
9897 "<value> mask <value> priority <value> queue <queue_id>: "
9898 "Add/Del a flex filter",
9900 (void *)&cmd_flex_filter_filter,
9901 (void *)&cmd_flex_filter_port_id,
9902 (void *)&cmd_flex_filter_ops,
9903 (void *)&cmd_flex_filter_len,
9904 (void *)&cmd_flex_filter_len_value,
9905 (void *)&cmd_flex_filter_bytes,
9906 (void *)&cmd_flex_filter_bytes_value,
9907 (void *)&cmd_flex_filter_mask,
9908 (void *)&cmd_flex_filter_mask_value,
9909 (void *)&cmd_flex_filter_priority,
9910 (void *)&cmd_flex_filter_priority_value,
9911 (void *)&cmd_flex_filter_queue,
9912 (void *)&cmd_flex_filter_queue_id,
9917 /* *** Filters Control *** */
9919 /* *** deal with ethertype filter *** */
9920 struct cmd_ethertype_filter_result {
9921 cmdline_fixed_string_t filter;
9923 cmdline_fixed_string_t ops;
9924 cmdline_fixed_string_t mac;
9925 struct ether_addr mac_addr;
9926 cmdline_fixed_string_t ethertype;
9927 uint16_t ethertype_value;
9928 cmdline_fixed_string_t drop;
9929 cmdline_fixed_string_t queue;
9933 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
9934 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9935 filter, "ethertype_filter");
9936 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
9937 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9939 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
9940 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9942 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
9943 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9944 mac, "mac_addr#mac_ignr");
9945 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
9946 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
9948 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
9949 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9950 ethertype, "ethertype");
9951 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
9952 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9953 ethertype_value, UINT16);
9954 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
9955 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9957 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
9958 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9960 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
9961 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9965 cmd_ethertype_filter_parsed(void *parsed_result,
9966 __attribute__((unused)) struct cmdline *cl,
9967 __attribute__((unused)) void *data)
9969 struct cmd_ethertype_filter_result *res = parsed_result;
9970 struct rte_eth_ethertype_filter filter;
9973 ret = rte_eth_dev_filter_supported(res->port_id,
9974 RTE_ETH_FILTER_ETHERTYPE);
9976 printf("ethertype filter is not supported on port %u.\n",
9981 memset(&filter, 0, sizeof(filter));
9982 if (!strcmp(res->mac, "mac_addr")) {
9983 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
9984 rte_memcpy(&filter.mac_addr, &res->mac_addr,
9985 sizeof(struct ether_addr));
9987 if (!strcmp(res->drop, "drop"))
9988 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
9989 filter.ether_type = res->ethertype_value;
9990 filter.queue = res->queue_id;
9992 if (!strcmp(res->ops, "add"))
9993 ret = rte_eth_dev_filter_ctrl(res->port_id,
9994 RTE_ETH_FILTER_ETHERTYPE,
9998 ret = rte_eth_dev_filter_ctrl(res->port_id,
9999 RTE_ETH_FILTER_ETHERTYPE,
10000 RTE_ETH_FILTER_DELETE,
10003 printf("ethertype filter programming error: (%s)\n",
10007 cmdline_parse_inst_t cmd_ethertype_filter = {
10008 .f = cmd_ethertype_filter_parsed,
10010 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
10011 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
10012 "Add or delete an ethertype filter entry",
10014 (void *)&cmd_ethertype_filter_filter,
10015 (void *)&cmd_ethertype_filter_port_id,
10016 (void *)&cmd_ethertype_filter_ops,
10017 (void *)&cmd_ethertype_filter_mac,
10018 (void *)&cmd_ethertype_filter_mac_addr,
10019 (void *)&cmd_ethertype_filter_ethertype,
10020 (void *)&cmd_ethertype_filter_ethertype_value,
10021 (void *)&cmd_ethertype_filter_drop,
10022 (void *)&cmd_ethertype_filter_queue,
10023 (void *)&cmd_ethertype_filter_queue_id,
10028 /* *** deal with flow director filter *** */
10029 struct cmd_flow_director_result {
10030 cmdline_fixed_string_t flow_director_filter;
10032 cmdline_fixed_string_t mode;
10033 cmdline_fixed_string_t mode_value;
10034 cmdline_fixed_string_t ops;
10035 cmdline_fixed_string_t flow;
10036 cmdline_fixed_string_t flow_type;
10037 cmdline_fixed_string_t ether;
10038 uint16_t ether_type;
10039 cmdline_fixed_string_t src;
10040 cmdline_ipaddr_t ip_src;
10042 cmdline_fixed_string_t dst;
10043 cmdline_ipaddr_t ip_dst;
10045 cmdline_fixed_string_t verify_tag;
10046 uint32_t verify_tag_value;
10047 cmdline_fixed_string_t tos;
10049 cmdline_fixed_string_t proto;
10050 uint8_t proto_value;
10051 cmdline_fixed_string_t ttl;
10053 cmdline_fixed_string_t vlan;
10054 uint16_t vlan_value;
10055 cmdline_fixed_string_t flexbytes;
10056 cmdline_fixed_string_t flexbytes_value;
10057 cmdline_fixed_string_t pf_vf;
10058 cmdline_fixed_string_t drop;
10059 cmdline_fixed_string_t queue;
10061 cmdline_fixed_string_t fd_id;
10062 uint32_t fd_id_value;
10063 cmdline_fixed_string_t mac;
10064 struct ether_addr mac_addr;
10065 cmdline_fixed_string_t tunnel;
10066 cmdline_fixed_string_t tunnel_type;
10067 cmdline_fixed_string_t tunnel_id;
10068 uint32_t tunnel_id_value;
10069 cmdline_fixed_string_t packet;
10074 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
10077 const char *p, *p0 = q_arg;
10079 unsigned long int_fld;
10080 char *str_fld[max_num];
10085 p = strchr(p0, '(');
10089 p0 = strchr(p, ')');
10094 if (size >= sizeof(s))
10097 snprintf(s, sizeof(s), "%.*s", size, p);
10098 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10099 if (ret < 0 || ret > max_num)
10101 for (i = 0; i < ret; i++) {
10103 int_fld = strtoul(str_fld[i], &end, 0);
10104 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
10106 flexbytes[i] = (uint8_t)int_fld;
10112 str2flowtype(char *string)
10115 static const struct {
10118 } flowtype_str[] = {
10119 {"raw", RTE_ETH_FLOW_RAW},
10120 {"ipv4", RTE_ETH_FLOW_IPV4},
10121 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10122 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10123 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10124 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10125 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10126 {"ipv6", RTE_ETH_FLOW_IPV6},
10127 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10128 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10129 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10130 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10131 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10132 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10135 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10136 if (!strcmp(flowtype_str[i].str, string))
10137 return flowtype_str[i].type;
10140 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10141 return (uint16_t)atoi(string);
10143 return RTE_ETH_FLOW_UNKNOWN;
10146 static enum rte_eth_fdir_tunnel_type
10147 str2fdir_tunneltype(char *string)
10151 static const struct {
10153 enum rte_eth_fdir_tunnel_type type;
10154 } tunneltype_str[] = {
10155 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
10156 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
10159 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
10160 if (!strcmp(tunneltype_str[i].str, string))
10161 return tunneltype_str[i].type;
10163 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
10166 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10168 if ((ip_addr).family == AF_INET) \
10169 (ip) = (ip_addr).addr.ipv4.s_addr; \
10171 printf("invalid parameter.\n"); \
10176 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10178 if ((ip_addr).family == AF_INET6) \
10179 rte_memcpy(&(ip), \
10180 &((ip_addr).addr.ipv6), \
10181 sizeof(struct in6_addr)); \
10183 printf("invalid parameter.\n"); \
10189 cmd_flow_director_filter_parsed(void *parsed_result,
10190 __attribute__((unused)) struct cmdline *cl,
10191 __attribute__((unused)) void *data)
10193 struct cmd_flow_director_result *res = parsed_result;
10194 struct rte_eth_fdir_filter entry;
10195 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
10197 unsigned long vf_id;
10200 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10202 printf("flow director is not supported on port %u.\n",
10206 memset(flexbytes, 0, sizeof(flexbytes));
10207 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
10209 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10210 if (strcmp(res->mode_value, "MAC-VLAN")) {
10211 printf("Please set mode to MAC-VLAN.\n");
10214 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10215 if (strcmp(res->mode_value, "Tunnel")) {
10216 printf("Please set mode to Tunnel.\n");
10220 if (!strcmp(res->mode_value, "raw")) {
10221 #ifdef RTE_LIBRTE_I40E_PMD
10222 struct rte_pmd_i40e_flow_type_mapping
10223 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10224 struct rte_pmd_i40e_pkt_template_conf conf;
10225 uint16_t flow_type = str2flowtype(res->flow_type);
10226 uint16_t i, port = res->port_id;
10229 memset(&conf, 0, sizeof(conf));
10231 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10232 printf("Invalid flow type specified.\n");
10235 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10239 if (mapping[flow_type].pctype == 0ULL) {
10240 printf("Invalid flow type specified.\n");
10243 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10244 if (mapping[flow_type].pctype & (1ULL << i)) {
10245 conf.input.pctype = i;
10250 conf.input.packet = open_file(res->filepath,
10251 &conf.input.length);
10252 if (!conf.input.packet)
10254 if (!strcmp(res->drop, "drop"))
10255 conf.action.behavior =
10256 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10258 conf.action.behavior =
10259 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10260 conf.action.report_status =
10261 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10262 conf.action.rx_queue = res->queue_id;
10263 conf.soft_id = res->fd_id_value;
10264 add = strcmp(res->ops, "del") ? 1 : 0;
10265 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10269 printf("flow director config error: (%s)\n",
10271 close_file(conf.input.packet);
10274 } else if (strcmp(res->mode_value, "IP")) {
10275 printf("Please set mode to IP or raw.\n");
10278 entry.input.flow_type = str2flowtype(res->flow_type);
10281 ret = parse_flexbytes(res->flexbytes_value,
10283 RTE_ETH_FDIR_MAX_FLEXLEN);
10285 printf("error: Cannot parse flexbytes input.\n");
10289 switch (entry.input.flow_type) {
10290 case RTE_ETH_FLOW_FRAG_IPV4:
10291 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
10292 entry.input.flow.ip4_flow.proto = res->proto_value;
10294 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
10295 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
10296 IPV4_ADDR_TO_UINT(res->ip_dst,
10297 entry.input.flow.ip4_flow.dst_ip);
10298 IPV4_ADDR_TO_UINT(res->ip_src,
10299 entry.input.flow.ip4_flow.src_ip);
10300 entry.input.flow.ip4_flow.tos = res->tos_value;
10301 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10302 /* need convert to big endian. */
10303 entry.input.flow.udp4_flow.dst_port =
10304 rte_cpu_to_be_16(res->port_dst);
10305 entry.input.flow.udp4_flow.src_port =
10306 rte_cpu_to_be_16(res->port_src);
10308 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
10309 IPV4_ADDR_TO_UINT(res->ip_dst,
10310 entry.input.flow.sctp4_flow.ip.dst_ip);
10311 IPV4_ADDR_TO_UINT(res->ip_src,
10312 entry.input.flow.sctp4_flow.ip.src_ip);
10313 entry.input.flow.ip4_flow.tos = res->tos_value;
10314 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10315 /* need convert to big endian. */
10316 entry.input.flow.sctp4_flow.dst_port =
10317 rte_cpu_to_be_16(res->port_dst);
10318 entry.input.flow.sctp4_flow.src_port =
10319 rte_cpu_to_be_16(res->port_src);
10320 entry.input.flow.sctp4_flow.verify_tag =
10321 rte_cpu_to_be_32(res->verify_tag_value);
10323 case RTE_ETH_FLOW_FRAG_IPV6:
10324 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
10325 entry.input.flow.ipv6_flow.proto = res->proto_value;
10327 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
10328 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
10329 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10330 entry.input.flow.ipv6_flow.dst_ip);
10331 IPV6_ADDR_TO_ARRAY(res->ip_src,
10332 entry.input.flow.ipv6_flow.src_ip);
10333 entry.input.flow.ipv6_flow.tc = res->tos_value;
10334 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10335 /* need convert to big endian. */
10336 entry.input.flow.udp6_flow.dst_port =
10337 rte_cpu_to_be_16(res->port_dst);
10338 entry.input.flow.udp6_flow.src_port =
10339 rte_cpu_to_be_16(res->port_src);
10341 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
10342 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10343 entry.input.flow.sctp6_flow.ip.dst_ip);
10344 IPV6_ADDR_TO_ARRAY(res->ip_src,
10345 entry.input.flow.sctp6_flow.ip.src_ip);
10346 entry.input.flow.ipv6_flow.tc = res->tos_value;
10347 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10348 /* need convert to big endian. */
10349 entry.input.flow.sctp6_flow.dst_port =
10350 rte_cpu_to_be_16(res->port_dst);
10351 entry.input.flow.sctp6_flow.src_port =
10352 rte_cpu_to_be_16(res->port_src);
10353 entry.input.flow.sctp6_flow.verify_tag =
10354 rte_cpu_to_be_32(res->verify_tag_value);
10356 case RTE_ETH_FLOW_L2_PAYLOAD:
10357 entry.input.flow.l2_flow.ether_type =
10358 rte_cpu_to_be_16(res->ether_type);
10364 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
10365 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
10367 sizeof(struct ether_addr));
10369 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10370 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
10372 sizeof(struct ether_addr));
10373 entry.input.flow.tunnel_flow.tunnel_type =
10374 str2fdir_tunneltype(res->tunnel_type);
10375 entry.input.flow.tunnel_flow.tunnel_id =
10376 rte_cpu_to_be_32(res->tunnel_id_value);
10379 rte_memcpy(entry.input.flow_ext.flexbytes,
10381 RTE_ETH_FDIR_MAX_FLEXLEN);
10383 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
10385 entry.action.flex_off = 0; /*use 0 by default */
10386 if (!strcmp(res->drop, "drop"))
10387 entry.action.behavior = RTE_ETH_FDIR_REJECT;
10389 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
10391 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
10392 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
10393 if (!strcmp(res->pf_vf, "pf"))
10394 entry.input.flow_ext.is_vf = 0;
10395 else if (!strncmp(res->pf_vf, "vf", 2)) {
10396 struct rte_eth_dev_info dev_info;
10398 memset(&dev_info, 0, sizeof(dev_info));
10399 rte_eth_dev_info_get(res->port_id, &dev_info);
10401 vf_id = strtoul(res->pf_vf + 2, &end, 10);
10402 if (errno != 0 || *end != '\0' ||
10403 vf_id >= dev_info.max_vfs) {
10404 printf("invalid parameter %s.\n", res->pf_vf);
10407 entry.input.flow_ext.is_vf = 1;
10408 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
10410 printf("invalid parameter %s.\n", res->pf_vf);
10415 /* set to report FD ID by default */
10416 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
10417 entry.action.rx_queue = res->queue_id;
10418 entry.soft_id = res->fd_id_value;
10419 if (!strcmp(res->ops, "add"))
10420 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10421 RTE_ETH_FILTER_ADD, &entry);
10422 else if (!strcmp(res->ops, "del"))
10423 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10424 RTE_ETH_FILTER_DELETE, &entry);
10426 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10427 RTE_ETH_FILTER_UPDATE, &entry);
10429 printf("flow director programming error: (%s)\n",
10433 cmdline_parse_token_string_t cmd_flow_director_filter =
10434 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10435 flow_director_filter, "flow_director_filter");
10436 cmdline_parse_token_num_t cmd_flow_director_port_id =
10437 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10439 cmdline_parse_token_string_t cmd_flow_director_ops =
10440 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10441 ops, "add#del#update");
10442 cmdline_parse_token_string_t cmd_flow_director_flow =
10443 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10445 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10446 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10448 cmdline_parse_token_string_t cmd_flow_director_ether =
10449 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10451 cmdline_parse_token_num_t cmd_flow_director_ether_type =
10452 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10453 ether_type, UINT16);
10454 cmdline_parse_token_string_t cmd_flow_director_src =
10455 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10457 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
10458 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10460 cmdline_parse_token_num_t cmd_flow_director_port_src =
10461 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10463 cmdline_parse_token_string_t cmd_flow_director_dst =
10464 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10466 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
10467 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10469 cmdline_parse_token_num_t cmd_flow_director_port_dst =
10470 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10472 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
10473 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10474 verify_tag, "verify_tag");
10475 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
10476 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10477 verify_tag_value, UINT32);
10478 cmdline_parse_token_string_t cmd_flow_director_tos =
10479 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10481 cmdline_parse_token_num_t cmd_flow_director_tos_value =
10482 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10484 cmdline_parse_token_string_t cmd_flow_director_proto =
10485 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10487 cmdline_parse_token_num_t cmd_flow_director_proto_value =
10488 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10489 proto_value, UINT8);
10490 cmdline_parse_token_string_t cmd_flow_director_ttl =
10491 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10493 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
10494 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10496 cmdline_parse_token_string_t cmd_flow_director_vlan =
10497 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10499 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
10500 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10501 vlan_value, UINT16);
10502 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
10503 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10504 flexbytes, "flexbytes");
10505 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
10506 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10507 flexbytes_value, NULL);
10508 cmdline_parse_token_string_t cmd_flow_director_drop =
10509 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10511 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
10512 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10514 cmdline_parse_token_string_t cmd_flow_director_queue =
10515 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10517 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10518 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10520 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10521 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10523 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10524 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10525 fd_id_value, UINT32);
10527 cmdline_parse_token_string_t cmd_flow_director_mode =
10528 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10530 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
10531 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10533 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
10534 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10535 mode_value, "MAC-VLAN");
10536 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
10537 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10538 mode_value, "Tunnel");
10539 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
10540 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10541 mode_value, "raw");
10542 cmdline_parse_token_string_t cmd_flow_director_mac =
10543 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10545 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
10546 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
10548 cmdline_parse_token_string_t cmd_flow_director_tunnel =
10549 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10551 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
10552 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10553 tunnel_type, "NVGRE#VxLAN");
10554 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
10555 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10556 tunnel_id, "tunnel-id");
10557 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
10558 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10559 tunnel_id_value, UINT32);
10560 cmdline_parse_token_string_t cmd_flow_director_packet =
10561 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10563 cmdline_parse_token_string_t cmd_flow_director_filepath =
10564 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10567 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
10568 .f = cmd_flow_director_filter_parsed,
10570 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
10571 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
10572 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
10573 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
10574 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
10575 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
10576 "fd_id <fd_id_value>: "
10577 "Add or delete an ip flow director entry on NIC",
10579 (void *)&cmd_flow_director_filter,
10580 (void *)&cmd_flow_director_port_id,
10581 (void *)&cmd_flow_director_mode,
10582 (void *)&cmd_flow_director_mode_ip,
10583 (void *)&cmd_flow_director_ops,
10584 (void *)&cmd_flow_director_flow,
10585 (void *)&cmd_flow_director_flow_type,
10586 (void *)&cmd_flow_director_src,
10587 (void *)&cmd_flow_director_ip_src,
10588 (void *)&cmd_flow_director_dst,
10589 (void *)&cmd_flow_director_ip_dst,
10590 (void *)&cmd_flow_director_tos,
10591 (void *)&cmd_flow_director_tos_value,
10592 (void *)&cmd_flow_director_proto,
10593 (void *)&cmd_flow_director_proto_value,
10594 (void *)&cmd_flow_director_ttl,
10595 (void *)&cmd_flow_director_ttl_value,
10596 (void *)&cmd_flow_director_vlan,
10597 (void *)&cmd_flow_director_vlan_value,
10598 (void *)&cmd_flow_director_flexbytes,
10599 (void *)&cmd_flow_director_flexbytes_value,
10600 (void *)&cmd_flow_director_drop,
10601 (void *)&cmd_flow_director_pf_vf,
10602 (void *)&cmd_flow_director_queue,
10603 (void *)&cmd_flow_director_queue_id,
10604 (void *)&cmd_flow_director_fd_id,
10605 (void *)&cmd_flow_director_fd_id_value,
10610 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
10611 .f = cmd_flow_director_filter_parsed,
10613 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
10614 "director entry on NIC",
10616 (void *)&cmd_flow_director_filter,
10617 (void *)&cmd_flow_director_port_id,
10618 (void *)&cmd_flow_director_mode,
10619 (void *)&cmd_flow_director_mode_ip,
10620 (void *)&cmd_flow_director_ops,
10621 (void *)&cmd_flow_director_flow,
10622 (void *)&cmd_flow_director_flow_type,
10623 (void *)&cmd_flow_director_src,
10624 (void *)&cmd_flow_director_ip_src,
10625 (void *)&cmd_flow_director_port_src,
10626 (void *)&cmd_flow_director_dst,
10627 (void *)&cmd_flow_director_ip_dst,
10628 (void *)&cmd_flow_director_port_dst,
10629 (void *)&cmd_flow_director_tos,
10630 (void *)&cmd_flow_director_tos_value,
10631 (void *)&cmd_flow_director_ttl,
10632 (void *)&cmd_flow_director_ttl_value,
10633 (void *)&cmd_flow_director_vlan,
10634 (void *)&cmd_flow_director_vlan_value,
10635 (void *)&cmd_flow_director_flexbytes,
10636 (void *)&cmd_flow_director_flexbytes_value,
10637 (void *)&cmd_flow_director_drop,
10638 (void *)&cmd_flow_director_pf_vf,
10639 (void *)&cmd_flow_director_queue,
10640 (void *)&cmd_flow_director_queue_id,
10641 (void *)&cmd_flow_director_fd_id,
10642 (void *)&cmd_flow_director_fd_id_value,
10647 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
10648 .f = cmd_flow_director_filter_parsed,
10650 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
10651 "director entry on NIC",
10653 (void *)&cmd_flow_director_filter,
10654 (void *)&cmd_flow_director_port_id,
10655 (void *)&cmd_flow_director_mode,
10656 (void *)&cmd_flow_director_mode_ip,
10657 (void *)&cmd_flow_director_ops,
10658 (void *)&cmd_flow_director_flow,
10659 (void *)&cmd_flow_director_flow_type,
10660 (void *)&cmd_flow_director_src,
10661 (void *)&cmd_flow_director_ip_src,
10662 (void *)&cmd_flow_director_port_src,
10663 (void *)&cmd_flow_director_dst,
10664 (void *)&cmd_flow_director_ip_dst,
10665 (void *)&cmd_flow_director_port_dst,
10666 (void *)&cmd_flow_director_verify_tag,
10667 (void *)&cmd_flow_director_verify_tag_value,
10668 (void *)&cmd_flow_director_tos,
10669 (void *)&cmd_flow_director_tos_value,
10670 (void *)&cmd_flow_director_ttl,
10671 (void *)&cmd_flow_director_ttl_value,
10672 (void *)&cmd_flow_director_vlan,
10673 (void *)&cmd_flow_director_vlan_value,
10674 (void *)&cmd_flow_director_flexbytes,
10675 (void *)&cmd_flow_director_flexbytes_value,
10676 (void *)&cmd_flow_director_drop,
10677 (void *)&cmd_flow_director_pf_vf,
10678 (void *)&cmd_flow_director_queue,
10679 (void *)&cmd_flow_director_queue_id,
10680 (void *)&cmd_flow_director_fd_id,
10681 (void *)&cmd_flow_director_fd_id_value,
10686 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
10687 .f = cmd_flow_director_filter_parsed,
10689 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
10690 "director entry on NIC",
10692 (void *)&cmd_flow_director_filter,
10693 (void *)&cmd_flow_director_port_id,
10694 (void *)&cmd_flow_director_mode,
10695 (void *)&cmd_flow_director_mode_ip,
10696 (void *)&cmd_flow_director_ops,
10697 (void *)&cmd_flow_director_flow,
10698 (void *)&cmd_flow_director_flow_type,
10699 (void *)&cmd_flow_director_ether,
10700 (void *)&cmd_flow_director_ether_type,
10701 (void *)&cmd_flow_director_flexbytes,
10702 (void *)&cmd_flow_director_flexbytes_value,
10703 (void *)&cmd_flow_director_drop,
10704 (void *)&cmd_flow_director_pf_vf,
10705 (void *)&cmd_flow_director_queue,
10706 (void *)&cmd_flow_director_queue_id,
10707 (void *)&cmd_flow_director_fd_id,
10708 (void *)&cmd_flow_director_fd_id_value,
10713 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
10714 .f = cmd_flow_director_filter_parsed,
10716 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
10717 "director entry on NIC",
10719 (void *)&cmd_flow_director_filter,
10720 (void *)&cmd_flow_director_port_id,
10721 (void *)&cmd_flow_director_mode,
10722 (void *)&cmd_flow_director_mode_mac_vlan,
10723 (void *)&cmd_flow_director_ops,
10724 (void *)&cmd_flow_director_mac,
10725 (void *)&cmd_flow_director_mac_addr,
10726 (void *)&cmd_flow_director_vlan,
10727 (void *)&cmd_flow_director_vlan_value,
10728 (void *)&cmd_flow_director_flexbytes,
10729 (void *)&cmd_flow_director_flexbytes_value,
10730 (void *)&cmd_flow_director_drop,
10731 (void *)&cmd_flow_director_queue,
10732 (void *)&cmd_flow_director_queue_id,
10733 (void *)&cmd_flow_director_fd_id,
10734 (void *)&cmd_flow_director_fd_id_value,
10739 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
10740 .f = cmd_flow_director_filter_parsed,
10742 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
10743 "director entry on NIC",
10745 (void *)&cmd_flow_director_filter,
10746 (void *)&cmd_flow_director_port_id,
10747 (void *)&cmd_flow_director_mode,
10748 (void *)&cmd_flow_director_mode_tunnel,
10749 (void *)&cmd_flow_director_ops,
10750 (void *)&cmd_flow_director_mac,
10751 (void *)&cmd_flow_director_mac_addr,
10752 (void *)&cmd_flow_director_vlan,
10753 (void *)&cmd_flow_director_vlan_value,
10754 (void *)&cmd_flow_director_tunnel,
10755 (void *)&cmd_flow_director_tunnel_type,
10756 (void *)&cmd_flow_director_tunnel_id,
10757 (void *)&cmd_flow_director_tunnel_id_value,
10758 (void *)&cmd_flow_director_flexbytes,
10759 (void *)&cmd_flow_director_flexbytes_value,
10760 (void *)&cmd_flow_director_drop,
10761 (void *)&cmd_flow_director_queue,
10762 (void *)&cmd_flow_director_queue_id,
10763 (void *)&cmd_flow_director_fd_id,
10764 (void *)&cmd_flow_director_fd_id_value,
10769 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
10770 .f = cmd_flow_director_filter_parsed,
10772 .help_str = "flow_director_filter ... : Add or delete a raw flow "
10773 "director entry on NIC",
10775 (void *)&cmd_flow_director_filter,
10776 (void *)&cmd_flow_director_port_id,
10777 (void *)&cmd_flow_director_mode,
10778 (void *)&cmd_flow_director_mode_raw,
10779 (void *)&cmd_flow_director_ops,
10780 (void *)&cmd_flow_director_flow,
10781 (void *)&cmd_flow_director_flow_type,
10782 (void *)&cmd_flow_director_drop,
10783 (void *)&cmd_flow_director_queue,
10784 (void *)&cmd_flow_director_queue_id,
10785 (void *)&cmd_flow_director_fd_id,
10786 (void *)&cmd_flow_director_fd_id_value,
10787 (void *)&cmd_flow_director_packet,
10788 (void *)&cmd_flow_director_filepath,
10793 struct cmd_flush_flow_director_result {
10794 cmdline_fixed_string_t flush_flow_director;
10798 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
10799 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
10800 flush_flow_director, "flush_flow_director");
10801 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
10802 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
10806 cmd_flush_flow_director_parsed(void *parsed_result,
10807 __attribute__((unused)) struct cmdline *cl,
10808 __attribute__((unused)) void *data)
10810 struct cmd_flow_director_result *res = parsed_result;
10813 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10815 printf("flow director is not supported on port %u.\n",
10820 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10821 RTE_ETH_FILTER_FLUSH, NULL);
10823 printf("flow director table flushing error: (%s)\n",
10827 cmdline_parse_inst_t cmd_flush_flow_director = {
10828 .f = cmd_flush_flow_director_parsed,
10830 .help_str = "flush_flow_director <port_id>: "
10831 "Flush all flow director entries of a device on NIC",
10833 (void *)&cmd_flush_flow_director_flush,
10834 (void *)&cmd_flush_flow_director_port_id,
10839 /* *** deal with flow director mask *** */
10840 struct cmd_flow_director_mask_result {
10841 cmdline_fixed_string_t flow_director_mask;
10843 cmdline_fixed_string_t mode;
10844 cmdline_fixed_string_t mode_value;
10845 cmdline_fixed_string_t vlan;
10846 uint16_t vlan_mask;
10847 cmdline_fixed_string_t src_mask;
10848 cmdline_ipaddr_t ipv4_src;
10849 cmdline_ipaddr_t ipv6_src;
10851 cmdline_fixed_string_t dst_mask;
10852 cmdline_ipaddr_t ipv4_dst;
10853 cmdline_ipaddr_t ipv6_dst;
10855 cmdline_fixed_string_t mac;
10856 uint8_t mac_addr_byte_mask;
10857 cmdline_fixed_string_t tunnel_id;
10858 uint32_t tunnel_id_mask;
10859 cmdline_fixed_string_t tunnel_type;
10860 uint8_t tunnel_type_mask;
10864 cmd_flow_director_mask_parsed(void *parsed_result,
10865 __attribute__((unused)) struct cmdline *cl,
10866 __attribute__((unused)) void *data)
10868 struct cmd_flow_director_mask_result *res = parsed_result;
10869 struct rte_eth_fdir_masks *mask;
10870 struct rte_port *port;
10872 if (res->port_id > nb_ports) {
10873 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
10877 port = &ports[res->port_id];
10878 /** Check if the port is not started **/
10879 if (port->port_status != RTE_PORT_STOPPED) {
10880 printf("Please stop port %d first\n", res->port_id);
10884 mask = &port->dev_conf.fdir_conf.mask;
10886 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10887 if (strcmp(res->mode_value, "MAC-VLAN")) {
10888 printf("Please set mode to MAC-VLAN.\n");
10892 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10893 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10894 if (strcmp(res->mode_value, "Tunnel")) {
10895 printf("Please set mode to Tunnel.\n");
10899 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10900 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
10901 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
10902 mask->tunnel_type_mask = res->tunnel_type_mask;
10904 if (strcmp(res->mode_value, "IP")) {
10905 printf("Please set mode to IP.\n");
10909 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10910 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
10911 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
10912 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
10913 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
10914 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
10915 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
10918 cmd_reconfig_device_queue(res->port_id, 1, 1);
10921 cmdline_parse_token_string_t cmd_flow_director_mask =
10922 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10923 flow_director_mask, "flow_director_mask");
10924 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
10925 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10927 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
10928 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10930 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
10931 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10932 vlan_mask, UINT16);
10933 cmdline_parse_token_string_t cmd_flow_director_mask_src =
10934 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10935 src_mask, "src_mask");
10936 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
10937 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10939 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
10940 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10942 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
10943 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10945 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
10946 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10947 dst_mask, "dst_mask");
10948 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
10949 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10951 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
10952 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10954 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
10955 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10958 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
10959 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10961 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
10962 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10964 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
10965 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10966 mode_value, "MAC-VLAN");
10967 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
10968 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10969 mode_value, "Tunnel");
10970 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
10971 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10973 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
10974 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10975 mac_addr_byte_mask, UINT8);
10976 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
10977 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10978 tunnel_type, "tunnel-type");
10979 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
10980 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10981 tunnel_type_mask, UINT8);
10982 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
10983 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10984 tunnel_id, "tunnel-id");
10985 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
10986 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10987 tunnel_id_mask, UINT32);
10989 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
10990 .f = cmd_flow_director_mask_parsed,
10992 .help_str = "flow_director_mask ... : "
10993 "Set IP mode flow director's mask on NIC",
10995 (void *)&cmd_flow_director_mask,
10996 (void *)&cmd_flow_director_mask_port_id,
10997 (void *)&cmd_flow_director_mask_mode,
10998 (void *)&cmd_flow_director_mask_mode_ip,
10999 (void *)&cmd_flow_director_mask_vlan,
11000 (void *)&cmd_flow_director_mask_vlan_value,
11001 (void *)&cmd_flow_director_mask_src,
11002 (void *)&cmd_flow_director_mask_ipv4_src,
11003 (void *)&cmd_flow_director_mask_ipv6_src,
11004 (void *)&cmd_flow_director_mask_port_src,
11005 (void *)&cmd_flow_director_mask_dst,
11006 (void *)&cmd_flow_director_mask_ipv4_dst,
11007 (void *)&cmd_flow_director_mask_ipv6_dst,
11008 (void *)&cmd_flow_director_mask_port_dst,
11013 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
11014 .f = cmd_flow_director_mask_parsed,
11016 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
11017 "flow director's mask on NIC",
11019 (void *)&cmd_flow_director_mask,
11020 (void *)&cmd_flow_director_mask_port_id,
11021 (void *)&cmd_flow_director_mask_mode,
11022 (void *)&cmd_flow_director_mask_mode_mac_vlan,
11023 (void *)&cmd_flow_director_mask_vlan,
11024 (void *)&cmd_flow_director_mask_vlan_value,
11029 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
11030 .f = cmd_flow_director_mask_parsed,
11032 .help_str = "flow_director_mask ... : Set tunnel mode "
11033 "flow director's mask on NIC",
11035 (void *)&cmd_flow_director_mask,
11036 (void *)&cmd_flow_director_mask_port_id,
11037 (void *)&cmd_flow_director_mask_mode,
11038 (void *)&cmd_flow_director_mask_mode_tunnel,
11039 (void *)&cmd_flow_director_mask_vlan,
11040 (void *)&cmd_flow_director_mask_vlan_value,
11041 (void *)&cmd_flow_director_mask_mac,
11042 (void *)&cmd_flow_director_mask_mac_value,
11043 (void *)&cmd_flow_director_mask_tunnel_type,
11044 (void *)&cmd_flow_director_mask_tunnel_type_value,
11045 (void *)&cmd_flow_director_mask_tunnel_id,
11046 (void *)&cmd_flow_director_mask_tunnel_id_value,
11051 /* *** deal with flow director mask on flexible payload *** */
11052 struct cmd_flow_director_flex_mask_result {
11053 cmdline_fixed_string_t flow_director_flexmask;
11055 cmdline_fixed_string_t flow;
11056 cmdline_fixed_string_t flow_type;
11057 cmdline_fixed_string_t mask;
11061 cmd_flow_director_flex_mask_parsed(void *parsed_result,
11062 __attribute__((unused)) struct cmdline *cl,
11063 __attribute__((unused)) void *data)
11065 struct cmd_flow_director_flex_mask_result *res = parsed_result;
11066 struct rte_eth_fdir_info fdir_info;
11067 struct rte_eth_fdir_flex_mask flex_mask;
11068 struct rte_port *port;
11069 uint64_t flow_type_mask;
11073 if (res->port_id > nb_ports) {
11074 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
11078 port = &ports[res->port_id];
11079 /** Check if the port is not started **/
11080 if (port->port_status != RTE_PORT_STOPPED) {
11081 printf("Please stop port %d first\n", res->port_id);
11085 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
11086 ret = parse_flexbytes(res->mask,
11088 RTE_ETH_FDIR_MAX_FLEXLEN);
11090 printf("error: Cannot parse mask input.\n");
11094 memset(&fdir_info, 0, sizeof(fdir_info));
11095 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11096 RTE_ETH_FILTER_INFO, &fdir_info);
11098 printf("Cannot get FDir filter info\n");
11102 if (!strcmp(res->flow_type, "none")) {
11103 /* means don't specify the flow type */
11104 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
11105 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
11106 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
11107 0, sizeof(struct rte_eth_fdir_flex_mask));
11108 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
11109 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
11111 sizeof(struct rte_eth_fdir_flex_mask));
11112 cmd_reconfig_device_queue(res->port_id, 1, 1);
11115 flow_type_mask = fdir_info.flow_types_mask[0];
11116 if (!strcmp(res->flow_type, "all")) {
11117 if (!flow_type_mask) {
11118 printf("No flow type supported\n");
11121 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
11122 if (flow_type_mask & (1ULL << i)) {
11123 flex_mask.flow_type = i;
11124 fdir_set_flex_mask(res->port_id, &flex_mask);
11127 cmd_reconfig_device_queue(res->port_id, 1, 1);
11130 flex_mask.flow_type = str2flowtype(res->flow_type);
11131 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
11132 printf("Flow type %s not supported on port %d\n",
11133 res->flow_type, res->port_id);
11136 fdir_set_flex_mask(res->port_id, &flex_mask);
11137 cmd_reconfig_device_queue(res->port_id, 1, 1);
11140 cmdline_parse_token_string_t cmd_flow_director_flexmask =
11141 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11142 flow_director_flexmask,
11143 "flow_director_flex_mask");
11144 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
11145 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11147 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
11148 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11150 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
11151 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11152 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
11153 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
11154 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
11155 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11158 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
11159 .f = cmd_flow_director_flex_mask_parsed,
11161 .help_str = "flow_director_flex_mask ... : "
11162 "Set flow director's flex mask on NIC",
11164 (void *)&cmd_flow_director_flexmask,
11165 (void *)&cmd_flow_director_flexmask_port_id,
11166 (void *)&cmd_flow_director_flexmask_flow,
11167 (void *)&cmd_flow_director_flexmask_flow_type,
11168 (void *)&cmd_flow_director_flexmask_mask,
11173 /* *** deal with flow director flexible payload configuration *** */
11174 struct cmd_flow_director_flexpayload_result {
11175 cmdline_fixed_string_t flow_director_flexpayload;
11177 cmdline_fixed_string_t payload_layer;
11178 cmdline_fixed_string_t payload_cfg;
11182 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
11185 const char *p, *p0 = q_arg;
11187 unsigned long int_fld;
11188 char *str_fld[max_num];
11193 p = strchr(p0, '(');
11197 p0 = strchr(p, ')');
11202 if (size >= sizeof(s))
11205 snprintf(s, sizeof(s), "%.*s", size, p);
11206 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
11207 if (ret < 0 || ret > max_num)
11209 for (i = 0; i < ret; i++) {
11211 int_fld = strtoul(str_fld[i], &end, 0);
11212 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
11214 offsets[i] = (uint16_t)int_fld;
11220 cmd_flow_director_flxpld_parsed(void *parsed_result,
11221 __attribute__((unused)) struct cmdline *cl,
11222 __attribute__((unused)) void *data)
11224 struct cmd_flow_director_flexpayload_result *res = parsed_result;
11225 struct rte_eth_flex_payload_cfg flex_cfg;
11226 struct rte_port *port;
11229 if (res->port_id > nb_ports) {
11230 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
11234 port = &ports[res->port_id];
11235 /** Check if the port is not started **/
11236 if (port->port_status != RTE_PORT_STOPPED) {
11237 printf("Please stop port %d first\n", res->port_id);
11241 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
11243 if (!strcmp(res->payload_layer, "raw"))
11244 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
11245 else if (!strcmp(res->payload_layer, "l2"))
11246 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
11247 else if (!strcmp(res->payload_layer, "l3"))
11248 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
11249 else if (!strcmp(res->payload_layer, "l4"))
11250 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
11252 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
11253 RTE_ETH_FDIR_MAX_FLEXLEN);
11255 printf("error: Cannot parse flex payload input.\n");
11259 fdir_set_flex_payload(res->port_id, &flex_cfg);
11260 cmd_reconfig_device_queue(res->port_id, 1, 1);
11263 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
11264 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11265 flow_director_flexpayload,
11266 "flow_director_flex_payload");
11267 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
11268 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11270 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
11271 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11272 payload_layer, "raw#l2#l3#l4");
11273 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
11274 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11275 payload_cfg, NULL);
11277 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
11278 .f = cmd_flow_director_flxpld_parsed,
11280 .help_str = "flow_director_flexpayload ... : "
11281 "Set flow director's flex payload on NIC",
11283 (void *)&cmd_flow_director_flexpayload,
11284 (void *)&cmd_flow_director_flexpayload_port_id,
11285 (void *)&cmd_flow_director_flexpayload_payload_layer,
11286 (void *)&cmd_flow_director_flexpayload_payload_cfg,
11291 /* Generic flow interface command. */
11292 extern cmdline_parse_inst_t cmd_flow;
11294 /* *** Classification Filters Control *** */
11295 /* *** Get symmetric hash enable per port *** */
11296 struct cmd_get_sym_hash_ena_per_port_result {
11297 cmdline_fixed_string_t get_sym_hash_ena_per_port;
11302 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
11303 __rte_unused struct cmdline *cl,
11304 __rte_unused void *data)
11306 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
11307 struct rte_eth_hash_filter_info info;
11310 if (rte_eth_dev_filter_supported(res->port_id,
11311 RTE_ETH_FILTER_HASH) < 0) {
11312 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11317 memset(&info, 0, sizeof(info));
11318 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11319 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11320 RTE_ETH_FILTER_GET, &info);
11323 printf("Cannot get symmetric hash enable per port "
11324 "on port %u\n", res->port_id);
11328 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
11329 "enabled" : "disabled", res->port_id);
11332 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
11333 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11334 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
11335 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
11336 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11339 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
11340 .f = cmd_get_sym_hash_per_port_parsed,
11342 .help_str = "get_sym_hash_ena_per_port <port_id>",
11344 (void *)&cmd_get_sym_hash_ena_per_port_all,
11345 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
11350 /* *** Set symmetric hash enable per port *** */
11351 struct cmd_set_sym_hash_ena_per_port_result {
11352 cmdline_fixed_string_t set_sym_hash_ena_per_port;
11353 cmdline_fixed_string_t enable;
11358 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
11359 __rte_unused struct cmdline *cl,
11360 __rte_unused void *data)
11362 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
11363 struct rte_eth_hash_filter_info info;
11366 if (rte_eth_dev_filter_supported(res->port_id,
11367 RTE_ETH_FILTER_HASH) < 0) {
11368 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11373 memset(&info, 0, sizeof(info));
11374 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11375 if (!strcmp(res->enable, "enable"))
11376 info.info.enable = 1;
11377 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11378 RTE_ETH_FILTER_SET, &info);
11380 printf("Cannot set symmetric hash enable per port on "
11381 "port %u\n", res->port_id);
11384 printf("Symmetric hash has been set to %s on port %u\n",
11385 res->enable, res->port_id);
11388 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
11389 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11390 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
11391 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
11392 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11394 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
11395 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11396 enable, "enable#disable");
11398 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
11399 .f = cmd_set_sym_hash_per_port_parsed,
11401 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
11403 (void *)&cmd_set_sym_hash_ena_per_port_all,
11404 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
11405 (void *)&cmd_set_sym_hash_ena_per_port_enable,
11410 /* Get global config of hash function */
11411 struct cmd_get_hash_global_config_result {
11412 cmdline_fixed_string_t get_hash_global_config;
11417 flowtype_to_str(uint16_t ftype)
11423 } ftype_table[] = {
11424 {"ipv4", RTE_ETH_FLOW_IPV4},
11425 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
11426 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
11427 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
11428 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
11429 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
11430 {"ipv6", RTE_ETH_FLOW_IPV6},
11431 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
11432 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
11433 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
11434 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
11435 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
11436 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
11437 {"port", RTE_ETH_FLOW_PORT},
11438 {"vxlan", RTE_ETH_FLOW_VXLAN},
11439 {"geneve", RTE_ETH_FLOW_GENEVE},
11440 {"nvgre", RTE_ETH_FLOW_NVGRE},
11443 for (i = 0; i < RTE_DIM(ftype_table); i++) {
11444 if (ftype_table[i].ftype == ftype)
11445 return ftype_table[i].str;
11452 cmd_get_hash_global_config_parsed(void *parsed_result,
11453 __rte_unused struct cmdline *cl,
11454 __rte_unused void *data)
11456 struct cmd_get_hash_global_config_result *res = parsed_result;
11457 struct rte_eth_hash_filter_info info;
11458 uint32_t idx, offset;
11463 if (rte_eth_dev_filter_supported(res->port_id,
11464 RTE_ETH_FILTER_HASH) < 0) {
11465 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11470 memset(&info, 0, sizeof(info));
11471 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11472 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11473 RTE_ETH_FILTER_GET, &info);
11475 printf("Cannot get hash global configurations by port %d\n",
11480 switch (info.info.global_conf.hash_func) {
11481 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
11482 printf("Hash function is Toeplitz\n");
11484 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
11485 printf("Hash function is Simple XOR\n");
11488 printf("Unknown hash function\n");
11492 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
11493 idx = i / UINT64_BIT;
11494 offset = i % UINT64_BIT;
11495 if (!(info.info.global_conf.valid_bit_mask[idx] &
11498 str = flowtype_to_str(i);
11501 printf("Symmetric hash is %s globally for flow type %s "
11503 ((info.info.global_conf.sym_hash_enable_mask[idx] &
11504 (1ULL << offset)) ? "enabled" : "disabled"), str,
11509 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
11510 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
11511 get_hash_global_config, "get_hash_global_config");
11512 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
11513 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
11516 cmdline_parse_inst_t cmd_get_hash_global_config = {
11517 .f = cmd_get_hash_global_config_parsed,
11519 .help_str = "get_hash_global_config <port_id>",
11521 (void *)&cmd_get_hash_global_config_all,
11522 (void *)&cmd_get_hash_global_config_port_id,
11527 /* Set global config of hash function */
11528 struct cmd_set_hash_global_config_result {
11529 cmdline_fixed_string_t set_hash_global_config;
11531 cmdline_fixed_string_t hash_func;
11532 cmdline_fixed_string_t flow_type;
11533 cmdline_fixed_string_t enable;
11537 cmd_set_hash_global_config_parsed(void *parsed_result,
11538 __rte_unused struct cmdline *cl,
11539 __rte_unused void *data)
11541 struct cmd_set_hash_global_config_result *res = parsed_result;
11542 struct rte_eth_hash_filter_info info;
11543 uint32_t ftype, idx, offset;
11546 if (rte_eth_dev_filter_supported(res->port_id,
11547 RTE_ETH_FILTER_HASH) < 0) {
11548 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11552 memset(&info, 0, sizeof(info));
11553 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11554 if (!strcmp(res->hash_func, "toeplitz"))
11555 info.info.global_conf.hash_func =
11556 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
11557 else if (!strcmp(res->hash_func, "simple_xor"))
11558 info.info.global_conf.hash_func =
11559 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
11560 else if (!strcmp(res->hash_func, "default"))
11561 info.info.global_conf.hash_func =
11562 RTE_ETH_HASH_FUNCTION_DEFAULT;
11564 ftype = str2flowtype(res->flow_type);
11565 idx = ftype / UINT64_BIT;
11566 offset = ftype % UINT64_BIT;
11567 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
11568 if (!strcmp(res->enable, "enable"))
11569 info.info.global_conf.sym_hash_enable_mask[idx] |=
11571 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11572 RTE_ETH_FILTER_SET, &info);
11574 printf("Cannot set global hash configurations by port %d\n",
11577 printf("Global hash configurations have been set "
11578 "succcessfully by port %d\n", res->port_id);
11581 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
11582 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11583 set_hash_global_config, "set_hash_global_config");
11584 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
11585 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
11587 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
11588 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11589 hash_func, "toeplitz#simple_xor#default");
11590 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
11591 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11593 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
11594 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11595 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
11596 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11597 enable, "enable#disable");
11599 cmdline_parse_inst_t cmd_set_hash_global_config = {
11600 .f = cmd_set_hash_global_config_parsed,
11602 .help_str = "set_hash_global_config <port_id> "
11603 "toeplitz|simple_xor|default "
11604 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11605 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
11606 "l2_payload enable|disable",
11608 (void *)&cmd_set_hash_global_config_all,
11609 (void *)&cmd_set_hash_global_config_port_id,
11610 (void *)&cmd_set_hash_global_config_hash_func,
11611 (void *)&cmd_set_hash_global_config_flow_type,
11612 (void *)&cmd_set_hash_global_config_enable,
11617 /* Set hash input set */
11618 struct cmd_set_hash_input_set_result {
11619 cmdline_fixed_string_t set_hash_input_set;
11621 cmdline_fixed_string_t flow_type;
11622 cmdline_fixed_string_t inset_field;
11623 cmdline_fixed_string_t select;
11626 static enum rte_eth_input_set_field
11627 str2inset(char *string)
11631 static const struct {
11633 enum rte_eth_input_set_field inset;
11634 } inset_table[] = {
11635 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
11636 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
11637 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
11638 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
11639 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
11640 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
11641 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
11642 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
11643 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
11644 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
11645 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
11646 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
11647 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
11648 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
11649 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
11650 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
11651 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
11652 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
11653 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
11654 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
11655 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
11656 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
11657 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
11658 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
11659 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
11660 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
11661 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
11662 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
11663 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
11664 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
11665 {"none", RTE_ETH_INPUT_SET_NONE},
11668 for (i = 0; i < RTE_DIM(inset_table); i++) {
11669 if (!strcmp(string, inset_table[i].str))
11670 return inset_table[i].inset;
11673 return RTE_ETH_INPUT_SET_UNKNOWN;
11677 cmd_set_hash_input_set_parsed(void *parsed_result,
11678 __rte_unused struct cmdline *cl,
11679 __rte_unused void *data)
11681 struct cmd_set_hash_input_set_result *res = parsed_result;
11682 struct rte_eth_hash_filter_info info;
11684 memset(&info, 0, sizeof(info));
11685 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
11686 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
11687 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
11688 info.info.input_set_conf.inset_size = 1;
11689 if (!strcmp(res->select, "select"))
11690 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
11691 else if (!strcmp(res->select, "add"))
11692 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
11693 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11694 RTE_ETH_FILTER_SET, &info);
11697 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
11698 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11699 set_hash_input_set, "set_hash_input_set");
11700 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
11701 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
11703 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
11704 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11706 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
11707 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11709 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
11710 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
11711 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
11712 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
11713 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
11715 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
11716 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11717 select, "select#add");
11719 cmdline_parse_inst_t cmd_set_hash_input_set = {
11720 .f = cmd_set_hash_input_set_parsed,
11722 .help_str = "set_hash_input_set <port_id> "
11723 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11724 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
11725 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
11726 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
11727 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
11728 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
11729 "fld-7th|fld-8th|none select|add",
11731 (void *)&cmd_set_hash_input_set_cmd,
11732 (void *)&cmd_set_hash_input_set_port_id,
11733 (void *)&cmd_set_hash_input_set_flow_type,
11734 (void *)&cmd_set_hash_input_set_field,
11735 (void *)&cmd_set_hash_input_set_select,
11740 /* Set flow director input set */
11741 struct cmd_set_fdir_input_set_result {
11742 cmdline_fixed_string_t set_fdir_input_set;
11744 cmdline_fixed_string_t flow_type;
11745 cmdline_fixed_string_t inset_field;
11746 cmdline_fixed_string_t select;
11750 cmd_set_fdir_input_set_parsed(void *parsed_result,
11751 __rte_unused struct cmdline *cl,
11752 __rte_unused void *data)
11754 struct cmd_set_fdir_input_set_result *res = parsed_result;
11755 struct rte_eth_fdir_filter_info info;
11757 memset(&info, 0, sizeof(info));
11758 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
11759 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
11760 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
11761 info.info.input_set_conf.inset_size = 1;
11762 if (!strcmp(res->select, "select"))
11763 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
11764 else if (!strcmp(res->select, "add"))
11765 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
11766 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11767 RTE_ETH_FILTER_SET, &info);
11770 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
11771 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11772 set_fdir_input_set, "set_fdir_input_set");
11773 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
11774 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
11776 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
11777 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11779 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
11780 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11781 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
11782 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11784 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
11785 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
11786 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
11787 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
11788 "sctp-veri-tag#none");
11789 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
11790 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11791 select, "select#add");
11793 cmdline_parse_inst_t cmd_set_fdir_input_set = {
11794 .f = cmd_set_fdir_input_set_parsed,
11796 .help_str = "set_fdir_input_set <port_id> "
11797 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11798 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
11799 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
11800 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
11801 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
11802 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
11803 "sctp-veri-tag|none select|add",
11805 (void *)&cmd_set_fdir_input_set_cmd,
11806 (void *)&cmd_set_fdir_input_set_port_id,
11807 (void *)&cmd_set_fdir_input_set_flow_type,
11808 (void *)&cmd_set_fdir_input_set_field,
11809 (void *)&cmd_set_fdir_input_set_select,
11814 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
11815 struct cmd_mcast_addr_result {
11816 cmdline_fixed_string_t mcast_addr_cmd;
11817 cmdline_fixed_string_t what;
11819 struct ether_addr mc_addr;
11822 static void cmd_mcast_addr_parsed(void *parsed_result,
11823 __attribute__((unused)) struct cmdline *cl,
11824 __attribute__((unused)) void *data)
11826 struct cmd_mcast_addr_result *res = parsed_result;
11828 if (!is_multicast_ether_addr(&res->mc_addr)) {
11829 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
11830 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
11831 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
11832 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
11835 if (strcmp(res->what, "add") == 0)
11836 mcast_addr_add(res->port_num, &res->mc_addr);
11838 mcast_addr_remove(res->port_num, &res->mc_addr);
11841 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
11842 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
11843 mcast_addr_cmd, "mcast_addr");
11844 cmdline_parse_token_string_t cmd_mcast_addr_what =
11845 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
11847 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
11848 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
11849 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
11850 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
11852 cmdline_parse_inst_t cmd_mcast_addr = {
11853 .f = cmd_mcast_addr_parsed,
11855 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
11856 "Add/Remove multicast MAC address on port_id",
11858 (void *)&cmd_mcast_addr_cmd,
11859 (void *)&cmd_mcast_addr_what,
11860 (void *)&cmd_mcast_addr_portnum,
11861 (void *)&cmd_mcast_addr_addr,
11866 /* l2 tunnel config
11867 * only support E-tag now.
11870 /* Ether type config */
11871 struct cmd_config_l2_tunnel_eth_type_result {
11872 cmdline_fixed_string_t port;
11873 cmdline_fixed_string_t config;
11874 cmdline_fixed_string_t all;
11876 cmdline_fixed_string_t l2_tunnel;
11877 cmdline_fixed_string_t l2_tunnel_type;
11878 cmdline_fixed_string_t eth_type;
11879 uint16_t eth_type_val;
11882 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
11883 TOKEN_STRING_INITIALIZER
11884 (struct cmd_config_l2_tunnel_eth_type_result,
11886 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
11887 TOKEN_STRING_INITIALIZER
11888 (struct cmd_config_l2_tunnel_eth_type_result,
11890 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
11891 TOKEN_STRING_INITIALIZER
11892 (struct cmd_config_l2_tunnel_eth_type_result,
11894 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
11895 TOKEN_NUM_INITIALIZER
11896 (struct cmd_config_l2_tunnel_eth_type_result,
11898 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
11899 TOKEN_STRING_INITIALIZER
11900 (struct cmd_config_l2_tunnel_eth_type_result,
11901 l2_tunnel, "l2-tunnel");
11902 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
11903 TOKEN_STRING_INITIALIZER
11904 (struct cmd_config_l2_tunnel_eth_type_result,
11905 l2_tunnel_type, "E-tag");
11906 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
11907 TOKEN_STRING_INITIALIZER
11908 (struct cmd_config_l2_tunnel_eth_type_result,
11909 eth_type, "ether-type");
11910 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
11911 TOKEN_NUM_INITIALIZER
11912 (struct cmd_config_l2_tunnel_eth_type_result,
11913 eth_type_val, UINT16);
11915 static enum rte_eth_tunnel_type
11916 str2fdir_l2_tunnel_type(char *string)
11920 static const struct {
11922 enum rte_eth_tunnel_type type;
11923 } l2_tunnel_type_str[] = {
11924 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
11927 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
11928 if (!strcmp(l2_tunnel_type_str[i].str, string))
11929 return l2_tunnel_type_str[i].type;
11931 return RTE_TUNNEL_TYPE_NONE;
11934 /* ether type config for all ports */
11936 cmd_config_l2_tunnel_eth_type_all_parsed
11937 (void *parsed_result,
11938 __attribute__((unused)) struct cmdline *cl,
11939 __attribute__((unused)) void *data)
11941 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
11942 struct rte_eth_l2_tunnel_conf entry;
11945 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11946 entry.ether_type = res->eth_type_val;
11948 RTE_ETH_FOREACH_DEV(pid) {
11949 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
11953 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
11954 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
11956 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
11958 (void *)&cmd_config_l2_tunnel_eth_type_port,
11959 (void *)&cmd_config_l2_tunnel_eth_type_config,
11960 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
11961 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
11962 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
11963 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
11964 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
11969 /* ether type config for a specific port */
11971 cmd_config_l2_tunnel_eth_type_specific_parsed(
11972 void *parsed_result,
11973 __attribute__((unused)) struct cmdline *cl,
11974 __attribute__((unused)) void *data)
11976 struct cmd_config_l2_tunnel_eth_type_result *res =
11978 struct rte_eth_l2_tunnel_conf entry;
11980 if (port_id_is_invalid(res->id, ENABLED_WARN))
11983 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11984 entry.ether_type = res->eth_type_val;
11986 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
11989 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
11990 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
11992 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
11994 (void *)&cmd_config_l2_tunnel_eth_type_port,
11995 (void *)&cmd_config_l2_tunnel_eth_type_config,
11996 (void *)&cmd_config_l2_tunnel_eth_type_id,
11997 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
11998 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
11999 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12000 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12005 /* Enable/disable l2 tunnel */
12006 struct cmd_config_l2_tunnel_en_dis_result {
12007 cmdline_fixed_string_t port;
12008 cmdline_fixed_string_t config;
12009 cmdline_fixed_string_t all;
12011 cmdline_fixed_string_t l2_tunnel;
12012 cmdline_fixed_string_t l2_tunnel_type;
12013 cmdline_fixed_string_t en_dis;
12016 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
12017 TOKEN_STRING_INITIALIZER
12018 (struct cmd_config_l2_tunnel_en_dis_result,
12020 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
12021 TOKEN_STRING_INITIALIZER
12022 (struct cmd_config_l2_tunnel_en_dis_result,
12024 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
12025 TOKEN_STRING_INITIALIZER
12026 (struct cmd_config_l2_tunnel_en_dis_result,
12028 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
12029 TOKEN_NUM_INITIALIZER
12030 (struct cmd_config_l2_tunnel_en_dis_result,
12032 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
12033 TOKEN_STRING_INITIALIZER
12034 (struct cmd_config_l2_tunnel_en_dis_result,
12035 l2_tunnel, "l2-tunnel");
12036 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
12037 TOKEN_STRING_INITIALIZER
12038 (struct cmd_config_l2_tunnel_en_dis_result,
12039 l2_tunnel_type, "E-tag");
12040 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
12041 TOKEN_STRING_INITIALIZER
12042 (struct cmd_config_l2_tunnel_en_dis_result,
12043 en_dis, "enable#disable");
12045 /* enable/disable l2 tunnel for all ports */
12047 cmd_config_l2_tunnel_en_dis_all_parsed(
12048 void *parsed_result,
12049 __attribute__((unused)) struct cmdline *cl,
12050 __attribute__((unused)) void *data)
12052 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
12053 struct rte_eth_l2_tunnel_conf entry;
12057 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12059 if (!strcmp("enable", res->en_dis))
12064 RTE_ETH_FOREACH_DEV(pid) {
12065 rte_eth_dev_l2_tunnel_offload_set(pid,
12067 ETH_L2_TUNNEL_ENABLE_MASK,
12072 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
12073 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
12075 .help_str = "port config all l2-tunnel E-tag enable|disable",
12077 (void *)&cmd_config_l2_tunnel_en_dis_port,
12078 (void *)&cmd_config_l2_tunnel_en_dis_config,
12079 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
12080 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12081 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12082 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12087 /* enable/disable l2 tunnel for a port */
12089 cmd_config_l2_tunnel_en_dis_specific_parsed(
12090 void *parsed_result,
12091 __attribute__((unused)) struct cmdline *cl,
12092 __attribute__((unused)) void *data)
12094 struct cmd_config_l2_tunnel_en_dis_result *res =
12096 struct rte_eth_l2_tunnel_conf entry;
12098 if (port_id_is_invalid(res->id, ENABLED_WARN))
12101 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12103 if (!strcmp("enable", res->en_dis))
12104 rte_eth_dev_l2_tunnel_offload_set(res->id,
12106 ETH_L2_TUNNEL_ENABLE_MASK,
12109 rte_eth_dev_l2_tunnel_offload_set(res->id,
12111 ETH_L2_TUNNEL_ENABLE_MASK,
12115 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
12116 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
12118 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
12120 (void *)&cmd_config_l2_tunnel_en_dis_port,
12121 (void *)&cmd_config_l2_tunnel_en_dis_config,
12122 (void *)&cmd_config_l2_tunnel_en_dis_id,
12123 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12124 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12125 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12130 /* E-tag configuration */
12132 /* Common result structure for all E-tag configuration */
12133 struct cmd_config_e_tag_result {
12134 cmdline_fixed_string_t e_tag;
12135 cmdline_fixed_string_t set;
12136 cmdline_fixed_string_t insertion;
12137 cmdline_fixed_string_t stripping;
12138 cmdline_fixed_string_t forwarding;
12139 cmdline_fixed_string_t filter;
12140 cmdline_fixed_string_t add;
12141 cmdline_fixed_string_t del;
12142 cmdline_fixed_string_t on;
12143 cmdline_fixed_string_t off;
12144 cmdline_fixed_string_t on_off;
12145 cmdline_fixed_string_t port_tag_id;
12146 uint32_t port_tag_id_val;
12147 cmdline_fixed_string_t e_tag_id;
12148 uint16_t e_tag_id_val;
12149 cmdline_fixed_string_t dst_pool;
12150 uint8_t dst_pool_val;
12151 cmdline_fixed_string_t port;
12153 cmdline_fixed_string_t vf;
12157 /* Common CLI fields for all E-tag configuration */
12158 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
12159 TOKEN_STRING_INITIALIZER
12160 (struct cmd_config_e_tag_result,
12162 cmdline_parse_token_string_t cmd_config_e_tag_set =
12163 TOKEN_STRING_INITIALIZER
12164 (struct cmd_config_e_tag_result,
12166 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
12167 TOKEN_STRING_INITIALIZER
12168 (struct cmd_config_e_tag_result,
12169 insertion, "insertion");
12170 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
12171 TOKEN_STRING_INITIALIZER
12172 (struct cmd_config_e_tag_result,
12173 stripping, "stripping");
12174 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
12175 TOKEN_STRING_INITIALIZER
12176 (struct cmd_config_e_tag_result,
12177 forwarding, "forwarding");
12178 cmdline_parse_token_string_t cmd_config_e_tag_filter =
12179 TOKEN_STRING_INITIALIZER
12180 (struct cmd_config_e_tag_result,
12182 cmdline_parse_token_string_t cmd_config_e_tag_add =
12183 TOKEN_STRING_INITIALIZER
12184 (struct cmd_config_e_tag_result,
12186 cmdline_parse_token_string_t cmd_config_e_tag_del =
12187 TOKEN_STRING_INITIALIZER
12188 (struct cmd_config_e_tag_result,
12190 cmdline_parse_token_string_t cmd_config_e_tag_on =
12191 TOKEN_STRING_INITIALIZER
12192 (struct cmd_config_e_tag_result,
12194 cmdline_parse_token_string_t cmd_config_e_tag_off =
12195 TOKEN_STRING_INITIALIZER
12196 (struct cmd_config_e_tag_result,
12198 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
12199 TOKEN_STRING_INITIALIZER
12200 (struct cmd_config_e_tag_result,
12202 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
12203 TOKEN_STRING_INITIALIZER
12204 (struct cmd_config_e_tag_result,
12205 port_tag_id, "port-tag-id");
12206 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
12207 TOKEN_NUM_INITIALIZER
12208 (struct cmd_config_e_tag_result,
12209 port_tag_id_val, UINT32);
12210 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
12211 TOKEN_STRING_INITIALIZER
12212 (struct cmd_config_e_tag_result,
12213 e_tag_id, "e-tag-id");
12214 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
12215 TOKEN_NUM_INITIALIZER
12216 (struct cmd_config_e_tag_result,
12217 e_tag_id_val, UINT16);
12218 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
12219 TOKEN_STRING_INITIALIZER
12220 (struct cmd_config_e_tag_result,
12221 dst_pool, "dst-pool");
12222 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
12223 TOKEN_NUM_INITIALIZER
12224 (struct cmd_config_e_tag_result,
12225 dst_pool_val, UINT8);
12226 cmdline_parse_token_string_t cmd_config_e_tag_port =
12227 TOKEN_STRING_INITIALIZER
12228 (struct cmd_config_e_tag_result,
12230 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
12231 TOKEN_NUM_INITIALIZER
12232 (struct cmd_config_e_tag_result,
12234 cmdline_parse_token_string_t cmd_config_e_tag_vf =
12235 TOKEN_STRING_INITIALIZER
12236 (struct cmd_config_e_tag_result,
12238 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
12239 TOKEN_NUM_INITIALIZER
12240 (struct cmd_config_e_tag_result,
12243 /* E-tag insertion configuration */
12245 cmd_config_e_tag_insertion_en_parsed(
12246 void *parsed_result,
12247 __attribute__((unused)) struct cmdline *cl,
12248 __attribute__((unused)) void *data)
12250 struct cmd_config_e_tag_result *res =
12252 struct rte_eth_l2_tunnel_conf entry;
12254 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12257 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12258 entry.tunnel_id = res->port_tag_id_val;
12259 entry.vf_id = res->vf_id;
12260 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12262 ETH_L2_TUNNEL_INSERTION_MASK,
12267 cmd_config_e_tag_insertion_dis_parsed(
12268 void *parsed_result,
12269 __attribute__((unused)) struct cmdline *cl,
12270 __attribute__((unused)) void *data)
12272 struct cmd_config_e_tag_result *res =
12274 struct rte_eth_l2_tunnel_conf entry;
12276 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12279 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12280 entry.vf_id = res->vf_id;
12282 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12284 ETH_L2_TUNNEL_INSERTION_MASK,
12288 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
12289 .f = cmd_config_e_tag_insertion_en_parsed,
12291 .help_str = "E-tag ... : E-tag insertion enable",
12293 (void *)&cmd_config_e_tag_e_tag,
12294 (void *)&cmd_config_e_tag_set,
12295 (void *)&cmd_config_e_tag_insertion,
12296 (void *)&cmd_config_e_tag_on,
12297 (void *)&cmd_config_e_tag_port_tag_id,
12298 (void *)&cmd_config_e_tag_port_tag_id_val,
12299 (void *)&cmd_config_e_tag_port,
12300 (void *)&cmd_config_e_tag_port_id,
12301 (void *)&cmd_config_e_tag_vf,
12302 (void *)&cmd_config_e_tag_vf_id,
12307 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
12308 .f = cmd_config_e_tag_insertion_dis_parsed,
12310 .help_str = "E-tag ... : E-tag insertion disable",
12312 (void *)&cmd_config_e_tag_e_tag,
12313 (void *)&cmd_config_e_tag_set,
12314 (void *)&cmd_config_e_tag_insertion,
12315 (void *)&cmd_config_e_tag_off,
12316 (void *)&cmd_config_e_tag_port,
12317 (void *)&cmd_config_e_tag_port_id,
12318 (void *)&cmd_config_e_tag_vf,
12319 (void *)&cmd_config_e_tag_vf_id,
12324 /* E-tag stripping configuration */
12326 cmd_config_e_tag_stripping_parsed(
12327 void *parsed_result,
12328 __attribute__((unused)) struct cmdline *cl,
12329 __attribute__((unused)) void *data)
12331 struct cmd_config_e_tag_result *res =
12333 struct rte_eth_l2_tunnel_conf entry;
12335 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12338 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12340 if (!strcmp(res->on_off, "on"))
12341 rte_eth_dev_l2_tunnel_offload_set
12344 ETH_L2_TUNNEL_STRIPPING_MASK,
12347 rte_eth_dev_l2_tunnel_offload_set
12350 ETH_L2_TUNNEL_STRIPPING_MASK,
12354 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
12355 .f = cmd_config_e_tag_stripping_parsed,
12357 .help_str = "E-tag ... : E-tag stripping enable/disable",
12359 (void *)&cmd_config_e_tag_e_tag,
12360 (void *)&cmd_config_e_tag_set,
12361 (void *)&cmd_config_e_tag_stripping,
12362 (void *)&cmd_config_e_tag_on_off,
12363 (void *)&cmd_config_e_tag_port,
12364 (void *)&cmd_config_e_tag_port_id,
12369 /* E-tag forwarding configuration */
12371 cmd_config_e_tag_forwarding_parsed(
12372 void *parsed_result,
12373 __attribute__((unused)) struct cmdline *cl,
12374 __attribute__((unused)) void *data)
12376 struct cmd_config_e_tag_result *res = parsed_result;
12377 struct rte_eth_l2_tunnel_conf entry;
12379 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12382 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12384 if (!strcmp(res->on_off, "on"))
12385 rte_eth_dev_l2_tunnel_offload_set
12388 ETH_L2_TUNNEL_FORWARDING_MASK,
12391 rte_eth_dev_l2_tunnel_offload_set
12394 ETH_L2_TUNNEL_FORWARDING_MASK,
12398 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
12399 .f = cmd_config_e_tag_forwarding_parsed,
12401 .help_str = "E-tag ... : E-tag forwarding enable/disable",
12403 (void *)&cmd_config_e_tag_e_tag,
12404 (void *)&cmd_config_e_tag_set,
12405 (void *)&cmd_config_e_tag_forwarding,
12406 (void *)&cmd_config_e_tag_on_off,
12407 (void *)&cmd_config_e_tag_port,
12408 (void *)&cmd_config_e_tag_port_id,
12413 /* E-tag filter configuration */
12415 cmd_config_e_tag_filter_add_parsed(
12416 void *parsed_result,
12417 __attribute__((unused)) struct cmdline *cl,
12418 __attribute__((unused)) void *data)
12420 struct cmd_config_e_tag_result *res = parsed_result;
12421 struct rte_eth_l2_tunnel_conf entry;
12424 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12427 if (res->e_tag_id_val > 0x3fff) {
12428 printf("e-tag-id must be equal or less than 0x3fff.\n");
12432 ret = rte_eth_dev_filter_supported(res->port_id,
12433 RTE_ETH_FILTER_L2_TUNNEL);
12435 printf("E-tag filter is not supported on port %u.\n",
12440 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12441 entry.tunnel_id = res->e_tag_id_val;
12442 entry.pool = res->dst_pool_val;
12444 ret = rte_eth_dev_filter_ctrl(res->port_id,
12445 RTE_ETH_FILTER_L2_TUNNEL,
12446 RTE_ETH_FILTER_ADD,
12449 printf("E-tag filter programming error: (%s)\n",
12453 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
12454 .f = cmd_config_e_tag_filter_add_parsed,
12456 .help_str = "E-tag ... : E-tag filter add",
12458 (void *)&cmd_config_e_tag_e_tag,
12459 (void *)&cmd_config_e_tag_set,
12460 (void *)&cmd_config_e_tag_filter,
12461 (void *)&cmd_config_e_tag_add,
12462 (void *)&cmd_config_e_tag_e_tag_id,
12463 (void *)&cmd_config_e_tag_e_tag_id_val,
12464 (void *)&cmd_config_e_tag_dst_pool,
12465 (void *)&cmd_config_e_tag_dst_pool_val,
12466 (void *)&cmd_config_e_tag_port,
12467 (void *)&cmd_config_e_tag_port_id,
12473 cmd_config_e_tag_filter_del_parsed(
12474 void *parsed_result,
12475 __attribute__((unused)) struct cmdline *cl,
12476 __attribute__((unused)) void *data)
12478 struct cmd_config_e_tag_result *res = parsed_result;
12479 struct rte_eth_l2_tunnel_conf entry;
12482 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12485 if (res->e_tag_id_val > 0x3fff) {
12486 printf("e-tag-id must be less than 0x3fff.\n");
12490 ret = rte_eth_dev_filter_supported(res->port_id,
12491 RTE_ETH_FILTER_L2_TUNNEL);
12493 printf("E-tag filter is not supported on port %u.\n",
12498 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12499 entry.tunnel_id = res->e_tag_id_val;
12501 ret = rte_eth_dev_filter_ctrl(res->port_id,
12502 RTE_ETH_FILTER_L2_TUNNEL,
12503 RTE_ETH_FILTER_DELETE,
12506 printf("E-tag filter programming error: (%s)\n",
12510 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
12511 .f = cmd_config_e_tag_filter_del_parsed,
12513 .help_str = "E-tag ... : E-tag filter delete",
12515 (void *)&cmd_config_e_tag_e_tag,
12516 (void *)&cmd_config_e_tag_set,
12517 (void *)&cmd_config_e_tag_filter,
12518 (void *)&cmd_config_e_tag_del,
12519 (void *)&cmd_config_e_tag_e_tag_id,
12520 (void *)&cmd_config_e_tag_e_tag_id_val,
12521 (void *)&cmd_config_e_tag_port,
12522 (void *)&cmd_config_e_tag_port_id,
12527 /* vf vlan anti spoof configuration */
12529 /* Common result structure for vf vlan anti spoof */
12530 struct cmd_vf_vlan_anti_spoof_result {
12531 cmdline_fixed_string_t set;
12532 cmdline_fixed_string_t vf;
12533 cmdline_fixed_string_t vlan;
12534 cmdline_fixed_string_t antispoof;
12537 cmdline_fixed_string_t on_off;
12540 /* Common CLI fields for vf vlan anti spoof enable disable */
12541 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
12542 TOKEN_STRING_INITIALIZER
12543 (struct cmd_vf_vlan_anti_spoof_result,
12545 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
12546 TOKEN_STRING_INITIALIZER
12547 (struct cmd_vf_vlan_anti_spoof_result,
12549 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
12550 TOKEN_STRING_INITIALIZER
12551 (struct cmd_vf_vlan_anti_spoof_result,
12553 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
12554 TOKEN_STRING_INITIALIZER
12555 (struct cmd_vf_vlan_anti_spoof_result,
12556 antispoof, "antispoof");
12557 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
12558 TOKEN_NUM_INITIALIZER
12559 (struct cmd_vf_vlan_anti_spoof_result,
12561 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
12562 TOKEN_NUM_INITIALIZER
12563 (struct cmd_vf_vlan_anti_spoof_result,
12565 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
12566 TOKEN_STRING_INITIALIZER
12567 (struct cmd_vf_vlan_anti_spoof_result,
12571 cmd_set_vf_vlan_anti_spoof_parsed(
12572 void *parsed_result,
12573 __attribute__((unused)) struct cmdline *cl,
12574 __attribute__((unused)) void *data)
12576 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
12577 int ret = -ENOTSUP;
12579 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12581 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12584 #ifdef RTE_LIBRTE_IXGBE_PMD
12585 if (ret == -ENOTSUP)
12586 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
12587 res->vf_id, is_on);
12589 #ifdef RTE_LIBRTE_I40E_PMD
12590 if (ret == -ENOTSUP)
12591 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
12592 res->vf_id, is_on);
12594 #ifdef RTE_LIBRTE_BNXT_PMD
12595 if (ret == -ENOTSUP)
12596 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
12597 res->vf_id, is_on);
12604 printf("invalid vf_id %d\n", res->vf_id);
12607 printf("invalid port_id %d\n", res->port_id);
12610 printf("function not implemented\n");
12613 printf("programming error: (%s)\n", strerror(-ret));
12617 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
12618 .f = cmd_set_vf_vlan_anti_spoof_parsed,
12620 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
12622 (void *)&cmd_vf_vlan_anti_spoof_set,
12623 (void *)&cmd_vf_vlan_anti_spoof_vf,
12624 (void *)&cmd_vf_vlan_anti_spoof_vlan,
12625 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
12626 (void *)&cmd_vf_vlan_anti_spoof_port_id,
12627 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
12628 (void *)&cmd_vf_vlan_anti_spoof_on_off,
12633 /* vf mac anti spoof configuration */
12635 /* Common result structure for vf mac anti spoof */
12636 struct cmd_vf_mac_anti_spoof_result {
12637 cmdline_fixed_string_t set;
12638 cmdline_fixed_string_t vf;
12639 cmdline_fixed_string_t mac;
12640 cmdline_fixed_string_t antispoof;
12643 cmdline_fixed_string_t on_off;
12646 /* Common CLI fields for vf mac anti spoof enable disable */
12647 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
12648 TOKEN_STRING_INITIALIZER
12649 (struct cmd_vf_mac_anti_spoof_result,
12651 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
12652 TOKEN_STRING_INITIALIZER
12653 (struct cmd_vf_mac_anti_spoof_result,
12655 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
12656 TOKEN_STRING_INITIALIZER
12657 (struct cmd_vf_mac_anti_spoof_result,
12659 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
12660 TOKEN_STRING_INITIALIZER
12661 (struct cmd_vf_mac_anti_spoof_result,
12662 antispoof, "antispoof");
12663 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
12664 TOKEN_NUM_INITIALIZER
12665 (struct cmd_vf_mac_anti_spoof_result,
12667 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
12668 TOKEN_NUM_INITIALIZER
12669 (struct cmd_vf_mac_anti_spoof_result,
12671 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
12672 TOKEN_STRING_INITIALIZER
12673 (struct cmd_vf_mac_anti_spoof_result,
12677 cmd_set_vf_mac_anti_spoof_parsed(
12678 void *parsed_result,
12679 __attribute__((unused)) struct cmdline *cl,
12680 __attribute__((unused)) void *data)
12682 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
12683 int ret = -ENOTSUP;
12685 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12687 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12690 #ifdef RTE_LIBRTE_IXGBE_PMD
12691 if (ret == -ENOTSUP)
12692 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
12693 res->vf_id, is_on);
12695 #ifdef RTE_LIBRTE_I40E_PMD
12696 if (ret == -ENOTSUP)
12697 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
12698 res->vf_id, is_on);
12700 #ifdef RTE_LIBRTE_BNXT_PMD
12701 if (ret == -ENOTSUP)
12702 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
12703 res->vf_id, is_on);
12710 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12713 printf("invalid port_id %d\n", res->port_id);
12716 printf("function not implemented\n");
12719 printf("programming error: (%s)\n", strerror(-ret));
12723 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
12724 .f = cmd_set_vf_mac_anti_spoof_parsed,
12726 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
12728 (void *)&cmd_vf_mac_anti_spoof_set,
12729 (void *)&cmd_vf_mac_anti_spoof_vf,
12730 (void *)&cmd_vf_mac_anti_spoof_mac,
12731 (void *)&cmd_vf_mac_anti_spoof_antispoof,
12732 (void *)&cmd_vf_mac_anti_spoof_port_id,
12733 (void *)&cmd_vf_mac_anti_spoof_vf_id,
12734 (void *)&cmd_vf_mac_anti_spoof_on_off,
12739 /* vf vlan strip queue configuration */
12741 /* Common result structure for vf mac anti spoof */
12742 struct cmd_vf_vlan_stripq_result {
12743 cmdline_fixed_string_t set;
12744 cmdline_fixed_string_t vf;
12745 cmdline_fixed_string_t vlan;
12746 cmdline_fixed_string_t stripq;
12749 cmdline_fixed_string_t on_off;
12752 /* Common CLI fields for vf vlan strip enable disable */
12753 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
12754 TOKEN_STRING_INITIALIZER
12755 (struct cmd_vf_vlan_stripq_result,
12757 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
12758 TOKEN_STRING_INITIALIZER
12759 (struct cmd_vf_vlan_stripq_result,
12761 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
12762 TOKEN_STRING_INITIALIZER
12763 (struct cmd_vf_vlan_stripq_result,
12765 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
12766 TOKEN_STRING_INITIALIZER
12767 (struct cmd_vf_vlan_stripq_result,
12769 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
12770 TOKEN_NUM_INITIALIZER
12771 (struct cmd_vf_vlan_stripq_result,
12773 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
12774 TOKEN_NUM_INITIALIZER
12775 (struct cmd_vf_vlan_stripq_result,
12777 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
12778 TOKEN_STRING_INITIALIZER
12779 (struct cmd_vf_vlan_stripq_result,
12783 cmd_set_vf_vlan_stripq_parsed(
12784 void *parsed_result,
12785 __attribute__((unused)) struct cmdline *cl,
12786 __attribute__((unused)) void *data)
12788 struct cmd_vf_vlan_stripq_result *res = parsed_result;
12789 int ret = -ENOTSUP;
12791 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12793 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12796 #ifdef RTE_LIBRTE_IXGBE_PMD
12797 if (ret == -ENOTSUP)
12798 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
12799 res->vf_id, is_on);
12801 #ifdef RTE_LIBRTE_I40E_PMD
12802 if (ret == -ENOTSUP)
12803 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
12804 res->vf_id, is_on);
12806 #ifdef RTE_LIBRTE_BNXT_PMD
12807 if (ret == -ENOTSUP)
12808 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
12809 res->vf_id, is_on);
12816 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12819 printf("invalid port_id %d\n", res->port_id);
12822 printf("function not implemented\n");
12825 printf("programming error: (%s)\n", strerror(-ret));
12829 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
12830 .f = cmd_set_vf_vlan_stripq_parsed,
12832 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
12834 (void *)&cmd_vf_vlan_stripq_set,
12835 (void *)&cmd_vf_vlan_stripq_vf,
12836 (void *)&cmd_vf_vlan_stripq_vlan,
12837 (void *)&cmd_vf_vlan_stripq_stripq,
12838 (void *)&cmd_vf_vlan_stripq_port_id,
12839 (void *)&cmd_vf_vlan_stripq_vf_id,
12840 (void *)&cmd_vf_vlan_stripq_on_off,
12845 /* vf vlan insert configuration */
12847 /* Common result structure for vf vlan insert */
12848 struct cmd_vf_vlan_insert_result {
12849 cmdline_fixed_string_t set;
12850 cmdline_fixed_string_t vf;
12851 cmdline_fixed_string_t vlan;
12852 cmdline_fixed_string_t insert;
12858 /* Common CLI fields for vf vlan insert enable disable */
12859 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
12860 TOKEN_STRING_INITIALIZER
12861 (struct cmd_vf_vlan_insert_result,
12863 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
12864 TOKEN_STRING_INITIALIZER
12865 (struct cmd_vf_vlan_insert_result,
12867 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
12868 TOKEN_STRING_INITIALIZER
12869 (struct cmd_vf_vlan_insert_result,
12871 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
12872 TOKEN_STRING_INITIALIZER
12873 (struct cmd_vf_vlan_insert_result,
12875 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
12876 TOKEN_NUM_INITIALIZER
12877 (struct cmd_vf_vlan_insert_result,
12879 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
12880 TOKEN_NUM_INITIALIZER
12881 (struct cmd_vf_vlan_insert_result,
12883 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
12884 TOKEN_NUM_INITIALIZER
12885 (struct cmd_vf_vlan_insert_result,
12889 cmd_set_vf_vlan_insert_parsed(
12890 void *parsed_result,
12891 __attribute__((unused)) struct cmdline *cl,
12892 __attribute__((unused)) void *data)
12894 struct cmd_vf_vlan_insert_result *res = parsed_result;
12895 int ret = -ENOTSUP;
12897 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12900 #ifdef RTE_LIBRTE_IXGBE_PMD
12901 if (ret == -ENOTSUP)
12902 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
12905 #ifdef RTE_LIBRTE_I40E_PMD
12906 if (ret == -ENOTSUP)
12907 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
12910 #ifdef RTE_LIBRTE_BNXT_PMD
12911 if (ret == -ENOTSUP)
12912 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
12920 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
12923 printf("invalid port_id %d\n", res->port_id);
12926 printf("function not implemented\n");
12929 printf("programming error: (%s)\n", strerror(-ret));
12933 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
12934 .f = cmd_set_vf_vlan_insert_parsed,
12936 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
12938 (void *)&cmd_vf_vlan_insert_set,
12939 (void *)&cmd_vf_vlan_insert_vf,
12940 (void *)&cmd_vf_vlan_insert_vlan,
12941 (void *)&cmd_vf_vlan_insert_insert,
12942 (void *)&cmd_vf_vlan_insert_port_id,
12943 (void *)&cmd_vf_vlan_insert_vf_id,
12944 (void *)&cmd_vf_vlan_insert_vlan_id,
12949 /* tx loopback configuration */
12951 /* Common result structure for tx loopback */
12952 struct cmd_tx_loopback_result {
12953 cmdline_fixed_string_t set;
12954 cmdline_fixed_string_t tx;
12955 cmdline_fixed_string_t loopback;
12957 cmdline_fixed_string_t on_off;
12960 /* Common CLI fields for tx loopback enable disable */
12961 cmdline_parse_token_string_t cmd_tx_loopback_set =
12962 TOKEN_STRING_INITIALIZER
12963 (struct cmd_tx_loopback_result,
12965 cmdline_parse_token_string_t cmd_tx_loopback_tx =
12966 TOKEN_STRING_INITIALIZER
12967 (struct cmd_tx_loopback_result,
12969 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
12970 TOKEN_STRING_INITIALIZER
12971 (struct cmd_tx_loopback_result,
12972 loopback, "loopback");
12973 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
12974 TOKEN_NUM_INITIALIZER
12975 (struct cmd_tx_loopback_result,
12977 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
12978 TOKEN_STRING_INITIALIZER
12979 (struct cmd_tx_loopback_result,
12983 cmd_set_tx_loopback_parsed(
12984 void *parsed_result,
12985 __attribute__((unused)) struct cmdline *cl,
12986 __attribute__((unused)) void *data)
12988 struct cmd_tx_loopback_result *res = parsed_result;
12989 int ret = -ENOTSUP;
12991 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12993 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12996 #ifdef RTE_LIBRTE_IXGBE_PMD
12997 if (ret == -ENOTSUP)
12998 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
13000 #ifdef RTE_LIBRTE_I40E_PMD
13001 if (ret == -ENOTSUP)
13002 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
13004 #ifdef RTE_LIBRTE_BNXT_PMD
13005 if (ret == -ENOTSUP)
13006 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
13008 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
13009 if (ret == -ENOTSUP)
13010 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
13017 printf("invalid is_on %d\n", is_on);
13020 printf("invalid port_id %d\n", res->port_id);
13023 printf("function not implemented\n");
13026 printf("programming error: (%s)\n", strerror(-ret));
13030 cmdline_parse_inst_t cmd_set_tx_loopback = {
13031 .f = cmd_set_tx_loopback_parsed,
13033 .help_str = "set tx loopback <port_id> on|off",
13035 (void *)&cmd_tx_loopback_set,
13036 (void *)&cmd_tx_loopback_tx,
13037 (void *)&cmd_tx_loopback_loopback,
13038 (void *)&cmd_tx_loopback_port_id,
13039 (void *)&cmd_tx_loopback_on_off,
13044 /* all queues drop enable configuration */
13046 /* Common result structure for all queues drop enable */
13047 struct cmd_all_queues_drop_en_result {
13048 cmdline_fixed_string_t set;
13049 cmdline_fixed_string_t all;
13050 cmdline_fixed_string_t queues;
13051 cmdline_fixed_string_t drop;
13053 cmdline_fixed_string_t on_off;
13056 /* Common CLI fields for tx loopback enable disable */
13057 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
13058 TOKEN_STRING_INITIALIZER
13059 (struct cmd_all_queues_drop_en_result,
13061 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
13062 TOKEN_STRING_INITIALIZER
13063 (struct cmd_all_queues_drop_en_result,
13065 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
13066 TOKEN_STRING_INITIALIZER
13067 (struct cmd_all_queues_drop_en_result,
13069 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
13070 TOKEN_STRING_INITIALIZER
13071 (struct cmd_all_queues_drop_en_result,
13073 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
13074 TOKEN_NUM_INITIALIZER
13075 (struct cmd_all_queues_drop_en_result,
13077 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
13078 TOKEN_STRING_INITIALIZER
13079 (struct cmd_all_queues_drop_en_result,
13083 cmd_set_all_queues_drop_en_parsed(
13084 void *parsed_result,
13085 __attribute__((unused)) struct cmdline *cl,
13086 __attribute__((unused)) void *data)
13088 struct cmd_all_queues_drop_en_result *res = parsed_result;
13089 int ret = -ENOTSUP;
13090 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13092 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13095 #ifdef RTE_LIBRTE_IXGBE_PMD
13096 if (ret == -ENOTSUP)
13097 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
13099 #ifdef RTE_LIBRTE_BNXT_PMD
13100 if (ret == -ENOTSUP)
13101 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
13107 printf("invalid is_on %d\n", is_on);
13110 printf("invalid port_id %d\n", res->port_id);
13113 printf("function not implemented\n");
13116 printf("programming error: (%s)\n", strerror(-ret));
13120 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
13121 .f = cmd_set_all_queues_drop_en_parsed,
13123 .help_str = "set all queues drop <port_id> on|off",
13125 (void *)&cmd_all_queues_drop_en_set,
13126 (void *)&cmd_all_queues_drop_en_all,
13127 (void *)&cmd_all_queues_drop_en_queues,
13128 (void *)&cmd_all_queues_drop_en_drop,
13129 (void *)&cmd_all_queues_drop_en_port_id,
13130 (void *)&cmd_all_queues_drop_en_on_off,
13135 /* vf split drop enable configuration */
13137 /* Common result structure for vf split drop enable */
13138 struct cmd_vf_split_drop_en_result {
13139 cmdline_fixed_string_t set;
13140 cmdline_fixed_string_t vf;
13141 cmdline_fixed_string_t split;
13142 cmdline_fixed_string_t drop;
13145 cmdline_fixed_string_t on_off;
13148 /* Common CLI fields for vf split drop enable disable */
13149 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
13150 TOKEN_STRING_INITIALIZER
13151 (struct cmd_vf_split_drop_en_result,
13153 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
13154 TOKEN_STRING_INITIALIZER
13155 (struct cmd_vf_split_drop_en_result,
13157 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
13158 TOKEN_STRING_INITIALIZER
13159 (struct cmd_vf_split_drop_en_result,
13161 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
13162 TOKEN_STRING_INITIALIZER
13163 (struct cmd_vf_split_drop_en_result,
13165 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
13166 TOKEN_NUM_INITIALIZER
13167 (struct cmd_vf_split_drop_en_result,
13169 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
13170 TOKEN_NUM_INITIALIZER
13171 (struct cmd_vf_split_drop_en_result,
13173 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
13174 TOKEN_STRING_INITIALIZER
13175 (struct cmd_vf_split_drop_en_result,
13179 cmd_set_vf_split_drop_en_parsed(
13180 void *parsed_result,
13181 __attribute__((unused)) struct cmdline *cl,
13182 __attribute__((unused)) void *data)
13184 struct cmd_vf_split_drop_en_result *res = parsed_result;
13185 int ret = -ENOTSUP;
13186 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13188 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13191 #ifdef RTE_LIBRTE_IXGBE_PMD
13192 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
13199 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13202 printf("invalid port_id %d\n", res->port_id);
13205 printf("not supported on port %d\n", res->port_id);
13208 printf("programming error: (%s)\n", strerror(-ret));
13212 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
13213 .f = cmd_set_vf_split_drop_en_parsed,
13215 .help_str = "set vf split drop <port_id> <vf_id> on|off",
13217 (void *)&cmd_vf_split_drop_en_set,
13218 (void *)&cmd_vf_split_drop_en_vf,
13219 (void *)&cmd_vf_split_drop_en_split,
13220 (void *)&cmd_vf_split_drop_en_drop,
13221 (void *)&cmd_vf_split_drop_en_port_id,
13222 (void *)&cmd_vf_split_drop_en_vf_id,
13223 (void *)&cmd_vf_split_drop_en_on_off,
13228 /* vf mac address configuration */
13230 /* Common result structure for vf mac address */
13231 struct cmd_set_vf_mac_addr_result {
13232 cmdline_fixed_string_t set;
13233 cmdline_fixed_string_t vf;
13234 cmdline_fixed_string_t mac;
13235 cmdline_fixed_string_t addr;
13238 struct ether_addr mac_addr;
13242 /* Common CLI fields for vf split drop enable disable */
13243 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
13244 TOKEN_STRING_INITIALIZER
13245 (struct cmd_set_vf_mac_addr_result,
13247 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
13248 TOKEN_STRING_INITIALIZER
13249 (struct cmd_set_vf_mac_addr_result,
13251 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
13252 TOKEN_STRING_INITIALIZER
13253 (struct cmd_set_vf_mac_addr_result,
13255 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
13256 TOKEN_STRING_INITIALIZER
13257 (struct cmd_set_vf_mac_addr_result,
13259 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
13260 TOKEN_NUM_INITIALIZER
13261 (struct cmd_set_vf_mac_addr_result,
13263 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
13264 TOKEN_NUM_INITIALIZER
13265 (struct cmd_set_vf_mac_addr_result,
13267 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
13268 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
13272 cmd_set_vf_mac_addr_parsed(
13273 void *parsed_result,
13274 __attribute__((unused)) struct cmdline *cl,
13275 __attribute__((unused)) void *data)
13277 struct cmd_set_vf_mac_addr_result *res = parsed_result;
13278 int ret = -ENOTSUP;
13280 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13283 #ifdef RTE_LIBRTE_IXGBE_PMD
13284 if (ret == -ENOTSUP)
13285 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
13288 #ifdef RTE_LIBRTE_I40E_PMD
13289 if (ret == -ENOTSUP)
13290 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
13293 #ifdef RTE_LIBRTE_BNXT_PMD
13294 if (ret == -ENOTSUP)
13295 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
13303 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
13306 printf("invalid port_id %d\n", res->port_id);
13309 printf("function not implemented\n");
13312 printf("programming error: (%s)\n", strerror(-ret));
13316 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
13317 .f = cmd_set_vf_mac_addr_parsed,
13319 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
13321 (void *)&cmd_set_vf_mac_addr_set,
13322 (void *)&cmd_set_vf_mac_addr_vf,
13323 (void *)&cmd_set_vf_mac_addr_mac,
13324 (void *)&cmd_set_vf_mac_addr_addr,
13325 (void *)&cmd_set_vf_mac_addr_port_id,
13326 (void *)&cmd_set_vf_mac_addr_vf_id,
13327 (void *)&cmd_set_vf_mac_addr_mac_addr,
13332 /* MACsec configuration */
13334 /* Common result structure for MACsec offload enable */
13335 struct cmd_macsec_offload_on_result {
13336 cmdline_fixed_string_t set;
13337 cmdline_fixed_string_t macsec;
13338 cmdline_fixed_string_t offload;
13340 cmdline_fixed_string_t on;
13341 cmdline_fixed_string_t encrypt;
13342 cmdline_fixed_string_t en_on_off;
13343 cmdline_fixed_string_t replay_protect;
13344 cmdline_fixed_string_t rp_on_off;
13347 /* Common CLI fields for MACsec offload disable */
13348 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
13349 TOKEN_STRING_INITIALIZER
13350 (struct cmd_macsec_offload_on_result,
13352 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
13353 TOKEN_STRING_INITIALIZER
13354 (struct cmd_macsec_offload_on_result,
13356 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
13357 TOKEN_STRING_INITIALIZER
13358 (struct cmd_macsec_offload_on_result,
13359 offload, "offload");
13360 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
13361 TOKEN_NUM_INITIALIZER
13362 (struct cmd_macsec_offload_on_result,
13364 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
13365 TOKEN_STRING_INITIALIZER
13366 (struct cmd_macsec_offload_on_result,
13368 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
13369 TOKEN_STRING_INITIALIZER
13370 (struct cmd_macsec_offload_on_result,
13371 encrypt, "encrypt");
13372 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
13373 TOKEN_STRING_INITIALIZER
13374 (struct cmd_macsec_offload_on_result,
13375 en_on_off, "on#off");
13376 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
13377 TOKEN_STRING_INITIALIZER
13378 (struct cmd_macsec_offload_on_result,
13379 replay_protect, "replay-protect");
13380 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
13381 TOKEN_STRING_INITIALIZER
13382 (struct cmd_macsec_offload_on_result,
13383 rp_on_off, "on#off");
13386 cmd_set_macsec_offload_on_parsed(
13387 void *parsed_result,
13388 __attribute__((unused)) struct cmdline *cl,
13389 __attribute__((unused)) void *data)
13391 struct cmd_macsec_offload_on_result *res = parsed_result;
13392 int ret = -ENOTSUP;
13393 portid_t port_id = res->port_id;
13394 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
13395 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
13396 struct rte_eth_dev_info dev_info;
13398 if (port_id_is_invalid(port_id, ENABLED_WARN))
13400 if (!port_is_stopped(port_id)) {
13401 printf("Please stop port %d first\n", port_id);
13405 rte_eth_dev_info_get(port_id, &dev_info);
13406 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13407 #ifdef RTE_LIBRTE_IXGBE_PMD
13408 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
13416 ports[port_id].dev_conf.txmode.offloads |=
13417 DEV_TX_OFFLOAD_MACSEC_INSERT;
13418 cmd_reconfig_device_queue(port_id, 1, 1);
13421 printf("invalid port_id %d\n", port_id);
13424 printf("not supported on port %d\n", port_id);
13427 printf("programming error: (%s)\n", strerror(-ret));
13431 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
13432 .f = cmd_set_macsec_offload_on_parsed,
13434 .help_str = "set macsec offload <port_id> on "
13435 "encrypt on|off replay-protect on|off",
13437 (void *)&cmd_macsec_offload_on_set,
13438 (void *)&cmd_macsec_offload_on_macsec,
13439 (void *)&cmd_macsec_offload_on_offload,
13440 (void *)&cmd_macsec_offload_on_port_id,
13441 (void *)&cmd_macsec_offload_on_on,
13442 (void *)&cmd_macsec_offload_on_encrypt,
13443 (void *)&cmd_macsec_offload_on_en_on_off,
13444 (void *)&cmd_macsec_offload_on_replay_protect,
13445 (void *)&cmd_macsec_offload_on_rp_on_off,
13450 /* Common result structure for MACsec offload disable */
13451 struct cmd_macsec_offload_off_result {
13452 cmdline_fixed_string_t set;
13453 cmdline_fixed_string_t macsec;
13454 cmdline_fixed_string_t offload;
13456 cmdline_fixed_string_t off;
13459 /* Common CLI fields for MACsec offload disable */
13460 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
13461 TOKEN_STRING_INITIALIZER
13462 (struct cmd_macsec_offload_off_result,
13464 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
13465 TOKEN_STRING_INITIALIZER
13466 (struct cmd_macsec_offload_off_result,
13468 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
13469 TOKEN_STRING_INITIALIZER
13470 (struct cmd_macsec_offload_off_result,
13471 offload, "offload");
13472 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
13473 TOKEN_NUM_INITIALIZER
13474 (struct cmd_macsec_offload_off_result,
13476 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
13477 TOKEN_STRING_INITIALIZER
13478 (struct cmd_macsec_offload_off_result,
13482 cmd_set_macsec_offload_off_parsed(
13483 void *parsed_result,
13484 __attribute__((unused)) struct cmdline *cl,
13485 __attribute__((unused)) void *data)
13487 struct cmd_macsec_offload_off_result *res = parsed_result;
13488 int ret = -ENOTSUP;
13489 struct rte_eth_dev_info dev_info;
13490 portid_t port_id = res->port_id;
13492 if (port_id_is_invalid(port_id, ENABLED_WARN))
13494 if (!port_is_stopped(port_id)) {
13495 printf("Please stop port %d first\n", port_id);
13499 rte_eth_dev_info_get(port_id, &dev_info);
13500 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13501 #ifdef RTE_LIBRTE_IXGBE_PMD
13502 ret = rte_pmd_ixgbe_macsec_disable(port_id);
13507 ports[port_id].dev_conf.txmode.offloads &=
13508 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
13509 cmd_reconfig_device_queue(port_id, 1, 1);
13512 printf("invalid port_id %d\n", port_id);
13515 printf("not supported on port %d\n", port_id);
13518 printf("programming error: (%s)\n", strerror(-ret));
13522 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
13523 .f = cmd_set_macsec_offload_off_parsed,
13525 .help_str = "set macsec offload <port_id> off",
13527 (void *)&cmd_macsec_offload_off_set,
13528 (void *)&cmd_macsec_offload_off_macsec,
13529 (void *)&cmd_macsec_offload_off_offload,
13530 (void *)&cmd_macsec_offload_off_port_id,
13531 (void *)&cmd_macsec_offload_off_off,
13536 /* Common result structure for MACsec secure connection configure */
13537 struct cmd_macsec_sc_result {
13538 cmdline_fixed_string_t set;
13539 cmdline_fixed_string_t macsec;
13540 cmdline_fixed_string_t sc;
13541 cmdline_fixed_string_t tx_rx;
13543 struct ether_addr mac;
13547 /* Common CLI fields for MACsec secure connection configure */
13548 cmdline_parse_token_string_t cmd_macsec_sc_set =
13549 TOKEN_STRING_INITIALIZER
13550 (struct cmd_macsec_sc_result,
13552 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
13553 TOKEN_STRING_INITIALIZER
13554 (struct cmd_macsec_sc_result,
13556 cmdline_parse_token_string_t cmd_macsec_sc_sc =
13557 TOKEN_STRING_INITIALIZER
13558 (struct cmd_macsec_sc_result,
13560 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
13561 TOKEN_STRING_INITIALIZER
13562 (struct cmd_macsec_sc_result,
13564 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
13565 TOKEN_NUM_INITIALIZER
13566 (struct cmd_macsec_sc_result,
13568 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
13569 TOKEN_ETHERADDR_INITIALIZER
13570 (struct cmd_macsec_sc_result,
13572 cmdline_parse_token_num_t cmd_macsec_sc_pi =
13573 TOKEN_NUM_INITIALIZER
13574 (struct cmd_macsec_sc_result,
13578 cmd_set_macsec_sc_parsed(
13579 void *parsed_result,
13580 __attribute__((unused)) struct cmdline *cl,
13581 __attribute__((unused)) void *data)
13583 struct cmd_macsec_sc_result *res = parsed_result;
13584 int ret = -ENOTSUP;
13585 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13587 #ifdef RTE_LIBRTE_IXGBE_PMD
13589 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
13590 res->mac.addr_bytes) :
13591 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
13592 res->mac.addr_bytes, res->pi);
13594 RTE_SET_USED(is_tx);
13600 printf("invalid port_id %d\n", res->port_id);
13603 printf("not supported on port %d\n", res->port_id);
13606 printf("programming error: (%s)\n", strerror(-ret));
13610 cmdline_parse_inst_t cmd_set_macsec_sc = {
13611 .f = cmd_set_macsec_sc_parsed,
13613 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
13615 (void *)&cmd_macsec_sc_set,
13616 (void *)&cmd_macsec_sc_macsec,
13617 (void *)&cmd_macsec_sc_sc,
13618 (void *)&cmd_macsec_sc_tx_rx,
13619 (void *)&cmd_macsec_sc_port_id,
13620 (void *)&cmd_macsec_sc_mac,
13621 (void *)&cmd_macsec_sc_pi,
13626 /* Common result structure for MACsec secure connection configure */
13627 struct cmd_macsec_sa_result {
13628 cmdline_fixed_string_t set;
13629 cmdline_fixed_string_t macsec;
13630 cmdline_fixed_string_t sa;
13631 cmdline_fixed_string_t tx_rx;
13636 cmdline_fixed_string_t key;
13639 /* Common CLI fields for MACsec secure connection configure */
13640 cmdline_parse_token_string_t cmd_macsec_sa_set =
13641 TOKEN_STRING_INITIALIZER
13642 (struct cmd_macsec_sa_result,
13644 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
13645 TOKEN_STRING_INITIALIZER
13646 (struct cmd_macsec_sa_result,
13648 cmdline_parse_token_string_t cmd_macsec_sa_sa =
13649 TOKEN_STRING_INITIALIZER
13650 (struct cmd_macsec_sa_result,
13652 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
13653 TOKEN_STRING_INITIALIZER
13654 (struct cmd_macsec_sa_result,
13656 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
13657 TOKEN_NUM_INITIALIZER
13658 (struct cmd_macsec_sa_result,
13660 cmdline_parse_token_num_t cmd_macsec_sa_idx =
13661 TOKEN_NUM_INITIALIZER
13662 (struct cmd_macsec_sa_result,
13664 cmdline_parse_token_num_t cmd_macsec_sa_an =
13665 TOKEN_NUM_INITIALIZER
13666 (struct cmd_macsec_sa_result,
13668 cmdline_parse_token_num_t cmd_macsec_sa_pn =
13669 TOKEN_NUM_INITIALIZER
13670 (struct cmd_macsec_sa_result,
13672 cmdline_parse_token_string_t cmd_macsec_sa_key =
13673 TOKEN_STRING_INITIALIZER
13674 (struct cmd_macsec_sa_result,
13678 cmd_set_macsec_sa_parsed(
13679 void *parsed_result,
13680 __attribute__((unused)) struct cmdline *cl,
13681 __attribute__((unused)) void *data)
13683 struct cmd_macsec_sa_result *res = parsed_result;
13684 int ret = -ENOTSUP;
13685 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13686 uint8_t key[16] = { 0 };
13692 key_len = strlen(res->key) / 2;
13696 for (i = 0; i < key_len; i++) {
13697 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
13700 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
13703 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
13706 #ifdef RTE_LIBRTE_IXGBE_PMD
13708 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
13709 res->idx, res->an, res->pn, key) :
13710 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
13711 res->idx, res->an, res->pn, key);
13713 RTE_SET_USED(is_tx);
13720 printf("invalid idx %d or an %d\n", res->idx, res->an);
13723 printf("invalid port_id %d\n", res->port_id);
13726 printf("not supported on port %d\n", res->port_id);
13729 printf("programming error: (%s)\n", strerror(-ret));
13733 cmdline_parse_inst_t cmd_set_macsec_sa = {
13734 .f = cmd_set_macsec_sa_parsed,
13736 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
13738 (void *)&cmd_macsec_sa_set,
13739 (void *)&cmd_macsec_sa_macsec,
13740 (void *)&cmd_macsec_sa_sa,
13741 (void *)&cmd_macsec_sa_tx_rx,
13742 (void *)&cmd_macsec_sa_port_id,
13743 (void *)&cmd_macsec_sa_idx,
13744 (void *)&cmd_macsec_sa_an,
13745 (void *)&cmd_macsec_sa_pn,
13746 (void *)&cmd_macsec_sa_key,
13751 /* VF unicast promiscuous mode configuration */
13753 /* Common result structure for VF unicast promiscuous mode */
13754 struct cmd_vf_promisc_result {
13755 cmdline_fixed_string_t set;
13756 cmdline_fixed_string_t vf;
13757 cmdline_fixed_string_t promisc;
13760 cmdline_fixed_string_t on_off;
13763 /* Common CLI fields for VF unicast promiscuous mode enable disable */
13764 cmdline_parse_token_string_t cmd_vf_promisc_set =
13765 TOKEN_STRING_INITIALIZER
13766 (struct cmd_vf_promisc_result,
13768 cmdline_parse_token_string_t cmd_vf_promisc_vf =
13769 TOKEN_STRING_INITIALIZER
13770 (struct cmd_vf_promisc_result,
13772 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
13773 TOKEN_STRING_INITIALIZER
13774 (struct cmd_vf_promisc_result,
13775 promisc, "promisc");
13776 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
13777 TOKEN_NUM_INITIALIZER
13778 (struct cmd_vf_promisc_result,
13780 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
13781 TOKEN_NUM_INITIALIZER
13782 (struct cmd_vf_promisc_result,
13784 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
13785 TOKEN_STRING_INITIALIZER
13786 (struct cmd_vf_promisc_result,
13790 cmd_set_vf_promisc_parsed(
13791 void *parsed_result,
13792 __attribute__((unused)) struct cmdline *cl,
13793 __attribute__((unused)) void *data)
13795 struct cmd_vf_promisc_result *res = parsed_result;
13796 int ret = -ENOTSUP;
13798 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13800 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13803 #ifdef RTE_LIBRTE_I40E_PMD
13804 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
13805 res->vf_id, is_on);
13812 printf("invalid vf_id %d\n", res->vf_id);
13815 printf("invalid port_id %d\n", res->port_id);
13818 printf("function not implemented\n");
13821 printf("programming error: (%s)\n", strerror(-ret));
13825 cmdline_parse_inst_t cmd_set_vf_promisc = {
13826 .f = cmd_set_vf_promisc_parsed,
13828 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
13829 "Set unicast promiscuous mode for a VF from the PF",
13831 (void *)&cmd_vf_promisc_set,
13832 (void *)&cmd_vf_promisc_vf,
13833 (void *)&cmd_vf_promisc_promisc,
13834 (void *)&cmd_vf_promisc_port_id,
13835 (void *)&cmd_vf_promisc_vf_id,
13836 (void *)&cmd_vf_promisc_on_off,
13841 /* VF multicast promiscuous mode configuration */
13843 /* Common result structure for VF multicast promiscuous mode */
13844 struct cmd_vf_allmulti_result {
13845 cmdline_fixed_string_t set;
13846 cmdline_fixed_string_t vf;
13847 cmdline_fixed_string_t allmulti;
13850 cmdline_fixed_string_t on_off;
13853 /* Common CLI fields for VF multicast promiscuous mode enable disable */
13854 cmdline_parse_token_string_t cmd_vf_allmulti_set =
13855 TOKEN_STRING_INITIALIZER
13856 (struct cmd_vf_allmulti_result,
13858 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
13859 TOKEN_STRING_INITIALIZER
13860 (struct cmd_vf_allmulti_result,
13862 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
13863 TOKEN_STRING_INITIALIZER
13864 (struct cmd_vf_allmulti_result,
13865 allmulti, "allmulti");
13866 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
13867 TOKEN_NUM_INITIALIZER
13868 (struct cmd_vf_allmulti_result,
13870 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
13871 TOKEN_NUM_INITIALIZER
13872 (struct cmd_vf_allmulti_result,
13874 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
13875 TOKEN_STRING_INITIALIZER
13876 (struct cmd_vf_allmulti_result,
13880 cmd_set_vf_allmulti_parsed(
13881 void *parsed_result,
13882 __attribute__((unused)) struct cmdline *cl,
13883 __attribute__((unused)) void *data)
13885 struct cmd_vf_allmulti_result *res = parsed_result;
13886 int ret = -ENOTSUP;
13888 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13890 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13893 #ifdef RTE_LIBRTE_I40E_PMD
13894 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
13895 res->vf_id, is_on);
13902 printf("invalid vf_id %d\n", res->vf_id);
13905 printf("invalid port_id %d\n", res->port_id);
13908 printf("function not implemented\n");
13911 printf("programming error: (%s)\n", strerror(-ret));
13915 cmdline_parse_inst_t cmd_set_vf_allmulti = {
13916 .f = cmd_set_vf_allmulti_parsed,
13918 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
13919 "Set multicast promiscuous mode for a VF from the PF",
13921 (void *)&cmd_vf_allmulti_set,
13922 (void *)&cmd_vf_allmulti_vf,
13923 (void *)&cmd_vf_allmulti_allmulti,
13924 (void *)&cmd_vf_allmulti_port_id,
13925 (void *)&cmd_vf_allmulti_vf_id,
13926 (void *)&cmd_vf_allmulti_on_off,
13931 /* vf broadcast mode configuration */
13933 /* Common result structure for vf broadcast */
13934 struct cmd_set_vf_broadcast_result {
13935 cmdline_fixed_string_t set;
13936 cmdline_fixed_string_t vf;
13937 cmdline_fixed_string_t broadcast;
13940 cmdline_fixed_string_t on_off;
13943 /* Common CLI fields for vf broadcast enable disable */
13944 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
13945 TOKEN_STRING_INITIALIZER
13946 (struct cmd_set_vf_broadcast_result,
13948 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
13949 TOKEN_STRING_INITIALIZER
13950 (struct cmd_set_vf_broadcast_result,
13952 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
13953 TOKEN_STRING_INITIALIZER
13954 (struct cmd_set_vf_broadcast_result,
13955 broadcast, "broadcast");
13956 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
13957 TOKEN_NUM_INITIALIZER
13958 (struct cmd_set_vf_broadcast_result,
13960 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
13961 TOKEN_NUM_INITIALIZER
13962 (struct cmd_set_vf_broadcast_result,
13964 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
13965 TOKEN_STRING_INITIALIZER
13966 (struct cmd_set_vf_broadcast_result,
13970 cmd_set_vf_broadcast_parsed(
13971 void *parsed_result,
13972 __attribute__((unused)) struct cmdline *cl,
13973 __attribute__((unused)) void *data)
13975 struct cmd_set_vf_broadcast_result *res = parsed_result;
13976 int ret = -ENOTSUP;
13978 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13980 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13983 #ifdef RTE_LIBRTE_I40E_PMD
13984 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
13985 res->vf_id, is_on);
13992 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13995 printf("invalid port_id %d\n", res->port_id);
13998 printf("function not implemented\n");
14001 printf("programming error: (%s)\n", strerror(-ret));
14005 cmdline_parse_inst_t cmd_set_vf_broadcast = {
14006 .f = cmd_set_vf_broadcast_parsed,
14008 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
14010 (void *)&cmd_set_vf_broadcast_set,
14011 (void *)&cmd_set_vf_broadcast_vf,
14012 (void *)&cmd_set_vf_broadcast_broadcast,
14013 (void *)&cmd_set_vf_broadcast_port_id,
14014 (void *)&cmd_set_vf_broadcast_vf_id,
14015 (void *)&cmd_set_vf_broadcast_on_off,
14020 /* vf vlan tag configuration */
14022 /* Common result structure for vf vlan tag */
14023 struct cmd_set_vf_vlan_tag_result {
14024 cmdline_fixed_string_t set;
14025 cmdline_fixed_string_t vf;
14026 cmdline_fixed_string_t vlan;
14027 cmdline_fixed_string_t tag;
14030 cmdline_fixed_string_t on_off;
14033 /* Common CLI fields for vf vlan tag enable disable */
14034 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
14035 TOKEN_STRING_INITIALIZER
14036 (struct cmd_set_vf_vlan_tag_result,
14038 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
14039 TOKEN_STRING_INITIALIZER
14040 (struct cmd_set_vf_vlan_tag_result,
14042 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
14043 TOKEN_STRING_INITIALIZER
14044 (struct cmd_set_vf_vlan_tag_result,
14046 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
14047 TOKEN_STRING_INITIALIZER
14048 (struct cmd_set_vf_vlan_tag_result,
14050 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
14051 TOKEN_NUM_INITIALIZER
14052 (struct cmd_set_vf_vlan_tag_result,
14054 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
14055 TOKEN_NUM_INITIALIZER
14056 (struct cmd_set_vf_vlan_tag_result,
14058 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
14059 TOKEN_STRING_INITIALIZER
14060 (struct cmd_set_vf_vlan_tag_result,
14064 cmd_set_vf_vlan_tag_parsed(
14065 void *parsed_result,
14066 __attribute__((unused)) struct cmdline *cl,
14067 __attribute__((unused)) void *data)
14069 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
14070 int ret = -ENOTSUP;
14072 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14074 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14077 #ifdef RTE_LIBRTE_I40E_PMD
14078 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
14079 res->vf_id, is_on);
14086 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14089 printf("invalid port_id %d\n", res->port_id);
14092 printf("function not implemented\n");
14095 printf("programming error: (%s)\n", strerror(-ret));
14099 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
14100 .f = cmd_set_vf_vlan_tag_parsed,
14102 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
14104 (void *)&cmd_set_vf_vlan_tag_set,
14105 (void *)&cmd_set_vf_vlan_tag_vf,
14106 (void *)&cmd_set_vf_vlan_tag_vlan,
14107 (void *)&cmd_set_vf_vlan_tag_tag,
14108 (void *)&cmd_set_vf_vlan_tag_port_id,
14109 (void *)&cmd_set_vf_vlan_tag_vf_id,
14110 (void *)&cmd_set_vf_vlan_tag_on_off,
14115 /* Common definition of VF and TC TX bandwidth configuration */
14116 struct cmd_vf_tc_bw_result {
14117 cmdline_fixed_string_t set;
14118 cmdline_fixed_string_t vf;
14119 cmdline_fixed_string_t tc;
14120 cmdline_fixed_string_t tx;
14121 cmdline_fixed_string_t min_bw;
14122 cmdline_fixed_string_t max_bw;
14123 cmdline_fixed_string_t strict_link_prio;
14128 cmdline_fixed_string_t bw_list;
14132 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
14133 TOKEN_STRING_INITIALIZER
14134 (struct cmd_vf_tc_bw_result,
14136 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
14137 TOKEN_STRING_INITIALIZER
14138 (struct cmd_vf_tc_bw_result,
14140 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
14141 TOKEN_STRING_INITIALIZER
14142 (struct cmd_vf_tc_bw_result,
14144 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
14145 TOKEN_STRING_INITIALIZER
14146 (struct cmd_vf_tc_bw_result,
14148 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
14149 TOKEN_STRING_INITIALIZER
14150 (struct cmd_vf_tc_bw_result,
14151 strict_link_prio, "strict-link-priority");
14152 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
14153 TOKEN_STRING_INITIALIZER
14154 (struct cmd_vf_tc_bw_result,
14155 min_bw, "min-bandwidth");
14156 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
14157 TOKEN_STRING_INITIALIZER
14158 (struct cmd_vf_tc_bw_result,
14159 max_bw, "max-bandwidth");
14160 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
14161 TOKEN_NUM_INITIALIZER
14162 (struct cmd_vf_tc_bw_result,
14164 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
14165 TOKEN_NUM_INITIALIZER
14166 (struct cmd_vf_tc_bw_result,
14168 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
14169 TOKEN_NUM_INITIALIZER
14170 (struct cmd_vf_tc_bw_result,
14172 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
14173 TOKEN_NUM_INITIALIZER
14174 (struct cmd_vf_tc_bw_result,
14176 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
14177 TOKEN_STRING_INITIALIZER
14178 (struct cmd_vf_tc_bw_result,
14180 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
14181 TOKEN_NUM_INITIALIZER
14182 (struct cmd_vf_tc_bw_result,
14185 /* VF max bandwidth setting */
14187 cmd_vf_max_bw_parsed(
14188 void *parsed_result,
14189 __attribute__((unused)) struct cmdline *cl,
14190 __attribute__((unused)) void *data)
14192 struct cmd_vf_tc_bw_result *res = parsed_result;
14193 int ret = -ENOTSUP;
14195 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14198 #ifdef RTE_LIBRTE_I40E_PMD
14199 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
14200 res->vf_id, res->bw);
14207 printf("invalid vf_id %d or bandwidth %d\n",
14208 res->vf_id, res->bw);
14211 printf("invalid port_id %d\n", res->port_id);
14214 printf("function not implemented\n");
14217 printf("programming error: (%s)\n", strerror(-ret));
14221 cmdline_parse_inst_t cmd_vf_max_bw = {
14222 .f = cmd_vf_max_bw_parsed,
14224 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
14226 (void *)&cmd_vf_tc_bw_set,
14227 (void *)&cmd_vf_tc_bw_vf,
14228 (void *)&cmd_vf_tc_bw_tx,
14229 (void *)&cmd_vf_tc_bw_max_bw,
14230 (void *)&cmd_vf_tc_bw_port_id,
14231 (void *)&cmd_vf_tc_bw_vf_id,
14232 (void *)&cmd_vf_tc_bw_bw,
14238 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
14243 const char *p, *p0 = str;
14250 p = strchr(p0, '(');
14252 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14256 p0 = strchr(p, ')');
14258 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14262 if (size >= sizeof(s)) {
14263 printf("The string size exceeds the internal buffer size\n");
14266 snprintf(s, sizeof(s), "%.*s", size, p);
14267 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
14269 printf("Failed to get the bandwidth list. ");
14273 for (i = 0; i < ret; i++)
14274 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
14279 /* TC min bandwidth setting */
14281 cmd_vf_tc_min_bw_parsed(
14282 void *parsed_result,
14283 __attribute__((unused)) struct cmdline *cl,
14284 __attribute__((unused)) void *data)
14286 struct cmd_vf_tc_bw_result *res = parsed_result;
14289 int ret = -ENOTSUP;
14291 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14294 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14298 #ifdef RTE_LIBRTE_I40E_PMD
14299 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
14307 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
14310 printf("invalid port_id %d\n", res->port_id);
14313 printf("function not implemented\n");
14316 printf("programming error: (%s)\n", strerror(-ret));
14320 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
14321 .f = cmd_vf_tc_min_bw_parsed,
14323 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
14324 " <bw1, bw2, ...>",
14326 (void *)&cmd_vf_tc_bw_set,
14327 (void *)&cmd_vf_tc_bw_vf,
14328 (void *)&cmd_vf_tc_bw_tc,
14329 (void *)&cmd_vf_tc_bw_tx,
14330 (void *)&cmd_vf_tc_bw_min_bw,
14331 (void *)&cmd_vf_tc_bw_port_id,
14332 (void *)&cmd_vf_tc_bw_vf_id,
14333 (void *)&cmd_vf_tc_bw_bw_list,
14339 cmd_tc_min_bw_parsed(
14340 void *parsed_result,
14341 __attribute__((unused)) struct cmdline *cl,
14342 __attribute__((unused)) void *data)
14344 struct cmd_vf_tc_bw_result *res = parsed_result;
14345 struct rte_port *port;
14348 int ret = -ENOTSUP;
14350 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14353 port = &ports[res->port_id];
14354 /** Check if the port is not started **/
14355 if (port->port_status != RTE_PORT_STOPPED) {
14356 printf("Please stop port %d first\n", res->port_id);
14360 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14364 #ifdef RTE_LIBRTE_IXGBE_PMD
14365 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
14372 printf("invalid bandwidth\n");
14375 printf("invalid port_id %d\n", res->port_id);
14378 printf("function not implemented\n");
14381 printf("programming error: (%s)\n", strerror(-ret));
14385 cmdline_parse_inst_t cmd_tc_min_bw = {
14386 .f = cmd_tc_min_bw_parsed,
14388 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
14390 (void *)&cmd_vf_tc_bw_set,
14391 (void *)&cmd_vf_tc_bw_tc,
14392 (void *)&cmd_vf_tc_bw_tx,
14393 (void *)&cmd_vf_tc_bw_min_bw,
14394 (void *)&cmd_vf_tc_bw_port_id,
14395 (void *)&cmd_vf_tc_bw_bw_list,
14400 /* TC max bandwidth setting */
14402 cmd_vf_tc_max_bw_parsed(
14403 void *parsed_result,
14404 __attribute__((unused)) struct cmdline *cl,
14405 __attribute__((unused)) void *data)
14407 struct cmd_vf_tc_bw_result *res = parsed_result;
14408 int ret = -ENOTSUP;
14410 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14413 #ifdef RTE_LIBRTE_I40E_PMD
14414 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
14415 res->tc_no, res->bw);
14422 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
14423 res->vf_id, res->tc_no, res->bw);
14426 printf("invalid port_id %d\n", res->port_id);
14429 printf("function not implemented\n");
14432 printf("programming error: (%s)\n", strerror(-ret));
14436 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
14437 .f = cmd_vf_tc_max_bw_parsed,
14439 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
14442 (void *)&cmd_vf_tc_bw_set,
14443 (void *)&cmd_vf_tc_bw_vf,
14444 (void *)&cmd_vf_tc_bw_tc,
14445 (void *)&cmd_vf_tc_bw_tx,
14446 (void *)&cmd_vf_tc_bw_max_bw,
14447 (void *)&cmd_vf_tc_bw_port_id,
14448 (void *)&cmd_vf_tc_bw_vf_id,
14449 (void *)&cmd_vf_tc_bw_tc_no,
14450 (void *)&cmd_vf_tc_bw_bw,
14456 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
14458 /* *** Set Port default Traffic Management Hierarchy *** */
14459 struct cmd_set_port_tm_hierarchy_default_result {
14460 cmdline_fixed_string_t set;
14461 cmdline_fixed_string_t port;
14462 cmdline_fixed_string_t tm;
14463 cmdline_fixed_string_t hierarchy;
14464 cmdline_fixed_string_t def;
14468 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
14469 TOKEN_STRING_INITIALIZER(
14470 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
14471 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
14472 TOKEN_STRING_INITIALIZER(
14473 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
14474 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
14475 TOKEN_STRING_INITIALIZER(
14476 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
14477 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
14478 TOKEN_STRING_INITIALIZER(
14479 struct cmd_set_port_tm_hierarchy_default_result,
14480 hierarchy, "hierarchy");
14481 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
14482 TOKEN_STRING_INITIALIZER(
14483 struct cmd_set_port_tm_hierarchy_default_result,
14485 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
14486 TOKEN_NUM_INITIALIZER(
14487 struct cmd_set_port_tm_hierarchy_default_result,
14490 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
14491 __attribute__((unused)) struct cmdline *cl,
14492 __attribute__((unused)) void *data)
14494 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
14495 struct rte_port *p;
14496 portid_t port_id = res->port_id;
14498 if (port_id_is_invalid(port_id, ENABLED_WARN))
14501 p = &ports[port_id];
14504 if (p->softport.tm_flag == 0) {
14505 printf(" tm not enabled on port %u (error)\n", port_id);
14509 /* Forward mode: tm */
14510 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "tm")) {
14511 printf(" tm mode not enabled(error)\n");
14515 /* Set the default tm hierarchy */
14516 p->softport.tm.default_hierarchy_enable = 1;
14519 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
14520 .f = cmd_set_port_tm_hierarchy_default_parsed,
14522 .help_str = "set port tm hierarchy default <port_id>",
14524 (void *)&cmd_set_port_tm_hierarchy_default_set,
14525 (void *)&cmd_set_port_tm_hierarchy_default_port,
14526 (void *)&cmd_set_port_tm_hierarchy_default_tm,
14527 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
14528 (void *)&cmd_set_port_tm_hierarchy_default_default,
14529 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
14535 /* Strict link priority scheduling mode setting */
14537 cmd_strict_link_prio_parsed(
14538 void *parsed_result,
14539 __attribute__((unused)) struct cmdline *cl,
14540 __attribute__((unused)) void *data)
14542 struct cmd_vf_tc_bw_result *res = parsed_result;
14543 int ret = -ENOTSUP;
14545 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14548 #ifdef RTE_LIBRTE_I40E_PMD
14549 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
14556 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
14559 printf("invalid port_id %d\n", res->port_id);
14562 printf("function not implemented\n");
14565 printf("programming error: (%s)\n", strerror(-ret));
14569 cmdline_parse_inst_t cmd_strict_link_prio = {
14570 .f = cmd_strict_link_prio_parsed,
14572 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
14574 (void *)&cmd_vf_tc_bw_set,
14575 (void *)&cmd_vf_tc_bw_tx,
14576 (void *)&cmd_vf_tc_bw_strict_link_prio,
14577 (void *)&cmd_vf_tc_bw_port_id,
14578 (void *)&cmd_vf_tc_bw_tc_map,
14583 /* Load dynamic device personalization*/
14584 struct cmd_ddp_add_result {
14585 cmdline_fixed_string_t ddp;
14586 cmdline_fixed_string_t add;
14591 cmdline_parse_token_string_t cmd_ddp_add_ddp =
14592 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
14593 cmdline_parse_token_string_t cmd_ddp_add_add =
14594 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
14595 cmdline_parse_token_num_t cmd_ddp_add_port_id =
14596 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
14597 cmdline_parse_token_string_t cmd_ddp_add_filepath =
14598 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
14601 cmd_ddp_add_parsed(
14602 void *parsed_result,
14603 __attribute__((unused)) struct cmdline *cl,
14604 __attribute__((unused)) void *data)
14606 struct cmd_ddp_add_result *res = parsed_result;
14612 int ret = -ENOTSUP;
14614 if (res->port_id > nb_ports) {
14615 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14619 if (!all_ports_stopped()) {
14620 printf("Please stop all ports first\n");
14624 filepath = strdup(res->filepath);
14625 if (filepath == NULL) {
14626 printf("Failed to allocate memory\n");
14629 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
14631 buff = open_file(file_fld[0], &size);
14633 free((void *)filepath);
14637 #ifdef RTE_LIBRTE_I40E_PMD
14638 if (ret == -ENOTSUP)
14639 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14641 RTE_PMD_I40E_PKG_OP_WR_ADD);
14644 if (ret == -EEXIST)
14645 printf("Profile has already existed.\n");
14647 printf("Failed to load profile.\n");
14648 else if (file_num == 2)
14649 save_file(file_fld[1], buff, size);
14652 free((void *)filepath);
14655 cmdline_parse_inst_t cmd_ddp_add = {
14656 .f = cmd_ddp_add_parsed,
14658 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
14660 (void *)&cmd_ddp_add_ddp,
14661 (void *)&cmd_ddp_add_add,
14662 (void *)&cmd_ddp_add_port_id,
14663 (void *)&cmd_ddp_add_filepath,
14668 /* Delete dynamic device personalization*/
14669 struct cmd_ddp_del_result {
14670 cmdline_fixed_string_t ddp;
14671 cmdline_fixed_string_t del;
14676 cmdline_parse_token_string_t cmd_ddp_del_ddp =
14677 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
14678 cmdline_parse_token_string_t cmd_ddp_del_del =
14679 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
14680 cmdline_parse_token_num_t cmd_ddp_del_port_id =
14681 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
14682 cmdline_parse_token_string_t cmd_ddp_del_filepath =
14683 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
14686 cmd_ddp_del_parsed(
14687 void *parsed_result,
14688 __attribute__((unused)) struct cmdline *cl,
14689 __attribute__((unused)) void *data)
14691 struct cmd_ddp_del_result *res = parsed_result;
14694 int ret = -ENOTSUP;
14696 if (res->port_id > nb_ports) {
14697 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14701 if (!all_ports_stopped()) {
14702 printf("Please stop all ports first\n");
14706 buff = open_file(res->filepath, &size);
14710 #ifdef RTE_LIBRTE_I40E_PMD
14711 if (ret == -ENOTSUP)
14712 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14714 RTE_PMD_I40E_PKG_OP_WR_DEL);
14717 if (ret == -EACCES)
14718 printf("Profile does not exist.\n");
14720 printf("Failed to delete profile.\n");
14725 cmdline_parse_inst_t cmd_ddp_del = {
14726 .f = cmd_ddp_del_parsed,
14728 .help_str = "ddp del <port_id> <backup_profile_path>",
14730 (void *)&cmd_ddp_del_ddp,
14731 (void *)&cmd_ddp_del_del,
14732 (void *)&cmd_ddp_del_port_id,
14733 (void *)&cmd_ddp_del_filepath,
14738 /* Get dynamic device personalization profile info */
14739 struct cmd_ddp_info_result {
14740 cmdline_fixed_string_t ddp;
14741 cmdline_fixed_string_t get;
14742 cmdline_fixed_string_t info;
14746 cmdline_parse_token_string_t cmd_ddp_info_ddp =
14747 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
14748 cmdline_parse_token_string_t cmd_ddp_info_get =
14749 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
14750 cmdline_parse_token_string_t cmd_ddp_info_info =
14751 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
14752 cmdline_parse_token_string_t cmd_ddp_info_filepath =
14753 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
14756 cmd_ddp_info_parsed(
14757 void *parsed_result,
14758 __attribute__((unused)) struct cmdline *cl,
14759 __attribute__((unused)) void *data)
14761 struct cmd_ddp_info_result *res = parsed_result;
14764 int ret = -ENOTSUP;
14765 #ifdef RTE_LIBRTE_I40E_PMD
14768 uint32_t buff_size = 0;
14769 struct rte_pmd_i40e_profile_info info;
14770 uint32_t dev_num = 0;
14771 struct rte_pmd_i40e_ddp_device_id *devs;
14772 uint32_t proto_num = 0;
14773 struct rte_pmd_i40e_proto_info *proto = NULL;
14774 uint32_t pctype_num = 0;
14775 struct rte_pmd_i40e_ptype_info *pctype;
14776 uint32_t ptype_num = 0;
14777 struct rte_pmd_i40e_ptype_info *ptype;
14782 pkg = open_file(res->filepath, &pkg_size);
14786 #ifdef RTE_LIBRTE_I40E_PMD
14787 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14788 (uint8_t *)&info, sizeof(info),
14789 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
14791 printf("Global Track id: 0x%x\n", info.track_id);
14792 printf("Global Version: %d.%d.%d.%d\n",
14793 info.version.major,
14794 info.version.minor,
14795 info.version.update,
14796 info.version.draft);
14797 printf("Global Package name: %s\n\n", info.name);
14800 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14801 (uint8_t *)&info, sizeof(info),
14802 RTE_PMD_I40E_PKG_INFO_HEADER);
14804 printf("i40e Profile Track id: 0x%x\n", info.track_id);
14805 printf("i40e Profile Version: %d.%d.%d.%d\n",
14806 info.version.major,
14807 info.version.minor,
14808 info.version.update,
14809 info.version.draft);
14810 printf("i40e Profile name: %s\n\n", info.name);
14813 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14814 (uint8_t *)&buff_size, sizeof(buff_size),
14815 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
14816 if (!ret && buff_size) {
14817 buff = (uint8_t *)malloc(buff_size);
14819 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14821 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
14823 printf("Package Notes:\n%s\n\n", buff);
14828 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14829 (uint8_t *)&dev_num, sizeof(dev_num),
14830 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
14831 if (!ret && dev_num) {
14832 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
14833 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
14835 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14836 (uint8_t *)devs, buff_size,
14837 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
14839 printf("List of supported devices:\n");
14840 for (i = 0; i < dev_num; i++) {
14841 printf(" %04X:%04X %04X:%04X\n",
14842 devs[i].vendor_dev_id >> 16,
14843 devs[i].vendor_dev_id & 0xFFFF,
14844 devs[i].sub_vendor_dev_id >> 16,
14845 devs[i].sub_vendor_dev_id & 0xFFFF);
14853 /* get information about protocols and packet types */
14854 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14855 (uint8_t *)&proto_num, sizeof(proto_num),
14856 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
14857 if (ret || !proto_num)
14858 goto no_print_return;
14860 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
14861 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
14863 goto no_print_return;
14865 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
14867 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
14869 printf("List of used protocols:\n");
14870 for (i = 0; i < proto_num; i++)
14871 printf(" %2u: %s\n", proto[i].proto_id,
14875 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14876 (uint8_t *)&pctype_num, sizeof(pctype_num),
14877 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
14878 if (ret || !pctype_num)
14879 goto no_print_pctypes;
14881 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14882 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14884 goto no_print_pctypes;
14886 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
14888 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
14891 goto no_print_pctypes;
14894 printf("List of defined packet classification types:\n");
14895 for (i = 0; i < pctype_num; i++) {
14896 printf(" %2u:", pctype[i].ptype_id);
14897 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14898 proto_id = pctype[i].protocols[j];
14899 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14900 for (n = 0; n < proto_num; n++) {
14901 if (proto[n].proto_id == proto_id) {
14902 printf(" %s", proto[n].name);
14915 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
14917 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
14918 if (ret || !ptype_num)
14919 goto no_print_return;
14921 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14922 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14924 goto no_print_return;
14926 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
14928 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
14931 goto no_print_return;
14933 printf("List of defined packet types:\n");
14934 for (i = 0; i < ptype_num; i++) {
14935 printf(" %2u:", ptype[i].ptype_id);
14936 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14937 proto_id = ptype[i].protocols[j];
14938 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14939 for (n = 0; n < proto_num; n++) {
14940 if (proto[n].proto_id == proto_id) {
14941 printf(" %s", proto[n].name);
14957 if (ret == -ENOTSUP)
14958 printf("Function not supported in PMD driver\n");
14962 cmdline_parse_inst_t cmd_ddp_get_info = {
14963 .f = cmd_ddp_info_parsed,
14965 .help_str = "ddp get info <profile_path>",
14967 (void *)&cmd_ddp_info_ddp,
14968 (void *)&cmd_ddp_info_get,
14969 (void *)&cmd_ddp_info_info,
14970 (void *)&cmd_ddp_info_filepath,
14975 /* Get dynamic device personalization profile info list*/
14976 #define PROFILE_INFO_SIZE 48
14977 #define MAX_PROFILE_NUM 16
14979 struct cmd_ddp_get_list_result {
14980 cmdline_fixed_string_t ddp;
14981 cmdline_fixed_string_t get;
14982 cmdline_fixed_string_t list;
14986 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
14987 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
14988 cmdline_parse_token_string_t cmd_ddp_get_list_get =
14989 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
14990 cmdline_parse_token_string_t cmd_ddp_get_list_list =
14991 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
14992 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
14993 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
14996 cmd_ddp_get_list_parsed(
14997 void *parsed_result,
14998 __attribute__((unused)) struct cmdline *cl,
14999 __attribute__((unused)) void *data)
15001 struct cmd_ddp_get_list_result *res = parsed_result;
15002 #ifdef RTE_LIBRTE_I40E_PMD
15003 struct rte_pmd_i40e_profile_list *p_list;
15004 struct rte_pmd_i40e_profile_info *p_info;
15009 int ret = -ENOTSUP;
15011 if (res->port_id > nb_ports) {
15012 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
15016 #ifdef RTE_LIBRTE_I40E_PMD
15017 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
15018 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
15020 printf("%s: Failed to malloc buffer\n", __func__);
15022 if (ret == -ENOTSUP)
15023 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
15024 (uint8_t *)p_list, size);
15027 p_num = p_list->p_count;
15028 printf("Profile number is: %d\n\n", p_num);
15030 for (i = 0; i < p_num; i++) {
15031 p_info = &p_list->p_info[i];
15032 printf("Profile %d:\n", i);
15033 printf("Track id: 0x%x\n", p_info->track_id);
15034 printf("Version: %d.%d.%d.%d\n",
15035 p_info->version.major,
15036 p_info->version.minor,
15037 p_info->version.update,
15038 p_info->version.draft);
15039 printf("Profile name: %s\n\n", p_info->name);
15047 printf("Failed to get ddp list\n");
15050 cmdline_parse_inst_t cmd_ddp_get_list = {
15051 .f = cmd_ddp_get_list_parsed,
15053 .help_str = "ddp get list <port_id>",
15055 (void *)&cmd_ddp_get_list_ddp,
15056 (void *)&cmd_ddp_get_list_get,
15057 (void *)&cmd_ddp_get_list_list,
15058 (void *)&cmd_ddp_get_list_port_id,
15063 /* Configure input set */
15064 struct cmd_cfg_input_set_result {
15065 cmdline_fixed_string_t port;
15066 cmdline_fixed_string_t cfg;
15068 cmdline_fixed_string_t pctype;
15070 cmdline_fixed_string_t inset_type;
15071 cmdline_fixed_string_t opt;
15072 cmdline_fixed_string_t field;
15077 cmd_cfg_input_set_parsed(
15078 void *parsed_result,
15079 __attribute__((unused)) struct cmdline *cl,
15080 __attribute__((unused)) void *data)
15082 struct cmd_cfg_input_set_result *res = parsed_result;
15083 #ifdef RTE_LIBRTE_I40E_PMD
15084 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
15085 struct rte_pmd_i40e_inset inset;
15087 int ret = -ENOTSUP;
15089 if (res->port_id > nb_ports) {
15090 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
15094 if (!all_ports_stopped()) {
15095 printf("Please stop all ports first\n");
15099 #ifdef RTE_LIBRTE_I40E_PMD
15100 if (!strcmp(res->inset_type, "hash_inset"))
15101 inset_type = INSET_HASH;
15102 else if (!strcmp(res->inset_type, "fdir_inset"))
15103 inset_type = INSET_FDIR;
15104 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
15105 inset_type = INSET_FDIR_FLX;
15106 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
15107 &inset, inset_type);
15109 printf("Failed to get input set.\n");
15113 if (!strcmp(res->opt, "get")) {
15114 ret = rte_pmd_i40e_inset_field_get(inset.inset,
15117 printf("Field index %d is enabled.\n", res->field_idx);
15119 printf("Field index %d is disabled.\n", res->field_idx);
15121 } else if (!strcmp(res->opt, "set"))
15122 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
15124 else if (!strcmp(res->opt, "clear"))
15125 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
15128 printf("Failed to configure input set field.\n");
15132 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15133 &inset, inset_type);
15135 printf("Failed to set input set.\n");
15140 if (ret == -ENOTSUP)
15141 printf("Function not supported\n");
15144 cmdline_parse_token_string_t cmd_cfg_input_set_port =
15145 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15147 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
15148 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15150 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
15151 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15153 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
15154 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15156 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
15157 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15159 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
15160 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15162 "hash_inset#fdir_inset#fdir_flx_inset");
15163 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
15164 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15165 opt, "get#set#clear");
15166 cmdline_parse_token_string_t cmd_cfg_input_set_field =
15167 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15169 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
15170 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15173 cmdline_parse_inst_t cmd_cfg_input_set = {
15174 .f = cmd_cfg_input_set_parsed,
15176 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15177 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
15179 (void *)&cmd_cfg_input_set_port,
15180 (void *)&cmd_cfg_input_set_cfg,
15181 (void *)&cmd_cfg_input_set_port_id,
15182 (void *)&cmd_cfg_input_set_pctype,
15183 (void *)&cmd_cfg_input_set_pctype_id,
15184 (void *)&cmd_cfg_input_set_inset_type,
15185 (void *)&cmd_cfg_input_set_opt,
15186 (void *)&cmd_cfg_input_set_field,
15187 (void *)&cmd_cfg_input_set_field_idx,
15192 /* Clear input set */
15193 struct cmd_clear_input_set_result {
15194 cmdline_fixed_string_t port;
15195 cmdline_fixed_string_t cfg;
15197 cmdline_fixed_string_t pctype;
15199 cmdline_fixed_string_t inset_type;
15200 cmdline_fixed_string_t clear;
15201 cmdline_fixed_string_t all;
15205 cmd_clear_input_set_parsed(
15206 void *parsed_result,
15207 __attribute__((unused)) struct cmdline *cl,
15208 __attribute__((unused)) void *data)
15210 struct cmd_clear_input_set_result *res = parsed_result;
15211 #ifdef RTE_LIBRTE_I40E_PMD
15212 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
15213 struct rte_pmd_i40e_inset inset;
15215 int ret = -ENOTSUP;
15217 if (res->port_id > nb_ports) {
15218 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
15222 if (!all_ports_stopped()) {
15223 printf("Please stop all ports first\n");
15227 #ifdef RTE_LIBRTE_I40E_PMD
15228 if (!strcmp(res->inset_type, "hash_inset"))
15229 inset_type = INSET_HASH;
15230 else if (!strcmp(res->inset_type, "fdir_inset"))
15231 inset_type = INSET_FDIR;
15232 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
15233 inset_type = INSET_FDIR_FLX;
15235 memset(&inset, 0, sizeof(inset));
15237 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15238 &inset, inset_type);
15240 printf("Failed to clear input set.\n");
15246 if (ret == -ENOTSUP)
15247 printf("Function not supported\n");
15250 cmdline_parse_token_string_t cmd_clear_input_set_port =
15251 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15253 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
15254 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15256 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
15257 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15259 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
15260 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15262 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
15263 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15265 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
15266 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15268 "hash_inset#fdir_inset#fdir_flx_inset");
15269 cmdline_parse_token_string_t cmd_clear_input_set_clear =
15270 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15272 cmdline_parse_token_string_t cmd_clear_input_set_all =
15273 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15276 cmdline_parse_inst_t cmd_clear_input_set = {
15277 .f = cmd_clear_input_set_parsed,
15279 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15280 "fdir_inset|fdir_flx_inset clear all",
15282 (void *)&cmd_clear_input_set_port,
15283 (void *)&cmd_clear_input_set_cfg,
15284 (void *)&cmd_clear_input_set_port_id,
15285 (void *)&cmd_clear_input_set_pctype,
15286 (void *)&cmd_clear_input_set_pctype_id,
15287 (void *)&cmd_clear_input_set_inset_type,
15288 (void *)&cmd_clear_input_set_clear,
15289 (void *)&cmd_clear_input_set_all,
15294 /* show vf stats */
15296 /* Common result structure for show vf stats */
15297 struct cmd_show_vf_stats_result {
15298 cmdline_fixed_string_t show;
15299 cmdline_fixed_string_t vf;
15300 cmdline_fixed_string_t stats;
15305 /* Common CLI fields show vf stats*/
15306 cmdline_parse_token_string_t cmd_show_vf_stats_show =
15307 TOKEN_STRING_INITIALIZER
15308 (struct cmd_show_vf_stats_result,
15310 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
15311 TOKEN_STRING_INITIALIZER
15312 (struct cmd_show_vf_stats_result,
15314 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
15315 TOKEN_STRING_INITIALIZER
15316 (struct cmd_show_vf_stats_result,
15318 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
15319 TOKEN_NUM_INITIALIZER
15320 (struct cmd_show_vf_stats_result,
15322 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
15323 TOKEN_NUM_INITIALIZER
15324 (struct cmd_show_vf_stats_result,
15328 cmd_show_vf_stats_parsed(
15329 void *parsed_result,
15330 __attribute__((unused)) struct cmdline *cl,
15331 __attribute__((unused)) void *data)
15333 struct cmd_show_vf_stats_result *res = parsed_result;
15334 struct rte_eth_stats stats;
15335 int ret = -ENOTSUP;
15336 static const char *nic_stats_border = "########################";
15338 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15341 memset(&stats, 0, sizeof(stats));
15343 #ifdef RTE_LIBRTE_I40E_PMD
15344 if (ret == -ENOTSUP)
15345 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
15349 #ifdef RTE_LIBRTE_BNXT_PMD
15350 if (ret == -ENOTSUP)
15351 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
15360 printf("invalid vf_id %d\n", res->vf_id);
15363 printf("invalid port_id %d\n", res->port_id);
15366 printf("function not implemented\n");
15369 printf("programming error: (%s)\n", strerror(-ret));
15372 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
15373 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
15375 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
15377 stats.ipackets, stats.imissed, stats.ibytes);
15378 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
15379 printf(" RX-nombuf: %-10"PRIu64"\n",
15381 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
15383 stats.opackets, stats.oerrors, stats.obytes);
15385 printf(" %s############################%s\n",
15386 nic_stats_border, nic_stats_border);
15389 cmdline_parse_inst_t cmd_show_vf_stats = {
15390 .f = cmd_show_vf_stats_parsed,
15392 .help_str = "show vf stats <port_id> <vf_id>",
15394 (void *)&cmd_show_vf_stats_show,
15395 (void *)&cmd_show_vf_stats_vf,
15396 (void *)&cmd_show_vf_stats_stats,
15397 (void *)&cmd_show_vf_stats_port_id,
15398 (void *)&cmd_show_vf_stats_vf_id,
15403 /* clear vf stats */
15405 /* Common result structure for clear vf stats */
15406 struct cmd_clear_vf_stats_result {
15407 cmdline_fixed_string_t clear;
15408 cmdline_fixed_string_t vf;
15409 cmdline_fixed_string_t stats;
15414 /* Common CLI fields clear vf stats*/
15415 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
15416 TOKEN_STRING_INITIALIZER
15417 (struct cmd_clear_vf_stats_result,
15419 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
15420 TOKEN_STRING_INITIALIZER
15421 (struct cmd_clear_vf_stats_result,
15423 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
15424 TOKEN_STRING_INITIALIZER
15425 (struct cmd_clear_vf_stats_result,
15427 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
15428 TOKEN_NUM_INITIALIZER
15429 (struct cmd_clear_vf_stats_result,
15431 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
15432 TOKEN_NUM_INITIALIZER
15433 (struct cmd_clear_vf_stats_result,
15437 cmd_clear_vf_stats_parsed(
15438 void *parsed_result,
15439 __attribute__((unused)) struct cmdline *cl,
15440 __attribute__((unused)) void *data)
15442 struct cmd_clear_vf_stats_result *res = parsed_result;
15443 int ret = -ENOTSUP;
15445 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15448 #ifdef RTE_LIBRTE_I40E_PMD
15449 if (ret == -ENOTSUP)
15450 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
15453 #ifdef RTE_LIBRTE_BNXT_PMD
15454 if (ret == -ENOTSUP)
15455 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
15463 printf("invalid vf_id %d\n", res->vf_id);
15466 printf("invalid port_id %d\n", res->port_id);
15469 printf("function not implemented\n");
15472 printf("programming error: (%s)\n", strerror(-ret));
15476 cmdline_parse_inst_t cmd_clear_vf_stats = {
15477 .f = cmd_clear_vf_stats_parsed,
15479 .help_str = "clear vf stats <port_id> <vf_id>",
15481 (void *)&cmd_clear_vf_stats_clear,
15482 (void *)&cmd_clear_vf_stats_vf,
15483 (void *)&cmd_clear_vf_stats_stats,
15484 (void *)&cmd_clear_vf_stats_port_id,
15485 (void *)&cmd_clear_vf_stats_vf_id,
15490 /* port config pctype mapping reset */
15492 /* Common result structure for port config pctype mapping reset */
15493 struct cmd_pctype_mapping_reset_result {
15494 cmdline_fixed_string_t port;
15495 cmdline_fixed_string_t config;
15497 cmdline_fixed_string_t pctype;
15498 cmdline_fixed_string_t mapping;
15499 cmdline_fixed_string_t reset;
15502 /* Common CLI fields for port config pctype mapping reset*/
15503 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
15504 TOKEN_STRING_INITIALIZER
15505 (struct cmd_pctype_mapping_reset_result,
15507 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
15508 TOKEN_STRING_INITIALIZER
15509 (struct cmd_pctype_mapping_reset_result,
15511 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
15512 TOKEN_NUM_INITIALIZER
15513 (struct cmd_pctype_mapping_reset_result,
15515 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
15516 TOKEN_STRING_INITIALIZER
15517 (struct cmd_pctype_mapping_reset_result,
15519 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
15520 TOKEN_STRING_INITIALIZER
15521 (struct cmd_pctype_mapping_reset_result,
15522 mapping, "mapping");
15523 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
15524 TOKEN_STRING_INITIALIZER
15525 (struct cmd_pctype_mapping_reset_result,
15529 cmd_pctype_mapping_reset_parsed(
15530 void *parsed_result,
15531 __attribute__((unused)) struct cmdline *cl,
15532 __attribute__((unused)) void *data)
15534 struct cmd_pctype_mapping_reset_result *res = parsed_result;
15535 int ret = -ENOTSUP;
15537 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15540 #ifdef RTE_LIBRTE_I40E_PMD
15541 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
15548 printf("invalid port_id %d\n", res->port_id);
15551 printf("function not implemented\n");
15554 printf("programming error: (%s)\n", strerror(-ret));
15558 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
15559 .f = cmd_pctype_mapping_reset_parsed,
15561 .help_str = "port config <port_id> pctype mapping reset",
15563 (void *)&cmd_pctype_mapping_reset_port,
15564 (void *)&cmd_pctype_mapping_reset_config,
15565 (void *)&cmd_pctype_mapping_reset_port_id,
15566 (void *)&cmd_pctype_mapping_reset_pctype,
15567 (void *)&cmd_pctype_mapping_reset_mapping,
15568 (void *)&cmd_pctype_mapping_reset_reset,
15573 /* show port pctype mapping */
15575 /* Common result structure for show port pctype mapping */
15576 struct cmd_pctype_mapping_get_result {
15577 cmdline_fixed_string_t show;
15578 cmdline_fixed_string_t port;
15580 cmdline_fixed_string_t pctype;
15581 cmdline_fixed_string_t mapping;
15584 /* Common CLI fields for pctype mapping get */
15585 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
15586 TOKEN_STRING_INITIALIZER
15587 (struct cmd_pctype_mapping_get_result,
15589 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
15590 TOKEN_STRING_INITIALIZER
15591 (struct cmd_pctype_mapping_get_result,
15593 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
15594 TOKEN_NUM_INITIALIZER
15595 (struct cmd_pctype_mapping_get_result,
15597 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
15598 TOKEN_STRING_INITIALIZER
15599 (struct cmd_pctype_mapping_get_result,
15601 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
15602 TOKEN_STRING_INITIALIZER
15603 (struct cmd_pctype_mapping_get_result,
15604 mapping, "mapping");
15607 cmd_pctype_mapping_get_parsed(
15608 void *parsed_result,
15609 __attribute__((unused)) struct cmdline *cl,
15610 __attribute__((unused)) void *data)
15612 struct cmd_pctype_mapping_get_result *res = parsed_result;
15613 int ret = -ENOTSUP;
15614 #ifdef RTE_LIBRTE_I40E_PMD
15615 struct rte_pmd_i40e_flow_type_mapping
15616 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
15617 int i, j, first_pctype;
15620 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15623 #ifdef RTE_LIBRTE_I40E_PMD
15624 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
15631 printf("invalid port_id %d\n", res->port_id);
15634 printf("function not implemented\n");
15637 printf("programming error: (%s)\n", strerror(-ret));
15641 #ifdef RTE_LIBRTE_I40E_PMD
15642 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
15643 if (mapping[i].pctype != 0ULL) {
15646 printf("pctype: ");
15647 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
15648 if (mapping[i].pctype & (1ULL << j)) {
15649 printf(first_pctype ?
15650 "%02d" : ",%02d", j);
15654 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
15660 cmdline_parse_inst_t cmd_pctype_mapping_get = {
15661 .f = cmd_pctype_mapping_get_parsed,
15663 .help_str = "show port <port_id> pctype mapping",
15665 (void *)&cmd_pctype_mapping_get_show,
15666 (void *)&cmd_pctype_mapping_get_port,
15667 (void *)&cmd_pctype_mapping_get_port_id,
15668 (void *)&cmd_pctype_mapping_get_pctype,
15669 (void *)&cmd_pctype_mapping_get_mapping,
15674 /* port config pctype mapping update */
15676 /* Common result structure for port config pctype mapping update */
15677 struct cmd_pctype_mapping_update_result {
15678 cmdline_fixed_string_t port;
15679 cmdline_fixed_string_t config;
15681 cmdline_fixed_string_t pctype;
15682 cmdline_fixed_string_t mapping;
15683 cmdline_fixed_string_t update;
15684 cmdline_fixed_string_t pctype_list;
15685 uint16_t flow_type;
15688 /* Common CLI fields for pctype mapping update*/
15689 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
15690 TOKEN_STRING_INITIALIZER
15691 (struct cmd_pctype_mapping_update_result,
15693 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
15694 TOKEN_STRING_INITIALIZER
15695 (struct cmd_pctype_mapping_update_result,
15697 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
15698 TOKEN_NUM_INITIALIZER
15699 (struct cmd_pctype_mapping_update_result,
15701 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
15702 TOKEN_STRING_INITIALIZER
15703 (struct cmd_pctype_mapping_update_result,
15705 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
15706 TOKEN_STRING_INITIALIZER
15707 (struct cmd_pctype_mapping_update_result,
15708 mapping, "mapping");
15709 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
15710 TOKEN_STRING_INITIALIZER
15711 (struct cmd_pctype_mapping_update_result,
15713 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
15714 TOKEN_STRING_INITIALIZER
15715 (struct cmd_pctype_mapping_update_result,
15716 pctype_list, NULL);
15717 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
15718 TOKEN_NUM_INITIALIZER
15719 (struct cmd_pctype_mapping_update_result,
15720 flow_type, UINT16);
15723 cmd_pctype_mapping_update_parsed(
15724 void *parsed_result,
15725 __attribute__((unused)) struct cmdline *cl,
15726 __attribute__((unused)) void *data)
15728 struct cmd_pctype_mapping_update_result *res = parsed_result;
15729 int ret = -ENOTSUP;
15730 #ifdef RTE_LIBRTE_I40E_PMD
15731 struct rte_pmd_i40e_flow_type_mapping mapping;
15733 unsigned int nb_item;
15734 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
15737 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15740 #ifdef RTE_LIBRTE_I40E_PMD
15741 nb_item = parse_item_list(res->pctype_list, "pctypes",
15742 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
15743 mapping.flow_type = res->flow_type;
15744 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
15745 mapping.pctype |= (1ULL << pctype_list[i]);
15746 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
15756 printf("invalid pctype or flow type\n");
15759 printf("invalid port_id %d\n", res->port_id);
15762 printf("function not implemented\n");
15765 printf("programming error: (%s)\n", strerror(-ret));
15769 cmdline_parse_inst_t cmd_pctype_mapping_update = {
15770 .f = cmd_pctype_mapping_update_parsed,
15772 .help_str = "port config <port_id> pctype mapping update"
15773 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
15775 (void *)&cmd_pctype_mapping_update_port,
15776 (void *)&cmd_pctype_mapping_update_config,
15777 (void *)&cmd_pctype_mapping_update_port_id,
15778 (void *)&cmd_pctype_mapping_update_pctype,
15779 (void *)&cmd_pctype_mapping_update_mapping,
15780 (void *)&cmd_pctype_mapping_update_update,
15781 (void *)&cmd_pctype_mapping_update_pc_type,
15782 (void *)&cmd_pctype_mapping_update_flow_type,
15787 /* ptype mapping get */
15789 /* Common result structure for ptype mapping get */
15790 struct cmd_ptype_mapping_get_result {
15791 cmdline_fixed_string_t ptype;
15792 cmdline_fixed_string_t mapping;
15793 cmdline_fixed_string_t get;
15795 uint8_t valid_only;
15798 /* Common CLI fields for ptype mapping get */
15799 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
15800 TOKEN_STRING_INITIALIZER
15801 (struct cmd_ptype_mapping_get_result,
15803 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
15804 TOKEN_STRING_INITIALIZER
15805 (struct cmd_ptype_mapping_get_result,
15806 mapping, "mapping");
15807 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
15808 TOKEN_STRING_INITIALIZER
15809 (struct cmd_ptype_mapping_get_result,
15811 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
15812 TOKEN_NUM_INITIALIZER
15813 (struct cmd_ptype_mapping_get_result,
15815 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
15816 TOKEN_NUM_INITIALIZER
15817 (struct cmd_ptype_mapping_get_result,
15818 valid_only, UINT8);
15821 cmd_ptype_mapping_get_parsed(
15822 void *parsed_result,
15823 __attribute__((unused)) struct cmdline *cl,
15824 __attribute__((unused)) void *data)
15826 struct cmd_ptype_mapping_get_result *res = parsed_result;
15827 int ret = -ENOTSUP;
15828 #ifdef RTE_LIBRTE_I40E_PMD
15829 int max_ptype_num = 256;
15830 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
15835 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15838 #ifdef RTE_LIBRTE_I40E_PMD
15839 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
15850 printf("invalid port_id %d\n", res->port_id);
15853 printf("function not implemented\n");
15856 printf("programming error: (%s)\n", strerror(-ret));
15859 #ifdef RTE_LIBRTE_I40E_PMD
15861 for (i = 0; i < count; i++)
15862 printf("%3d\t0x%08x\n",
15863 mapping[i].hw_ptype, mapping[i].sw_ptype);
15868 cmdline_parse_inst_t cmd_ptype_mapping_get = {
15869 .f = cmd_ptype_mapping_get_parsed,
15871 .help_str = "ptype mapping get <port_id> <valid_only>",
15873 (void *)&cmd_ptype_mapping_get_ptype,
15874 (void *)&cmd_ptype_mapping_get_mapping,
15875 (void *)&cmd_ptype_mapping_get_get,
15876 (void *)&cmd_ptype_mapping_get_port_id,
15877 (void *)&cmd_ptype_mapping_get_valid_only,
15882 /* ptype mapping replace */
15884 /* Common result structure for ptype mapping replace */
15885 struct cmd_ptype_mapping_replace_result {
15886 cmdline_fixed_string_t ptype;
15887 cmdline_fixed_string_t mapping;
15888 cmdline_fixed_string_t replace;
15895 /* Common CLI fields for ptype mapping replace */
15896 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
15897 TOKEN_STRING_INITIALIZER
15898 (struct cmd_ptype_mapping_replace_result,
15900 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
15901 TOKEN_STRING_INITIALIZER
15902 (struct cmd_ptype_mapping_replace_result,
15903 mapping, "mapping");
15904 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
15905 TOKEN_STRING_INITIALIZER
15906 (struct cmd_ptype_mapping_replace_result,
15907 replace, "replace");
15908 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
15909 TOKEN_NUM_INITIALIZER
15910 (struct cmd_ptype_mapping_replace_result,
15912 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
15913 TOKEN_NUM_INITIALIZER
15914 (struct cmd_ptype_mapping_replace_result,
15916 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
15917 TOKEN_NUM_INITIALIZER
15918 (struct cmd_ptype_mapping_replace_result,
15920 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
15921 TOKEN_NUM_INITIALIZER
15922 (struct cmd_ptype_mapping_replace_result,
15926 cmd_ptype_mapping_replace_parsed(
15927 void *parsed_result,
15928 __attribute__((unused)) struct cmdline *cl,
15929 __attribute__((unused)) void *data)
15931 struct cmd_ptype_mapping_replace_result *res = parsed_result;
15932 int ret = -ENOTSUP;
15934 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15937 #ifdef RTE_LIBRTE_I40E_PMD
15938 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
15948 printf("invalid ptype 0x%8x or 0x%8x\n",
15949 res->target, res->pkt_type);
15952 printf("invalid port_id %d\n", res->port_id);
15955 printf("function not implemented\n");
15958 printf("programming error: (%s)\n", strerror(-ret));
15962 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
15963 .f = cmd_ptype_mapping_replace_parsed,
15966 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
15968 (void *)&cmd_ptype_mapping_replace_ptype,
15969 (void *)&cmd_ptype_mapping_replace_mapping,
15970 (void *)&cmd_ptype_mapping_replace_replace,
15971 (void *)&cmd_ptype_mapping_replace_port_id,
15972 (void *)&cmd_ptype_mapping_replace_target,
15973 (void *)&cmd_ptype_mapping_replace_mask,
15974 (void *)&cmd_ptype_mapping_replace_pkt_type,
15979 /* ptype mapping reset */
15981 /* Common result structure for ptype mapping reset */
15982 struct cmd_ptype_mapping_reset_result {
15983 cmdline_fixed_string_t ptype;
15984 cmdline_fixed_string_t mapping;
15985 cmdline_fixed_string_t reset;
15989 /* Common CLI fields for ptype mapping reset*/
15990 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
15991 TOKEN_STRING_INITIALIZER
15992 (struct cmd_ptype_mapping_reset_result,
15994 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
15995 TOKEN_STRING_INITIALIZER
15996 (struct cmd_ptype_mapping_reset_result,
15997 mapping, "mapping");
15998 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
15999 TOKEN_STRING_INITIALIZER
16000 (struct cmd_ptype_mapping_reset_result,
16002 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
16003 TOKEN_NUM_INITIALIZER
16004 (struct cmd_ptype_mapping_reset_result,
16008 cmd_ptype_mapping_reset_parsed(
16009 void *parsed_result,
16010 __attribute__((unused)) struct cmdline *cl,
16011 __attribute__((unused)) void *data)
16013 struct cmd_ptype_mapping_reset_result *res = parsed_result;
16014 int ret = -ENOTSUP;
16016 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16019 #ifdef RTE_LIBRTE_I40E_PMD
16020 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
16027 printf("invalid port_id %d\n", res->port_id);
16030 printf("function not implemented\n");
16033 printf("programming error: (%s)\n", strerror(-ret));
16037 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
16038 .f = cmd_ptype_mapping_reset_parsed,
16040 .help_str = "ptype mapping reset <port_id>",
16042 (void *)&cmd_ptype_mapping_reset_ptype,
16043 (void *)&cmd_ptype_mapping_reset_mapping,
16044 (void *)&cmd_ptype_mapping_reset_reset,
16045 (void *)&cmd_ptype_mapping_reset_port_id,
16050 /* ptype mapping update */
16052 /* Common result structure for ptype mapping update */
16053 struct cmd_ptype_mapping_update_result {
16054 cmdline_fixed_string_t ptype;
16055 cmdline_fixed_string_t mapping;
16056 cmdline_fixed_string_t reset;
16062 /* Common CLI fields for ptype mapping update*/
16063 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
16064 TOKEN_STRING_INITIALIZER
16065 (struct cmd_ptype_mapping_update_result,
16067 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
16068 TOKEN_STRING_INITIALIZER
16069 (struct cmd_ptype_mapping_update_result,
16070 mapping, "mapping");
16071 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
16072 TOKEN_STRING_INITIALIZER
16073 (struct cmd_ptype_mapping_update_result,
16075 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
16076 TOKEN_NUM_INITIALIZER
16077 (struct cmd_ptype_mapping_update_result,
16079 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
16080 TOKEN_NUM_INITIALIZER
16081 (struct cmd_ptype_mapping_update_result,
16083 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
16084 TOKEN_NUM_INITIALIZER
16085 (struct cmd_ptype_mapping_update_result,
16089 cmd_ptype_mapping_update_parsed(
16090 void *parsed_result,
16091 __attribute__((unused)) struct cmdline *cl,
16092 __attribute__((unused)) void *data)
16094 struct cmd_ptype_mapping_update_result *res = parsed_result;
16095 int ret = -ENOTSUP;
16096 #ifdef RTE_LIBRTE_I40E_PMD
16097 struct rte_pmd_i40e_ptype_mapping mapping;
16099 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16102 #ifdef RTE_LIBRTE_I40E_PMD
16103 mapping.hw_ptype = res->hw_ptype;
16104 mapping.sw_ptype = res->sw_ptype;
16105 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
16115 printf("invalid ptype 0x%8x\n", res->sw_ptype);
16118 printf("invalid port_id %d\n", res->port_id);
16121 printf("function not implemented\n");
16124 printf("programming error: (%s)\n", strerror(-ret));
16128 cmdline_parse_inst_t cmd_ptype_mapping_update = {
16129 .f = cmd_ptype_mapping_update_parsed,
16131 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
16133 (void *)&cmd_ptype_mapping_update_ptype,
16134 (void *)&cmd_ptype_mapping_update_mapping,
16135 (void *)&cmd_ptype_mapping_update_update,
16136 (void *)&cmd_ptype_mapping_update_port_id,
16137 (void *)&cmd_ptype_mapping_update_hw_ptype,
16138 (void *)&cmd_ptype_mapping_update_sw_ptype,
16143 /* Common result structure for file commands */
16144 struct cmd_cmdfile_result {
16145 cmdline_fixed_string_t load;
16146 cmdline_fixed_string_t filename;
16149 /* Common CLI fields for file commands */
16150 cmdline_parse_token_string_t cmd_load_cmdfile =
16151 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
16152 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
16153 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
16156 cmd_load_from_file_parsed(
16157 void *parsed_result,
16158 __attribute__((unused)) struct cmdline *cl,
16159 __attribute__((unused)) void *data)
16161 struct cmd_cmdfile_result *res = parsed_result;
16163 cmdline_read_from_file(res->filename);
16166 cmdline_parse_inst_t cmd_load_from_file = {
16167 .f = cmd_load_from_file_parsed,
16169 .help_str = "load <filename>",
16171 (void *)&cmd_load_cmdfile,
16172 (void *)&cmd_load_cmdfile_filename,
16177 /* ******************************************************************************** */
16179 /* list of instructions */
16180 cmdline_parse_ctx_t main_ctx[] = {
16181 (cmdline_parse_inst_t *)&cmd_help_brief,
16182 (cmdline_parse_inst_t *)&cmd_help_long,
16183 (cmdline_parse_inst_t *)&cmd_quit,
16184 (cmdline_parse_inst_t *)&cmd_load_from_file,
16185 (cmdline_parse_inst_t *)&cmd_showport,
16186 (cmdline_parse_inst_t *)&cmd_showqueue,
16187 (cmdline_parse_inst_t *)&cmd_showportall,
16188 (cmdline_parse_inst_t *)&cmd_showcfg,
16189 (cmdline_parse_inst_t *)&cmd_start,
16190 (cmdline_parse_inst_t *)&cmd_start_tx_first,
16191 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
16192 (cmdline_parse_inst_t *)&cmd_set_link_up,
16193 (cmdline_parse_inst_t *)&cmd_set_link_down,
16194 (cmdline_parse_inst_t *)&cmd_reset,
16195 (cmdline_parse_inst_t *)&cmd_set_numbers,
16196 (cmdline_parse_inst_t *)&cmd_set_log,
16197 (cmdline_parse_inst_t *)&cmd_set_txpkts,
16198 (cmdline_parse_inst_t *)&cmd_set_txsplit,
16199 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
16200 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
16201 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
16202 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
16203 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
16204 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
16205 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
16206 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
16207 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
16208 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
16209 (cmdline_parse_inst_t *)&cmd_set_link_check,
16210 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
16211 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
16212 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
16213 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
16214 #ifdef RTE_LIBRTE_PMD_BOND
16215 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
16216 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
16217 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
16218 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
16219 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
16220 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
16221 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
16222 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
16223 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
16224 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
16225 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
16227 (cmdline_parse_inst_t *)&cmd_vlan_offload,
16228 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
16229 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
16230 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
16231 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
16232 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
16233 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
16234 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
16235 (cmdline_parse_inst_t *)&cmd_csum_set,
16236 (cmdline_parse_inst_t *)&cmd_csum_show,
16237 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
16238 (cmdline_parse_inst_t *)&cmd_tso_set,
16239 (cmdline_parse_inst_t *)&cmd_tso_show,
16240 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
16241 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
16242 (cmdline_parse_inst_t *)&cmd_gro_enable,
16243 (cmdline_parse_inst_t *)&cmd_gro_flush,
16244 (cmdline_parse_inst_t *)&cmd_gro_show,
16245 (cmdline_parse_inst_t *)&cmd_gso_enable,
16246 (cmdline_parse_inst_t *)&cmd_gso_size,
16247 (cmdline_parse_inst_t *)&cmd_gso_show,
16248 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
16249 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
16250 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
16251 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
16252 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
16253 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
16254 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
16255 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
16256 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
16257 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
16258 (cmdline_parse_inst_t *)&cmd_config_dcb,
16259 (cmdline_parse_inst_t *)&cmd_read_reg,
16260 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
16261 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
16262 (cmdline_parse_inst_t *)&cmd_write_reg,
16263 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
16264 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
16265 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
16266 (cmdline_parse_inst_t *)&cmd_stop,
16267 (cmdline_parse_inst_t *)&cmd_mac_addr,
16268 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
16269 (cmdline_parse_inst_t *)&cmd_set_qmap,
16270 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
16271 (cmdline_parse_inst_t *)&cmd_operate_port,
16272 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
16273 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
16274 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
16275 (cmdline_parse_inst_t *)&cmd_config_speed_all,
16276 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
16277 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
16278 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
16279 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
16280 (cmdline_parse_inst_t *)&cmd_config_mtu,
16281 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
16282 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
16283 (cmdline_parse_inst_t *)&cmd_config_rss,
16284 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
16285 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
16286 (cmdline_parse_inst_t *)&cmd_showport_reta,
16287 (cmdline_parse_inst_t *)&cmd_config_burst,
16288 (cmdline_parse_inst_t *)&cmd_config_thresh,
16289 (cmdline_parse_inst_t *)&cmd_config_threshold,
16290 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
16291 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
16292 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
16293 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
16294 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
16295 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
16296 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
16297 (cmdline_parse_inst_t *)&cmd_global_config,
16298 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
16299 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
16300 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
16301 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
16302 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
16303 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
16304 (cmdline_parse_inst_t *)&cmd_dump,
16305 (cmdline_parse_inst_t *)&cmd_dump_one,
16306 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
16307 (cmdline_parse_inst_t *)&cmd_syn_filter,
16308 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
16309 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
16310 (cmdline_parse_inst_t *)&cmd_flex_filter,
16311 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
16312 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
16313 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
16314 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
16315 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
16316 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
16317 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
16318 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
16319 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
16320 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
16321 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
16322 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
16323 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
16324 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
16325 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
16326 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
16327 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
16328 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
16329 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
16330 (cmdline_parse_inst_t *)&cmd_flow,
16331 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
16332 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
16333 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
16334 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
16335 (cmdline_parse_inst_t *)&cmd_create_port_meter,
16336 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
16337 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
16338 (cmdline_parse_inst_t *)&cmd_del_port_meter,
16339 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
16340 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
16341 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
16342 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
16343 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
16344 (cmdline_parse_inst_t *)&cmd_mcast_addr,
16345 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
16346 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
16347 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
16348 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
16349 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
16350 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
16351 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
16352 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
16353 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
16354 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
16355 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
16356 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
16357 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
16358 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
16359 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
16360 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
16361 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
16362 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
16363 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
16364 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
16365 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
16366 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
16367 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
16368 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
16369 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
16370 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
16371 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
16372 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
16373 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
16374 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
16375 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
16376 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
16377 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
16378 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
16379 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
16380 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
16381 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
16383 (cmdline_parse_inst_t *)&cmd_ddp_add,
16384 (cmdline_parse_inst_t *)&cmd_ddp_del,
16385 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
16386 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
16387 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
16388 (cmdline_parse_inst_t *)&cmd_clear_input_set,
16389 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
16390 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
16391 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
16392 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
16393 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
16394 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
16396 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
16397 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
16398 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
16399 (cmdline_parse_inst_t *)&cmd_queue_region,
16400 (cmdline_parse_inst_t *)&cmd_region_flowtype,
16401 (cmdline_parse_inst_t *)&cmd_user_priority_region,
16402 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
16403 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
16404 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
16405 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
16406 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
16407 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
16408 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
16409 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
16410 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
16411 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
16412 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
16413 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
16414 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
16415 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
16416 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
16417 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
16418 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
16419 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
16420 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
16424 /* read cmdline commands from file */
16426 cmdline_read_from_file(const char *filename)
16428 struct cmdline *cl;
16430 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
16432 printf("Failed to create file based cmdline context: %s\n",
16437 cmdline_interact(cl);
16442 printf("Read CLI commands from %s\n", filename);
16445 /* prompt function, called from main on MASTER lcore */
16449 /* initialize non-constant commands */
16450 cmd_set_fwd_mode_init();
16451 cmd_set_fwd_retry_mode_init();
16453 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
16454 if (testpmd_cl == NULL)
16456 cmdline_interact(testpmd_cl);
16457 cmdline_stdin_exit(testpmd_cl);
16463 if (testpmd_cl != NULL)
16464 cmdline_quit(testpmd_cl);
16468 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
16470 if (id == (portid_t)RTE_PORT_ALL) {
16473 RTE_ETH_FOREACH_DEV(pid) {
16474 /* check if need_reconfig has been set to 1 */
16475 if (ports[pid].need_reconfig == 0)
16476 ports[pid].need_reconfig = dev;
16477 /* check if need_reconfig_queues has been set to 1 */
16478 if (ports[pid].need_reconfig_queues == 0)
16479 ports[pid].need_reconfig_queues = queue;
16481 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
16482 /* check if need_reconfig has been set to 1 */
16483 if (ports[id].need_reconfig == 0)
16484 ports[id].need_reconfig = dev;
16485 /* check if need_reconfig_queues has been set to 1 */
16486 if (ports[id].need_reconfig_queues == 0)
16487 ports[id].need_reconfig_queues = queue;