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 for (i = 0; i < rte_eth_dev_count(); 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;
2722 if (!all_ports_stopped()) {
2723 printf("Please stop all ports first\n");
2727 if (!strcmp(res->name, "burst")) {
2728 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2729 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2732 nb_pkt_per_burst = res->value;
2734 printf("Unknown parameter\n");
2740 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2743 cmdline_parse_token_string_t cmd_config_burst_port =
2744 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2745 cmdline_parse_token_string_t cmd_config_burst_keyword =
2746 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2747 cmdline_parse_token_string_t cmd_config_burst_all =
2748 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2749 cmdline_parse_token_string_t cmd_config_burst_name =
2750 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2751 cmdline_parse_token_num_t cmd_config_burst_value =
2752 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2754 cmdline_parse_inst_t cmd_config_burst = {
2755 .f = cmd_config_burst_parsed,
2757 .help_str = "port config all burst <value>",
2759 (void *)&cmd_config_burst_port,
2760 (void *)&cmd_config_burst_keyword,
2761 (void *)&cmd_config_burst_all,
2762 (void *)&cmd_config_burst_name,
2763 (void *)&cmd_config_burst_value,
2768 /* *** configure rx/tx queues *** */
2769 struct cmd_config_thresh {
2770 cmdline_fixed_string_t port;
2771 cmdline_fixed_string_t keyword;
2772 cmdline_fixed_string_t all;
2773 cmdline_fixed_string_t name;
2778 cmd_config_thresh_parsed(void *parsed_result,
2779 __attribute__((unused)) struct cmdline *cl,
2780 __attribute__((unused)) void *data)
2782 struct cmd_config_thresh *res = parsed_result;
2784 if (!all_ports_stopped()) {
2785 printf("Please stop all ports first\n");
2789 if (!strcmp(res->name, "txpt"))
2790 tx_pthresh = res->value;
2791 else if(!strcmp(res->name, "txht"))
2792 tx_hthresh = res->value;
2793 else if(!strcmp(res->name, "txwt"))
2794 tx_wthresh = res->value;
2795 else if(!strcmp(res->name, "rxpt"))
2796 rx_pthresh = res->value;
2797 else if(!strcmp(res->name, "rxht"))
2798 rx_hthresh = res->value;
2799 else if(!strcmp(res->name, "rxwt"))
2800 rx_wthresh = res->value;
2802 printf("Unknown parameter\n");
2808 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2811 cmdline_parse_token_string_t cmd_config_thresh_port =
2812 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2813 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2814 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2815 cmdline_parse_token_string_t cmd_config_thresh_all =
2816 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2817 cmdline_parse_token_string_t cmd_config_thresh_name =
2818 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2819 "txpt#txht#txwt#rxpt#rxht#rxwt");
2820 cmdline_parse_token_num_t cmd_config_thresh_value =
2821 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2823 cmdline_parse_inst_t cmd_config_thresh = {
2824 .f = cmd_config_thresh_parsed,
2826 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
2828 (void *)&cmd_config_thresh_port,
2829 (void *)&cmd_config_thresh_keyword,
2830 (void *)&cmd_config_thresh_all,
2831 (void *)&cmd_config_thresh_name,
2832 (void *)&cmd_config_thresh_value,
2837 /* *** configure free/rs threshold *** */
2838 struct cmd_config_threshold {
2839 cmdline_fixed_string_t port;
2840 cmdline_fixed_string_t keyword;
2841 cmdline_fixed_string_t all;
2842 cmdline_fixed_string_t name;
2847 cmd_config_threshold_parsed(void *parsed_result,
2848 __attribute__((unused)) struct cmdline *cl,
2849 __attribute__((unused)) void *data)
2851 struct cmd_config_threshold *res = parsed_result;
2853 if (!all_ports_stopped()) {
2854 printf("Please stop all ports first\n");
2858 if (!strcmp(res->name, "txfreet"))
2859 tx_free_thresh = res->value;
2860 else if (!strcmp(res->name, "txrst"))
2861 tx_rs_thresh = res->value;
2862 else if (!strcmp(res->name, "rxfreet"))
2863 rx_free_thresh = res->value;
2865 printf("Unknown parameter\n");
2871 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2874 cmdline_parse_token_string_t cmd_config_threshold_port =
2875 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2876 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2877 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2879 cmdline_parse_token_string_t cmd_config_threshold_all =
2880 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2881 cmdline_parse_token_string_t cmd_config_threshold_name =
2882 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2883 "txfreet#txrst#rxfreet");
2884 cmdline_parse_token_num_t cmd_config_threshold_value =
2885 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2887 cmdline_parse_inst_t cmd_config_threshold = {
2888 .f = cmd_config_threshold_parsed,
2890 .help_str = "port config all txfreet|txrst|rxfreet <value>",
2892 (void *)&cmd_config_threshold_port,
2893 (void *)&cmd_config_threshold_keyword,
2894 (void *)&cmd_config_threshold_all,
2895 (void *)&cmd_config_threshold_name,
2896 (void *)&cmd_config_threshold_value,
2902 struct cmd_stop_result {
2903 cmdline_fixed_string_t stop;
2906 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2907 __attribute__((unused)) struct cmdline *cl,
2908 __attribute__((unused)) void *data)
2910 stop_packet_forwarding();
2913 cmdline_parse_token_string_t cmd_stop_stop =
2914 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2916 cmdline_parse_inst_t cmd_stop = {
2917 .f = cmd_stop_parsed,
2919 .help_str = "stop: Stop packet forwarding",
2921 (void *)&cmd_stop_stop,
2926 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2929 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2930 unsigned int *parsed_items, int check_unique_values)
2932 unsigned int nb_item;
2940 * First parse all items in the list and store their value.
2945 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2947 if ((c >= '0') && (c <= '9')) {
2948 value = (unsigned int) (value * 10 + (c - '0'));
2953 printf("character %c is not a decimal digit\n", c);
2957 printf("No valid value before comma\n");
2960 if (nb_item < max_items) {
2961 parsed_items[nb_item] = value;
2967 if (nb_item >= max_items) {
2968 printf("Number of %s = %u > %u (maximum items)\n",
2969 item_name, nb_item + 1, max_items);
2972 parsed_items[nb_item++] = value;
2973 if (! check_unique_values)
2977 * Then, check that all values in the list are differents.
2978 * No optimization here...
2980 for (i = 0; i < nb_item; i++) {
2981 for (j = i + 1; j < nb_item; j++) {
2982 if (parsed_items[j] == parsed_items[i]) {
2983 printf("duplicated %s %u at index %u and %u\n",
2984 item_name, parsed_items[i], i, j);
2992 struct cmd_set_list_result {
2993 cmdline_fixed_string_t cmd_keyword;
2994 cmdline_fixed_string_t list_name;
2995 cmdline_fixed_string_t list_of_items;
2998 static void cmd_set_list_parsed(void *parsed_result,
2999 __attribute__((unused)) struct cmdline *cl,
3000 __attribute__((unused)) void *data)
3002 struct cmd_set_list_result *res;
3004 unsigned int lcorelist[RTE_MAX_LCORE];
3005 unsigned int portlist[RTE_MAX_ETHPORTS];
3007 unsigned int nb_item;
3009 if (test_done == 0) {
3010 printf("Please stop forwarding first\n");
3014 res = parsed_result;
3015 if (!strcmp(res->list_name, "corelist")) {
3016 nb_item = parse_item_list(res->list_of_items, "core",
3018 parsed_items.lcorelist, 1);
3020 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3025 if (!strcmp(res->list_name, "portlist")) {
3026 nb_item = parse_item_list(res->list_of_items, "port",
3028 parsed_items.portlist, 1);
3030 set_fwd_ports_list(parsed_items.portlist, nb_item);
3036 cmdline_parse_token_string_t cmd_set_list_keyword =
3037 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3039 cmdline_parse_token_string_t cmd_set_list_name =
3040 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3041 "corelist#portlist");
3042 cmdline_parse_token_string_t cmd_set_list_of_items =
3043 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3046 cmdline_parse_inst_t cmd_set_fwd_list = {
3047 .f = cmd_set_list_parsed,
3049 .help_str = "set corelist|portlist <list0[,list1]*>",
3051 (void *)&cmd_set_list_keyword,
3052 (void *)&cmd_set_list_name,
3053 (void *)&cmd_set_list_of_items,
3058 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3060 struct cmd_setmask_result {
3061 cmdline_fixed_string_t set;
3062 cmdline_fixed_string_t mask;
3066 static void cmd_set_mask_parsed(void *parsed_result,
3067 __attribute__((unused)) struct cmdline *cl,
3068 __attribute__((unused)) void *data)
3070 struct cmd_setmask_result *res = parsed_result;
3072 if (test_done == 0) {
3073 printf("Please stop forwarding first\n");
3076 if (!strcmp(res->mask, "coremask")) {
3077 set_fwd_lcores_mask(res->hexavalue);
3079 } else if (!strcmp(res->mask, "portmask")) {
3080 set_fwd_ports_mask(res->hexavalue);
3085 cmdline_parse_token_string_t cmd_setmask_set =
3086 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3087 cmdline_parse_token_string_t cmd_setmask_mask =
3088 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3089 "coremask#portmask");
3090 cmdline_parse_token_num_t cmd_setmask_value =
3091 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3093 cmdline_parse_inst_t cmd_set_fwd_mask = {
3094 .f = cmd_set_mask_parsed,
3096 .help_str = "set coremask|portmask <hexadecimal value>",
3098 (void *)&cmd_setmask_set,
3099 (void *)&cmd_setmask_mask,
3100 (void *)&cmd_setmask_value,
3106 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3108 struct cmd_set_result {
3109 cmdline_fixed_string_t set;
3110 cmdline_fixed_string_t what;
3114 static void cmd_set_parsed(void *parsed_result,
3115 __attribute__((unused)) struct cmdline *cl,
3116 __attribute__((unused)) void *data)
3118 struct cmd_set_result *res = parsed_result;
3119 if (!strcmp(res->what, "nbport")) {
3120 set_fwd_ports_number(res->value);
3122 } else if (!strcmp(res->what, "nbcore")) {
3123 set_fwd_lcores_number(res->value);
3125 } else if (!strcmp(res->what, "burst"))
3126 set_nb_pkt_per_burst(res->value);
3127 else if (!strcmp(res->what, "verbose"))
3128 set_verbose_level(res->value);
3131 cmdline_parse_token_string_t cmd_set_set =
3132 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3133 cmdline_parse_token_string_t cmd_set_what =
3134 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3135 "nbport#nbcore#burst#verbose");
3136 cmdline_parse_token_num_t cmd_set_value =
3137 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3139 cmdline_parse_inst_t cmd_set_numbers = {
3140 .f = cmd_set_parsed,
3142 .help_str = "set nbport|nbcore|burst|verbose <value>",
3144 (void *)&cmd_set_set,
3145 (void *)&cmd_set_what,
3146 (void *)&cmd_set_value,
3151 /* *** SET LOG LEVEL CONFIGURATION *** */
3153 struct cmd_set_log_result {
3154 cmdline_fixed_string_t set;
3155 cmdline_fixed_string_t log;
3156 cmdline_fixed_string_t type;
3161 cmd_set_log_parsed(void *parsed_result,
3162 __attribute__((unused)) struct cmdline *cl,
3163 __attribute__((unused)) void *data)
3165 struct cmd_set_log_result *res;
3168 res = parsed_result;
3169 if (!strcmp(res->type, "global"))
3170 rte_log_set_global_level(res->level);
3172 ret = rte_log_set_level_regexp(res->type, res->level);
3174 printf("Unable to set log level\n");
3178 cmdline_parse_token_string_t cmd_set_log_set =
3179 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3180 cmdline_parse_token_string_t cmd_set_log_log =
3181 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3182 cmdline_parse_token_string_t cmd_set_log_type =
3183 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3184 cmdline_parse_token_num_t cmd_set_log_level =
3185 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3187 cmdline_parse_inst_t cmd_set_log = {
3188 .f = cmd_set_log_parsed,
3190 .help_str = "set log global|<type> <level>",
3192 (void *)&cmd_set_log_set,
3193 (void *)&cmd_set_log_log,
3194 (void *)&cmd_set_log_type,
3195 (void *)&cmd_set_log_level,
3200 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3202 struct cmd_set_txpkts_result {
3203 cmdline_fixed_string_t cmd_keyword;
3204 cmdline_fixed_string_t txpkts;
3205 cmdline_fixed_string_t seg_lengths;
3209 cmd_set_txpkts_parsed(void *parsed_result,
3210 __attribute__((unused)) struct cmdline *cl,
3211 __attribute__((unused)) void *data)
3213 struct cmd_set_txpkts_result *res;
3214 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3215 unsigned int nb_segs;
3217 res = parsed_result;
3218 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3219 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3221 set_tx_pkt_segments(seg_lengths, nb_segs);
3224 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3225 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3226 cmd_keyword, "set");
3227 cmdline_parse_token_string_t cmd_set_txpkts_name =
3228 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3230 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3231 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3234 cmdline_parse_inst_t cmd_set_txpkts = {
3235 .f = cmd_set_txpkts_parsed,
3237 .help_str = "set txpkts <len0[,len1]*>",
3239 (void *)&cmd_set_txpkts_keyword,
3240 (void *)&cmd_set_txpkts_name,
3241 (void *)&cmd_set_txpkts_lengths,
3246 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3248 struct cmd_set_txsplit_result {
3249 cmdline_fixed_string_t cmd_keyword;
3250 cmdline_fixed_string_t txsplit;
3251 cmdline_fixed_string_t mode;
3255 cmd_set_txsplit_parsed(void *parsed_result,
3256 __attribute__((unused)) struct cmdline *cl,
3257 __attribute__((unused)) void *data)
3259 struct cmd_set_txsplit_result *res;
3261 res = parsed_result;
3262 set_tx_pkt_split(res->mode);
3265 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3266 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3267 cmd_keyword, "set");
3268 cmdline_parse_token_string_t cmd_set_txsplit_name =
3269 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3270 txsplit, "txsplit");
3271 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3272 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3275 cmdline_parse_inst_t cmd_set_txsplit = {
3276 .f = cmd_set_txsplit_parsed,
3278 .help_str = "set txsplit on|off|rand",
3280 (void *)&cmd_set_txsplit_keyword,
3281 (void *)&cmd_set_txsplit_name,
3282 (void *)&cmd_set_txsplit_mode,
3287 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3288 struct cmd_rx_vlan_filter_all_result {
3289 cmdline_fixed_string_t rx_vlan;
3290 cmdline_fixed_string_t what;
3291 cmdline_fixed_string_t all;
3296 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3297 __attribute__((unused)) struct cmdline *cl,
3298 __attribute__((unused)) void *data)
3300 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3302 if (!strcmp(res->what, "add"))
3303 rx_vlan_all_filter_set(res->port_id, 1);
3305 rx_vlan_all_filter_set(res->port_id, 0);
3308 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3309 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3310 rx_vlan, "rx_vlan");
3311 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3312 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3314 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3315 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3317 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3318 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3321 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3322 .f = cmd_rx_vlan_filter_all_parsed,
3324 .help_str = "rx_vlan add|rm all <port_id>: "
3325 "Add/Remove all identifiers to/from the set of VLAN "
3326 "identifiers filtered by a port",
3328 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3329 (void *)&cmd_rx_vlan_filter_all_what,
3330 (void *)&cmd_rx_vlan_filter_all_all,
3331 (void *)&cmd_rx_vlan_filter_all_portid,
3336 /* *** VLAN OFFLOAD SET ON A PORT *** */
3337 struct cmd_vlan_offload_result {
3338 cmdline_fixed_string_t vlan;
3339 cmdline_fixed_string_t set;
3340 cmdline_fixed_string_t vlan_type;
3341 cmdline_fixed_string_t what;
3342 cmdline_fixed_string_t on;
3343 cmdline_fixed_string_t port_id;
3347 cmd_vlan_offload_parsed(void *parsed_result,
3348 __attribute__((unused)) struct cmdline *cl,
3349 __attribute__((unused)) void *data)
3352 struct cmd_vlan_offload_result *res = parsed_result;
3355 portid_t port_id = 0;
3359 len = strnlen(str, STR_TOKEN_SIZE);
3361 /* Get port_id first */
3369 tmp = strtoul(str, NULL, 0);
3370 /* If port_id greater that what portid_t can represent, return */
3371 if(tmp >= RTE_MAX_ETHPORTS)
3373 port_id = (portid_t)tmp;
3375 if (!strcmp(res->on, "on"))
3380 if (!strcmp(res->what, "strip"))
3381 rx_vlan_strip_set(port_id, on);
3382 else if(!strcmp(res->what, "stripq")){
3383 uint16_t queue_id = 0;
3385 /* No queue_id, return */
3387 printf("must specify (port,queue_id)\n");
3390 tmp = strtoul(str + i + 1, NULL, 0);
3391 /* If queue_id greater that what 16-bits can represent, return */
3395 queue_id = (uint16_t)tmp;
3396 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3398 else if (!strcmp(res->what, "filter"))
3399 rx_vlan_filter_set(port_id, on);
3401 vlan_extend_set(port_id, on);
3406 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3407 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3409 cmdline_parse_token_string_t cmd_vlan_offload_set =
3410 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3412 cmdline_parse_token_string_t cmd_vlan_offload_what =
3413 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3414 what, "strip#filter#qinq#stripq");
3415 cmdline_parse_token_string_t cmd_vlan_offload_on =
3416 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3418 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3419 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3422 cmdline_parse_inst_t cmd_vlan_offload = {
3423 .f = cmd_vlan_offload_parsed,
3425 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3426 "<port_id[,queue_id]>: "
3427 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3429 (void *)&cmd_vlan_offload_vlan,
3430 (void *)&cmd_vlan_offload_set,
3431 (void *)&cmd_vlan_offload_what,
3432 (void *)&cmd_vlan_offload_on,
3433 (void *)&cmd_vlan_offload_portid,
3438 /* *** VLAN TPID SET ON A PORT *** */
3439 struct cmd_vlan_tpid_result {
3440 cmdline_fixed_string_t vlan;
3441 cmdline_fixed_string_t set;
3442 cmdline_fixed_string_t vlan_type;
3443 cmdline_fixed_string_t what;
3449 cmd_vlan_tpid_parsed(void *parsed_result,
3450 __attribute__((unused)) struct cmdline *cl,
3451 __attribute__((unused)) void *data)
3453 struct cmd_vlan_tpid_result *res = parsed_result;
3454 enum rte_vlan_type vlan_type;
3456 if (!strcmp(res->vlan_type, "inner"))
3457 vlan_type = ETH_VLAN_TYPE_INNER;
3458 else if (!strcmp(res->vlan_type, "outer"))
3459 vlan_type = ETH_VLAN_TYPE_OUTER;
3461 printf("Unknown vlan type\n");
3464 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3467 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3468 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3470 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3471 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3473 cmdline_parse_token_string_t cmd_vlan_type =
3474 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3475 vlan_type, "inner#outer");
3476 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3477 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3479 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3480 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3482 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3483 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3486 cmdline_parse_inst_t cmd_vlan_tpid = {
3487 .f = cmd_vlan_tpid_parsed,
3489 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3490 "Set the VLAN Ether type",
3492 (void *)&cmd_vlan_tpid_vlan,
3493 (void *)&cmd_vlan_tpid_set,
3494 (void *)&cmd_vlan_type,
3495 (void *)&cmd_vlan_tpid_what,
3496 (void *)&cmd_vlan_tpid_tpid,
3497 (void *)&cmd_vlan_tpid_portid,
3502 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3503 struct cmd_rx_vlan_filter_result {
3504 cmdline_fixed_string_t rx_vlan;
3505 cmdline_fixed_string_t what;
3511 cmd_rx_vlan_filter_parsed(void *parsed_result,
3512 __attribute__((unused)) struct cmdline *cl,
3513 __attribute__((unused)) void *data)
3515 struct cmd_rx_vlan_filter_result *res = parsed_result;
3517 if (!strcmp(res->what, "add"))
3518 rx_vft_set(res->port_id, res->vlan_id, 1);
3520 rx_vft_set(res->port_id, res->vlan_id, 0);
3523 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3524 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3525 rx_vlan, "rx_vlan");
3526 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3527 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3529 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3530 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3532 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3533 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3536 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3537 .f = cmd_rx_vlan_filter_parsed,
3539 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3540 "Add/Remove a VLAN identifier to/from the set of VLAN "
3541 "identifiers filtered by a port",
3543 (void *)&cmd_rx_vlan_filter_rx_vlan,
3544 (void *)&cmd_rx_vlan_filter_what,
3545 (void *)&cmd_rx_vlan_filter_vlanid,
3546 (void *)&cmd_rx_vlan_filter_portid,
3551 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3552 struct cmd_tx_vlan_set_result {
3553 cmdline_fixed_string_t tx_vlan;
3554 cmdline_fixed_string_t set;
3560 cmd_tx_vlan_set_parsed(void *parsed_result,
3561 __attribute__((unused)) struct cmdline *cl,
3562 __attribute__((unused)) void *data)
3564 struct cmd_tx_vlan_set_result *res = parsed_result;
3566 if (!port_is_stopped(res->port_id)) {
3567 printf("Please stop port %d first\n", res->port_id);
3571 tx_vlan_set(res->port_id, res->vlan_id);
3573 cmd_reconfig_device_queue(res->port_id, 1, 1);
3576 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3577 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3578 tx_vlan, "tx_vlan");
3579 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3580 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3582 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3583 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3585 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3586 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3589 cmdline_parse_inst_t cmd_tx_vlan_set = {
3590 .f = cmd_tx_vlan_set_parsed,
3592 .help_str = "tx_vlan set <port_id> <vlan_id>: "
3593 "Enable hardware insertion of a single VLAN header "
3594 "with a given TAG Identifier in packets sent on a port",
3596 (void *)&cmd_tx_vlan_set_tx_vlan,
3597 (void *)&cmd_tx_vlan_set_set,
3598 (void *)&cmd_tx_vlan_set_portid,
3599 (void *)&cmd_tx_vlan_set_vlanid,
3604 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3605 struct cmd_tx_vlan_set_qinq_result {
3606 cmdline_fixed_string_t tx_vlan;
3607 cmdline_fixed_string_t set;
3610 uint16_t vlan_id_outer;
3614 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3615 __attribute__((unused)) struct cmdline *cl,
3616 __attribute__((unused)) void *data)
3618 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3620 if (!port_is_stopped(res->port_id)) {
3621 printf("Please stop port %d first\n", res->port_id);
3625 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3627 cmd_reconfig_device_queue(res->port_id, 1, 1);
3630 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3631 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3632 tx_vlan, "tx_vlan");
3633 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3634 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3636 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3637 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3639 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3640 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3642 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3643 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3644 vlan_id_outer, UINT16);
3646 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3647 .f = cmd_tx_vlan_set_qinq_parsed,
3649 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3650 "Enable hardware insertion of double VLAN header "
3651 "with given TAG Identifiers in packets sent on a port",
3653 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3654 (void *)&cmd_tx_vlan_set_qinq_set,
3655 (void *)&cmd_tx_vlan_set_qinq_portid,
3656 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3657 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3662 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3663 struct cmd_tx_vlan_set_pvid_result {
3664 cmdline_fixed_string_t tx_vlan;
3665 cmdline_fixed_string_t set;
3666 cmdline_fixed_string_t pvid;
3669 cmdline_fixed_string_t mode;
3673 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3674 __attribute__((unused)) struct cmdline *cl,
3675 __attribute__((unused)) void *data)
3677 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3679 if (strcmp(res->mode, "on") == 0)
3680 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3682 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3685 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3686 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3687 tx_vlan, "tx_vlan");
3688 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3689 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3691 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3692 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3694 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3695 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3697 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3698 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3700 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3701 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3704 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3705 .f = cmd_tx_vlan_set_pvid_parsed,
3707 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
3709 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3710 (void *)&cmd_tx_vlan_set_pvid_set,
3711 (void *)&cmd_tx_vlan_set_pvid_pvid,
3712 (void *)&cmd_tx_vlan_set_pvid_port_id,
3713 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3714 (void *)&cmd_tx_vlan_set_pvid_mode,
3719 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3720 struct cmd_tx_vlan_reset_result {
3721 cmdline_fixed_string_t tx_vlan;
3722 cmdline_fixed_string_t reset;
3727 cmd_tx_vlan_reset_parsed(void *parsed_result,
3728 __attribute__((unused)) struct cmdline *cl,
3729 __attribute__((unused)) void *data)
3731 struct cmd_tx_vlan_reset_result *res = parsed_result;
3733 if (!port_is_stopped(res->port_id)) {
3734 printf("Please stop port %d first\n", res->port_id);
3738 tx_vlan_reset(res->port_id);
3740 cmd_reconfig_device_queue(res->port_id, 1, 1);
3743 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3744 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3745 tx_vlan, "tx_vlan");
3746 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3747 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3749 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3750 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3753 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3754 .f = cmd_tx_vlan_reset_parsed,
3756 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
3757 "VLAN header in packets sent on a port",
3759 (void *)&cmd_tx_vlan_reset_tx_vlan,
3760 (void *)&cmd_tx_vlan_reset_reset,
3761 (void *)&cmd_tx_vlan_reset_portid,
3767 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3768 struct cmd_csum_result {
3769 cmdline_fixed_string_t csum;
3770 cmdline_fixed_string_t mode;
3771 cmdline_fixed_string_t proto;
3772 cmdline_fixed_string_t hwsw;
3777 csum_show(int port_id)
3779 struct rte_eth_dev_info dev_info;
3780 uint64_t tx_offloads;
3782 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
3783 printf("Parse tunnel is %s\n",
3784 (ports[port_id].parse_tunnel) ? "on" : "off");
3785 printf("IP checksum offload is %s\n",
3786 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
3787 printf("UDP checksum offload is %s\n",
3788 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3789 printf("TCP checksum offload is %s\n",
3790 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3791 printf("SCTP checksum offload is %s\n",
3792 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3793 printf("Outer-Ip checksum offload is %s\n",
3794 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
3796 /* display warnings if configuration is not supported by the NIC */
3797 rte_eth_dev_info_get(port_id, &dev_info);
3798 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
3799 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3800 printf("Warning: hardware IP checksum enabled but not "
3801 "supported by port %d\n", port_id);
3803 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
3804 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3805 printf("Warning: hardware UDP checksum enabled but not "
3806 "supported by port %d\n", port_id);
3808 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
3809 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3810 printf("Warning: hardware TCP checksum enabled but not "
3811 "supported by port %d\n", port_id);
3813 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
3814 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3815 printf("Warning: hardware SCTP checksum enabled but not "
3816 "supported by port %d\n", port_id);
3818 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
3819 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3820 printf("Warning: hardware outer IP checksum enabled but not "
3821 "supported by port %d\n", port_id);
3826 cmd_csum_parsed(void *parsed_result,
3827 __attribute__((unused)) struct cmdline *cl,
3828 __attribute__((unused)) void *data)
3830 struct cmd_csum_result *res = parsed_result;
3832 uint64_t csum_offloads = 0;
3833 struct rte_eth_dev_info dev_info;
3835 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3836 printf("invalid port %d\n", res->port_id);
3839 if (!port_is_stopped(res->port_id)) {
3840 printf("Please stop port %d first\n", res->port_id);
3844 rte_eth_dev_info_get(res->port_id, &dev_info);
3845 if (!strcmp(res->mode, "set")) {
3847 if (!strcmp(res->hwsw, "hw"))
3850 if (!strcmp(res->proto, "ip")) {
3851 if (hw == 0 || (dev_info.tx_offload_capa &
3852 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
3853 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
3855 printf("IP checksum offload is not supported "
3856 "by port %u\n", res->port_id);
3858 } else if (!strcmp(res->proto, "udp")) {
3859 if (hw == 0 || (dev_info.tx_offload_capa &
3860 DEV_TX_OFFLOAD_UDP_CKSUM)) {
3861 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
3863 printf("UDP checksum offload is not supported "
3864 "by port %u\n", res->port_id);
3866 } else if (!strcmp(res->proto, "tcp")) {
3867 if (hw == 0 || (dev_info.tx_offload_capa &
3868 DEV_TX_OFFLOAD_TCP_CKSUM)) {
3869 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
3871 printf("TCP checksum offload is not supported "
3872 "by port %u\n", res->port_id);
3874 } else if (!strcmp(res->proto, "sctp")) {
3875 if (hw == 0 || (dev_info.tx_offload_capa &
3876 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
3877 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
3879 printf("SCTP checksum offload is not supported "
3880 "by port %u\n", res->port_id);
3882 } else if (!strcmp(res->proto, "outer-ip")) {
3883 if (hw == 0 || (dev_info.tx_offload_capa &
3884 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
3886 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
3888 printf("Outer IP checksum offload is not "
3889 "supported by port %u\n", res->port_id);
3894 ports[res->port_id].dev_conf.txmode.offloads |=
3897 ports[res->port_id].dev_conf.txmode.offloads &=
3901 csum_show(res->port_id);
3903 cmd_reconfig_device_queue(res->port_id, 1, 1);
3906 cmdline_parse_token_string_t cmd_csum_csum =
3907 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3909 cmdline_parse_token_string_t cmd_csum_mode =
3910 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3912 cmdline_parse_token_string_t cmd_csum_proto =
3913 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3914 proto, "ip#tcp#udp#sctp#outer-ip");
3915 cmdline_parse_token_string_t cmd_csum_hwsw =
3916 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3918 cmdline_parse_token_num_t cmd_csum_portid =
3919 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3922 cmdline_parse_inst_t cmd_csum_set = {
3923 .f = cmd_csum_parsed,
3925 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
3926 "Enable/Disable hardware calculation of L3/L4 checksum when "
3927 "using csum forward engine",
3929 (void *)&cmd_csum_csum,
3930 (void *)&cmd_csum_mode,
3931 (void *)&cmd_csum_proto,
3932 (void *)&cmd_csum_hwsw,
3933 (void *)&cmd_csum_portid,
3938 cmdline_parse_token_string_t cmd_csum_mode_show =
3939 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3942 cmdline_parse_inst_t cmd_csum_show = {
3943 .f = cmd_csum_parsed,
3945 .help_str = "csum show <port_id>: Show checksum offload configuration",
3947 (void *)&cmd_csum_csum,
3948 (void *)&cmd_csum_mode_show,
3949 (void *)&cmd_csum_portid,
3954 /* Enable/disable tunnel parsing */
3955 struct cmd_csum_tunnel_result {
3956 cmdline_fixed_string_t csum;
3957 cmdline_fixed_string_t parse;
3958 cmdline_fixed_string_t onoff;
3963 cmd_csum_tunnel_parsed(void *parsed_result,
3964 __attribute__((unused)) struct cmdline *cl,
3965 __attribute__((unused)) void *data)
3967 struct cmd_csum_tunnel_result *res = parsed_result;
3969 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3972 if (!strcmp(res->onoff, "on"))
3973 ports[res->port_id].parse_tunnel = 1;
3975 ports[res->port_id].parse_tunnel = 0;
3977 csum_show(res->port_id);
3980 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3981 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3983 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3984 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3985 parse, "parse_tunnel");
3986 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3987 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3989 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3990 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3993 cmdline_parse_inst_t cmd_csum_tunnel = {
3994 .f = cmd_csum_tunnel_parsed,
3996 .help_str = "csum parse_tunnel on|off <port_id>: "
3997 "Enable/Disable parsing of tunnels for csum engine",
3999 (void *)&cmd_csum_tunnel_csum,
4000 (void *)&cmd_csum_tunnel_parse,
4001 (void *)&cmd_csum_tunnel_onoff,
4002 (void *)&cmd_csum_tunnel_portid,
4007 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4008 struct cmd_tso_set_result {
4009 cmdline_fixed_string_t tso;
4010 cmdline_fixed_string_t mode;
4016 cmd_tso_set_parsed(void *parsed_result,
4017 __attribute__((unused)) struct cmdline *cl,
4018 __attribute__((unused)) void *data)
4020 struct cmd_tso_set_result *res = parsed_result;
4021 struct rte_eth_dev_info dev_info;
4023 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4025 if (!port_is_stopped(res->port_id)) {
4026 printf("Please stop port %d first\n", res->port_id);
4030 if (!strcmp(res->mode, "set"))
4031 ports[res->port_id].tso_segsz = res->tso_segsz;
4033 rte_eth_dev_info_get(res->port_id, &dev_info);
4034 if ((ports[res->port_id].tso_segsz != 0) &&
4035 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4036 printf("Error: TSO is not supported by port %d\n",
4041 if (ports[res->port_id].tso_segsz == 0) {
4042 ports[res->port_id].dev_conf.txmode.offloads &=
4043 ~DEV_TX_OFFLOAD_TCP_TSO;
4044 printf("TSO for non-tunneled packets is disabled\n");
4046 ports[res->port_id].dev_conf.txmode.offloads |=
4047 DEV_TX_OFFLOAD_TCP_TSO;
4048 printf("TSO segment size for non-tunneled packets is %d\n",
4049 ports[res->port_id].tso_segsz);
4052 /* display warnings if configuration is not supported by the NIC */
4053 rte_eth_dev_info_get(res->port_id, &dev_info);
4054 if ((ports[res->port_id].tso_segsz != 0) &&
4055 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4056 printf("Warning: TSO enabled but not "
4057 "supported by port %d\n", res->port_id);
4060 cmd_reconfig_device_queue(res->port_id, 1, 1);
4063 cmdline_parse_token_string_t cmd_tso_set_tso =
4064 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4066 cmdline_parse_token_string_t cmd_tso_set_mode =
4067 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4069 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4070 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4072 cmdline_parse_token_num_t cmd_tso_set_portid =
4073 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4076 cmdline_parse_inst_t cmd_tso_set = {
4077 .f = cmd_tso_set_parsed,
4079 .help_str = "tso set <tso_segsz> <port_id>: "
4080 "Set TSO segment size of non-tunneled packets for csum engine "
4083 (void *)&cmd_tso_set_tso,
4084 (void *)&cmd_tso_set_mode,
4085 (void *)&cmd_tso_set_tso_segsz,
4086 (void *)&cmd_tso_set_portid,
4091 cmdline_parse_token_string_t cmd_tso_show_mode =
4092 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4096 cmdline_parse_inst_t cmd_tso_show = {
4097 .f = cmd_tso_set_parsed,
4099 .help_str = "tso show <port_id>: "
4100 "Show TSO segment size of non-tunneled packets for csum engine",
4102 (void *)&cmd_tso_set_tso,
4103 (void *)&cmd_tso_show_mode,
4104 (void *)&cmd_tso_set_portid,
4109 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4110 struct cmd_tunnel_tso_set_result {
4111 cmdline_fixed_string_t tso;
4112 cmdline_fixed_string_t mode;
4117 static struct rte_eth_dev_info
4118 check_tunnel_tso_nic_support(portid_t port_id)
4120 struct rte_eth_dev_info dev_info;
4122 rte_eth_dev_info_get(port_id, &dev_info);
4123 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4124 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4125 "not enabled for port %d\n", port_id);
4126 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4127 printf("Warning: GRE TUNNEL TSO not supported therefore "
4128 "not enabled for port %d\n", port_id);
4129 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4130 printf("Warning: IPIP TUNNEL TSO not supported therefore "
4131 "not enabled for port %d\n", port_id);
4132 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4133 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4134 "not enabled for port %d\n", port_id);
4139 cmd_tunnel_tso_set_parsed(void *parsed_result,
4140 __attribute__((unused)) struct cmdline *cl,
4141 __attribute__((unused)) void *data)
4143 struct cmd_tunnel_tso_set_result *res = parsed_result;
4144 struct rte_eth_dev_info dev_info;
4146 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4148 if (!port_is_stopped(res->port_id)) {
4149 printf("Please stop port %d first\n", res->port_id);
4153 if (!strcmp(res->mode, "set"))
4154 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4156 dev_info = check_tunnel_tso_nic_support(res->port_id);
4157 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4158 ports[res->port_id].dev_conf.txmode.offloads &=
4159 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4160 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4161 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4162 DEV_TX_OFFLOAD_GENEVE_TNL_TSO);
4163 printf("TSO for tunneled packets is disabled\n");
4165 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4166 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4167 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4168 DEV_TX_OFFLOAD_GENEVE_TNL_TSO);
4170 ports[res->port_id].dev_conf.txmode.offloads |=
4171 (tso_offloads & dev_info.tx_offload_capa);
4172 printf("TSO segment size for tunneled packets is %d\n",
4173 ports[res->port_id].tunnel_tso_segsz);
4175 /* Below conditions are needed to make it work:
4176 * (1) tunnel TSO is supported by the NIC;
4177 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4179 * (3) for tunneled pkts with outer L3 of IPv4,
4180 * "csum set outer-ip" must be set to hw, because after tso,
4181 * total_len of outer IP header is changed, and the checksum
4182 * of outer IP header calculated by sw should be wrong; that
4183 * is not necessary for IPv6 tunneled pkts because there's no
4184 * checksum in IP header anymore.
4187 if (!ports[res->port_id].parse_tunnel)
4188 printf("Warning: csum parse_tunnel must be set "
4189 "so that tunneled packets are recognized\n");
4190 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4191 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4192 printf("Warning: csum set outer-ip must be set to hw "
4193 "if outer L3 is IPv4; not necessary for IPv6\n");
4196 cmd_reconfig_device_queue(res->port_id, 1, 1);
4199 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4200 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4202 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4203 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4205 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4206 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4208 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4209 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4212 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4213 .f = cmd_tunnel_tso_set_parsed,
4215 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4216 "Set TSO segment size of tunneled packets for csum engine "
4219 (void *)&cmd_tunnel_tso_set_tso,
4220 (void *)&cmd_tunnel_tso_set_mode,
4221 (void *)&cmd_tunnel_tso_set_tso_segsz,
4222 (void *)&cmd_tunnel_tso_set_portid,
4227 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4228 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4232 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4233 .f = cmd_tunnel_tso_set_parsed,
4235 .help_str = "tunnel_tso show <port_id> "
4236 "Show TSO segment size of tunneled packets for csum engine",
4238 (void *)&cmd_tunnel_tso_set_tso,
4239 (void *)&cmd_tunnel_tso_show_mode,
4240 (void *)&cmd_tunnel_tso_set_portid,
4245 /* *** SET GRO FOR A PORT *** */
4246 struct cmd_gro_enable_result {
4247 cmdline_fixed_string_t cmd_set;
4248 cmdline_fixed_string_t cmd_port;
4249 cmdline_fixed_string_t cmd_keyword;
4250 cmdline_fixed_string_t cmd_onoff;
4255 cmd_gro_enable_parsed(void *parsed_result,
4256 __attribute__((unused)) struct cmdline *cl,
4257 __attribute__((unused)) void *data)
4259 struct cmd_gro_enable_result *res;
4261 res = parsed_result;
4262 if (!strcmp(res->cmd_keyword, "gro"))
4263 setup_gro(res->cmd_onoff, res->cmd_pid);
4266 cmdline_parse_token_string_t cmd_gro_enable_set =
4267 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4269 cmdline_parse_token_string_t cmd_gro_enable_port =
4270 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4271 cmd_keyword, "port");
4272 cmdline_parse_token_num_t cmd_gro_enable_pid =
4273 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4275 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4276 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4277 cmd_keyword, "gro");
4278 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4279 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4280 cmd_onoff, "on#off");
4282 cmdline_parse_inst_t cmd_gro_enable = {
4283 .f = cmd_gro_enable_parsed,
4285 .help_str = "set port <port_id> gro on|off",
4287 (void *)&cmd_gro_enable_set,
4288 (void *)&cmd_gro_enable_port,
4289 (void *)&cmd_gro_enable_pid,
4290 (void *)&cmd_gro_enable_keyword,
4291 (void *)&cmd_gro_enable_onoff,
4296 /* *** DISPLAY GRO CONFIGURATION *** */
4297 struct cmd_gro_show_result {
4298 cmdline_fixed_string_t cmd_show;
4299 cmdline_fixed_string_t cmd_port;
4300 cmdline_fixed_string_t cmd_keyword;
4305 cmd_gro_show_parsed(void *parsed_result,
4306 __attribute__((unused)) struct cmdline *cl,
4307 __attribute__((unused)) void *data)
4309 struct cmd_gro_show_result *res;
4311 res = parsed_result;
4312 if (!strcmp(res->cmd_keyword, "gro"))
4313 show_gro(res->cmd_pid);
4316 cmdline_parse_token_string_t cmd_gro_show_show =
4317 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4319 cmdline_parse_token_string_t cmd_gro_show_port =
4320 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4322 cmdline_parse_token_num_t cmd_gro_show_pid =
4323 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
4325 cmdline_parse_token_string_t cmd_gro_show_keyword =
4326 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4327 cmd_keyword, "gro");
4329 cmdline_parse_inst_t cmd_gro_show = {
4330 .f = cmd_gro_show_parsed,
4332 .help_str = "show port <port_id> gro",
4334 (void *)&cmd_gro_show_show,
4335 (void *)&cmd_gro_show_port,
4336 (void *)&cmd_gro_show_pid,
4337 (void *)&cmd_gro_show_keyword,
4342 /* *** SET FLUSH CYCLES FOR GRO *** */
4343 struct cmd_gro_flush_result {
4344 cmdline_fixed_string_t cmd_set;
4345 cmdline_fixed_string_t cmd_keyword;
4346 cmdline_fixed_string_t cmd_flush;
4351 cmd_gro_flush_parsed(void *parsed_result,
4352 __attribute__((unused)) struct cmdline *cl,
4353 __attribute__((unused)) void *data)
4355 struct cmd_gro_flush_result *res;
4357 res = parsed_result;
4358 if ((!strcmp(res->cmd_keyword, "gro")) &&
4359 (!strcmp(res->cmd_flush, "flush")))
4360 setup_gro_flush_cycles(res->cmd_cycles);
4363 cmdline_parse_token_string_t cmd_gro_flush_set =
4364 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4366 cmdline_parse_token_string_t cmd_gro_flush_keyword =
4367 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4368 cmd_keyword, "gro");
4369 cmdline_parse_token_string_t cmd_gro_flush_flush =
4370 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4371 cmd_flush, "flush");
4372 cmdline_parse_token_num_t cmd_gro_flush_cycles =
4373 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
4376 cmdline_parse_inst_t cmd_gro_flush = {
4377 .f = cmd_gro_flush_parsed,
4379 .help_str = "set gro flush <cycles>",
4381 (void *)&cmd_gro_flush_set,
4382 (void *)&cmd_gro_flush_keyword,
4383 (void *)&cmd_gro_flush_flush,
4384 (void *)&cmd_gro_flush_cycles,
4389 /* *** ENABLE/DISABLE GSO *** */
4390 struct cmd_gso_enable_result {
4391 cmdline_fixed_string_t cmd_set;
4392 cmdline_fixed_string_t cmd_port;
4393 cmdline_fixed_string_t cmd_keyword;
4394 cmdline_fixed_string_t cmd_mode;
4399 cmd_gso_enable_parsed(void *parsed_result,
4400 __attribute__((unused)) struct cmdline *cl,
4401 __attribute__((unused)) void *data)
4403 struct cmd_gso_enable_result *res;
4405 res = parsed_result;
4406 if (!strcmp(res->cmd_keyword, "gso"))
4407 setup_gso(res->cmd_mode, res->cmd_pid);
4410 cmdline_parse_token_string_t cmd_gso_enable_set =
4411 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4413 cmdline_parse_token_string_t cmd_gso_enable_port =
4414 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4416 cmdline_parse_token_string_t cmd_gso_enable_keyword =
4417 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4418 cmd_keyword, "gso");
4419 cmdline_parse_token_string_t cmd_gso_enable_mode =
4420 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4421 cmd_mode, "on#off");
4422 cmdline_parse_token_num_t cmd_gso_enable_pid =
4423 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
4426 cmdline_parse_inst_t cmd_gso_enable = {
4427 .f = cmd_gso_enable_parsed,
4429 .help_str = "set port <port_id> gso on|off",
4431 (void *)&cmd_gso_enable_set,
4432 (void *)&cmd_gso_enable_port,
4433 (void *)&cmd_gso_enable_pid,
4434 (void *)&cmd_gso_enable_keyword,
4435 (void *)&cmd_gso_enable_mode,
4440 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
4441 struct cmd_gso_size_result {
4442 cmdline_fixed_string_t cmd_set;
4443 cmdline_fixed_string_t cmd_keyword;
4444 cmdline_fixed_string_t cmd_segsz;
4449 cmd_gso_size_parsed(void *parsed_result,
4450 __attribute__((unused)) struct cmdline *cl,
4451 __attribute__((unused)) void *data)
4453 struct cmd_gso_size_result *res = parsed_result;
4455 if (test_done == 0) {
4456 printf("Before setting GSO segsz, please first"
4457 " stop fowarding\n");
4461 if (!strcmp(res->cmd_keyword, "gso") &&
4462 !strcmp(res->cmd_segsz, "segsz")) {
4463 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
4464 printf("gso_size should be larger than %zu."
4465 " Please input a legal value\n",
4466 RTE_GSO_SEG_SIZE_MIN);
4468 gso_max_segment_size = res->cmd_size;
4472 cmdline_parse_token_string_t cmd_gso_size_set =
4473 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4475 cmdline_parse_token_string_t cmd_gso_size_keyword =
4476 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4477 cmd_keyword, "gso");
4478 cmdline_parse_token_string_t cmd_gso_size_segsz =
4479 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4480 cmd_segsz, "segsz");
4481 cmdline_parse_token_num_t cmd_gso_size_size =
4482 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
4485 cmdline_parse_inst_t cmd_gso_size = {
4486 .f = cmd_gso_size_parsed,
4488 .help_str = "set gso segsz <length>",
4490 (void *)&cmd_gso_size_set,
4491 (void *)&cmd_gso_size_keyword,
4492 (void *)&cmd_gso_size_segsz,
4493 (void *)&cmd_gso_size_size,
4498 /* *** SHOW GSO CONFIGURATION *** */
4499 struct cmd_gso_show_result {
4500 cmdline_fixed_string_t cmd_show;
4501 cmdline_fixed_string_t cmd_port;
4502 cmdline_fixed_string_t cmd_keyword;
4507 cmd_gso_show_parsed(void *parsed_result,
4508 __attribute__((unused)) struct cmdline *cl,
4509 __attribute__((unused)) void *data)
4511 struct cmd_gso_show_result *res = parsed_result;
4513 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
4514 printf("invalid port id %u\n", res->cmd_pid);
4517 if (!strcmp(res->cmd_keyword, "gso")) {
4518 if (gso_ports[res->cmd_pid].enable) {
4519 printf("Max GSO'd packet size: %uB\n"
4520 "Supported GSO types: TCP/IPv4, "
4521 "VxLAN with inner TCP/IPv4 packet, "
4522 "GRE with inner TCP/IPv4 packet\n",
4523 gso_max_segment_size);
4525 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
4529 cmdline_parse_token_string_t cmd_gso_show_show =
4530 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4532 cmdline_parse_token_string_t cmd_gso_show_port =
4533 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4535 cmdline_parse_token_string_t cmd_gso_show_keyword =
4536 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4537 cmd_keyword, "gso");
4538 cmdline_parse_token_num_t cmd_gso_show_pid =
4539 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
4542 cmdline_parse_inst_t cmd_gso_show = {
4543 .f = cmd_gso_show_parsed,
4545 .help_str = "show port <port_id> gso",
4547 (void *)&cmd_gso_show_show,
4548 (void *)&cmd_gso_show_port,
4549 (void *)&cmd_gso_show_pid,
4550 (void *)&cmd_gso_show_keyword,
4555 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
4556 struct cmd_set_flush_rx {
4557 cmdline_fixed_string_t set;
4558 cmdline_fixed_string_t flush_rx;
4559 cmdline_fixed_string_t mode;
4563 cmd_set_flush_rx_parsed(void *parsed_result,
4564 __attribute__((unused)) struct cmdline *cl,
4565 __attribute__((unused)) void *data)
4567 struct cmd_set_flush_rx *res = parsed_result;
4568 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4571 cmdline_parse_token_string_t cmd_setflushrx_set =
4572 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4574 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
4575 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4576 flush_rx, "flush_rx");
4577 cmdline_parse_token_string_t cmd_setflushrx_mode =
4578 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4582 cmdline_parse_inst_t cmd_set_flush_rx = {
4583 .f = cmd_set_flush_rx_parsed,
4584 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
4587 (void *)&cmd_setflushrx_set,
4588 (void *)&cmd_setflushrx_flush_rx,
4589 (void *)&cmd_setflushrx_mode,
4594 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
4595 struct cmd_set_link_check {
4596 cmdline_fixed_string_t set;
4597 cmdline_fixed_string_t link_check;
4598 cmdline_fixed_string_t mode;
4602 cmd_set_link_check_parsed(void *parsed_result,
4603 __attribute__((unused)) struct cmdline *cl,
4604 __attribute__((unused)) void *data)
4606 struct cmd_set_link_check *res = parsed_result;
4607 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4610 cmdline_parse_token_string_t cmd_setlinkcheck_set =
4611 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4613 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
4614 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4615 link_check, "link_check");
4616 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
4617 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4621 cmdline_parse_inst_t cmd_set_link_check = {
4622 .f = cmd_set_link_check_parsed,
4623 .help_str = "set link_check on|off: Enable/Disable link status check "
4624 "when starting/stopping a port",
4627 (void *)&cmd_setlinkcheck_set,
4628 (void *)&cmd_setlinkcheck_link_check,
4629 (void *)&cmd_setlinkcheck_mode,
4634 /* *** SET NIC BYPASS MODE *** */
4635 struct cmd_set_bypass_mode_result {
4636 cmdline_fixed_string_t set;
4637 cmdline_fixed_string_t bypass;
4638 cmdline_fixed_string_t mode;
4639 cmdline_fixed_string_t value;
4644 cmd_set_bypass_mode_parsed(void *parsed_result,
4645 __attribute__((unused)) struct cmdline *cl,
4646 __attribute__((unused)) void *data)
4648 struct cmd_set_bypass_mode_result *res = parsed_result;
4649 portid_t port_id = res->port_id;
4650 int32_t rc = -EINVAL;
4652 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4653 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4655 if (!strcmp(res->value, "bypass"))
4656 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4657 else if (!strcmp(res->value, "isolate"))
4658 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4660 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4662 /* Set the bypass mode for the relevant port. */
4663 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
4666 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
4669 cmdline_parse_token_string_t cmd_setbypass_mode_set =
4670 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4672 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
4673 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4675 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
4676 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4678 cmdline_parse_token_string_t cmd_setbypass_mode_value =
4679 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4680 value, "normal#bypass#isolate");
4681 cmdline_parse_token_num_t cmd_setbypass_mode_port =
4682 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
4685 cmdline_parse_inst_t cmd_set_bypass_mode = {
4686 .f = cmd_set_bypass_mode_parsed,
4687 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
4688 "Set the NIC bypass mode for port_id",
4691 (void *)&cmd_setbypass_mode_set,
4692 (void *)&cmd_setbypass_mode_bypass,
4693 (void *)&cmd_setbypass_mode_mode,
4694 (void *)&cmd_setbypass_mode_value,
4695 (void *)&cmd_setbypass_mode_port,
4700 /* *** SET NIC BYPASS EVENT *** */
4701 struct cmd_set_bypass_event_result {
4702 cmdline_fixed_string_t set;
4703 cmdline_fixed_string_t bypass;
4704 cmdline_fixed_string_t event;
4705 cmdline_fixed_string_t event_value;
4706 cmdline_fixed_string_t mode;
4707 cmdline_fixed_string_t mode_value;
4712 cmd_set_bypass_event_parsed(void *parsed_result,
4713 __attribute__((unused)) struct cmdline *cl,
4714 __attribute__((unused)) void *data)
4716 int32_t rc = -EINVAL;
4717 struct cmd_set_bypass_event_result *res = parsed_result;
4718 portid_t port_id = res->port_id;
4720 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4721 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4722 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4724 if (!strcmp(res->event_value, "timeout"))
4725 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
4726 else if (!strcmp(res->event_value, "os_on"))
4727 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
4728 else if (!strcmp(res->event_value, "os_off"))
4729 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
4730 else if (!strcmp(res->event_value, "power_on"))
4731 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
4732 else if (!strcmp(res->event_value, "power_off"))
4733 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
4735 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4737 if (!strcmp(res->mode_value, "bypass"))
4738 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4739 else if (!strcmp(res->mode_value, "isolate"))
4740 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4742 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4744 /* Set the watchdog timeout. */
4745 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
4748 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
4749 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
4753 printf("Failed to set timeout value %u "
4754 "for port %d, errto code: %d.\n",
4755 bypass_timeout, port_id, rc);
4759 /* Set the bypass event to transition to bypass mode. */
4760 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
4765 printf("\t Failed to set bypass event for port = %d.\n",
4769 cmdline_parse_token_string_t cmd_setbypass_event_set =
4770 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4772 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
4773 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4775 cmdline_parse_token_string_t cmd_setbypass_event_event =
4776 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4778 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
4779 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4780 event_value, "none#timeout#os_off#os_on#power_on#power_off");
4781 cmdline_parse_token_string_t cmd_setbypass_event_mode =
4782 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4784 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
4785 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4786 mode_value, "normal#bypass#isolate");
4787 cmdline_parse_token_num_t cmd_setbypass_event_port =
4788 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
4791 cmdline_parse_inst_t cmd_set_bypass_event = {
4792 .f = cmd_set_bypass_event_parsed,
4793 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
4794 "power_off mode normal|bypass|isolate <port_id>: "
4795 "Set the NIC bypass event mode for port_id",
4798 (void *)&cmd_setbypass_event_set,
4799 (void *)&cmd_setbypass_event_bypass,
4800 (void *)&cmd_setbypass_event_event,
4801 (void *)&cmd_setbypass_event_event_value,
4802 (void *)&cmd_setbypass_event_mode,
4803 (void *)&cmd_setbypass_event_mode_value,
4804 (void *)&cmd_setbypass_event_port,
4810 /* *** SET NIC BYPASS TIMEOUT *** */
4811 struct cmd_set_bypass_timeout_result {
4812 cmdline_fixed_string_t set;
4813 cmdline_fixed_string_t bypass;
4814 cmdline_fixed_string_t timeout;
4815 cmdline_fixed_string_t value;
4819 cmd_set_bypass_timeout_parsed(void *parsed_result,
4820 __attribute__((unused)) struct cmdline *cl,
4821 __attribute__((unused)) void *data)
4823 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
4825 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4826 if (!strcmp(res->value, "1.5"))
4827 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
4828 else if (!strcmp(res->value, "2"))
4829 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
4830 else if (!strcmp(res->value, "3"))
4831 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
4832 else if (!strcmp(res->value, "4"))
4833 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
4834 else if (!strcmp(res->value, "8"))
4835 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
4836 else if (!strcmp(res->value, "16"))
4837 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
4838 else if (!strcmp(res->value, "32"))
4839 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
4841 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4845 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
4846 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4848 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
4849 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4851 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
4852 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4853 timeout, "timeout");
4854 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
4855 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4856 value, "0#1.5#2#3#4#8#16#32");
4858 cmdline_parse_inst_t cmd_set_bypass_timeout = {
4859 .f = cmd_set_bypass_timeout_parsed,
4860 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
4861 "Set the NIC bypass watchdog timeout in seconds",
4864 (void *)&cmd_setbypass_timeout_set,
4865 (void *)&cmd_setbypass_timeout_bypass,
4866 (void *)&cmd_setbypass_timeout_timeout,
4867 (void *)&cmd_setbypass_timeout_value,
4872 /* *** SHOW NIC BYPASS MODE *** */
4873 struct cmd_show_bypass_config_result {
4874 cmdline_fixed_string_t show;
4875 cmdline_fixed_string_t bypass;
4876 cmdline_fixed_string_t config;
4881 cmd_show_bypass_config_parsed(void *parsed_result,
4882 __attribute__((unused)) struct cmdline *cl,
4883 __attribute__((unused)) void *data)
4885 struct cmd_show_bypass_config_result *res = parsed_result;
4886 portid_t port_id = res->port_id;
4888 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4889 uint32_t event_mode;
4890 uint32_t bypass_mode;
4891 uint32_t timeout = bypass_timeout;
4894 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
4895 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
4896 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
4897 {"UNKNOWN", "normal", "bypass", "isolate"};
4898 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
4905 int num_events = (sizeof events) / (sizeof events[0]);
4907 /* Display the bypass mode.*/
4908 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
4909 printf("\tFailed to get bypass mode for port = %d\n", port_id);
4913 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
4914 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4916 printf("\tbypass mode = %s\n", modes[bypass_mode]);
4919 /* Display the bypass timeout.*/
4920 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
4921 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4923 printf("\tbypass timeout = %s\n", timeouts[timeout]);
4925 /* Display the bypass events and associated modes. */
4926 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
4928 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
4929 printf("\tFailed to get bypass mode for event = %s\n",
4932 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
4933 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4935 printf("\tbypass event: %-16s = %s\n", events[i],
4941 printf("\tFailed to get bypass configuration for port = %d\n",
4945 cmdline_parse_token_string_t cmd_showbypass_config_show =
4946 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4948 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
4949 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4951 cmdline_parse_token_string_t cmd_showbypass_config_config =
4952 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4954 cmdline_parse_token_num_t cmd_showbypass_config_port =
4955 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
4958 cmdline_parse_inst_t cmd_show_bypass_config = {
4959 .f = cmd_show_bypass_config_parsed,
4960 .help_str = "show bypass config <port_id>: "
4961 "Show the NIC bypass config for port_id",
4964 (void *)&cmd_showbypass_config_show,
4965 (void *)&cmd_showbypass_config_bypass,
4966 (void *)&cmd_showbypass_config_config,
4967 (void *)&cmd_showbypass_config_port,
4972 #ifdef RTE_LIBRTE_PMD_BOND
4973 /* *** SET BONDING MODE *** */
4974 struct cmd_set_bonding_mode_result {
4975 cmdline_fixed_string_t set;
4976 cmdline_fixed_string_t bonding;
4977 cmdline_fixed_string_t mode;
4982 static void cmd_set_bonding_mode_parsed(void *parsed_result,
4983 __attribute__((unused)) struct cmdline *cl,
4984 __attribute__((unused)) void *data)
4986 struct cmd_set_bonding_mode_result *res = parsed_result;
4987 portid_t port_id = res->port_id;
4989 /* Set the bonding mode for the relevant port. */
4990 if (0 != rte_eth_bond_mode_set(port_id, res->value))
4991 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
4994 cmdline_parse_token_string_t cmd_setbonding_mode_set =
4995 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4997 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
4998 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4999 bonding, "bonding");
5000 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5001 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5003 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5004 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5006 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5007 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5010 cmdline_parse_inst_t cmd_set_bonding_mode = {
5011 .f = cmd_set_bonding_mode_parsed,
5012 .help_str = "set bonding mode <mode_value> <port_id>: "
5013 "Set the bonding mode for port_id",
5016 (void *) &cmd_setbonding_mode_set,
5017 (void *) &cmd_setbonding_mode_bonding,
5018 (void *) &cmd_setbonding_mode_mode,
5019 (void *) &cmd_setbonding_mode_value,
5020 (void *) &cmd_setbonding_mode_port,
5025 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5026 struct cmd_set_bonding_lacp_dedicated_queues_result {
5027 cmdline_fixed_string_t set;
5028 cmdline_fixed_string_t bonding;
5029 cmdline_fixed_string_t lacp;
5030 cmdline_fixed_string_t dedicated_queues;
5032 cmdline_fixed_string_t mode;
5035 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5036 __attribute__((unused)) struct cmdline *cl,
5037 __attribute__((unused)) void *data)
5039 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5040 portid_t port_id = res->port_id;
5041 struct rte_port *port;
5043 port = &ports[port_id];
5045 /** Check if the port is not started **/
5046 if (port->port_status != RTE_PORT_STOPPED) {
5047 printf("Please stop port %d first\n", port_id);
5051 if (!strcmp(res->mode, "enable")) {
5052 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5053 printf("Dedicate queues for LACP control packets"
5056 printf("Enabling dedicate queues for LACP control "
5057 "packets on port %d failed\n", port_id);
5058 } else if (!strcmp(res->mode, "disable")) {
5059 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5060 printf("Dedicated queues for LACP control packets "
5063 printf("Disabling dedicated queues for LACP control "
5064 "traffic on port %d failed\n", port_id);
5068 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5069 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5071 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5072 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5073 bonding, "bonding");
5074 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5075 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5077 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5078 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5079 dedicated_queues, "dedicated_queues");
5080 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5081 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5083 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5084 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5085 mode, "enable#disable");
5087 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5088 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5089 .help_str = "set bonding lacp dedicated_queues <port_id> "
5091 "Enable/disable dedicated queues for LACP control traffic for port_id",
5094 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5095 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5096 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5097 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5098 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5099 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5104 /* *** SET BALANCE XMIT POLICY *** */
5105 struct cmd_set_bonding_balance_xmit_policy_result {
5106 cmdline_fixed_string_t set;
5107 cmdline_fixed_string_t bonding;
5108 cmdline_fixed_string_t balance_xmit_policy;
5110 cmdline_fixed_string_t policy;
5113 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5114 __attribute__((unused)) struct cmdline *cl,
5115 __attribute__((unused)) void *data)
5117 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5118 portid_t port_id = res->port_id;
5121 if (!strcmp(res->policy, "l2")) {
5122 policy = BALANCE_XMIT_POLICY_LAYER2;
5123 } else if (!strcmp(res->policy, "l23")) {
5124 policy = BALANCE_XMIT_POLICY_LAYER23;
5125 } else if (!strcmp(res->policy, "l34")) {
5126 policy = BALANCE_XMIT_POLICY_LAYER34;
5128 printf("\t Invalid xmit policy selection");
5132 /* Set the bonding mode for the relevant port. */
5133 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5134 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5139 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5140 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5142 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5143 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5144 bonding, "bonding");
5145 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5146 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5147 balance_xmit_policy, "balance_xmit_policy");
5148 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5149 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5151 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5152 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5153 policy, "l2#l23#l34");
5155 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5156 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5157 .help_str = "set bonding balance_xmit_policy <port_id> "
5159 "Set the bonding balance_xmit_policy for port_id",
5162 (void *)&cmd_setbonding_balance_xmit_policy_set,
5163 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5164 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5165 (void *)&cmd_setbonding_balance_xmit_policy_port,
5166 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5171 /* *** SHOW NIC BONDING CONFIGURATION *** */
5172 struct cmd_show_bonding_config_result {
5173 cmdline_fixed_string_t show;
5174 cmdline_fixed_string_t bonding;
5175 cmdline_fixed_string_t config;
5179 static void cmd_show_bonding_config_parsed(void *parsed_result,
5180 __attribute__((unused)) struct cmdline *cl,
5181 __attribute__((unused)) void *data)
5183 struct cmd_show_bonding_config_result *res = parsed_result;
5184 int bonding_mode, agg_mode;
5185 portid_t slaves[RTE_MAX_ETHPORTS];
5186 int num_slaves, num_active_slaves;
5189 portid_t port_id = res->port_id;
5191 /* Display the bonding mode.*/
5192 bonding_mode = rte_eth_bond_mode_get(port_id);
5193 if (bonding_mode < 0) {
5194 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5197 printf("\tBonding mode: %d\n", bonding_mode);
5199 if (bonding_mode == BONDING_MODE_BALANCE) {
5200 int balance_xmit_policy;
5202 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5203 if (balance_xmit_policy < 0) {
5204 printf("\tFailed to get balance xmit policy for port = %d\n",
5208 printf("\tBalance Xmit Policy: ");
5210 switch (balance_xmit_policy) {
5211 case BALANCE_XMIT_POLICY_LAYER2:
5212 printf("BALANCE_XMIT_POLICY_LAYER2");
5214 case BALANCE_XMIT_POLICY_LAYER23:
5215 printf("BALANCE_XMIT_POLICY_LAYER23");
5217 case BALANCE_XMIT_POLICY_LAYER34:
5218 printf("BALANCE_XMIT_POLICY_LAYER34");
5225 if (bonding_mode == BONDING_MODE_8023AD) {
5226 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5227 printf("\tIEEE802.3AD Aggregator Mode: ");
5230 printf("bandwidth");
5242 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5244 if (num_slaves < 0) {
5245 printf("\tFailed to get slave list for port = %d\n", port_id);
5248 if (num_slaves > 0) {
5249 printf("\tSlaves (%d): [", num_slaves);
5250 for (i = 0; i < num_slaves - 1; i++)
5251 printf("%d ", slaves[i]);
5253 printf("%d]\n", slaves[num_slaves - 1]);
5255 printf("\tSlaves: []\n");
5259 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5262 if (num_active_slaves < 0) {
5263 printf("\tFailed to get active slave list for port = %d\n", port_id);
5266 if (num_active_slaves > 0) {
5267 printf("\tActive Slaves (%d): [", num_active_slaves);
5268 for (i = 0; i < num_active_slaves - 1; i++)
5269 printf("%d ", slaves[i]);
5271 printf("%d]\n", slaves[num_active_slaves - 1]);
5274 printf("\tActive Slaves: []\n");
5278 primary_id = rte_eth_bond_primary_get(port_id);
5279 if (primary_id < 0) {
5280 printf("\tFailed to get primary slave for port = %d\n", port_id);
5283 printf("\tPrimary: [%d]\n", primary_id);
5287 cmdline_parse_token_string_t cmd_showbonding_config_show =
5288 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5290 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5291 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5292 bonding, "bonding");
5293 cmdline_parse_token_string_t cmd_showbonding_config_config =
5294 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5296 cmdline_parse_token_num_t cmd_showbonding_config_port =
5297 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
5300 cmdline_parse_inst_t cmd_show_bonding_config = {
5301 .f = cmd_show_bonding_config_parsed,
5302 .help_str = "show bonding config <port_id>: "
5303 "Show the bonding config for port_id",
5306 (void *)&cmd_showbonding_config_show,
5307 (void *)&cmd_showbonding_config_bonding,
5308 (void *)&cmd_showbonding_config_config,
5309 (void *)&cmd_showbonding_config_port,
5314 /* *** SET BONDING PRIMARY *** */
5315 struct cmd_set_bonding_primary_result {
5316 cmdline_fixed_string_t set;
5317 cmdline_fixed_string_t bonding;
5318 cmdline_fixed_string_t primary;
5323 static void cmd_set_bonding_primary_parsed(void *parsed_result,
5324 __attribute__((unused)) struct cmdline *cl,
5325 __attribute__((unused)) void *data)
5327 struct cmd_set_bonding_primary_result *res = parsed_result;
5328 portid_t master_port_id = res->port_id;
5329 portid_t slave_port_id = res->slave_id;
5331 /* Set the primary slave for a bonded device. */
5332 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
5333 printf("\t Failed to set primary slave for port = %d.\n",
5340 cmdline_parse_token_string_t cmd_setbonding_primary_set =
5341 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5343 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
5344 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5345 bonding, "bonding");
5346 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
5347 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5348 primary, "primary");
5349 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
5350 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5352 cmdline_parse_token_num_t cmd_setbonding_primary_port =
5353 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5356 cmdline_parse_inst_t cmd_set_bonding_primary = {
5357 .f = cmd_set_bonding_primary_parsed,
5358 .help_str = "set bonding primary <slave_id> <port_id>: "
5359 "Set the primary slave for port_id",
5362 (void *)&cmd_setbonding_primary_set,
5363 (void *)&cmd_setbonding_primary_bonding,
5364 (void *)&cmd_setbonding_primary_primary,
5365 (void *)&cmd_setbonding_primary_slave,
5366 (void *)&cmd_setbonding_primary_port,
5371 /* *** ADD SLAVE *** */
5372 struct cmd_add_bonding_slave_result {
5373 cmdline_fixed_string_t add;
5374 cmdline_fixed_string_t bonding;
5375 cmdline_fixed_string_t slave;
5380 static void cmd_add_bonding_slave_parsed(void *parsed_result,
5381 __attribute__((unused)) struct cmdline *cl,
5382 __attribute__((unused)) void *data)
5384 struct cmd_add_bonding_slave_result *res = parsed_result;
5385 portid_t master_port_id = res->port_id;
5386 portid_t slave_port_id = res->slave_id;
5388 /* add the slave for a bonded device. */
5389 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
5390 printf("\t Failed to add slave %d to master port = %d.\n",
5391 slave_port_id, master_port_id);
5395 set_port_slave_flag(slave_port_id);
5398 cmdline_parse_token_string_t cmd_addbonding_slave_add =
5399 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5401 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
5402 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5403 bonding, "bonding");
5404 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
5405 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5407 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
5408 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5410 cmdline_parse_token_num_t cmd_addbonding_slave_port =
5411 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5414 cmdline_parse_inst_t cmd_add_bonding_slave = {
5415 .f = cmd_add_bonding_slave_parsed,
5416 .help_str = "add bonding slave <slave_id> <port_id>: "
5417 "Add a slave device to a bonded device",
5420 (void *)&cmd_addbonding_slave_add,
5421 (void *)&cmd_addbonding_slave_bonding,
5422 (void *)&cmd_addbonding_slave_slave,
5423 (void *)&cmd_addbonding_slave_slaveid,
5424 (void *)&cmd_addbonding_slave_port,
5429 /* *** REMOVE SLAVE *** */
5430 struct cmd_remove_bonding_slave_result {
5431 cmdline_fixed_string_t remove;
5432 cmdline_fixed_string_t bonding;
5433 cmdline_fixed_string_t slave;
5438 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
5439 __attribute__((unused)) struct cmdline *cl,
5440 __attribute__((unused)) void *data)
5442 struct cmd_remove_bonding_slave_result *res = parsed_result;
5443 portid_t master_port_id = res->port_id;
5444 portid_t slave_port_id = res->slave_id;
5446 /* remove the slave from a bonded device. */
5447 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
5448 printf("\t Failed to remove slave %d from master port = %d.\n",
5449 slave_port_id, master_port_id);
5453 clear_port_slave_flag(slave_port_id);
5456 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
5457 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5459 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
5460 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5461 bonding, "bonding");
5462 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
5463 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5465 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
5466 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5468 cmdline_parse_token_num_t cmd_removebonding_slave_port =
5469 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5472 cmdline_parse_inst_t cmd_remove_bonding_slave = {
5473 .f = cmd_remove_bonding_slave_parsed,
5474 .help_str = "remove bonding slave <slave_id> <port_id>: "
5475 "Remove a slave device from a bonded device",
5478 (void *)&cmd_removebonding_slave_remove,
5479 (void *)&cmd_removebonding_slave_bonding,
5480 (void *)&cmd_removebonding_slave_slave,
5481 (void *)&cmd_removebonding_slave_slaveid,
5482 (void *)&cmd_removebonding_slave_port,
5487 /* *** CREATE BONDED DEVICE *** */
5488 struct cmd_create_bonded_device_result {
5489 cmdline_fixed_string_t create;
5490 cmdline_fixed_string_t bonded;
5491 cmdline_fixed_string_t device;
5496 static int bond_dev_num = 0;
5498 static void cmd_create_bonded_device_parsed(void *parsed_result,
5499 __attribute__((unused)) struct cmdline *cl,
5500 __attribute__((unused)) void *data)
5502 struct cmd_create_bonded_device_result *res = parsed_result;
5503 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
5506 if (test_done == 0) {
5507 printf("Please stop forwarding first\n");
5511 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
5514 /* Create a new bonded device. */
5515 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
5517 printf("\t Failed to create bonded device.\n");
5520 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
5523 /* Update number of ports */
5524 nb_ports = rte_eth_dev_count();
5525 reconfig(port_id, res->socket);
5526 rte_eth_promiscuous_enable(port_id);
5531 cmdline_parse_token_string_t cmd_createbonded_device_create =
5532 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5534 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
5535 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5537 cmdline_parse_token_string_t cmd_createbonded_device_device =
5538 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5540 cmdline_parse_token_num_t cmd_createbonded_device_mode =
5541 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5543 cmdline_parse_token_num_t cmd_createbonded_device_socket =
5544 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5547 cmdline_parse_inst_t cmd_create_bonded_device = {
5548 .f = cmd_create_bonded_device_parsed,
5549 .help_str = "create bonded device <mode> <socket>: "
5550 "Create a new bonded device with specific bonding mode and socket",
5553 (void *)&cmd_createbonded_device_create,
5554 (void *)&cmd_createbonded_device_bonded,
5555 (void *)&cmd_createbonded_device_device,
5556 (void *)&cmd_createbonded_device_mode,
5557 (void *)&cmd_createbonded_device_socket,
5562 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
5563 struct cmd_set_bond_mac_addr_result {
5564 cmdline_fixed_string_t set;
5565 cmdline_fixed_string_t bonding;
5566 cmdline_fixed_string_t mac_addr;
5568 struct ether_addr address;
5571 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
5572 __attribute__((unused)) struct cmdline *cl,
5573 __attribute__((unused)) void *data)
5575 struct cmd_set_bond_mac_addr_result *res = parsed_result;
5578 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
5581 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
5583 /* check the return value and print it if is < 0 */
5585 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5588 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
5589 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
5590 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
5591 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
5593 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
5594 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
5596 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
5597 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
5599 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
5600 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
5602 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
5603 .f = cmd_set_bond_mac_addr_parsed,
5605 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
5607 (void *)&cmd_set_bond_mac_addr_set,
5608 (void *)&cmd_set_bond_mac_addr_bonding,
5609 (void *)&cmd_set_bond_mac_addr_mac,
5610 (void *)&cmd_set_bond_mac_addr_portnum,
5611 (void *)&cmd_set_bond_mac_addr_addr,
5617 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
5618 struct cmd_set_bond_mon_period_result {
5619 cmdline_fixed_string_t set;
5620 cmdline_fixed_string_t bonding;
5621 cmdline_fixed_string_t mon_period;
5626 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
5627 __attribute__((unused)) struct cmdline *cl,
5628 __attribute__((unused)) void *data)
5630 struct cmd_set_bond_mon_period_result *res = parsed_result;
5633 if (res->port_num >= nb_ports) {
5634 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
5638 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
5640 /* check the return value and print it if is < 0 */
5642 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5645 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
5646 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5648 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
5649 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5650 bonding, "bonding");
5651 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
5652 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5653 mon_period, "mon_period");
5654 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
5655 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5657 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
5658 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5661 cmdline_parse_inst_t cmd_set_bond_mon_period = {
5662 .f = cmd_set_bond_mon_period_parsed,
5664 .help_str = "set bonding mon_period <port_id> <period_ms>",
5666 (void *)&cmd_set_bond_mon_period_set,
5667 (void *)&cmd_set_bond_mon_period_bonding,
5668 (void *)&cmd_set_bond_mon_period_mon_period,
5669 (void *)&cmd_set_bond_mon_period_portnum,
5670 (void *)&cmd_set_bond_mon_period_period_ms,
5677 struct cmd_set_bonding_agg_mode_policy_result {
5678 cmdline_fixed_string_t set;
5679 cmdline_fixed_string_t bonding;
5680 cmdline_fixed_string_t agg_mode;
5682 cmdline_fixed_string_t policy;
5687 cmd_set_bonding_agg_mode(void *parsed_result,
5688 __attribute__((unused)) struct cmdline *cl,
5689 __attribute__((unused)) void *data)
5691 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
5692 uint8_t policy = AGG_BANDWIDTH;
5694 if (res->port_num >= nb_ports) {
5695 printf("Port id %d must be less than %d\n",
5696 res->port_num, nb_ports);
5700 if (!strcmp(res->policy, "bandwidth"))
5701 policy = AGG_BANDWIDTH;
5702 else if (!strcmp(res->policy, "stable"))
5703 policy = AGG_STABLE;
5704 else if (!strcmp(res->policy, "count"))
5707 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
5711 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
5712 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5714 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
5715 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5716 bonding, "bonding");
5718 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
5719 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5720 agg_mode, "agg_mode");
5722 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
5723 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5726 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
5727 TOKEN_STRING_INITIALIZER(
5728 struct cmd_set_bonding_balance_xmit_policy_result,
5729 policy, "stable#bandwidth#count");
5731 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
5732 .f = cmd_set_bonding_agg_mode,
5734 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
5736 (void *)&cmd_set_bonding_agg_mode_set,
5737 (void *)&cmd_set_bonding_agg_mode_bonding,
5738 (void *)&cmd_set_bonding_agg_mode_agg_mode,
5739 (void *)&cmd_set_bonding_agg_mode_portnum,
5740 (void *)&cmd_set_bonding_agg_mode_policy_string,
5746 #endif /* RTE_LIBRTE_PMD_BOND */
5748 /* *** SET FORWARDING MODE *** */
5749 struct cmd_set_fwd_mode_result {
5750 cmdline_fixed_string_t set;
5751 cmdline_fixed_string_t fwd;
5752 cmdline_fixed_string_t mode;
5755 static void cmd_set_fwd_mode_parsed(void *parsed_result,
5756 __attribute__((unused)) struct cmdline *cl,
5757 __attribute__((unused)) void *data)
5759 struct cmd_set_fwd_mode_result *res = parsed_result;
5762 set_pkt_forwarding_mode(res->mode);
5765 cmdline_parse_token_string_t cmd_setfwd_set =
5766 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
5767 cmdline_parse_token_string_t cmd_setfwd_fwd =
5768 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
5769 cmdline_parse_token_string_t cmd_setfwd_mode =
5770 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
5771 "" /* defined at init */);
5773 cmdline_parse_inst_t cmd_set_fwd_mode = {
5774 .f = cmd_set_fwd_mode_parsed,
5776 .help_str = NULL, /* defined at init */
5778 (void *)&cmd_setfwd_set,
5779 (void *)&cmd_setfwd_fwd,
5780 (void *)&cmd_setfwd_mode,
5785 static void cmd_set_fwd_mode_init(void)
5788 static char token[128];
5789 static char help[256];
5790 cmdline_parse_token_string_t *token_struct;
5792 modes = list_pkt_forwarding_modes();
5793 snprintf(help, sizeof(help), "set fwd %s: "
5794 "Set packet forwarding mode", modes);
5795 cmd_set_fwd_mode.help_str = help;
5797 /* string token separator is # */
5798 for (c = token; *modes != '\0'; modes++)
5803 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
5804 token_struct->string_data.str = token;
5807 /* *** SET RETRY FORWARDING MODE *** */
5808 struct cmd_set_fwd_retry_mode_result {
5809 cmdline_fixed_string_t set;
5810 cmdline_fixed_string_t fwd;
5811 cmdline_fixed_string_t mode;
5812 cmdline_fixed_string_t retry;
5815 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
5816 __attribute__((unused)) struct cmdline *cl,
5817 __attribute__((unused)) void *data)
5819 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
5822 set_pkt_forwarding_mode(res->mode);
5825 cmdline_parse_token_string_t cmd_setfwd_retry_set =
5826 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5828 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
5829 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5831 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
5832 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5834 "" /* defined at init */);
5835 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
5836 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5839 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
5840 .f = cmd_set_fwd_retry_mode_parsed,
5842 .help_str = NULL, /* defined at init */
5844 (void *)&cmd_setfwd_retry_set,
5845 (void *)&cmd_setfwd_retry_fwd,
5846 (void *)&cmd_setfwd_retry_mode,
5847 (void *)&cmd_setfwd_retry_retry,
5852 static void cmd_set_fwd_retry_mode_init(void)
5855 static char token[128];
5856 static char help[256];
5857 cmdline_parse_token_string_t *token_struct;
5859 modes = list_pkt_forwarding_retry_modes();
5860 snprintf(help, sizeof(help), "set fwd %s retry: "
5861 "Set packet forwarding mode with retry", modes);
5862 cmd_set_fwd_retry_mode.help_str = help;
5864 /* string token separator is # */
5865 for (c = token; *modes != '\0'; modes++)
5870 token_struct = (cmdline_parse_token_string_t *)
5871 cmd_set_fwd_retry_mode.tokens[2];
5872 token_struct->string_data.str = token;
5875 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
5876 struct cmd_set_burst_tx_retry_result {
5877 cmdline_fixed_string_t set;
5878 cmdline_fixed_string_t burst;
5879 cmdline_fixed_string_t tx;
5880 cmdline_fixed_string_t delay;
5882 cmdline_fixed_string_t retry;
5886 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
5887 __attribute__((unused)) struct cmdline *cl,
5888 __attribute__((unused)) void *data)
5890 struct cmd_set_burst_tx_retry_result *res = parsed_result;
5892 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
5893 && !strcmp(res->tx, "tx")) {
5894 if (!strcmp(res->delay, "delay"))
5895 burst_tx_delay_time = res->time;
5896 if (!strcmp(res->retry, "retry"))
5897 burst_tx_retry_num = res->retry_num;
5902 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
5903 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
5904 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
5905 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
5907 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
5908 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
5909 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
5910 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
5911 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
5912 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
5913 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
5914 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
5915 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
5916 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
5918 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
5919 .f = cmd_set_burst_tx_retry_parsed,
5920 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
5922 (void *)&cmd_set_burst_tx_retry_set,
5923 (void *)&cmd_set_burst_tx_retry_burst,
5924 (void *)&cmd_set_burst_tx_retry_tx,
5925 (void *)&cmd_set_burst_tx_retry_delay,
5926 (void *)&cmd_set_burst_tx_retry_time,
5927 (void *)&cmd_set_burst_tx_retry_retry,
5928 (void *)&cmd_set_burst_tx_retry_retry_num,
5933 /* *** SET PROMISC MODE *** */
5934 struct cmd_set_promisc_mode_result {
5935 cmdline_fixed_string_t set;
5936 cmdline_fixed_string_t promisc;
5937 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5938 uint16_t port_num; /* valid if "allports" argument == 0 */
5939 cmdline_fixed_string_t mode;
5942 static void cmd_set_promisc_mode_parsed(void *parsed_result,
5943 __attribute__((unused)) struct cmdline *cl,
5946 struct cmd_set_promisc_mode_result *res = parsed_result;
5950 if (!strcmp(res->mode, "on"))
5957 RTE_ETH_FOREACH_DEV(i) {
5959 rte_eth_promiscuous_enable(i);
5961 rte_eth_promiscuous_disable(i);
5966 rte_eth_promiscuous_enable(res->port_num);
5968 rte_eth_promiscuous_disable(res->port_num);
5972 cmdline_parse_token_string_t cmd_setpromisc_set =
5973 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
5974 cmdline_parse_token_string_t cmd_setpromisc_promisc =
5975 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
5977 cmdline_parse_token_string_t cmd_setpromisc_portall =
5978 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
5980 cmdline_parse_token_num_t cmd_setpromisc_portnum =
5981 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
5983 cmdline_parse_token_string_t cmd_setpromisc_mode =
5984 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
5987 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
5988 .f = cmd_set_promisc_mode_parsed,
5990 .help_str = "set promisc all on|off: Set promisc mode for all ports",
5992 (void *)&cmd_setpromisc_set,
5993 (void *)&cmd_setpromisc_promisc,
5994 (void *)&cmd_setpromisc_portall,
5995 (void *)&cmd_setpromisc_mode,
6000 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6001 .f = cmd_set_promisc_mode_parsed,
6003 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6005 (void *)&cmd_setpromisc_set,
6006 (void *)&cmd_setpromisc_promisc,
6007 (void *)&cmd_setpromisc_portnum,
6008 (void *)&cmd_setpromisc_mode,
6013 /* *** SET ALLMULTI MODE *** */
6014 struct cmd_set_allmulti_mode_result {
6015 cmdline_fixed_string_t set;
6016 cmdline_fixed_string_t allmulti;
6017 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6018 uint16_t port_num; /* valid if "allports" argument == 0 */
6019 cmdline_fixed_string_t mode;
6022 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6023 __attribute__((unused)) struct cmdline *cl,
6026 struct cmd_set_allmulti_mode_result *res = parsed_result;
6030 if (!strcmp(res->mode, "on"))
6037 RTE_ETH_FOREACH_DEV(i) {
6039 rte_eth_allmulticast_enable(i);
6041 rte_eth_allmulticast_disable(i);
6046 rte_eth_allmulticast_enable(res->port_num);
6048 rte_eth_allmulticast_disable(res->port_num);
6052 cmdline_parse_token_string_t cmd_setallmulti_set =
6053 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6054 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6055 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6057 cmdline_parse_token_string_t cmd_setallmulti_portall =
6058 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6060 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6061 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6063 cmdline_parse_token_string_t cmd_setallmulti_mode =
6064 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6067 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6068 .f = cmd_set_allmulti_mode_parsed,
6070 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6072 (void *)&cmd_setallmulti_set,
6073 (void *)&cmd_setallmulti_allmulti,
6074 (void *)&cmd_setallmulti_portall,
6075 (void *)&cmd_setallmulti_mode,
6080 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6081 .f = cmd_set_allmulti_mode_parsed,
6083 .help_str = "set allmulti <port_id> on|off: "
6084 "Set allmulti mode on port_id",
6086 (void *)&cmd_setallmulti_set,
6087 (void *)&cmd_setallmulti_allmulti,
6088 (void *)&cmd_setallmulti_portnum,
6089 (void *)&cmd_setallmulti_mode,
6094 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6095 struct cmd_link_flow_ctrl_set_result {
6096 cmdline_fixed_string_t set;
6097 cmdline_fixed_string_t flow_ctrl;
6098 cmdline_fixed_string_t rx;
6099 cmdline_fixed_string_t rx_lfc_mode;
6100 cmdline_fixed_string_t tx;
6101 cmdline_fixed_string_t tx_lfc_mode;
6102 cmdline_fixed_string_t mac_ctrl_frame_fwd;
6103 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6104 cmdline_fixed_string_t autoneg_str;
6105 cmdline_fixed_string_t autoneg;
6106 cmdline_fixed_string_t hw_str;
6107 uint32_t high_water;
6108 cmdline_fixed_string_t lw_str;
6110 cmdline_fixed_string_t pt_str;
6111 uint16_t pause_time;
6112 cmdline_fixed_string_t xon_str;
6117 cmdline_parse_token_string_t cmd_lfc_set_set =
6118 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6120 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6121 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6122 flow_ctrl, "flow_ctrl");
6123 cmdline_parse_token_string_t cmd_lfc_set_rx =
6124 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6126 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6127 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6128 rx_lfc_mode, "on#off");
6129 cmdline_parse_token_string_t cmd_lfc_set_tx =
6130 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6132 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6133 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6134 tx_lfc_mode, "on#off");
6135 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6136 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6137 hw_str, "high_water");
6138 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6139 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6140 high_water, UINT32);
6141 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6142 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6143 lw_str, "low_water");
6144 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6145 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6147 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6148 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6149 pt_str, "pause_time");
6150 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6151 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6152 pause_time, UINT16);
6153 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6154 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6155 xon_str, "send_xon");
6156 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6157 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6159 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6160 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6161 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6162 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6163 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6164 mac_ctrl_frame_fwd_mode, "on#off");
6165 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6166 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6167 autoneg_str, "autoneg");
6168 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6169 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6171 cmdline_parse_token_num_t cmd_lfc_set_portid =
6172 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6175 /* forward declaration */
6177 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6180 cmdline_parse_inst_t cmd_link_flow_control_set = {
6181 .f = cmd_link_flow_ctrl_set_parsed,
6183 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6184 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6185 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6187 (void *)&cmd_lfc_set_set,
6188 (void *)&cmd_lfc_set_flow_ctrl,
6189 (void *)&cmd_lfc_set_rx,
6190 (void *)&cmd_lfc_set_rx_mode,
6191 (void *)&cmd_lfc_set_tx,
6192 (void *)&cmd_lfc_set_tx_mode,
6193 (void *)&cmd_lfc_set_high_water,
6194 (void *)&cmd_lfc_set_low_water,
6195 (void *)&cmd_lfc_set_pause_time,
6196 (void *)&cmd_lfc_set_send_xon,
6197 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6198 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6199 (void *)&cmd_lfc_set_autoneg_str,
6200 (void *)&cmd_lfc_set_autoneg,
6201 (void *)&cmd_lfc_set_portid,
6206 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6207 .f = cmd_link_flow_ctrl_set_parsed,
6208 .data = (void *)&cmd_link_flow_control_set_rx,
6209 .help_str = "set flow_ctrl rx on|off <port_id>: "
6210 "Change rx flow control parameter",
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_portid,
6221 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6222 .f = cmd_link_flow_ctrl_set_parsed,
6223 .data = (void *)&cmd_link_flow_control_set_tx,
6224 .help_str = "set flow_ctrl tx on|off <port_id>: "
6225 "Change tx flow control parameter",
6227 (void *)&cmd_lfc_set_set,
6228 (void *)&cmd_lfc_set_flow_ctrl,
6229 (void *)&cmd_lfc_set_tx,
6230 (void *)&cmd_lfc_set_tx_mode,
6231 (void *)&cmd_lfc_set_portid,
6236 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6237 .f = cmd_link_flow_ctrl_set_parsed,
6238 .data = (void *)&cmd_link_flow_control_set_hw,
6239 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6240 "Change high water flow control parameter",
6242 (void *)&cmd_lfc_set_set,
6243 (void *)&cmd_lfc_set_flow_ctrl,
6244 (void *)&cmd_lfc_set_high_water_str,
6245 (void *)&cmd_lfc_set_high_water,
6246 (void *)&cmd_lfc_set_portid,
6251 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6252 .f = cmd_link_flow_ctrl_set_parsed,
6253 .data = (void *)&cmd_link_flow_control_set_lw,
6254 .help_str = "set flow_ctrl low_water <value> <port_id>: "
6255 "Change low water flow control parameter",
6257 (void *)&cmd_lfc_set_set,
6258 (void *)&cmd_lfc_set_flow_ctrl,
6259 (void *)&cmd_lfc_set_low_water_str,
6260 (void *)&cmd_lfc_set_low_water,
6261 (void *)&cmd_lfc_set_portid,
6266 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6267 .f = cmd_link_flow_ctrl_set_parsed,
6268 .data = (void *)&cmd_link_flow_control_set_pt,
6269 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6270 "Change pause time flow control parameter",
6272 (void *)&cmd_lfc_set_set,
6273 (void *)&cmd_lfc_set_flow_ctrl,
6274 (void *)&cmd_lfc_set_pause_time_str,
6275 (void *)&cmd_lfc_set_pause_time,
6276 (void *)&cmd_lfc_set_portid,
6281 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6282 .f = cmd_link_flow_ctrl_set_parsed,
6283 .data = (void *)&cmd_link_flow_control_set_xon,
6284 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6285 "Change send_xon flow control parameter",
6287 (void *)&cmd_lfc_set_set,
6288 (void *)&cmd_lfc_set_flow_ctrl,
6289 (void *)&cmd_lfc_set_send_xon_str,
6290 (void *)&cmd_lfc_set_send_xon,
6291 (void *)&cmd_lfc_set_portid,
6296 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6297 .f = cmd_link_flow_ctrl_set_parsed,
6298 .data = (void *)&cmd_link_flow_control_set_macfwd,
6299 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6300 "Change mac ctrl fwd flow control parameter",
6302 (void *)&cmd_lfc_set_set,
6303 (void *)&cmd_lfc_set_flow_ctrl,
6304 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6305 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6306 (void *)&cmd_lfc_set_portid,
6311 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6312 .f = cmd_link_flow_ctrl_set_parsed,
6313 .data = (void *)&cmd_link_flow_control_set_autoneg,
6314 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6315 "Change autoneg flow control parameter",
6317 (void *)&cmd_lfc_set_set,
6318 (void *)&cmd_lfc_set_flow_ctrl,
6319 (void *)&cmd_lfc_set_autoneg_str,
6320 (void *)&cmd_lfc_set_autoneg,
6321 (void *)&cmd_lfc_set_portid,
6327 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6328 __attribute__((unused)) struct cmdline *cl,
6331 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6332 cmdline_parse_inst_t *cmd = data;
6333 struct rte_eth_fc_conf fc_conf;
6339 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6340 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6341 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6342 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6344 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6345 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
6348 /* Partial command line, retrieve current configuration */
6350 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6352 printf("cannot get current flow ctrl parameters, return"
6353 "code = %d\n", ret);
6357 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
6358 (fc_conf.mode == RTE_FC_FULL))
6360 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
6361 (fc_conf.mode == RTE_FC_FULL))
6365 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6366 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6368 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6369 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6371 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6373 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6374 fc_conf.high_water = res->high_water;
6376 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6377 fc_conf.low_water = res->low_water;
6379 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6380 fc_conf.pause_time = res->pause_time;
6382 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6383 fc_conf.send_xon = res->send_xon;
6385 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6386 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6387 fc_conf.mac_ctrl_frame_fwd = 1;
6389 fc_conf.mac_ctrl_frame_fwd = 0;
6392 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6393 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6395 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6397 printf("bad flow contrl parameter, return code = %d \n", ret);
6400 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6401 struct cmd_priority_flow_ctrl_set_result {
6402 cmdline_fixed_string_t set;
6403 cmdline_fixed_string_t pfc_ctrl;
6404 cmdline_fixed_string_t rx;
6405 cmdline_fixed_string_t rx_pfc_mode;
6406 cmdline_fixed_string_t tx;
6407 cmdline_fixed_string_t tx_pfc_mode;
6408 uint32_t high_water;
6410 uint16_t pause_time;
6416 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6417 __attribute__((unused)) struct cmdline *cl,
6418 __attribute__((unused)) void *data)
6420 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
6421 struct rte_eth_pfc_conf pfc_conf;
6422 int rx_fc_enable, tx_fc_enable;
6426 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6427 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6428 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6429 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6431 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
6432 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
6435 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
6436 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
6437 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
6438 pfc_conf.fc.high_water = res->high_water;
6439 pfc_conf.fc.low_water = res->low_water;
6440 pfc_conf.fc.pause_time = res->pause_time;
6441 pfc_conf.priority = res->priority;
6443 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
6445 printf("bad priority flow contrl parameter, return code = %d \n", ret);
6448 cmdline_parse_token_string_t cmd_pfc_set_set =
6449 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6451 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
6452 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6453 pfc_ctrl, "pfc_ctrl");
6454 cmdline_parse_token_string_t cmd_pfc_set_rx =
6455 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6457 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
6458 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6459 rx_pfc_mode, "on#off");
6460 cmdline_parse_token_string_t cmd_pfc_set_tx =
6461 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6463 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
6464 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6465 tx_pfc_mode, "on#off");
6466 cmdline_parse_token_num_t cmd_pfc_set_high_water =
6467 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6468 high_water, UINT32);
6469 cmdline_parse_token_num_t cmd_pfc_set_low_water =
6470 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6472 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
6473 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6474 pause_time, UINT16);
6475 cmdline_parse_token_num_t cmd_pfc_set_priority =
6476 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6478 cmdline_parse_token_num_t cmd_pfc_set_portid =
6479 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6482 cmdline_parse_inst_t cmd_priority_flow_control_set = {
6483 .f = cmd_priority_flow_ctrl_set_parsed,
6485 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
6486 "<pause_time> <priority> <port_id>: "
6487 "Configure the Ethernet priority flow control",
6489 (void *)&cmd_pfc_set_set,
6490 (void *)&cmd_pfc_set_flow_ctrl,
6491 (void *)&cmd_pfc_set_rx,
6492 (void *)&cmd_pfc_set_rx_mode,
6493 (void *)&cmd_pfc_set_tx,
6494 (void *)&cmd_pfc_set_tx_mode,
6495 (void *)&cmd_pfc_set_high_water,
6496 (void *)&cmd_pfc_set_low_water,
6497 (void *)&cmd_pfc_set_pause_time,
6498 (void *)&cmd_pfc_set_priority,
6499 (void *)&cmd_pfc_set_portid,
6504 /* *** RESET CONFIGURATION *** */
6505 struct cmd_reset_result {
6506 cmdline_fixed_string_t reset;
6507 cmdline_fixed_string_t def;
6510 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
6512 __attribute__((unused)) void *data)
6514 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
6515 set_def_fwd_config();
6518 cmdline_parse_token_string_t cmd_reset_set =
6519 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
6520 cmdline_parse_token_string_t cmd_reset_def =
6521 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
6524 cmdline_parse_inst_t cmd_reset = {
6525 .f = cmd_reset_parsed,
6527 .help_str = "set default: Reset default forwarding configuration",
6529 (void *)&cmd_reset_set,
6530 (void *)&cmd_reset_def,
6535 /* *** START FORWARDING *** */
6536 struct cmd_start_result {
6537 cmdline_fixed_string_t start;
6540 cmdline_parse_token_string_t cmd_start_start =
6541 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
6543 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
6544 __attribute__((unused)) struct cmdline *cl,
6545 __attribute__((unused)) void *data)
6547 start_packet_forwarding(0);
6550 cmdline_parse_inst_t cmd_start = {
6551 .f = cmd_start_parsed,
6553 .help_str = "start: Start packet forwarding",
6555 (void *)&cmd_start_start,
6560 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
6561 struct cmd_start_tx_first_result {
6562 cmdline_fixed_string_t start;
6563 cmdline_fixed_string_t tx_first;
6567 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
6568 __attribute__((unused)) struct cmdline *cl,
6569 __attribute__((unused)) void *data)
6571 start_packet_forwarding(1);
6574 cmdline_parse_token_string_t cmd_start_tx_first_start =
6575 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
6577 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
6578 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
6579 tx_first, "tx_first");
6581 cmdline_parse_inst_t cmd_start_tx_first = {
6582 .f = cmd_start_tx_first_parsed,
6584 .help_str = "start tx_first: Start packet forwarding, "
6585 "after sending 1 burst of packets",
6587 (void *)&cmd_start_tx_first_start,
6588 (void *)&cmd_start_tx_first_tx_first,
6593 /* *** START FORWARDING WITH N TX BURST FIRST *** */
6594 struct cmd_start_tx_first_n_result {
6595 cmdline_fixed_string_t start;
6596 cmdline_fixed_string_t tx_first;
6601 cmd_start_tx_first_n_parsed(void *parsed_result,
6602 __attribute__((unused)) struct cmdline *cl,
6603 __attribute__((unused)) void *data)
6605 struct cmd_start_tx_first_n_result *res = parsed_result;
6607 start_packet_forwarding(res->tx_num);
6610 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
6611 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6613 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
6614 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6615 tx_first, "tx_first");
6616 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
6617 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
6620 cmdline_parse_inst_t cmd_start_tx_first_n = {
6621 .f = cmd_start_tx_first_n_parsed,
6623 .help_str = "start tx_first <num>: "
6624 "packet forwarding, after sending <num> bursts of packets",
6626 (void *)&cmd_start_tx_first_n_start,
6627 (void *)&cmd_start_tx_first_n_tx_first,
6628 (void *)&cmd_start_tx_first_n_tx_num,
6633 /* *** SET LINK UP *** */
6634 struct cmd_set_link_up_result {
6635 cmdline_fixed_string_t set;
6636 cmdline_fixed_string_t link_up;
6637 cmdline_fixed_string_t port;
6641 cmdline_parse_token_string_t cmd_set_link_up_set =
6642 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
6643 cmdline_parse_token_string_t cmd_set_link_up_link_up =
6644 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
6646 cmdline_parse_token_string_t cmd_set_link_up_port =
6647 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
6648 cmdline_parse_token_num_t cmd_set_link_up_port_id =
6649 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
6651 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
6652 __attribute__((unused)) struct cmdline *cl,
6653 __attribute__((unused)) void *data)
6655 struct cmd_set_link_up_result *res = parsed_result;
6656 dev_set_link_up(res->port_id);
6659 cmdline_parse_inst_t cmd_set_link_up = {
6660 .f = cmd_set_link_up_parsed,
6662 .help_str = "set link-up port <port id>",
6664 (void *)&cmd_set_link_up_set,
6665 (void *)&cmd_set_link_up_link_up,
6666 (void *)&cmd_set_link_up_port,
6667 (void *)&cmd_set_link_up_port_id,
6672 /* *** SET LINK DOWN *** */
6673 struct cmd_set_link_down_result {
6674 cmdline_fixed_string_t set;
6675 cmdline_fixed_string_t link_down;
6676 cmdline_fixed_string_t port;
6680 cmdline_parse_token_string_t cmd_set_link_down_set =
6681 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
6682 cmdline_parse_token_string_t cmd_set_link_down_link_down =
6683 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
6685 cmdline_parse_token_string_t cmd_set_link_down_port =
6686 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
6687 cmdline_parse_token_num_t cmd_set_link_down_port_id =
6688 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
6690 static void cmd_set_link_down_parsed(
6691 __attribute__((unused)) void *parsed_result,
6692 __attribute__((unused)) struct cmdline *cl,
6693 __attribute__((unused)) void *data)
6695 struct cmd_set_link_down_result *res = parsed_result;
6696 dev_set_link_down(res->port_id);
6699 cmdline_parse_inst_t cmd_set_link_down = {
6700 .f = cmd_set_link_down_parsed,
6702 .help_str = "set link-down port <port id>",
6704 (void *)&cmd_set_link_down_set,
6705 (void *)&cmd_set_link_down_link_down,
6706 (void *)&cmd_set_link_down_port,
6707 (void *)&cmd_set_link_down_port_id,
6712 /* *** SHOW CFG *** */
6713 struct cmd_showcfg_result {
6714 cmdline_fixed_string_t show;
6715 cmdline_fixed_string_t cfg;
6716 cmdline_fixed_string_t what;
6719 static void cmd_showcfg_parsed(void *parsed_result,
6720 __attribute__((unused)) struct cmdline *cl,
6721 __attribute__((unused)) void *data)
6723 struct cmd_showcfg_result *res = parsed_result;
6724 if (!strcmp(res->what, "rxtx"))
6725 rxtx_config_display();
6726 else if (!strcmp(res->what, "cores"))
6727 fwd_lcores_config_display();
6728 else if (!strcmp(res->what, "fwd"))
6729 pkt_fwd_config_display(&cur_fwd_config);
6730 else if (!strcmp(res->what, "txpkts"))
6731 show_tx_pkt_segments();
6734 cmdline_parse_token_string_t cmd_showcfg_show =
6735 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
6736 cmdline_parse_token_string_t cmd_showcfg_port =
6737 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
6738 cmdline_parse_token_string_t cmd_showcfg_what =
6739 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
6740 "rxtx#cores#fwd#txpkts");
6742 cmdline_parse_inst_t cmd_showcfg = {
6743 .f = cmd_showcfg_parsed,
6745 .help_str = "show config rxtx|cores|fwd|txpkts",
6747 (void *)&cmd_showcfg_show,
6748 (void *)&cmd_showcfg_port,
6749 (void *)&cmd_showcfg_what,
6754 /* *** SHOW ALL PORT INFO *** */
6755 struct cmd_showportall_result {
6756 cmdline_fixed_string_t show;
6757 cmdline_fixed_string_t port;
6758 cmdline_fixed_string_t what;
6759 cmdline_fixed_string_t all;
6762 static void cmd_showportall_parsed(void *parsed_result,
6763 __attribute__((unused)) struct cmdline *cl,
6764 __attribute__((unused)) void *data)
6768 struct cmd_showportall_result *res = parsed_result;
6769 if (!strcmp(res->show, "clear")) {
6770 if (!strcmp(res->what, "stats"))
6771 RTE_ETH_FOREACH_DEV(i)
6773 else if (!strcmp(res->what, "xstats"))
6774 RTE_ETH_FOREACH_DEV(i)
6775 nic_xstats_clear(i);
6776 } else if (!strcmp(res->what, "info"))
6777 RTE_ETH_FOREACH_DEV(i)
6778 port_infos_display(i);
6779 else if (!strcmp(res->what, "stats"))
6780 RTE_ETH_FOREACH_DEV(i)
6781 nic_stats_display(i);
6782 else if (!strcmp(res->what, "xstats"))
6783 RTE_ETH_FOREACH_DEV(i)
6784 nic_xstats_display(i);
6785 else if (!strcmp(res->what, "fdir"))
6786 RTE_ETH_FOREACH_DEV(i)
6788 else if (!strcmp(res->what, "stat_qmap"))
6789 RTE_ETH_FOREACH_DEV(i)
6790 nic_stats_mapping_display(i);
6791 else if (!strcmp(res->what, "dcb_tc"))
6792 RTE_ETH_FOREACH_DEV(i)
6793 port_dcb_info_display(i);
6794 else if (!strcmp(res->what, "cap"))
6795 RTE_ETH_FOREACH_DEV(i)
6796 port_offload_cap_display(i);
6799 cmdline_parse_token_string_t cmd_showportall_show =
6800 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
6802 cmdline_parse_token_string_t cmd_showportall_port =
6803 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
6804 cmdline_parse_token_string_t cmd_showportall_what =
6805 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
6806 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
6807 cmdline_parse_token_string_t cmd_showportall_all =
6808 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
6809 cmdline_parse_inst_t cmd_showportall = {
6810 .f = cmd_showportall_parsed,
6812 .help_str = "show|clear port "
6813 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
6815 (void *)&cmd_showportall_show,
6816 (void *)&cmd_showportall_port,
6817 (void *)&cmd_showportall_what,
6818 (void *)&cmd_showportall_all,
6823 /* *** SHOW PORT INFO *** */
6824 struct cmd_showport_result {
6825 cmdline_fixed_string_t show;
6826 cmdline_fixed_string_t port;
6827 cmdline_fixed_string_t what;
6831 static void cmd_showport_parsed(void *parsed_result,
6832 __attribute__((unused)) struct cmdline *cl,
6833 __attribute__((unused)) void *data)
6835 struct cmd_showport_result *res = parsed_result;
6836 if (!strcmp(res->show, "clear")) {
6837 if (!strcmp(res->what, "stats"))
6838 nic_stats_clear(res->portnum);
6839 else if (!strcmp(res->what, "xstats"))
6840 nic_xstats_clear(res->portnum);
6841 } else if (!strcmp(res->what, "info"))
6842 port_infos_display(res->portnum);
6843 else if (!strcmp(res->what, "stats"))
6844 nic_stats_display(res->portnum);
6845 else if (!strcmp(res->what, "xstats"))
6846 nic_xstats_display(res->portnum);
6847 else if (!strcmp(res->what, "fdir"))
6848 fdir_get_infos(res->portnum);
6849 else if (!strcmp(res->what, "stat_qmap"))
6850 nic_stats_mapping_display(res->portnum);
6851 else if (!strcmp(res->what, "dcb_tc"))
6852 port_dcb_info_display(res->portnum);
6853 else if (!strcmp(res->what, "cap"))
6854 port_offload_cap_display(res->portnum);
6857 cmdline_parse_token_string_t cmd_showport_show =
6858 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
6860 cmdline_parse_token_string_t cmd_showport_port =
6861 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
6862 cmdline_parse_token_string_t cmd_showport_what =
6863 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
6864 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
6865 cmdline_parse_token_num_t cmd_showport_portnum =
6866 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
6868 cmdline_parse_inst_t cmd_showport = {
6869 .f = cmd_showport_parsed,
6871 .help_str = "show|clear port "
6872 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
6875 (void *)&cmd_showport_show,
6876 (void *)&cmd_showport_port,
6877 (void *)&cmd_showport_what,
6878 (void *)&cmd_showport_portnum,
6883 /* *** SHOW QUEUE INFO *** */
6884 struct cmd_showqueue_result {
6885 cmdline_fixed_string_t show;
6886 cmdline_fixed_string_t type;
6887 cmdline_fixed_string_t what;
6893 cmd_showqueue_parsed(void *parsed_result,
6894 __attribute__((unused)) struct cmdline *cl,
6895 __attribute__((unused)) void *data)
6897 struct cmd_showqueue_result *res = parsed_result;
6899 if (!strcmp(res->type, "rxq"))
6900 rx_queue_infos_display(res->portnum, res->queuenum);
6901 else if (!strcmp(res->type, "txq"))
6902 tx_queue_infos_display(res->portnum, res->queuenum);
6905 cmdline_parse_token_string_t cmd_showqueue_show =
6906 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
6907 cmdline_parse_token_string_t cmd_showqueue_type =
6908 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
6909 cmdline_parse_token_string_t cmd_showqueue_what =
6910 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
6911 cmdline_parse_token_num_t cmd_showqueue_portnum =
6912 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
6913 cmdline_parse_token_num_t cmd_showqueue_queuenum =
6914 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
6916 cmdline_parse_inst_t cmd_showqueue = {
6917 .f = cmd_showqueue_parsed,
6919 .help_str = "show rxq|txq info <port_id> <queue_id>",
6921 (void *)&cmd_showqueue_show,
6922 (void *)&cmd_showqueue_type,
6923 (void *)&cmd_showqueue_what,
6924 (void *)&cmd_showqueue_portnum,
6925 (void *)&cmd_showqueue_queuenum,
6930 /* *** READ PORT REGISTER *** */
6931 struct cmd_read_reg_result {
6932 cmdline_fixed_string_t read;
6933 cmdline_fixed_string_t reg;
6939 cmd_read_reg_parsed(void *parsed_result,
6940 __attribute__((unused)) struct cmdline *cl,
6941 __attribute__((unused)) void *data)
6943 struct cmd_read_reg_result *res = parsed_result;
6944 port_reg_display(res->port_id, res->reg_off);
6947 cmdline_parse_token_string_t cmd_read_reg_read =
6948 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
6949 cmdline_parse_token_string_t cmd_read_reg_reg =
6950 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
6951 cmdline_parse_token_num_t cmd_read_reg_port_id =
6952 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
6953 cmdline_parse_token_num_t cmd_read_reg_reg_off =
6954 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
6956 cmdline_parse_inst_t cmd_read_reg = {
6957 .f = cmd_read_reg_parsed,
6959 .help_str = "read reg <port_id> <reg_off>",
6961 (void *)&cmd_read_reg_read,
6962 (void *)&cmd_read_reg_reg,
6963 (void *)&cmd_read_reg_port_id,
6964 (void *)&cmd_read_reg_reg_off,
6969 /* *** READ PORT REGISTER BIT FIELD *** */
6970 struct cmd_read_reg_bit_field_result {
6971 cmdline_fixed_string_t read;
6972 cmdline_fixed_string_t regfield;
6980 cmd_read_reg_bit_field_parsed(void *parsed_result,
6981 __attribute__((unused)) struct cmdline *cl,
6982 __attribute__((unused)) void *data)
6984 struct cmd_read_reg_bit_field_result *res = parsed_result;
6985 port_reg_bit_field_display(res->port_id, res->reg_off,
6986 res->bit1_pos, res->bit2_pos);
6989 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
6990 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
6992 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
6993 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
6994 regfield, "regfield");
6995 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
6996 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
6998 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
6999 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7001 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7002 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7004 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7005 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7008 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7009 .f = cmd_read_reg_bit_field_parsed,
7011 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7012 "Read register bit field between bit_x and bit_y included",
7014 (void *)&cmd_read_reg_bit_field_read,
7015 (void *)&cmd_read_reg_bit_field_regfield,
7016 (void *)&cmd_read_reg_bit_field_port_id,
7017 (void *)&cmd_read_reg_bit_field_reg_off,
7018 (void *)&cmd_read_reg_bit_field_bit1_pos,
7019 (void *)&cmd_read_reg_bit_field_bit2_pos,
7024 /* *** READ PORT REGISTER BIT *** */
7025 struct cmd_read_reg_bit_result {
7026 cmdline_fixed_string_t read;
7027 cmdline_fixed_string_t regbit;
7034 cmd_read_reg_bit_parsed(void *parsed_result,
7035 __attribute__((unused)) struct cmdline *cl,
7036 __attribute__((unused)) void *data)
7038 struct cmd_read_reg_bit_result *res = parsed_result;
7039 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7042 cmdline_parse_token_string_t cmd_read_reg_bit_read =
7043 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
7044 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
7045 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
7047 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
7048 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
7049 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
7050 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
7051 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
7052 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
7054 cmdline_parse_inst_t cmd_read_reg_bit = {
7055 .f = cmd_read_reg_bit_parsed,
7057 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7059 (void *)&cmd_read_reg_bit_read,
7060 (void *)&cmd_read_reg_bit_regbit,
7061 (void *)&cmd_read_reg_bit_port_id,
7062 (void *)&cmd_read_reg_bit_reg_off,
7063 (void *)&cmd_read_reg_bit_bit_pos,
7068 /* *** WRITE PORT REGISTER *** */
7069 struct cmd_write_reg_result {
7070 cmdline_fixed_string_t write;
7071 cmdline_fixed_string_t reg;
7078 cmd_write_reg_parsed(void *parsed_result,
7079 __attribute__((unused)) struct cmdline *cl,
7080 __attribute__((unused)) void *data)
7082 struct cmd_write_reg_result *res = parsed_result;
7083 port_reg_set(res->port_id, res->reg_off, res->value);
7086 cmdline_parse_token_string_t cmd_write_reg_write =
7087 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
7088 cmdline_parse_token_string_t cmd_write_reg_reg =
7089 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
7090 cmdline_parse_token_num_t cmd_write_reg_port_id =
7091 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
7092 cmdline_parse_token_num_t cmd_write_reg_reg_off =
7093 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
7094 cmdline_parse_token_num_t cmd_write_reg_value =
7095 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
7097 cmdline_parse_inst_t cmd_write_reg = {
7098 .f = cmd_write_reg_parsed,
7100 .help_str = "write reg <port_id> <reg_off> <reg_value>",
7102 (void *)&cmd_write_reg_write,
7103 (void *)&cmd_write_reg_reg,
7104 (void *)&cmd_write_reg_port_id,
7105 (void *)&cmd_write_reg_reg_off,
7106 (void *)&cmd_write_reg_value,
7111 /* *** WRITE PORT REGISTER BIT FIELD *** */
7112 struct cmd_write_reg_bit_field_result {
7113 cmdline_fixed_string_t write;
7114 cmdline_fixed_string_t regfield;
7123 cmd_write_reg_bit_field_parsed(void *parsed_result,
7124 __attribute__((unused)) struct cmdline *cl,
7125 __attribute__((unused)) void *data)
7127 struct cmd_write_reg_bit_field_result *res = parsed_result;
7128 port_reg_bit_field_set(res->port_id, res->reg_off,
7129 res->bit1_pos, res->bit2_pos, res->value);
7132 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
7133 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
7135 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
7136 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
7137 regfield, "regfield");
7138 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
7139 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
7141 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
7142 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
7144 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
7145 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
7147 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
7148 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
7150 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
7151 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
7154 cmdline_parse_inst_t cmd_write_reg_bit_field = {
7155 .f = cmd_write_reg_bit_field_parsed,
7157 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
7159 "Set register bit field between bit_x and bit_y included",
7161 (void *)&cmd_write_reg_bit_field_write,
7162 (void *)&cmd_write_reg_bit_field_regfield,
7163 (void *)&cmd_write_reg_bit_field_port_id,
7164 (void *)&cmd_write_reg_bit_field_reg_off,
7165 (void *)&cmd_write_reg_bit_field_bit1_pos,
7166 (void *)&cmd_write_reg_bit_field_bit2_pos,
7167 (void *)&cmd_write_reg_bit_field_value,
7172 /* *** WRITE PORT REGISTER BIT *** */
7173 struct cmd_write_reg_bit_result {
7174 cmdline_fixed_string_t write;
7175 cmdline_fixed_string_t regbit;
7183 cmd_write_reg_bit_parsed(void *parsed_result,
7184 __attribute__((unused)) struct cmdline *cl,
7185 __attribute__((unused)) void *data)
7187 struct cmd_write_reg_bit_result *res = parsed_result;
7188 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
7191 cmdline_parse_token_string_t cmd_write_reg_bit_write =
7192 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
7194 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
7195 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
7197 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
7198 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
7199 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
7200 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
7201 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
7202 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
7203 cmdline_parse_token_num_t cmd_write_reg_bit_value =
7204 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
7206 cmdline_parse_inst_t cmd_write_reg_bit = {
7207 .f = cmd_write_reg_bit_parsed,
7209 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
7212 (void *)&cmd_write_reg_bit_write,
7213 (void *)&cmd_write_reg_bit_regbit,
7214 (void *)&cmd_write_reg_bit_port_id,
7215 (void *)&cmd_write_reg_bit_reg_off,
7216 (void *)&cmd_write_reg_bit_bit_pos,
7217 (void *)&cmd_write_reg_bit_value,
7222 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7223 struct cmd_read_rxd_txd_result {
7224 cmdline_fixed_string_t read;
7225 cmdline_fixed_string_t rxd_txd;
7232 cmd_read_rxd_txd_parsed(void *parsed_result,
7233 __attribute__((unused)) struct cmdline *cl,
7234 __attribute__((unused)) void *data)
7236 struct cmd_read_rxd_txd_result *res = parsed_result;
7238 if (!strcmp(res->rxd_txd, "rxd"))
7239 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7240 else if (!strcmp(res->rxd_txd, "txd"))
7241 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7244 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
7245 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
7246 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
7247 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
7249 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
7250 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
7251 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
7252 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
7253 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
7254 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
7256 cmdline_parse_inst_t cmd_read_rxd_txd = {
7257 .f = cmd_read_rxd_txd_parsed,
7259 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
7261 (void *)&cmd_read_rxd_txd_read,
7262 (void *)&cmd_read_rxd_txd_rxd_txd,
7263 (void *)&cmd_read_rxd_txd_port_id,
7264 (void *)&cmd_read_rxd_txd_queue_id,
7265 (void *)&cmd_read_rxd_txd_desc_id,
7271 struct cmd_quit_result {
7272 cmdline_fixed_string_t quit;
7275 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
7277 __attribute__((unused)) void *data)
7283 cmdline_parse_token_string_t cmd_quit_quit =
7284 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
7286 cmdline_parse_inst_t cmd_quit = {
7287 .f = cmd_quit_parsed,
7289 .help_str = "quit: Exit application",
7291 (void *)&cmd_quit_quit,
7296 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
7297 struct cmd_mac_addr_result {
7298 cmdline_fixed_string_t mac_addr_cmd;
7299 cmdline_fixed_string_t what;
7301 struct ether_addr address;
7304 static void cmd_mac_addr_parsed(void *parsed_result,
7305 __attribute__((unused)) struct cmdline *cl,
7306 __attribute__((unused)) void *data)
7308 struct cmd_mac_addr_result *res = parsed_result;
7311 if (strcmp(res->what, "add") == 0)
7312 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
7313 else if (strcmp(res->what, "set") == 0)
7314 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
7317 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
7319 /* check the return value and print it if is < 0 */
7321 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
7325 cmdline_parse_token_string_t cmd_mac_addr_cmd =
7326 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
7328 cmdline_parse_token_string_t cmd_mac_addr_what =
7329 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
7331 cmdline_parse_token_num_t cmd_mac_addr_portnum =
7332 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
7334 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
7335 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
7337 cmdline_parse_inst_t cmd_mac_addr = {
7338 .f = cmd_mac_addr_parsed,
7340 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
7341 "Add/Remove/Set MAC address on port_id",
7343 (void *)&cmd_mac_addr_cmd,
7344 (void *)&cmd_mac_addr_what,
7345 (void *)&cmd_mac_addr_portnum,
7346 (void *)&cmd_mac_addr_addr,
7351 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
7352 struct cmd_eth_peer_result {
7353 cmdline_fixed_string_t set;
7354 cmdline_fixed_string_t eth_peer;
7356 cmdline_fixed_string_t peer_addr;
7359 static void cmd_set_eth_peer_parsed(void *parsed_result,
7360 __attribute__((unused)) struct cmdline *cl,
7361 __attribute__((unused)) void *data)
7363 struct cmd_eth_peer_result *res = parsed_result;
7365 if (test_done == 0) {
7366 printf("Please stop forwarding first\n");
7369 if (!strcmp(res->eth_peer, "eth-peer")) {
7370 set_fwd_eth_peer(res->port_id, res->peer_addr);
7374 cmdline_parse_token_string_t cmd_eth_peer_set =
7375 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
7376 cmdline_parse_token_string_t cmd_eth_peer =
7377 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
7378 cmdline_parse_token_num_t cmd_eth_peer_port_id =
7379 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
7380 cmdline_parse_token_string_t cmd_eth_peer_addr =
7381 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
7383 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
7384 .f = cmd_set_eth_peer_parsed,
7386 .help_str = "set eth-peer <port_id> <peer_mac>",
7388 (void *)&cmd_eth_peer_set,
7389 (void *)&cmd_eth_peer,
7390 (void *)&cmd_eth_peer_port_id,
7391 (void *)&cmd_eth_peer_addr,
7396 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
7397 struct cmd_set_qmap_result {
7398 cmdline_fixed_string_t set;
7399 cmdline_fixed_string_t qmap;
7400 cmdline_fixed_string_t what;
7407 cmd_set_qmap_parsed(void *parsed_result,
7408 __attribute__((unused)) struct cmdline *cl,
7409 __attribute__((unused)) void *data)
7411 struct cmd_set_qmap_result *res = parsed_result;
7412 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
7414 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
7417 cmdline_parse_token_string_t cmd_setqmap_set =
7418 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7420 cmdline_parse_token_string_t cmd_setqmap_qmap =
7421 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7423 cmdline_parse_token_string_t cmd_setqmap_what =
7424 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7426 cmdline_parse_token_num_t cmd_setqmap_portid =
7427 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7429 cmdline_parse_token_num_t cmd_setqmap_queueid =
7430 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7432 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
7433 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7436 cmdline_parse_inst_t cmd_set_qmap = {
7437 .f = cmd_set_qmap_parsed,
7439 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
7440 "Set statistics mapping value on tx|rx queue_id of port_id",
7442 (void *)&cmd_setqmap_set,
7443 (void *)&cmd_setqmap_qmap,
7444 (void *)&cmd_setqmap_what,
7445 (void *)&cmd_setqmap_portid,
7446 (void *)&cmd_setqmap_queueid,
7447 (void *)&cmd_setqmap_mapvalue,
7452 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
7453 struct cmd_set_xstats_hide_zero_result {
7454 cmdline_fixed_string_t keyword;
7455 cmdline_fixed_string_t name;
7456 cmdline_fixed_string_t on_off;
7460 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
7461 __attribute__((unused)) struct cmdline *cl,
7462 __attribute__((unused)) void *data)
7464 struct cmd_set_xstats_hide_zero_result *res;
7465 uint16_t on_off = 0;
7467 res = parsed_result;
7468 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
7469 set_xstats_hide_zero(on_off);
7472 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
7473 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7475 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
7476 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7477 name, "xstats-hide-zero");
7478 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
7479 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7482 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
7483 .f = cmd_set_xstats_hide_zero_parsed,
7485 .help_str = "set xstats-hide-zero on|off",
7487 (void *)&cmd_set_xstats_hide_zero_keyword,
7488 (void *)&cmd_set_xstats_hide_zero_name,
7489 (void *)&cmd_set_xstats_hide_zero_on_off,
7494 /* *** CONFIGURE UNICAST HASH TABLE *** */
7495 struct cmd_set_uc_hash_table {
7496 cmdline_fixed_string_t set;
7497 cmdline_fixed_string_t port;
7499 cmdline_fixed_string_t what;
7500 struct ether_addr address;
7501 cmdline_fixed_string_t mode;
7505 cmd_set_uc_hash_parsed(void *parsed_result,
7506 __attribute__((unused)) struct cmdline *cl,
7507 __attribute__((unused)) void *data)
7510 struct cmd_set_uc_hash_table *res = parsed_result;
7512 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7514 if (strcmp(res->what, "uta") == 0)
7515 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
7516 &res->address,(uint8_t)is_on);
7518 printf("bad unicast hash table parameter, return code = %d \n", ret);
7522 cmdline_parse_token_string_t cmd_set_uc_hash_set =
7523 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7525 cmdline_parse_token_string_t cmd_set_uc_hash_port =
7526 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7528 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
7529 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
7531 cmdline_parse_token_string_t cmd_set_uc_hash_what =
7532 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7534 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
7535 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
7537 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
7538 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7541 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
7542 .f = cmd_set_uc_hash_parsed,
7544 .help_str = "set port <port_id> uta <mac_addr> on|off)",
7546 (void *)&cmd_set_uc_hash_set,
7547 (void *)&cmd_set_uc_hash_port,
7548 (void *)&cmd_set_uc_hash_portid,
7549 (void *)&cmd_set_uc_hash_what,
7550 (void *)&cmd_set_uc_hash_mac,
7551 (void *)&cmd_set_uc_hash_mode,
7556 struct cmd_set_uc_all_hash_table {
7557 cmdline_fixed_string_t set;
7558 cmdline_fixed_string_t port;
7560 cmdline_fixed_string_t what;
7561 cmdline_fixed_string_t value;
7562 cmdline_fixed_string_t mode;
7566 cmd_set_uc_all_hash_parsed(void *parsed_result,
7567 __attribute__((unused)) struct cmdline *cl,
7568 __attribute__((unused)) void *data)
7571 struct cmd_set_uc_all_hash_table *res = parsed_result;
7573 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7575 if ((strcmp(res->what, "uta") == 0) &&
7576 (strcmp(res->value, "all") == 0))
7577 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
7579 printf("bad unicast hash table parameter,"
7580 "return code = %d \n", ret);
7583 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
7584 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7586 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
7587 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7589 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
7590 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
7592 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
7593 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7595 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
7596 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7598 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
7599 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7602 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
7603 .f = cmd_set_uc_all_hash_parsed,
7605 .help_str = "set port <port_id> uta all on|off",
7607 (void *)&cmd_set_uc_all_hash_set,
7608 (void *)&cmd_set_uc_all_hash_port,
7609 (void *)&cmd_set_uc_all_hash_portid,
7610 (void *)&cmd_set_uc_all_hash_what,
7611 (void *)&cmd_set_uc_all_hash_value,
7612 (void *)&cmd_set_uc_all_hash_mode,
7617 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
7618 struct cmd_set_vf_macvlan_filter {
7619 cmdline_fixed_string_t set;
7620 cmdline_fixed_string_t port;
7622 cmdline_fixed_string_t vf;
7624 struct ether_addr address;
7625 cmdline_fixed_string_t filter_type;
7626 cmdline_fixed_string_t mode;
7630 cmd_set_vf_macvlan_parsed(void *parsed_result,
7631 __attribute__((unused)) struct cmdline *cl,
7632 __attribute__((unused)) void *data)
7635 struct cmd_set_vf_macvlan_filter *res = parsed_result;
7636 struct rte_eth_mac_filter filter;
7638 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
7640 rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
7642 /* set VF MAC filter */
7646 filter.dst_id = res->vf_id;
7648 if (!strcmp(res->filter_type, "exact-mac"))
7649 filter.filter_type = RTE_MAC_PERFECT_MATCH;
7650 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
7651 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
7652 else if (!strcmp(res->filter_type, "hashmac"))
7653 filter.filter_type = RTE_MAC_HASH_MATCH;
7654 else if (!strcmp(res->filter_type, "hashmac-vlan"))
7655 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
7657 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7660 ret = rte_eth_dev_filter_ctrl(res->port_id,
7661 RTE_ETH_FILTER_MACVLAN,
7665 ret = rte_eth_dev_filter_ctrl(res->port_id,
7666 RTE_ETH_FILTER_MACVLAN,
7667 RTE_ETH_FILTER_DELETE,
7671 printf("bad set MAC hash parameter, return code = %d\n", ret);
7675 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
7676 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7678 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
7679 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7681 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
7682 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7684 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
7685 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7687 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
7688 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7690 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
7691 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7693 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
7694 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7695 filter_type, "exact-mac#exact-mac-vlan"
7696 "#hashmac#hashmac-vlan");
7697 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
7698 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7701 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
7702 .f = cmd_set_vf_macvlan_parsed,
7704 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
7705 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
7706 "Exact match rule: exact match of MAC or MAC and VLAN; "
7707 "hash match rule: hash match of MAC and exact match of VLAN",
7709 (void *)&cmd_set_vf_macvlan_set,
7710 (void *)&cmd_set_vf_macvlan_port,
7711 (void *)&cmd_set_vf_macvlan_portid,
7712 (void *)&cmd_set_vf_macvlan_vf,
7713 (void *)&cmd_set_vf_macvlan_vf_id,
7714 (void *)&cmd_set_vf_macvlan_mac,
7715 (void *)&cmd_set_vf_macvlan_filter_type,
7716 (void *)&cmd_set_vf_macvlan_mode,
7721 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
7722 struct cmd_set_vf_traffic {
7723 cmdline_fixed_string_t set;
7724 cmdline_fixed_string_t port;
7726 cmdline_fixed_string_t vf;
7728 cmdline_fixed_string_t what;
7729 cmdline_fixed_string_t mode;
7733 cmd_set_vf_traffic_parsed(void *parsed_result,
7734 __attribute__((unused)) struct cmdline *cl,
7735 __attribute__((unused)) void *data)
7737 struct cmd_set_vf_traffic *res = parsed_result;
7738 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
7739 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7741 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
7744 cmdline_parse_token_string_t cmd_setvf_traffic_set =
7745 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7747 cmdline_parse_token_string_t cmd_setvf_traffic_port =
7748 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7750 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
7751 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7753 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
7754 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7756 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
7757 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7759 cmdline_parse_token_string_t cmd_setvf_traffic_what =
7760 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7762 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
7763 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7766 cmdline_parse_inst_t cmd_set_vf_traffic = {
7767 .f = cmd_set_vf_traffic_parsed,
7769 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
7771 (void *)&cmd_setvf_traffic_set,
7772 (void *)&cmd_setvf_traffic_port,
7773 (void *)&cmd_setvf_traffic_portid,
7774 (void *)&cmd_setvf_traffic_vf,
7775 (void *)&cmd_setvf_traffic_vfid,
7776 (void *)&cmd_setvf_traffic_what,
7777 (void *)&cmd_setvf_traffic_mode,
7782 /* *** CONFIGURE VF RECEIVE MODE *** */
7783 struct cmd_set_vf_rxmode {
7784 cmdline_fixed_string_t set;
7785 cmdline_fixed_string_t port;
7787 cmdline_fixed_string_t vf;
7789 cmdline_fixed_string_t what;
7790 cmdline_fixed_string_t mode;
7791 cmdline_fixed_string_t on;
7795 cmd_set_vf_rxmode_parsed(void *parsed_result,
7796 __attribute__((unused)) struct cmdline *cl,
7797 __attribute__((unused)) void *data)
7800 uint16_t rx_mode = 0;
7801 struct cmd_set_vf_rxmode *res = parsed_result;
7803 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
7804 if (!strcmp(res->what,"rxmode")) {
7805 if (!strcmp(res->mode, "AUPE"))
7806 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
7807 else if (!strcmp(res->mode, "ROPE"))
7808 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
7809 else if (!strcmp(res->mode, "BAM"))
7810 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
7811 else if (!strncmp(res->mode, "MPE",3))
7812 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
7815 RTE_SET_USED(is_on);
7817 #ifdef RTE_LIBRTE_IXGBE_PMD
7818 if (ret == -ENOTSUP)
7819 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
7820 rx_mode, (uint8_t)is_on);
7822 #ifdef RTE_LIBRTE_BNXT_PMD
7823 if (ret == -ENOTSUP)
7824 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
7825 rx_mode, (uint8_t)is_on);
7828 printf("bad VF receive mode parameter, return code = %d \n",
7832 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
7833 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7835 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
7836 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7838 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
7839 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7841 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
7842 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7844 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
7845 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7847 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
7848 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7850 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
7851 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7852 mode, "AUPE#ROPE#BAM#MPE");
7853 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
7854 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7857 cmdline_parse_inst_t cmd_set_vf_rxmode = {
7858 .f = cmd_set_vf_rxmode_parsed,
7860 .help_str = "set port <port_id> vf <vf_id> rxmode "
7861 "AUPE|ROPE|BAM|MPE on|off",
7863 (void *)&cmd_set_vf_rxmode_set,
7864 (void *)&cmd_set_vf_rxmode_port,
7865 (void *)&cmd_set_vf_rxmode_portid,
7866 (void *)&cmd_set_vf_rxmode_vf,
7867 (void *)&cmd_set_vf_rxmode_vfid,
7868 (void *)&cmd_set_vf_rxmode_what,
7869 (void *)&cmd_set_vf_rxmode_mode,
7870 (void *)&cmd_set_vf_rxmode_on,
7875 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
7876 struct cmd_vf_mac_addr_result {
7877 cmdline_fixed_string_t mac_addr_cmd;
7878 cmdline_fixed_string_t what;
7879 cmdline_fixed_string_t port;
7881 cmdline_fixed_string_t vf;
7883 struct ether_addr address;
7886 static void cmd_vf_mac_addr_parsed(void *parsed_result,
7887 __attribute__((unused)) struct cmdline *cl,
7888 __attribute__((unused)) void *data)
7890 struct cmd_vf_mac_addr_result *res = parsed_result;
7893 if (strcmp(res->what, "add") != 0)
7896 #ifdef RTE_LIBRTE_I40E_PMD
7897 if (ret == -ENOTSUP)
7898 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
7901 #ifdef RTE_LIBRTE_BNXT_PMD
7902 if (ret == -ENOTSUP)
7903 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
7908 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
7912 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
7913 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7914 mac_addr_cmd,"mac_addr");
7915 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
7916 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7918 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
7919 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7921 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
7922 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7924 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
7925 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7927 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
7928 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7930 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
7931 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
7934 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
7935 .f = cmd_vf_mac_addr_parsed,
7937 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
7938 "Add MAC address filtering for a VF on port_id",
7940 (void *)&cmd_vf_mac_addr_cmd,
7941 (void *)&cmd_vf_mac_addr_what,
7942 (void *)&cmd_vf_mac_addr_port,
7943 (void *)&cmd_vf_mac_addr_portnum,
7944 (void *)&cmd_vf_mac_addr_vf,
7945 (void *)&cmd_vf_mac_addr_vfnum,
7946 (void *)&cmd_vf_mac_addr_addr,
7951 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
7952 struct cmd_vf_rx_vlan_filter {
7953 cmdline_fixed_string_t rx_vlan;
7954 cmdline_fixed_string_t what;
7956 cmdline_fixed_string_t port;
7958 cmdline_fixed_string_t vf;
7963 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
7964 __attribute__((unused)) struct cmdline *cl,
7965 __attribute__((unused)) void *data)
7967 struct cmd_vf_rx_vlan_filter *res = parsed_result;
7970 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
7972 #ifdef RTE_LIBRTE_IXGBE_PMD
7973 if (ret == -ENOTSUP)
7974 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
7975 res->vlan_id, res->vf_mask, is_add);
7977 #ifdef RTE_LIBRTE_I40E_PMD
7978 if (ret == -ENOTSUP)
7979 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
7980 res->vlan_id, res->vf_mask, is_add);
7982 #ifdef RTE_LIBRTE_BNXT_PMD
7983 if (ret == -ENOTSUP)
7984 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
7985 res->vlan_id, res->vf_mask, is_add);
7992 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
7993 res->vlan_id, res->vf_mask);
7996 printf("invalid port_id %d\n", res->port_id);
7999 printf("function not implemented or supported\n");
8002 printf("programming error: (%s)\n", strerror(-ret));
8006 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8007 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8008 rx_vlan, "rx_vlan");
8009 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8010 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8012 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8013 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8015 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8016 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8018 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8019 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8021 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8022 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8024 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8025 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8028 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8029 .f = cmd_vf_rx_vlan_filter_parsed,
8031 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8032 "(vf_mask = hexadecimal VF mask)",
8034 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8035 (void *)&cmd_vf_rx_vlan_filter_what,
8036 (void *)&cmd_vf_rx_vlan_filter_vlanid,
8037 (void *)&cmd_vf_rx_vlan_filter_port,
8038 (void *)&cmd_vf_rx_vlan_filter_portid,
8039 (void *)&cmd_vf_rx_vlan_filter_vf,
8040 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8045 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8046 struct cmd_queue_rate_limit_result {
8047 cmdline_fixed_string_t set;
8048 cmdline_fixed_string_t port;
8050 cmdline_fixed_string_t queue;
8052 cmdline_fixed_string_t rate;
8056 static void cmd_queue_rate_limit_parsed(void *parsed_result,
8057 __attribute__((unused)) struct cmdline *cl,
8058 __attribute__((unused)) void *data)
8060 struct cmd_queue_rate_limit_result *res = parsed_result;
8063 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8064 && (strcmp(res->queue, "queue") == 0)
8065 && (strcmp(res->rate, "rate") == 0))
8066 ret = set_queue_rate_limit(res->port_num, res->queue_num,
8069 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
8073 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8074 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8076 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8077 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8079 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8080 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8082 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8083 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8085 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8086 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8088 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8089 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8091 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8092 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8095 cmdline_parse_inst_t cmd_queue_rate_limit = {
8096 .f = cmd_queue_rate_limit_parsed,
8098 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8099 "Set rate limit for a queue on port_id",
8101 (void *)&cmd_queue_rate_limit_set,
8102 (void *)&cmd_queue_rate_limit_port,
8103 (void *)&cmd_queue_rate_limit_portnum,
8104 (void *)&cmd_queue_rate_limit_queue,
8105 (void *)&cmd_queue_rate_limit_queuenum,
8106 (void *)&cmd_queue_rate_limit_rate,
8107 (void *)&cmd_queue_rate_limit_ratenum,
8112 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
8113 struct cmd_vf_rate_limit_result {
8114 cmdline_fixed_string_t set;
8115 cmdline_fixed_string_t port;
8117 cmdline_fixed_string_t vf;
8119 cmdline_fixed_string_t rate;
8121 cmdline_fixed_string_t q_msk;
8125 static void cmd_vf_rate_limit_parsed(void *parsed_result,
8126 __attribute__((unused)) struct cmdline *cl,
8127 __attribute__((unused)) void *data)
8129 struct cmd_vf_rate_limit_result *res = parsed_result;
8132 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8133 && (strcmp(res->vf, "vf") == 0)
8134 && (strcmp(res->rate, "rate") == 0)
8135 && (strcmp(res->q_msk, "queue_mask") == 0))
8136 ret = set_vf_rate_limit(res->port_num, res->vf_num,
8137 res->rate_num, res->q_msk_val);
8139 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
8143 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
8144 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8146 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
8147 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8149 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
8150 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8152 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
8153 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8155 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
8156 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8158 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
8159 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8161 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
8162 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8164 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
8165 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8166 q_msk, "queue_mask");
8167 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
8168 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8171 cmdline_parse_inst_t cmd_vf_rate_limit = {
8172 .f = cmd_vf_rate_limit_parsed,
8174 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
8175 "queue_mask <queue_mask_value>: "
8176 "Set rate limit for queues of VF on port_id",
8178 (void *)&cmd_vf_rate_limit_set,
8179 (void *)&cmd_vf_rate_limit_port,
8180 (void *)&cmd_vf_rate_limit_portnum,
8181 (void *)&cmd_vf_rate_limit_vf,
8182 (void *)&cmd_vf_rate_limit_vfnum,
8183 (void *)&cmd_vf_rate_limit_rate,
8184 (void *)&cmd_vf_rate_limit_ratenum,
8185 (void *)&cmd_vf_rate_limit_q_msk,
8186 (void *)&cmd_vf_rate_limit_q_msk_val,
8191 /* *** ADD TUNNEL FILTER OF A PORT *** */
8192 struct cmd_tunnel_filter_result {
8193 cmdline_fixed_string_t cmd;
8194 cmdline_fixed_string_t what;
8196 struct ether_addr outer_mac;
8197 struct ether_addr inner_mac;
8198 cmdline_ipaddr_t ip_value;
8199 uint16_t inner_vlan;
8200 cmdline_fixed_string_t tunnel_type;
8201 cmdline_fixed_string_t filter_type;
8207 cmd_tunnel_filter_parsed(void *parsed_result,
8208 __attribute__((unused)) struct cmdline *cl,
8209 __attribute__((unused)) void *data)
8211 struct cmd_tunnel_filter_result *res = parsed_result;
8212 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
8215 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
8217 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
8218 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
8219 tunnel_filter_conf.inner_vlan = res->inner_vlan;
8221 if (res->ip_value.family == AF_INET) {
8222 tunnel_filter_conf.ip_addr.ipv4_addr =
8223 res->ip_value.addr.ipv4.s_addr;
8224 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
8226 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
8227 &(res->ip_value.addr.ipv6),
8228 sizeof(struct in6_addr));
8229 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
8232 if (!strcmp(res->filter_type, "imac-ivlan"))
8233 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
8234 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
8235 tunnel_filter_conf.filter_type =
8236 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
8237 else if (!strcmp(res->filter_type, "imac-tenid"))
8238 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
8239 else if (!strcmp(res->filter_type, "imac"))
8240 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
8241 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
8242 tunnel_filter_conf.filter_type =
8243 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
8244 else if (!strcmp(res->filter_type, "oip"))
8245 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
8246 else if (!strcmp(res->filter_type, "iip"))
8247 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
8249 printf("The filter type is not supported");
8253 if (!strcmp(res->tunnel_type, "vxlan"))
8254 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
8255 else if (!strcmp(res->tunnel_type, "nvgre"))
8256 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
8257 else if (!strcmp(res->tunnel_type, "ipingre"))
8258 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
8260 printf("The tunnel type %s not supported.\n", res->tunnel_type);
8264 tunnel_filter_conf.tenant_id = res->tenant_id;
8265 tunnel_filter_conf.queue_id = res->queue_num;
8266 if (!strcmp(res->what, "add"))
8267 ret = rte_eth_dev_filter_ctrl(res->port_id,
8268 RTE_ETH_FILTER_TUNNEL,
8270 &tunnel_filter_conf);
8272 ret = rte_eth_dev_filter_ctrl(res->port_id,
8273 RTE_ETH_FILTER_TUNNEL,
8274 RTE_ETH_FILTER_DELETE,
8275 &tunnel_filter_conf);
8277 printf("cmd_tunnel_filter_parsed error: (%s)\n",
8281 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
8282 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8283 cmd, "tunnel_filter");
8284 cmdline_parse_token_string_t cmd_tunnel_filter_what =
8285 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8287 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
8288 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8290 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
8291 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8293 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
8294 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8296 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
8297 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8298 inner_vlan, UINT16);
8299 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
8300 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8302 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
8303 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8304 tunnel_type, "vxlan#nvgre#ipingre");
8306 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
8307 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8308 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
8309 "imac#omac-imac-tenid");
8310 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
8311 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8313 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
8314 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8317 cmdline_parse_inst_t cmd_tunnel_filter = {
8318 .f = cmd_tunnel_filter_parsed,
8320 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
8321 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
8322 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
8323 "<queue_id>: Add/Rm tunnel filter of a port",
8325 (void *)&cmd_tunnel_filter_cmd,
8326 (void *)&cmd_tunnel_filter_what,
8327 (void *)&cmd_tunnel_filter_port_id,
8328 (void *)&cmd_tunnel_filter_outer_mac,
8329 (void *)&cmd_tunnel_filter_inner_mac,
8330 (void *)&cmd_tunnel_filter_ip_value,
8331 (void *)&cmd_tunnel_filter_innner_vlan,
8332 (void *)&cmd_tunnel_filter_tunnel_type,
8333 (void *)&cmd_tunnel_filter_filter_type,
8334 (void *)&cmd_tunnel_filter_tenant_id,
8335 (void *)&cmd_tunnel_filter_queue_num,
8340 /* *** CONFIGURE TUNNEL UDP PORT *** */
8341 struct cmd_tunnel_udp_config {
8342 cmdline_fixed_string_t cmd;
8343 cmdline_fixed_string_t what;
8349 cmd_tunnel_udp_config_parsed(void *parsed_result,
8350 __attribute__((unused)) struct cmdline *cl,
8351 __attribute__((unused)) void *data)
8353 struct cmd_tunnel_udp_config *res = parsed_result;
8354 struct rte_eth_udp_tunnel tunnel_udp;
8357 tunnel_udp.udp_port = res->udp_port;
8359 if (!strcmp(res->cmd, "rx_vxlan_port"))
8360 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8362 if (!strcmp(res->what, "add"))
8363 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8366 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8370 printf("udp tunneling add error: (%s)\n", strerror(-ret));
8373 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
8374 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8375 cmd, "rx_vxlan_port");
8376 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
8377 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8379 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
8380 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8382 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
8383 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8386 cmdline_parse_inst_t cmd_tunnel_udp_config = {
8387 .f = cmd_tunnel_udp_config_parsed,
8389 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
8390 "Add/Remove a tunneling UDP port filter",
8392 (void *)&cmd_tunnel_udp_config_cmd,
8393 (void *)&cmd_tunnel_udp_config_what,
8394 (void *)&cmd_tunnel_udp_config_udp_port,
8395 (void *)&cmd_tunnel_udp_config_port_id,
8400 /* *** GLOBAL CONFIG *** */
8401 struct cmd_global_config_result {
8402 cmdline_fixed_string_t cmd;
8404 cmdline_fixed_string_t cfg_type;
8409 cmd_global_config_parsed(void *parsed_result,
8410 __attribute__((unused)) struct cmdline *cl,
8411 __attribute__((unused)) void *data)
8413 struct cmd_global_config_result *res = parsed_result;
8414 struct rte_eth_global_cfg conf;
8417 memset(&conf, 0, sizeof(conf));
8418 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
8419 conf.cfg.gre_key_len = res->len;
8420 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
8421 RTE_ETH_FILTER_SET, &conf);
8423 printf("Global config error\n");
8426 cmdline_parse_token_string_t cmd_global_config_cmd =
8427 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
8429 cmdline_parse_token_num_t cmd_global_config_port_id =
8430 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
8432 cmdline_parse_token_string_t cmd_global_config_type =
8433 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
8434 cfg_type, "gre-key-len");
8435 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
8436 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
8439 cmdline_parse_inst_t cmd_global_config = {
8440 .f = cmd_global_config_parsed,
8441 .data = (void *)NULL,
8442 .help_str = "global_config <port_id> gre-key-len <key_len>",
8444 (void *)&cmd_global_config_cmd,
8445 (void *)&cmd_global_config_port_id,
8446 (void *)&cmd_global_config_type,
8447 (void *)&cmd_global_config_gre_key_len,
8452 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
8453 struct cmd_set_mirror_mask_result {
8454 cmdline_fixed_string_t set;
8455 cmdline_fixed_string_t port;
8457 cmdline_fixed_string_t mirror;
8459 cmdline_fixed_string_t what;
8460 cmdline_fixed_string_t value;
8461 cmdline_fixed_string_t dstpool;
8463 cmdline_fixed_string_t on;
8466 cmdline_parse_token_string_t cmd_mirror_mask_set =
8467 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8469 cmdline_parse_token_string_t cmd_mirror_mask_port =
8470 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8472 cmdline_parse_token_num_t cmd_mirror_mask_portid =
8473 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8475 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
8476 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8477 mirror, "mirror-rule");
8478 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
8479 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8481 cmdline_parse_token_string_t cmd_mirror_mask_what =
8482 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8483 what, "pool-mirror-up#pool-mirror-down"
8485 cmdline_parse_token_string_t cmd_mirror_mask_value =
8486 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8488 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
8489 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8490 dstpool, "dst-pool");
8491 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
8492 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8494 cmdline_parse_token_string_t cmd_mirror_mask_on =
8495 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8499 cmd_set_mirror_mask_parsed(void *parsed_result,
8500 __attribute__((unused)) struct cmdline *cl,
8501 __attribute__((unused)) void *data)
8504 struct cmd_set_mirror_mask_result *res = parsed_result;
8505 struct rte_eth_mirror_conf mr_conf;
8507 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8509 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
8511 mr_conf.dst_pool = res->dstpool_id;
8513 if (!strcmp(res->what, "pool-mirror-up")) {
8514 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8515 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
8516 } else if (!strcmp(res->what, "pool-mirror-down")) {
8517 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8518 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
8519 } else if (!strcmp(res->what, "vlan-mirror")) {
8520 mr_conf.rule_type = ETH_MIRROR_VLAN;
8521 nb_item = parse_item_list(res->value, "vlan",
8522 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
8526 for (i = 0; i < nb_item; i++) {
8527 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
8528 printf("Invalid vlan_id: must be < 4096\n");
8532 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
8533 mr_conf.vlan.vlan_mask |= 1ULL << i;
8537 if (!strcmp(res->on, "on"))
8538 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8541 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8544 printf("mirror rule add error: (%s)\n", strerror(-ret));
8547 cmdline_parse_inst_t cmd_set_mirror_mask = {
8548 .f = cmd_set_mirror_mask_parsed,
8550 .help_str = "set port <port_id> mirror-rule <rule_id> "
8551 "pool-mirror-up|pool-mirror-down|vlan-mirror "
8552 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
8554 (void *)&cmd_mirror_mask_set,
8555 (void *)&cmd_mirror_mask_port,
8556 (void *)&cmd_mirror_mask_portid,
8557 (void *)&cmd_mirror_mask_mirror,
8558 (void *)&cmd_mirror_mask_ruleid,
8559 (void *)&cmd_mirror_mask_what,
8560 (void *)&cmd_mirror_mask_value,
8561 (void *)&cmd_mirror_mask_dstpool,
8562 (void *)&cmd_mirror_mask_poolid,
8563 (void *)&cmd_mirror_mask_on,
8568 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
8569 struct cmd_set_mirror_link_result {
8570 cmdline_fixed_string_t set;
8571 cmdline_fixed_string_t port;
8573 cmdline_fixed_string_t mirror;
8575 cmdline_fixed_string_t what;
8576 cmdline_fixed_string_t dstpool;
8578 cmdline_fixed_string_t on;
8581 cmdline_parse_token_string_t cmd_mirror_link_set =
8582 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8584 cmdline_parse_token_string_t cmd_mirror_link_port =
8585 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8587 cmdline_parse_token_num_t cmd_mirror_link_portid =
8588 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8590 cmdline_parse_token_string_t cmd_mirror_link_mirror =
8591 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8592 mirror, "mirror-rule");
8593 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
8594 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8596 cmdline_parse_token_string_t cmd_mirror_link_what =
8597 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8598 what, "uplink-mirror#downlink-mirror");
8599 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
8600 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8601 dstpool, "dst-pool");
8602 cmdline_parse_token_num_t cmd_mirror_link_poolid =
8603 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8605 cmdline_parse_token_string_t cmd_mirror_link_on =
8606 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8610 cmd_set_mirror_link_parsed(void *parsed_result,
8611 __attribute__((unused)) struct cmdline *cl,
8612 __attribute__((unused)) void *data)
8615 struct cmd_set_mirror_link_result *res = parsed_result;
8616 struct rte_eth_mirror_conf mr_conf;
8618 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8619 if (!strcmp(res->what, "uplink-mirror"))
8620 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
8622 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
8624 mr_conf.dst_pool = res->dstpool_id;
8626 if (!strcmp(res->on, "on"))
8627 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8630 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8633 /* check the return value and print it if is < 0 */
8635 printf("mirror rule add error: (%s)\n", strerror(-ret));
8639 cmdline_parse_inst_t cmd_set_mirror_link = {
8640 .f = cmd_set_mirror_link_parsed,
8642 .help_str = "set port <port_id> mirror-rule <rule_id> "
8643 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
8645 (void *)&cmd_mirror_link_set,
8646 (void *)&cmd_mirror_link_port,
8647 (void *)&cmd_mirror_link_portid,
8648 (void *)&cmd_mirror_link_mirror,
8649 (void *)&cmd_mirror_link_ruleid,
8650 (void *)&cmd_mirror_link_what,
8651 (void *)&cmd_mirror_link_dstpool,
8652 (void *)&cmd_mirror_link_poolid,
8653 (void *)&cmd_mirror_link_on,
8658 /* *** RESET VM MIRROR RULE *** */
8659 struct cmd_rm_mirror_rule_result {
8660 cmdline_fixed_string_t reset;
8661 cmdline_fixed_string_t port;
8663 cmdline_fixed_string_t mirror;
8667 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
8668 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8670 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
8671 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8673 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
8674 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
8676 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
8677 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8678 mirror, "mirror-rule");
8679 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
8680 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
8684 cmd_reset_mirror_rule_parsed(void *parsed_result,
8685 __attribute__((unused)) struct cmdline *cl,
8686 __attribute__((unused)) void *data)
8689 struct cmd_set_mirror_link_result *res = parsed_result;
8691 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
8693 printf("mirror rule remove error: (%s)\n", strerror(-ret));
8696 cmdline_parse_inst_t cmd_reset_mirror_rule = {
8697 .f = cmd_reset_mirror_rule_parsed,
8699 .help_str = "reset port <port_id> mirror-rule <rule_id>",
8701 (void *)&cmd_rm_mirror_rule_reset,
8702 (void *)&cmd_rm_mirror_rule_port,
8703 (void *)&cmd_rm_mirror_rule_portid,
8704 (void *)&cmd_rm_mirror_rule_mirror,
8705 (void *)&cmd_rm_mirror_rule_ruleid,
8710 /* ******************************************************************************** */
8712 struct cmd_dump_result {
8713 cmdline_fixed_string_t dump;
8717 dump_struct_sizes(void)
8719 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
8720 DUMP_SIZE(struct rte_mbuf);
8721 DUMP_SIZE(struct rte_mempool);
8722 DUMP_SIZE(struct rte_ring);
8726 static void cmd_dump_parsed(void *parsed_result,
8727 __attribute__((unused)) struct cmdline *cl,
8728 __attribute__((unused)) void *data)
8730 struct cmd_dump_result *res = parsed_result;
8732 if (!strcmp(res->dump, "dump_physmem"))
8733 rte_dump_physmem_layout(stdout);
8734 else if (!strcmp(res->dump, "dump_memzone"))
8735 rte_memzone_dump(stdout);
8736 else if (!strcmp(res->dump, "dump_struct_sizes"))
8737 dump_struct_sizes();
8738 else if (!strcmp(res->dump, "dump_ring"))
8739 rte_ring_list_dump(stdout);
8740 else if (!strcmp(res->dump, "dump_mempool"))
8741 rte_mempool_list_dump(stdout);
8742 else if (!strcmp(res->dump, "dump_devargs"))
8743 rte_eal_devargs_dump(stdout);
8744 else if (!strcmp(res->dump, "dump_log_types"))
8745 rte_log_dump(stdout);
8748 cmdline_parse_token_string_t cmd_dump_dump =
8749 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
8752 "dump_struct_sizes#"
8758 cmdline_parse_inst_t cmd_dump = {
8759 .f = cmd_dump_parsed, /* function to call */
8760 .data = NULL, /* 2nd arg of func */
8761 .help_str = "Dump status",
8762 .tokens = { /* token list, NULL terminated */
8763 (void *)&cmd_dump_dump,
8768 /* ******************************************************************************** */
8770 struct cmd_dump_one_result {
8771 cmdline_fixed_string_t dump;
8772 cmdline_fixed_string_t name;
8775 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
8776 __attribute__((unused)) void *data)
8778 struct cmd_dump_one_result *res = parsed_result;
8780 if (!strcmp(res->dump, "dump_ring")) {
8782 r = rte_ring_lookup(res->name);
8784 cmdline_printf(cl, "Cannot find ring\n");
8787 rte_ring_dump(stdout, r);
8788 } else if (!strcmp(res->dump, "dump_mempool")) {
8789 struct rte_mempool *mp;
8790 mp = rte_mempool_lookup(res->name);
8792 cmdline_printf(cl, "Cannot find mempool\n");
8795 rte_mempool_dump(stdout, mp);
8799 cmdline_parse_token_string_t cmd_dump_one_dump =
8800 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
8801 "dump_ring#dump_mempool");
8803 cmdline_parse_token_string_t cmd_dump_one_name =
8804 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
8806 cmdline_parse_inst_t cmd_dump_one = {
8807 .f = cmd_dump_one_parsed, /* function to call */
8808 .data = NULL, /* 2nd arg of func */
8809 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
8810 .tokens = { /* token list, NULL terminated */
8811 (void *)&cmd_dump_one_dump,
8812 (void *)&cmd_dump_one_name,
8817 /* *** Add/Del syn filter *** */
8818 struct cmd_syn_filter_result {
8819 cmdline_fixed_string_t filter;
8821 cmdline_fixed_string_t ops;
8822 cmdline_fixed_string_t priority;
8823 cmdline_fixed_string_t high;
8824 cmdline_fixed_string_t queue;
8829 cmd_syn_filter_parsed(void *parsed_result,
8830 __attribute__((unused)) struct cmdline *cl,
8831 __attribute__((unused)) void *data)
8833 struct cmd_syn_filter_result *res = parsed_result;
8834 struct rte_eth_syn_filter syn_filter;
8837 ret = rte_eth_dev_filter_supported(res->port_id,
8838 RTE_ETH_FILTER_SYN);
8840 printf("syn filter is not supported on port %u.\n",
8845 memset(&syn_filter, 0, sizeof(syn_filter));
8847 if (!strcmp(res->ops, "add")) {
8848 if (!strcmp(res->high, "high"))
8849 syn_filter.hig_pri = 1;
8851 syn_filter.hig_pri = 0;
8853 syn_filter.queue = res->queue_id;
8854 ret = rte_eth_dev_filter_ctrl(res->port_id,
8859 ret = rte_eth_dev_filter_ctrl(res->port_id,
8861 RTE_ETH_FILTER_DELETE,
8865 printf("syn filter programming error: (%s)\n",
8869 cmdline_parse_token_string_t cmd_syn_filter_filter =
8870 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8871 filter, "syn_filter");
8872 cmdline_parse_token_num_t cmd_syn_filter_port_id =
8873 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8875 cmdline_parse_token_string_t cmd_syn_filter_ops =
8876 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8878 cmdline_parse_token_string_t cmd_syn_filter_priority =
8879 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8880 priority, "priority");
8881 cmdline_parse_token_string_t cmd_syn_filter_high =
8882 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8884 cmdline_parse_token_string_t cmd_syn_filter_queue =
8885 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8887 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
8888 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8891 cmdline_parse_inst_t cmd_syn_filter = {
8892 .f = cmd_syn_filter_parsed,
8894 .help_str = "syn_filter <port_id> add|del priority high|low queue "
8895 "<queue_id>: Add/Delete syn filter",
8897 (void *)&cmd_syn_filter_filter,
8898 (void *)&cmd_syn_filter_port_id,
8899 (void *)&cmd_syn_filter_ops,
8900 (void *)&cmd_syn_filter_priority,
8901 (void *)&cmd_syn_filter_high,
8902 (void *)&cmd_syn_filter_queue,
8903 (void *)&cmd_syn_filter_queue_id,
8908 /* *** queue region set *** */
8909 struct cmd_queue_region_result {
8910 cmdline_fixed_string_t set;
8911 cmdline_fixed_string_t port;
8913 cmdline_fixed_string_t cmd;
8914 cmdline_fixed_string_t region;
8916 cmdline_fixed_string_t queue_start_index;
8918 cmdline_fixed_string_t queue_num;
8919 uint8_t queue_num_value;
8923 cmd_queue_region_parsed(void *parsed_result,
8924 __attribute__((unused)) struct cmdline *cl,
8925 __attribute__((unused)) void *data)
8927 struct cmd_queue_region_result *res = parsed_result;
8929 #ifdef RTE_LIBRTE_I40E_PMD
8930 struct rte_pmd_i40e_queue_region_conf region_conf;
8931 enum rte_pmd_i40e_queue_region_op op_type;
8934 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8937 #ifdef RTE_LIBRTE_I40E_PMD
8938 memset(®ion_conf, 0, sizeof(region_conf));
8939 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
8940 region_conf.region_id = res->region_id;
8941 region_conf.queue_num = res->queue_num_value;
8942 region_conf.queue_start_index = res->queue_id;
8944 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8945 op_type, ®ion_conf);
8952 printf("function not implemented or supported\n");
8955 printf("queue region config error: (%s)\n", strerror(-ret));
8959 cmdline_parse_token_string_t cmd_queue_region_set =
8960 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8962 cmdline_parse_token_string_t cmd_queue_region_port =
8963 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
8964 cmdline_parse_token_num_t cmd_queue_region_port_id =
8965 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8967 cmdline_parse_token_string_t cmd_queue_region_cmd =
8968 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8969 cmd, "queue-region");
8970 cmdline_parse_token_string_t cmd_queue_region_id =
8971 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8972 region, "region_id");
8973 cmdline_parse_token_num_t cmd_queue_region_index =
8974 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8976 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
8977 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8978 queue_start_index, "queue_start_index");
8979 cmdline_parse_token_num_t cmd_queue_region_queue_id =
8980 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8982 cmdline_parse_token_string_t cmd_queue_region_queue_num =
8983 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8984 queue_num, "queue_num");
8985 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
8986 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8987 queue_num_value, UINT8);
8989 cmdline_parse_inst_t cmd_queue_region = {
8990 .f = cmd_queue_region_parsed,
8992 .help_str = "set port <port_id> queue-region region_id <value> "
8993 "queue_start_index <value> queue_num <value>: Set a queue region",
8995 (void *)&cmd_queue_region_set,
8996 (void *)&cmd_queue_region_port,
8997 (void *)&cmd_queue_region_port_id,
8998 (void *)&cmd_queue_region_cmd,
8999 (void *)&cmd_queue_region_id,
9000 (void *)&cmd_queue_region_index,
9001 (void *)&cmd_queue_region_queue_start_index,
9002 (void *)&cmd_queue_region_queue_id,
9003 (void *)&cmd_queue_region_queue_num,
9004 (void *)&cmd_queue_region_queue_num_value,
9009 /* *** queue region and flowtype set *** */
9010 struct cmd_region_flowtype_result {
9011 cmdline_fixed_string_t set;
9012 cmdline_fixed_string_t port;
9014 cmdline_fixed_string_t cmd;
9015 cmdline_fixed_string_t region;
9017 cmdline_fixed_string_t flowtype;
9018 uint8_t flowtype_id;
9022 cmd_region_flowtype_parsed(void *parsed_result,
9023 __attribute__((unused)) struct cmdline *cl,
9024 __attribute__((unused)) void *data)
9026 struct cmd_region_flowtype_result *res = parsed_result;
9028 #ifdef RTE_LIBRTE_I40E_PMD
9029 struct rte_pmd_i40e_queue_region_conf region_conf;
9030 enum rte_pmd_i40e_queue_region_op op_type;
9033 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9036 #ifdef RTE_LIBRTE_I40E_PMD
9037 memset(®ion_conf, 0, sizeof(region_conf));
9039 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9040 region_conf.region_id = res->region_id;
9041 region_conf.hw_flowtype = res->flowtype_id;
9043 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9044 op_type, ®ion_conf);
9051 printf("function not implemented or supported\n");
9054 printf("region flowtype config error: (%s)\n", strerror(-ret));
9058 cmdline_parse_token_string_t cmd_region_flowtype_set =
9059 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9061 cmdline_parse_token_string_t cmd_region_flowtype_port =
9062 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9064 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9065 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9067 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9068 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9069 cmd, "queue-region");
9070 cmdline_parse_token_string_t cmd_region_flowtype_index =
9071 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9072 region, "region_id");
9073 cmdline_parse_token_num_t cmd_region_flowtype_id =
9074 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9076 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
9077 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9078 flowtype, "flowtype");
9079 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
9080 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9081 flowtype_id, UINT8);
9082 cmdline_parse_inst_t cmd_region_flowtype = {
9083 .f = cmd_region_flowtype_parsed,
9085 .help_str = "set port <port_id> queue-region region_id <value> "
9086 "flowtype <value>: Set a flowtype region index",
9088 (void *)&cmd_region_flowtype_set,
9089 (void *)&cmd_region_flowtype_port,
9090 (void *)&cmd_region_flowtype_port_index,
9091 (void *)&cmd_region_flowtype_cmd,
9092 (void *)&cmd_region_flowtype_index,
9093 (void *)&cmd_region_flowtype_id,
9094 (void *)&cmd_region_flowtype_flow_index,
9095 (void *)&cmd_region_flowtype_flow_id,
9100 /* *** User Priority (UP) to queue region (region_id) set *** */
9101 struct cmd_user_priority_region_result {
9102 cmdline_fixed_string_t set;
9103 cmdline_fixed_string_t port;
9105 cmdline_fixed_string_t cmd;
9106 cmdline_fixed_string_t user_priority;
9107 uint8_t user_priority_id;
9108 cmdline_fixed_string_t region;
9113 cmd_user_priority_region_parsed(void *parsed_result,
9114 __attribute__((unused)) struct cmdline *cl,
9115 __attribute__((unused)) void *data)
9117 struct cmd_user_priority_region_result *res = parsed_result;
9119 #ifdef RTE_LIBRTE_I40E_PMD
9120 struct rte_pmd_i40e_queue_region_conf region_conf;
9121 enum rte_pmd_i40e_queue_region_op op_type;
9124 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9127 #ifdef RTE_LIBRTE_I40E_PMD
9128 memset(®ion_conf, 0, sizeof(region_conf));
9129 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
9130 region_conf.user_priority = res->user_priority_id;
9131 region_conf.region_id = res->region_id;
9133 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9134 op_type, ®ion_conf);
9141 printf("function not implemented or supported\n");
9144 printf("user_priority region config error: (%s)\n",
9149 cmdline_parse_token_string_t cmd_user_priority_region_set =
9150 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9152 cmdline_parse_token_string_t cmd_user_priority_region_port =
9153 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9155 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
9156 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9158 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
9159 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9160 cmd, "queue-region");
9161 cmdline_parse_token_string_t cmd_user_priority_region_UP =
9162 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9163 user_priority, "UP");
9164 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
9165 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9166 user_priority_id, UINT8);
9167 cmdline_parse_token_string_t cmd_user_priority_region_region =
9168 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9169 region, "region_id");
9170 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
9171 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9174 cmdline_parse_inst_t cmd_user_priority_region = {
9175 .f = cmd_user_priority_region_parsed,
9177 .help_str = "set port <port_id> queue-region UP <value> "
9178 "region_id <value>: Set the mapping of User Priority (UP) "
9179 "to queue region (region_id) ",
9181 (void *)&cmd_user_priority_region_set,
9182 (void *)&cmd_user_priority_region_port,
9183 (void *)&cmd_user_priority_region_port_index,
9184 (void *)&cmd_user_priority_region_cmd,
9185 (void *)&cmd_user_priority_region_UP,
9186 (void *)&cmd_user_priority_region_UP_id,
9187 (void *)&cmd_user_priority_region_region,
9188 (void *)&cmd_user_priority_region_region_id,
9193 /* *** flush all queue region related configuration *** */
9194 struct cmd_flush_queue_region_result {
9195 cmdline_fixed_string_t set;
9196 cmdline_fixed_string_t port;
9198 cmdline_fixed_string_t cmd;
9199 cmdline_fixed_string_t flush;
9200 cmdline_fixed_string_t what;
9204 cmd_flush_queue_region_parsed(void *parsed_result,
9205 __attribute__((unused)) struct cmdline *cl,
9206 __attribute__((unused)) void *data)
9208 struct cmd_flush_queue_region_result *res = parsed_result;
9210 #ifdef RTE_LIBRTE_I40E_PMD
9211 struct rte_pmd_i40e_queue_region_conf region_conf;
9212 enum rte_pmd_i40e_queue_region_op op_type;
9215 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9218 #ifdef RTE_LIBRTE_I40E_PMD
9219 memset(®ion_conf, 0, sizeof(region_conf));
9221 if (strcmp(res->what, "on") == 0)
9222 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
9224 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
9226 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9227 op_type, ®ion_conf);
9234 printf("function not implemented or supported\n");
9237 printf("queue region config flush error: (%s)\n",
9242 cmdline_parse_token_string_t cmd_flush_queue_region_set =
9243 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9245 cmdline_parse_token_string_t cmd_flush_queue_region_port =
9246 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9248 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
9249 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
9251 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
9252 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9253 cmd, "queue-region");
9254 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
9255 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9257 cmdline_parse_token_string_t cmd_flush_queue_region_what =
9258 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9261 cmdline_parse_inst_t cmd_flush_queue_region = {
9262 .f = cmd_flush_queue_region_parsed,
9264 .help_str = "set port <port_id> queue-region flush on|off"
9265 ": flush all queue region related configuration",
9267 (void *)&cmd_flush_queue_region_set,
9268 (void *)&cmd_flush_queue_region_port,
9269 (void *)&cmd_flush_queue_region_port_index,
9270 (void *)&cmd_flush_queue_region_cmd,
9271 (void *)&cmd_flush_queue_region_flush,
9272 (void *)&cmd_flush_queue_region_what,
9277 /* *** get all queue region related configuration info *** */
9278 struct cmd_show_queue_region_info {
9279 cmdline_fixed_string_t show;
9280 cmdline_fixed_string_t port;
9282 cmdline_fixed_string_t cmd;
9286 cmd_show_queue_region_info_parsed(void *parsed_result,
9287 __attribute__((unused)) struct cmdline *cl,
9288 __attribute__((unused)) void *data)
9290 struct cmd_show_queue_region_info *res = parsed_result;
9292 #ifdef RTE_LIBRTE_I40E_PMD
9293 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
9294 enum rte_pmd_i40e_queue_region_op op_type;
9297 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9300 #ifdef RTE_LIBRTE_I40E_PMD
9301 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
9303 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
9305 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9306 op_type, &rte_pmd_regions);
9308 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
9315 printf("function not implemented or supported\n");
9318 printf("queue region config info show error: (%s)\n",
9323 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
9324 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9326 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
9327 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9329 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
9330 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
9332 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
9333 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9334 cmd, "queue-region");
9336 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
9337 .f = cmd_show_queue_region_info_parsed,
9339 .help_str = "show port <port_id> queue-region"
9340 ": show all queue region related configuration info",
9342 (void *)&cmd_show_queue_region_info_get,
9343 (void *)&cmd_show_queue_region_info_port,
9344 (void *)&cmd_show_queue_region_info_port_index,
9345 (void *)&cmd_show_queue_region_info_cmd,
9350 /* *** ADD/REMOVE A 2tuple FILTER *** */
9351 struct cmd_2tuple_filter_result {
9352 cmdline_fixed_string_t filter;
9354 cmdline_fixed_string_t ops;
9355 cmdline_fixed_string_t dst_port;
9356 uint16_t dst_port_value;
9357 cmdline_fixed_string_t protocol;
9358 uint8_t protocol_value;
9359 cmdline_fixed_string_t mask;
9361 cmdline_fixed_string_t tcp_flags;
9362 uint8_t tcp_flags_value;
9363 cmdline_fixed_string_t priority;
9364 uint8_t priority_value;
9365 cmdline_fixed_string_t queue;
9370 cmd_2tuple_filter_parsed(void *parsed_result,
9371 __attribute__((unused)) struct cmdline *cl,
9372 __attribute__((unused)) void *data)
9374 struct rte_eth_ntuple_filter filter;
9375 struct cmd_2tuple_filter_result *res = parsed_result;
9378 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9380 printf("ntuple filter is not supported on port %u.\n",
9385 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9387 filter.flags = RTE_2TUPLE_FLAGS;
9388 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9389 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9390 filter.proto = res->protocol_value;
9391 filter.priority = res->priority_value;
9392 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9393 printf("nonzero tcp_flags is only meaningful"
9394 " when protocol is TCP.\n");
9397 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9398 printf("invalid TCP flags.\n");
9402 if (res->tcp_flags_value != 0) {
9403 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9404 filter.tcp_flags = res->tcp_flags_value;
9407 /* need convert to big endian. */
9408 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9409 filter.queue = res->queue_id;
9411 if (!strcmp(res->ops, "add"))
9412 ret = rte_eth_dev_filter_ctrl(res->port_id,
9413 RTE_ETH_FILTER_NTUPLE,
9417 ret = rte_eth_dev_filter_ctrl(res->port_id,
9418 RTE_ETH_FILTER_NTUPLE,
9419 RTE_ETH_FILTER_DELETE,
9422 printf("2tuple filter programming error: (%s)\n",
9427 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
9428 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9429 filter, "2tuple_filter");
9430 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
9431 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9433 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
9434 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9436 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
9437 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9438 dst_port, "dst_port");
9439 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
9440 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9441 dst_port_value, UINT16);
9442 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
9443 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9444 protocol, "protocol");
9445 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
9446 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9447 protocol_value, UINT8);
9448 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
9449 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9451 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
9452 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9454 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
9455 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9456 tcp_flags, "tcp_flags");
9457 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
9458 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9459 tcp_flags_value, UINT8);
9460 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
9461 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9462 priority, "priority");
9463 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
9464 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9465 priority_value, UINT8);
9466 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
9467 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9469 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
9470 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9473 cmdline_parse_inst_t cmd_2tuple_filter = {
9474 .f = cmd_2tuple_filter_parsed,
9476 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
9477 "<value> mask <value> tcp_flags <value> priority <value> queue "
9478 "<queue_id>: Add a 2tuple filter",
9480 (void *)&cmd_2tuple_filter_filter,
9481 (void *)&cmd_2tuple_filter_port_id,
9482 (void *)&cmd_2tuple_filter_ops,
9483 (void *)&cmd_2tuple_filter_dst_port,
9484 (void *)&cmd_2tuple_filter_dst_port_value,
9485 (void *)&cmd_2tuple_filter_protocol,
9486 (void *)&cmd_2tuple_filter_protocol_value,
9487 (void *)&cmd_2tuple_filter_mask,
9488 (void *)&cmd_2tuple_filter_mask_value,
9489 (void *)&cmd_2tuple_filter_tcp_flags,
9490 (void *)&cmd_2tuple_filter_tcp_flags_value,
9491 (void *)&cmd_2tuple_filter_priority,
9492 (void *)&cmd_2tuple_filter_priority_value,
9493 (void *)&cmd_2tuple_filter_queue,
9494 (void *)&cmd_2tuple_filter_queue_id,
9499 /* *** ADD/REMOVE A 5tuple FILTER *** */
9500 struct cmd_5tuple_filter_result {
9501 cmdline_fixed_string_t filter;
9503 cmdline_fixed_string_t ops;
9504 cmdline_fixed_string_t dst_ip;
9505 cmdline_ipaddr_t dst_ip_value;
9506 cmdline_fixed_string_t src_ip;
9507 cmdline_ipaddr_t src_ip_value;
9508 cmdline_fixed_string_t dst_port;
9509 uint16_t dst_port_value;
9510 cmdline_fixed_string_t src_port;
9511 uint16_t src_port_value;
9512 cmdline_fixed_string_t protocol;
9513 uint8_t protocol_value;
9514 cmdline_fixed_string_t mask;
9516 cmdline_fixed_string_t tcp_flags;
9517 uint8_t tcp_flags_value;
9518 cmdline_fixed_string_t priority;
9519 uint8_t priority_value;
9520 cmdline_fixed_string_t queue;
9525 cmd_5tuple_filter_parsed(void *parsed_result,
9526 __attribute__((unused)) struct cmdline *cl,
9527 __attribute__((unused)) void *data)
9529 struct rte_eth_ntuple_filter filter;
9530 struct cmd_5tuple_filter_result *res = parsed_result;
9533 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9535 printf("ntuple filter is not supported on port %u.\n",
9540 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9542 filter.flags = RTE_5TUPLE_FLAGS;
9543 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
9544 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
9545 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
9546 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9547 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9548 filter.proto = res->protocol_value;
9549 filter.priority = res->priority_value;
9550 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9551 printf("nonzero tcp_flags is only meaningful"
9552 " when protocol is TCP.\n");
9555 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9556 printf("invalid TCP flags.\n");
9560 if (res->tcp_flags_value != 0) {
9561 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9562 filter.tcp_flags = res->tcp_flags_value;
9565 if (res->dst_ip_value.family == AF_INET)
9566 /* no need to convert, already big endian. */
9567 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
9569 if (filter.dst_ip_mask == 0) {
9570 printf("can not support ipv6 involved compare.\n");
9576 if (res->src_ip_value.family == AF_INET)
9577 /* no need to convert, already big endian. */
9578 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
9580 if (filter.src_ip_mask == 0) {
9581 printf("can not support ipv6 involved compare.\n");
9586 /* need convert to big endian. */
9587 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9588 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
9589 filter.queue = res->queue_id;
9591 if (!strcmp(res->ops, "add"))
9592 ret = rte_eth_dev_filter_ctrl(res->port_id,
9593 RTE_ETH_FILTER_NTUPLE,
9597 ret = rte_eth_dev_filter_ctrl(res->port_id,
9598 RTE_ETH_FILTER_NTUPLE,
9599 RTE_ETH_FILTER_DELETE,
9602 printf("5tuple filter programming error: (%s)\n",
9606 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
9607 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9608 filter, "5tuple_filter");
9609 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
9610 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9612 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
9613 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9615 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
9616 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9618 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
9619 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9621 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
9622 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9624 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
9625 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9627 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
9628 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9629 dst_port, "dst_port");
9630 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
9631 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9632 dst_port_value, UINT16);
9633 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
9634 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9635 src_port, "src_port");
9636 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
9637 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9638 src_port_value, UINT16);
9639 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
9640 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9641 protocol, "protocol");
9642 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
9643 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9644 protocol_value, UINT8);
9645 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
9646 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9648 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
9649 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9651 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
9652 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9653 tcp_flags, "tcp_flags");
9654 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
9655 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9656 tcp_flags_value, UINT8);
9657 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
9658 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9659 priority, "priority");
9660 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
9661 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9662 priority_value, UINT8);
9663 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
9664 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9666 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
9667 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9670 cmdline_parse_inst_t cmd_5tuple_filter = {
9671 .f = cmd_5tuple_filter_parsed,
9673 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
9674 "src_ip <value> dst_port <value> src_port <value> "
9675 "protocol <value> mask <value> tcp_flags <value> "
9676 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
9678 (void *)&cmd_5tuple_filter_filter,
9679 (void *)&cmd_5tuple_filter_port_id,
9680 (void *)&cmd_5tuple_filter_ops,
9681 (void *)&cmd_5tuple_filter_dst_ip,
9682 (void *)&cmd_5tuple_filter_dst_ip_value,
9683 (void *)&cmd_5tuple_filter_src_ip,
9684 (void *)&cmd_5tuple_filter_src_ip_value,
9685 (void *)&cmd_5tuple_filter_dst_port,
9686 (void *)&cmd_5tuple_filter_dst_port_value,
9687 (void *)&cmd_5tuple_filter_src_port,
9688 (void *)&cmd_5tuple_filter_src_port_value,
9689 (void *)&cmd_5tuple_filter_protocol,
9690 (void *)&cmd_5tuple_filter_protocol_value,
9691 (void *)&cmd_5tuple_filter_mask,
9692 (void *)&cmd_5tuple_filter_mask_value,
9693 (void *)&cmd_5tuple_filter_tcp_flags,
9694 (void *)&cmd_5tuple_filter_tcp_flags_value,
9695 (void *)&cmd_5tuple_filter_priority,
9696 (void *)&cmd_5tuple_filter_priority_value,
9697 (void *)&cmd_5tuple_filter_queue,
9698 (void *)&cmd_5tuple_filter_queue_id,
9703 /* *** ADD/REMOVE A flex FILTER *** */
9704 struct cmd_flex_filter_result {
9705 cmdline_fixed_string_t filter;
9706 cmdline_fixed_string_t ops;
9708 cmdline_fixed_string_t len;
9710 cmdline_fixed_string_t bytes;
9711 cmdline_fixed_string_t bytes_value;
9712 cmdline_fixed_string_t mask;
9713 cmdline_fixed_string_t mask_value;
9714 cmdline_fixed_string_t priority;
9715 uint8_t priority_value;
9716 cmdline_fixed_string_t queue;
9720 static int xdigit2val(unsigned char c)
9725 else if (isupper(c))
9733 cmd_flex_filter_parsed(void *parsed_result,
9734 __attribute__((unused)) struct cmdline *cl,
9735 __attribute__((unused)) void *data)
9738 struct rte_eth_flex_filter filter;
9739 struct cmd_flex_filter_result *res = parsed_result;
9740 char *bytes_ptr, *mask_ptr;
9741 uint16_t len, i, j = 0;
9746 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
9747 printf("the len exceed the max length 128\n");
9750 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
9751 filter.len = res->len_value;
9752 filter.priority = res->priority_value;
9753 filter.queue = res->queue_id;
9754 bytes_ptr = res->bytes_value;
9755 mask_ptr = res->mask_value;
9757 /* translate bytes string to array. */
9758 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
9759 (bytes_ptr[1] == 'X')))
9761 len = strnlen(bytes_ptr, res->len_value * 2);
9762 if (len == 0 || (len % 8 != 0)) {
9763 printf("please check len and bytes input\n");
9766 for (i = 0; i < len; i++) {
9768 if (isxdigit(c) == 0) {
9769 /* invalid characters. */
9770 printf("invalid input\n");
9773 val = xdigit2val(c);
9776 filter.bytes[j] = byte;
9777 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
9784 /* translate mask string to uint8_t array. */
9785 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
9786 (mask_ptr[1] == 'X')))
9788 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
9790 printf("invalid input\n");
9795 for (i = 0; i < len; i++) {
9797 if (isxdigit(c) == 0) {
9798 /* invalid characters. */
9799 printf("invalid input\n");
9802 val = xdigit2val(c);
9805 filter.mask[j] = byte;
9806 printf("mask[%d]:%02x ", j, filter.mask[j]);
9814 if (!strcmp(res->ops, "add"))
9815 ret = rte_eth_dev_filter_ctrl(res->port_id,
9816 RTE_ETH_FILTER_FLEXIBLE,
9820 ret = rte_eth_dev_filter_ctrl(res->port_id,
9821 RTE_ETH_FILTER_FLEXIBLE,
9822 RTE_ETH_FILTER_DELETE,
9826 printf("flex filter setting error: (%s)\n", strerror(-ret));
9829 cmdline_parse_token_string_t cmd_flex_filter_filter =
9830 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9831 filter, "flex_filter");
9832 cmdline_parse_token_num_t cmd_flex_filter_port_id =
9833 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9835 cmdline_parse_token_string_t cmd_flex_filter_ops =
9836 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9838 cmdline_parse_token_string_t cmd_flex_filter_len =
9839 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9841 cmdline_parse_token_num_t cmd_flex_filter_len_value =
9842 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9844 cmdline_parse_token_string_t cmd_flex_filter_bytes =
9845 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9847 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
9848 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9850 cmdline_parse_token_string_t cmd_flex_filter_mask =
9851 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9853 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
9854 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9856 cmdline_parse_token_string_t cmd_flex_filter_priority =
9857 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9858 priority, "priority");
9859 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
9860 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9861 priority_value, UINT8);
9862 cmdline_parse_token_string_t cmd_flex_filter_queue =
9863 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9865 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
9866 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9868 cmdline_parse_inst_t cmd_flex_filter = {
9869 .f = cmd_flex_filter_parsed,
9871 .help_str = "flex_filter <port_id> add|del len <value> bytes "
9872 "<value> mask <value> priority <value> queue <queue_id>: "
9873 "Add/Del a flex filter",
9875 (void *)&cmd_flex_filter_filter,
9876 (void *)&cmd_flex_filter_port_id,
9877 (void *)&cmd_flex_filter_ops,
9878 (void *)&cmd_flex_filter_len,
9879 (void *)&cmd_flex_filter_len_value,
9880 (void *)&cmd_flex_filter_bytes,
9881 (void *)&cmd_flex_filter_bytes_value,
9882 (void *)&cmd_flex_filter_mask,
9883 (void *)&cmd_flex_filter_mask_value,
9884 (void *)&cmd_flex_filter_priority,
9885 (void *)&cmd_flex_filter_priority_value,
9886 (void *)&cmd_flex_filter_queue,
9887 (void *)&cmd_flex_filter_queue_id,
9892 /* *** Filters Control *** */
9894 /* *** deal with ethertype filter *** */
9895 struct cmd_ethertype_filter_result {
9896 cmdline_fixed_string_t filter;
9898 cmdline_fixed_string_t ops;
9899 cmdline_fixed_string_t mac;
9900 struct ether_addr mac_addr;
9901 cmdline_fixed_string_t ethertype;
9902 uint16_t ethertype_value;
9903 cmdline_fixed_string_t drop;
9904 cmdline_fixed_string_t queue;
9908 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
9909 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9910 filter, "ethertype_filter");
9911 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
9912 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9914 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
9915 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9917 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
9918 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9919 mac, "mac_addr#mac_ignr");
9920 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
9921 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
9923 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
9924 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9925 ethertype, "ethertype");
9926 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
9927 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9928 ethertype_value, UINT16);
9929 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
9930 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9932 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
9933 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9935 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
9936 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9940 cmd_ethertype_filter_parsed(void *parsed_result,
9941 __attribute__((unused)) struct cmdline *cl,
9942 __attribute__((unused)) void *data)
9944 struct cmd_ethertype_filter_result *res = parsed_result;
9945 struct rte_eth_ethertype_filter filter;
9948 ret = rte_eth_dev_filter_supported(res->port_id,
9949 RTE_ETH_FILTER_ETHERTYPE);
9951 printf("ethertype filter is not supported on port %u.\n",
9956 memset(&filter, 0, sizeof(filter));
9957 if (!strcmp(res->mac, "mac_addr")) {
9958 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
9959 rte_memcpy(&filter.mac_addr, &res->mac_addr,
9960 sizeof(struct ether_addr));
9962 if (!strcmp(res->drop, "drop"))
9963 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
9964 filter.ether_type = res->ethertype_value;
9965 filter.queue = res->queue_id;
9967 if (!strcmp(res->ops, "add"))
9968 ret = rte_eth_dev_filter_ctrl(res->port_id,
9969 RTE_ETH_FILTER_ETHERTYPE,
9973 ret = rte_eth_dev_filter_ctrl(res->port_id,
9974 RTE_ETH_FILTER_ETHERTYPE,
9975 RTE_ETH_FILTER_DELETE,
9978 printf("ethertype filter programming error: (%s)\n",
9982 cmdline_parse_inst_t cmd_ethertype_filter = {
9983 .f = cmd_ethertype_filter_parsed,
9985 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
9986 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
9987 "Add or delete an ethertype filter entry",
9989 (void *)&cmd_ethertype_filter_filter,
9990 (void *)&cmd_ethertype_filter_port_id,
9991 (void *)&cmd_ethertype_filter_ops,
9992 (void *)&cmd_ethertype_filter_mac,
9993 (void *)&cmd_ethertype_filter_mac_addr,
9994 (void *)&cmd_ethertype_filter_ethertype,
9995 (void *)&cmd_ethertype_filter_ethertype_value,
9996 (void *)&cmd_ethertype_filter_drop,
9997 (void *)&cmd_ethertype_filter_queue,
9998 (void *)&cmd_ethertype_filter_queue_id,
10003 /* *** deal with flow director filter *** */
10004 struct cmd_flow_director_result {
10005 cmdline_fixed_string_t flow_director_filter;
10007 cmdline_fixed_string_t mode;
10008 cmdline_fixed_string_t mode_value;
10009 cmdline_fixed_string_t ops;
10010 cmdline_fixed_string_t flow;
10011 cmdline_fixed_string_t flow_type;
10012 cmdline_fixed_string_t ether;
10013 uint16_t ether_type;
10014 cmdline_fixed_string_t src;
10015 cmdline_ipaddr_t ip_src;
10017 cmdline_fixed_string_t dst;
10018 cmdline_ipaddr_t ip_dst;
10020 cmdline_fixed_string_t verify_tag;
10021 uint32_t verify_tag_value;
10022 cmdline_fixed_string_t tos;
10024 cmdline_fixed_string_t proto;
10025 uint8_t proto_value;
10026 cmdline_fixed_string_t ttl;
10028 cmdline_fixed_string_t vlan;
10029 uint16_t vlan_value;
10030 cmdline_fixed_string_t flexbytes;
10031 cmdline_fixed_string_t flexbytes_value;
10032 cmdline_fixed_string_t pf_vf;
10033 cmdline_fixed_string_t drop;
10034 cmdline_fixed_string_t queue;
10036 cmdline_fixed_string_t fd_id;
10037 uint32_t fd_id_value;
10038 cmdline_fixed_string_t mac;
10039 struct ether_addr mac_addr;
10040 cmdline_fixed_string_t tunnel;
10041 cmdline_fixed_string_t tunnel_type;
10042 cmdline_fixed_string_t tunnel_id;
10043 uint32_t tunnel_id_value;
10044 cmdline_fixed_string_t packet;
10049 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
10052 const char *p, *p0 = q_arg;
10054 unsigned long int_fld;
10055 char *str_fld[max_num];
10060 p = strchr(p0, '(');
10064 p0 = strchr(p, ')');
10069 if (size >= sizeof(s))
10072 snprintf(s, sizeof(s), "%.*s", size, p);
10073 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10074 if (ret < 0 || ret > max_num)
10076 for (i = 0; i < ret; i++) {
10078 int_fld = strtoul(str_fld[i], &end, 0);
10079 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
10081 flexbytes[i] = (uint8_t)int_fld;
10087 str2flowtype(char *string)
10090 static const struct {
10093 } flowtype_str[] = {
10094 {"raw", RTE_ETH_FLOW_RAW},
10095 {"ipv4", RTE_ETH_FLOW_IPV4},
10096 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10097 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10098 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10099 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10100 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10101 {"ipv6", RTE_ETH_FLOW_IPV6},
10102 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10103 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10104 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10105 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10106 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10107 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10110 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10111 if (!strcmp(flowtype_str[i].str, string))
10112 return flowtype_str[i].type;
10115 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10116 return (uint16_t)atoi(string);
10118 return RTE_ETH_FLOW_UNKNOWN;
10121 static enum rte_eth_fdir_tunnel_type
10122 str2fdir_tunneltype(char *string)
10126 static const struct {
10128 enum rte_eth_fdir_tunnel_type type;
10129 } tunneltype_str[] = {
10130 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
10131 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
10134 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
10135 if (!strcmp(tunneltype_str[i].str, string))
10136 return tunneltype_str[i].type;
10138 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
10141 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10143 if ((ip_addr).family == AF_INET) \
10144 (ip) = (ip_addr).addr.ipv4.s_addr; \
10146 printf("invalid parameter.\n"); \
10151 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10153 if ((ip_addr).family == AF_INET6) \
10154 rte_memcpy(&(ip), \
10155 &((ip_addr).addr.ipv6), \
10156 sizeof(struct in6_addr)); \
10158 printf("invalid parameter.\n"); \
10164 cmd_flow_director_filter_parsed(void *parsed_result,
10165 __attribute__((unused)) struct cmdline *cl,
10166 __attribute__((unused)) void *data)
10168 struct cmd_flow_director_result *res = parsed_result;
10169 struct rte_eth_fdir_filter entry;
10170 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
10172 unsigned long vf_id;
10175 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10177 printf("flow director is not supported on port %u.\n",
10181 memset(flexbytes, 0, sizeof(flexbytes));
10182 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
10184 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10185 if (strcmp(res->mode_value, "MAC-VLAN")) {
10186 printf("Please set mode to MAC-VLAN.\n");
10189 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10190 if (strcmp(res->mode_value, "Tunnel")) {
10191 printf("Please set mode to Tunnel.\n");
10195 if (!strcmp(res->mode_value, "raw")) {
10196 #ifdef RTE_LIBRTE_I40E_PMD
10197 struct rte_pmd_i40e_flow_type_mapping
10198 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10199 struct rte_pmd_i40e_pkt_template_conf conf;
10200 uint16_t flow_type = str2flowtype(res->flow_type);
10201 uint16_t i, port = res->port_id;
10204 memset(&conf, 0, sizeof(conf));
10206 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10207 printf("Invalid flow type specified.\n");
10210 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10214 if (mapping[flow_type].pctype == 0ULL) {
10215 printf("Invalid flow type specified.\n");
10218 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10219 if (mapping[flow_type].pctype & (1ULL << i)) {
10220 conf.input.pctype = i;
10225 conf.input.packet = open_file(res->filepath,
10226 &conf.input.length);
10227 if (!conf.input.packet)
10229 if (!strcmp(res->drop, "drop"))
10230 conf.action.behavior =
10231 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10233 conf.action.behavior =
10234 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10235 conf.action.report_status =
10236 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10237 conf.action.rx_queue = res->queue_id;
10238 conf.soft_id = res->fd_id_value;
10239 add = strcmp(res->ops, "del") ? 1 : 0;
10240 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10244 printf("flow director config error: (%s)\n",
10246 close_file(conf.input.packet);
10249 } else if (strcmp(res->mode_value, "IP")) {
10250 printf("Please set mode to IP or raw.\n");
10253 entry.input.flow_type = str2flowtype(res->flow_type);
10256 ret = parse_flexbytes(res->flexbytes_value,
10258 RTE_ETH_FDIR_MAX_FLEXLEN);
10260 printf("error: Cannot parse flexbytes input.\n");
10264 switch (entry.input.flow_type) {
10265 case RTE_ETH_FLOW_FRAG_IPV4:
10266 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
10267 entry.input.flow.ip4_flow.proto = res->proto_value;
10269 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
10270 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
10271 IPV4_ADDR_TO_UINT(res->ip_dst,
10272 entry.input.flow.ip4_flow.dst_ip);
10273 IPV4_ADDR_TO_UINT(res->ip_src,
10274 entry.input.flow.ip4_flow.src_ip);
10275 entry.input.flow.ip4_flow.tos = res->tos_value;
10276 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10277 /* need convert to big endian. */
10278 entry.input.flow.udp4_flow.dst_port =
10279 rte_cpu_to_be_16(res->port_dst);
10280 entry.input.flow.udp4_flow.src_port =
10281 rte_cpu_to_be_16(res->port_src);
10283 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
10284 IPV4_ADDR_TO_UINT(res->ip_dst,
10285 entry.input.flow.sctp4_flow.ip.dst_ip);
10286 IPV4_ADDR_TO_UINT(res->ip_src,
10287 entry.input.flow.sctp4_flow.ip.src_ip);
10288 entry.input.flow.ip4_flow.tos = res->tos_value;
10289 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10290 /* need convert to big endian. */
10291 entry.input.flow.sctp4_flow.dst_port =
10292 rte_cpu_to_be_16(res->port_dst);
10293 entry.input.flow.sctp4_flow.src_port =
10294 rte_cpu_to_be_16(res->port_src);
10295 entry.input.flow.sctp4_flow.verify_tag =
10296 rte_cpu_to_be_32(res->verify_tag_value);
10298 case RTE_ETH_FLOW_FRAG_IPV6:
10299 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
10300 entry.input.flow.ipv6_flow.proto = res->proto_value;
10302 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
10303 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
10304 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10305 entry.input.flow.ipv6_flow.dst_ip);
10306 IPV6_ADDR_TO_ARRAY(res->ip_src,
10307 entry.input.flow.ipv6_flow.src_ip);
10308 entry.input.flow.ipv6_flow.tc = res->tos_value;
10309 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10310 /* need convert to big endian. */
10311 entry.input.flow.udp6_flow.dst_port =
10312 rte_cpu_to_be_16(res->port_dst);
10313 entry.input.flow.udp6_flow.src_port =
10314 rte_cpu_to_be_16(res->port_src);
10316 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
10317 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10318 entry.input.flow.sctp6_flow.ip.dst_ip);
10319 IPV6_ADDR_TO_ARRAY(res->ip_src,
10320 entry.input.flow.sctp6_flow.ip.src_ip);
10321 entry.input.flow.ipv6_flow.tc = res->tos_value;
10322 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10323 /* need convert to big endian. */
10324 entry.input.flow.sctp6_flow.dst_port =
10325 rte_cpu_to_be_16(res->port_dst);
10326 entry.input.flow.sctp6_flow.src_port =
10327 rte_cpu_to_be_16(res->port_src);
10328 entry.input.flow.sctp6_flow.verify_tag =
10329 rte_cpu_to_be_32(res->verify_tag_value);
10331 case RTE_ETH_FLOW_L2_PAYLOAD:
10332 entry.input.flow.l2_flow.ether_type =
10333 rte_cpu_to_be_16(res->ether_type);
10339 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
10340 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
10342 sizeof(struct ether_addr));
10344 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10345 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
10347 sizeof(struct ether_addr));
10348 entry.input.flow.tunnel_flow.tunnel_type =
10349 str2fdir_tunneltype(res->tunnel_type);
10350 entry.input.flow.tunnel_flow.tunnel_id =
10351 rte_cpu_to_be_32(res->tunnel_id_value);
10354 rte_memcpy(entry.input.flow_ext.flexbytes,
10356 RTE_ETH_FDIR_MAX_FLEXLEN);
10358 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
10360 entry.action.flex_off = 0; /*use 0 by default */
10361 if (!strcmp(res->drop, "drop"))
10362 entry.action.behavior = RTE_ETH_FDIR_REJECT;
10364 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
10366 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
10367 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
10368 if (!strcmp(res->pf_vf, "pf"))
10369 entry.input.flow_ext.is_vf = 0;
10370 else if (!strncmp(res->pf_vf, "vf", 2)) {
10371 struct rte_eth_dev_info dev_info;
10373 memset(&dev_info, 0, sizeof(dev_info));
10374 rte_eth_dev_info_get(res->port_id, &dev_info);
10376 vf_id = strtoul(res->pf_vf + 2, &end, 10);
10377 if (errno != 0 || *end != '\0' ||
10378 vf_id >= dev_info.max_vfs) {
10379 printf("invalid parameter %s.\n", res->pf_vf);
10382 entry.input.flow_ext.is_vf = 1;
10383 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
10385 printf("invalid parameter %s.\n", res->pf_vf);
10390 /* set to report FD ID by default */
10391 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
10392 entry.action.rx_queue = res->queue_id;
10393 entry.soft_id = res->fd_id_value;
10394 if (!strcmp(res->ops, "add"))
10395 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10396 RTE_ETH_FILTER_ADD, &entry);
10397 else if (!strcmp(res->ops, "del"))
10398 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10399 RTE_ETH_FILTER_DELETE, &entry);
10401 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10402 RTE_ETH_FILTER_UPDATE, &entry);
10404 printf("flow director programming error: (%s)\n",
10408 cmdline_parse_token_string_t cmd_flow_director_filter =
10409 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10410 flow_director_filter, "flow_director_filter");
10411 cmdline_parse_token_num_t cmd_flow_director_port_id =
10412 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10414 cmdline_parse_token_string_t cmd_flow_director_ops =
10415 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10416 ops, "add#del#update");
10417 cmdline_parse_token_string_t cmd_flow_director_flow =
10418 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10420 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10421 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10423 cmdline_parse_token_string_t cmd_flow_director_ether =
10424 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10426 cmdline_parse_token_num_t cmd_flow_director_ether_type =
10427 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10428 ether_type, UINT16);
10429 cmdline_parse_token_string_t cmd_flow_director_src =
10430 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10432 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
10433 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10435 cmdline_parse_token_num_t cmd_flow_director_port_src =
10436 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10438 cmdline_parse_token_string_t cmd_flow_director_dst =
10439 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10441 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
10442 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10444 cmdline_parse_token_num_t cmd_flow_director_port_dst =
10445 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10447 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
10448 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10449 verify_tag, "verify_tag");
10450 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
10451 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10452 verify_tag_value, UINT32);
10453 cmdline_parse_token_string_t cmd_flow_director_tos =
10454 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10456 cmdline_parse_token_num_t cmd_flow_director_tos_value =
10457 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10459 cmdline_parse_token_string_t cmd_flow_director_proto =
10460 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10462 cmdline_parse_token_num_t cmd_flow_director_proto_value =
10463 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10464 proto_value, UINT8);
10465 cmdline_parse_token_string_t cmd_flow_director_ttl =
10466 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10468 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
10469 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10471 cmdline_parse_token_string_t cmd_flow_director_vlan =
10472 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10474 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
10475 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10476 vlan_value, UINT16);
10477 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
10478 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10479 flexbytes, "flexbytes");
10480 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
10481 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10482 flexbytes_value, NULL);
10483 cmdline_parse_token_string_t cmd_flow_director_drop =
10484 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10486 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
10487 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10489 cmdline_parse_token_string_t cmd_flow_director_queue =
10490 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10492 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10493 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10495 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10496 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10498 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10499 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10500 fd_id_value, UINT32);
10502 cmdline_parse_token_string_t cmd_flow_director_mode =
10503 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10505 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
10506 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10508 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
10509 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10510 mode_value, "MAC-VLAN");
10511 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
10512 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10513 mode_value, "Tunnel");
10514 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
10515 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10516 mode_value, "raw");
10517 cmdline_parse_token_string_t cmd_flow_director_mac =
10518 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10520 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
10521 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
10523 cmdline_parse_token_string_t cmd_flow_director_tunnel =
10524 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10526 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
10527 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10528 tunnel_type, "NVGRE#VxLAN");
10529 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
10530 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10531 tunnel_id, "tunnel-id");
10532 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
10533 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10534 tunnel_id_value, UINT32);
10535 cmdline_parse_token_string_t cmd_flow_director_packet =
10536 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10538 cmdline_parse_token_string_t cmd_flow_director_filepath =
10539 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10542 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
10543 .f = cmd_flow_director_filter_parsed,
10545 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
10546 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
10547 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
10548 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
10549 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
10550 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
10551 "fd_id <fd_id_value>: "
10552 "Add or delete an ip flow director entry on NIC",
10554 (void *)&cmd_flow_director_filter,
10555 (void *)&cmd_flow_director_port_id,
10556 (void *)&cmd_flow_director_mode,
10557 (void *)&cmd_flow_director_mode_ip,
10558 (void *)&cmd_flow_director_ops,
10559 (void *)&cmd_flow_director_flow,
10560 (void *)&cmd_flow_director_flow_type,
10561 (void *)&cmd_flow_director_src,
10562 (void *)&cmd_flow_director_ip_src,
10563 (void *)&cmd_flow_director_dst,
10564 (void *)&cmd_flow_director_ip_dst,
10565 (void *)&cmd_flow_director_tos,
10566 (void *)&cmd_flow_director_tos_value,
10567 (void *)&cmd_flow_director_proto,
10568 (void *)&cmd_flow_director_proto_value,
10569 (void *)&cmd_flow_director_ttl,
10570 (void *)&cmd_flow_director_ttl_value,
10571 (void *)&cmd_flow_director_vlan,
10572 (void *)&cmd_flow_director_vlan_value,
10573 (void *)&cmd_flow_director_flexbytes,
10574 (void *)&cmd_flow_director_flexbytes_value,
10575 (void *)&cmd_flow_director_drop,
10576 (void *)&cmd_flow_director_pf_vf,
10577 (void *)&cmd_flow_director_queue,
10578 (void *)&cmd_flow_director_queue_id,
10579 (void *)&cmd_flow_director_fd_id,
10580 (void *)&cmd_flow_director_fd_id_value,
10585 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
10586 .f = cmd_flow_director_filter_parsed,
10588 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
10589 "director entry on NIC",
10591 (void *)&cmd_flow_director_filter,
10592 (void *)&cmd_flow_director_port_id,
10593 (void *)&cmd_flow_director_mode,
10594 (void *)&cmd_flow_director_mode_ip,
10595 (void *)&cmd_flow_director_ops,
10596 (void *)&cmd_flow_director_flow,
10597 (void *)&cmd_flow_director_flow_type,
10598 (void *)&cmd_flow_director_src,
10599 (void *)&cmd_flow_director_ip_src,
10600 (void *)&cmd_flow_director_port_src,
10601 (void *)&cmd_flow_director_dst,
10602 (void *)&cmd_flow_director_ip_dst,
10603 (void *)&cmd_flow_director_port_dst,
10604 (void *)&cmd_flow_director_tos,
10605 (void *)&cmd_flow_director_tos_value,
10606 (void *)&cmd_flow_director_ttl,
10607 (void *)&cmd_flow_director_ttl_value,
10608 (void *)&cmd_flow_director_vlan,
10609 (void *)&cmd_flow_director_vlan_value,
10610 (void *)&cmd_flow_director_flexbytes,
10611 (void *)&cmd_flow_director_flexbytes_value,
10612 (void *)&cmd_flow_director_drop,
10613 (void *)&cmd_flow_director_pf_vf,
10614 (void *)&cmd_flow_director_queue,
10615 (void *)&cmd_flow_director_queue_id,
10616 (void *)&cmd_flow_director_fd_id,
10617 (void *)&cmd_flow_director_fd_id_value,
10622 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
10623 .f = cmd_flow_director_filter_parsed,
10625 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
10626 "director entry on NIC",
10628 (void *)&cmd_flow_director_filter,
10629 (void *)&cmd_flow_director_port_id,
10630 (void *)&cmd_flow_director_mode,
10631 (void *)&cmd_flow_director_mode_ip,
10632 (void *)&cmd_flow_director_ops,
10633 (void *)&cmd_flow_director_flow,
10634 (void *)&cmd_flow_director_flow_type,
10635 (void *)&cmd_flow_director_src,
10636 (void *)&cmd_flow_director_ip_src,
10637 (void *)&cmd_flow_director_port_src,
10638 (void *)&cmd_flow_director_dst,
10639 (void *)&cmd_flow_director_ip_dst,
10640 (void *)&cmd_flow_director_port_dst,
10641 (void *)&cmd_flow_director_verify_tag,
10642 (void *)&cmd_flow_director_verify_tag_value,
10643 (void *)&cmd_flow_director_tos,
10644 (void *)&cmd_flow_director_tos_value,
10645 (void *)&cmd_flow_director_ttl,
10646 (void *)&cmd_flow_director_ttl_value,
10647 (void *)&cmd_flow_director_vlan,
10648 (void *)&cmd_flow_director_vlan_value,
10649 (void *)&cmd_flow_director_flexbytes,
10650 (void *)&cmd_flow_director_flexbytes_value,
10651 (void *)&cmd_flow_director_drop,
10652 (void *)&cmd_flow_director_pf_vf,
10653 (void *)&cmd_flow_director_queue,
10654 (void *)&cmd_flow_director_queue_id,
10655 (void *)&cmd_flow_director_fd_id,
10656 (void *)&cmd_flow_director_fd_id_value,
10661 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
10662 .f = cmd_flow_director_filter_parsed,
10664 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
10665 "director entry on NIC",
10667 (void *)&cmd_flow_director_filter,
10668 (void *)&cmd_flow_director_port_id,
10669 (void *)&cmd_flow_director_mode,
10670 (void *)&cmd_flow_director_mode_ip,
10671 (void *)&cmd_flow_director_ops,
10672 (void *)&cmd_flow_director_flow,
10673 (void *)&cmd_flow_director_flow_type,
10674 (void *)&cmd_flow_director_ether,
10675 (void *)&cmd_flow_director_ether_type,
10676 (void *)&cmd_flow_director_flexbytes,
10677 (void *)&cmd_flow_director_flexbytes_value,
10678 (void *)&cmd_flow_director_drop,
10679 (void *)&cmd_flow_director_pf_vf,
10680 (void *)&cmd_flow_director_queue,
10681 (void *)&cmd_flow_director_queue_id,
10682 (void *)&cmd_flow_director_fd_id,
10683 (void *)&cmd_flow_director_fd_id_value,
10688 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
10689 .f = cmd_flow_director_filter_parsed,
10691 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
10692 "director entry on NIC",
10694 (void *)&cmd_flow_director_filter,
10695 (void *)&cmd_flow_director_port_id,
10696 (void *)&cmd_flow_director_mode,
10697 (void *)&cmd_flow_director_mode_mac_vlan,
10698 (void *)&cmd_flow_director_ops,
10699 (void *)&cmd_flow_director_mac,
10700 (void *)&cmd_flow_director_mac_addr,
10701 (void *)&cmd_flow_director_vlan,
10702 (void *)&cmd_flow_director_vlan_value,
10703 (void *)&cmd_flow_director_flexbytes,
10704 (void *)&cmd_flow_director_flexbytes_value,
10705 (void *)&cmd_flow_director_drop,
10706 (void *)&cmd_flow_director_queue,
10707 (void *)&cmd_flow_director_queue_id,
10708 (void *)&cmd_flow_director_fd_id,
10709 (void *)&cmd_flow_director_fd_id_value,
10714 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
10715 .f = cmd_flow_director_filter_parsed,
10717 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
10718 "director entry on NIC",
10720 (void *)&cmd_flow_director_filter,
10721 (void *)&cmd_flow_director_port_id,
10722 (void *)&cmd_flow_director_mode,
10723 (void *)&cmd_flow_director_mode_tunnel,
10724 (void *)&cmd_flow_director_ops,
10725 (void *)&cmd_flow_director_mac,
10726 (void *)&cmd_flow_director_mac_addr,
10727 (void *)&cmd_flow_director_vlan,
10728 (void *)&cmd_flow_director_vlan_value,
10729 (void *)&cmd_flow_director_tunnel,
10730 (void *)&cmd_flow_director_tunnel_type,
10731 (void *)&cmd_flow_director_tunnel_id,
10732 (void *)&cmd_flow_director_tunnel_id_value,
10733 (void *)&cmd_flow_director_flexbytes,
10734 (void *)&cmd_flow_director_flexbytes_value,
10735 (void *)&cmd_flow_director_drop,
10736 (void *)&cmd_flow_director_queue,
10737 (void *)&cmd_flow_director_queue_id,
10738 (void *)&cmd_flow_director_fd_id,
10739 (void *)&cmd_flow_director_fd_id_value,
10744 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
10745 .f = cmd_flow_director_filter_parsed,
10747 .help_str = "flow_director_filter ... : Add or delete a raw flow "
10748 "director entry on NIC",
10750 (void *)&cmd_flow_director_filter,
10751 (void *)&cmd_flow_director_port_id,
10752 (void *)&cmd_flow_director_mode,
10753 (void *)&cmd_flow_director_mode_raw,
10754 (void *)&cmd_flow_director_ops,
10755 (void *)&cmd_flow_director_flow,
10756 (void *)&cmd_flow_director_flow_type,
10757 (void *)&cmd_flow_director_drop,
10758 (void *)&cmd_flow_director_queue,
10759 (void *)&cmd_flow_director_queue_id,
10760 (void *)&cmd_flow_director_fd_id,
10761 (void *)&cmd_flow_director_fd_id_value,
10762 (void *)&cmd_flow_director_packet,
10763 (void *)&cmd_flow_director_filepath,
10768 struct cmd_flush_flow_director_result {
10769 cmdline_fixed_string_t flush_flow_director;
10773 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
10774 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
10775 flush_flow_director, "flush_flow_director");
10776 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
10777 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
10781 cmd_flush_flow_director_parsed(void *parsed_result,
10782 __attribute__((unused)) struct cmdline *cl,
10783 __attribute__((unused)) void *data)
10785 struct cmd_flow_director_result *res = parsed_result;
10788 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10790 printf("flow director is not supported on port %u.\n",
10795 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10796 RTE_ETH_FILTER_FLUSH, NULL);
10798 printf("flow director table flushing error: (%s)\n",
10802 cmdline_parse_inst_t cmd_flush_flow_director = {
10803 .f = cmd_flush_flow_director_parsed,
10805 .help_str = "flush_flow_director <port_id>: "
10806 "Flush all flow director entries of a device on NIC",
10808 (void *)&cmd_flush_flow_director_flush,
10809 (void *)&cmd_flush_flow_director_port_id,
10814 /* *** deal with flow director mask *** */
10815 struct cmd_flow_director_mask_result {
10816 cmdline_fixed_string_t flow_director_mask;
10818 cmdline_fixed_string_t mode;
10819 cmdline_fixed_string_t mode_value;
10820 cmdline_fixed_string_t vlan;
10821 uint16_t vlan_mask;
10822 cmdline_fixed_string_t src_mask;
10823 cmdline_ipaddr_t ipv4_src;
10824 cmdline_ipaddr_t ipv6_src;
10826 cmdline_fixed_string_t dst_mask;
10827 cmdline_ipaddr_t ipv4_dst;
10828 cmdline_ipaddr_t ipv6_dst;
10830 cmdline_fixed_string_t mac;
10831 uint8_t mac_addr_byte_mask;
10832 cmdline_fixed_string_t tunnel_id;
10833 uint32_t tunnel_id_mask;
10834 cmdline_fixed_string_t tunnel_type;
10835 uint8_t tunnel_type_mask;
10839 cmd_flow_director_mask_parsed(void *parsed_result,
10840 __attribute__((unused)) struct cmdline *cl,
10841 __attribute__((unused)) void *data)
10843 struct cmd_flow_director_mask_result *res = parsed_result;
10844 struct rte_eth_fdir_masks *mask;
10845 struct rte_port *port;
10847 if (res->port_id > nb_ports) {
10848 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
10852 port = &ports[res->port_id];
10853 /** Check if the port is not started **/
10854 if (port->port_status != RTE_PORT_STOPPED) {
10855 printf("Please stop port %d first\n", res->port_id);
10859 mask = &port->dev_conf.fdir_conf.mask;
10861 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10862 if (strcmp(res->mode_value, "MAC-VLAN")) {
10863 printf("Please set mode to MAC-VLAN.\n");
10867 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10868 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10869 if (strcmp(res->mode_value, "Tunnel")) {
10870 printf("Please set mode to Tunnel.\n");
10874 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10875 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
10876 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
10877 mask->tunnel_type_mask = res->tunnel_type_mask;
10879 if (strcmp(res->mode_value, "IP")) {
10880 printf("Please set mode to IP.\n");
10884 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10885 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
10886 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
10887 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
10888 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
10889 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
10890 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
10893 cmd_reconfig_device_queue(res->port_id, 1, 1);
10896 cmdline_parse_token_string_t cmd_flow_director_mask =
10897 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10898 flow_director_mask, "flow_director_mask");
10899 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
10900 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10902 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
10903 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10905 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
10906 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10907 vlan_mask, UINT16);
10908 cmdline_parse_token_string_t cmd_flow_director_mask_src =
10909 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10910 src_mask, "src_mask");
10911 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
10912 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10914 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
10915 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10917 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
10918 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10920 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
10921 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10922 dst_mask, "dst_mask");
10923 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
10924 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10926 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
10927 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10929 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
10930 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10933 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
10934 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10936 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
10937 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10939 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
10940 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10941 mode_value, "MAC-VLAN");
10942 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
10943 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10944 mode_value, "Tunnel");
10945 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
10946 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10948 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
10949 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10950 mac_addr_byte_mask, UINT8);
10951 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
10952 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10953 tunnel_type, "tunnel-type");
10954 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
10955 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10956 tunnel_type_mask, UINT8);
10957 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
10958 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10959 tunnel_id, "tunnel-id");
10960 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
10961 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10962 tunnel_id_mask, UINT32);
10964 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
10965 .f = cmd_flow_director_mask_parsed,
10967 .help_str = "flow_director_mask ... : "
10968 "Set IP mode flow director's mask on NIC",
10970 (void *)&cmd_flow_director_mask,
10971 (void *)&cmd_flow_director_mask_port_id,
10972 (void *)&cmd_flow_director_mask_mode,
10973 (void *)&cmd_flow_director_mask_mode_ip,
10974 (void *)&cmd_flow_director_mask_vlan,
10975 (void *)&cmd_flow_director_mask_vlan_value,
10976 (void *)&cmd_flow_director_mask_src,
10977 (void *)&cmd_flow_director_mask_ipv4_src,
10978 (void *)&cmd_flow_director_mask_ipv6_src,
10979 (void *)&cmd_flow_director_mask_port_src,
10980 (void *)&cmd_flow_director_mask_dst,
10981 (void *)&cmd_flow_director_mask_ipv4_dst,
10982 (void *)&cmd_flow_director_mask_ipv6_dst,
10983 (void *)&cmd_flow_director_mask_port_dst,
10988 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
10989 .f = cmd_flow_director_mask_parsed,
10991 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
10992 "flow director's mask on NIC",
10994 (void *)&cmd_flow_director_mask,
10995 (void *)&cmd_flow_director_mask_port_id,
10996 (void *)&cmd_flow_director_mask_mode,
10997 (void *)&cmd_flow_director_mask_mode_mac_vlan,
10998 (void *)&cmd_flow_director_mask_vlan,
10999 (void *)&cmd_flow_director_mask_vlan_value,
11004 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
11005 .f = cmd_flow_director_mask_parsed,
11007 .help_str = "flow_director_mask ... : Set tunnel mode "
11008 "flow director's mask on NIC",
11010 (void *)&cmd_flow_director_mask,
11011 (void *)&cmd_flow_director_mask_port_id,
11012 (void *)&cmd_flow_director_mask_mode,
11013 (void *)&cmd_flow_director_mask_mode_tunnel,
11014 (void *)&cmd_flow_director_mask_vlan,
11015 (void *)&cmd_flow_director_mask_vlan_value,
11016 (void *)&cmd_flow_director_mask_mac,
11017 (void *)&cmd_flow_director_mask_mac_value,
11018 (void *)&cmd_flow_director_mask_tunnel_type,
11019 (void *)&cmd_flow_director_mask_tunnel_type_value,
11020 (void *)&cmd_flow_director_mask_tunnel_id,
11021 (void *)&cmd_flow_director_mask_tunnel_id_value,
11026 /* *** deal with flow director mask on flexible payload *** */
11027 struct cmd_flow_director_flex_mask_result {
11028 cmdline_fixed_string_t flow_director_flexmask;
11030 cmdline_fixed_string_t flow;
11031 cmdline_fixed_string_t flow_type;
11032 cmdline_fixed_string_t mask;
11036 cmd_flow_director_flex_mask_parsed(void *parsed_result,
11037 __attribute__((unused)) struct cmdline *cl,
11038 __attribute__((unused)) void *data)
11040 struct cmd_flow_director_flex_mask_result *res = parsed_result;
11041 struct rte_eth_fdir_info fdir_info;
11042 struct rte_eth_fdir_flex_mask flex_mask;
11043 struct rte_port *port;
11044 uint64_t flow_type_mask;
11048 if (res->port_id > nb_ports) {
11049 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
11053 port = &ports[res->port_id];
11054 /** Check if the port is not started **/
11055 if (port->port_status != RTE_PORT_STOPPED) {
11056 printf("Please stop port %d first\n", res->port_id);
11060 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
11061 ret = parse_flexbytes(res->mask,
11063 RTE_ETH_FDIR_MAX_FLEXLEN);
11065 printf("error: Cannot parse mask input.\n");
11069 memset(&fdir_info, 0, sizeof(fdir_info));
11070 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11071 RTE_ETH_FILTER_INFO, &fdir_info);
11073 printf("Cannot get FDir filter info\n");
11077 if (!strcmp(res->flow_type, "none")) {
11078 /* means don't specify the flow type */
11079 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
11080 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
11081 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
11082 0, sizeof(struct rte_eth_fdir_flex_mask));
11083 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
11084 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
11086 sizeof(struct rte_eth_fdir_flex_mask));
11087 cmd_reconfig_device_queue(res->port_id, 1, 1);
11090 flow_type_mask = fdir_info.flow_types_mask[0];
11091 if (!strcmp(res->flow_type, "all")) {
11092 if (!flow_type_mask) {
11093 printf("No flow type supported\n");
11096 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
11097 if (flow_type_mask & (1ULL << i)) {
11098 flex_mask.flow_type = i;
11099 fdir_set_flex_mask(res->port_id, &flex_mask);
11102 cmd_reconfig_device_queue(res->port_id, 1, 1);
11105 flex_mask.flow_type = str2flowtype(res->flow_type);
11106 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
11107 printf("Flow type %s not supported on port %d\n",
11108 res->flow_type, res->port_id);
11111 fdir_set_flex_mask(res->port_id, &flex_mask);
11112 cmd_reconfig_device_queue(res->port_id, 1, 1);
11115 cmdline_parse_token_string_t cmd_flow_director_flexmask =
11116 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11117 flow_director_flexmask,
11118 "flow_director_flex_mask");
11119 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
11120 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11122 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
11123 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11125 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
11126 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11127 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
11128 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
11129 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
11130 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11133 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
11134 .f = cmd_flow_director_flex_mask_parsed,
11136 .help_str = "flow_director_flex_mask ... : "
11137 "Set flow director's flex mask on NIC",
11139 (void *)&cmd_flow_director_flexmask,
11140 (void *)&cmd_flow_director_flexmask_port_id,
11141 (void *)&cmd_flow_director_flexmask_flow,
11142 (void *)&cmd_flow_director_flexmask_flow_type,
11143 (void *)&cmd_flow_director_flexmask_mask,
11148 /* *** deal with flow director flexible payload configuration *** */
11149 struct cmd_flow_director_flexpayload_result {
11150 cmdline_fixed_string_t flow_director_flexpayload;
11152 cmdline_fixed_string_t payload_layer;
11153 cmdline_fixed_string_t payload_cfg;
11157 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
11160 const char *p, *p0 = q_arg;
11162 unsigned long int_fld;
11163 char *str_fld[max_num];
11168 p = strchr(p0, '(');
11172 p0 = strchr(p, ')');
11177 if (size >= sizeof(s))
11180 snprintf(s, sizeof(s), "%.*s", size, p);
11181 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
11182 if (ret < 0 || ret > max_num)
11184 for (i = 0; i < ret; i++) {
11186 int_fld = strtoul(str_fld[i], &end, 0);
11187 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
11189 offsets[i] = (uint16_t)int_fld;
11195 cmd_flow_director_flxpld_parsed(void *parsed_result,
11196 __attribute__((unused)) struct cmdline *cl,
11197 __attribute__((unused)) void *data)
11199 struct cmd_flow_director_flexpayload_result *res = parsed_result;
11200 struct rte_eth_flex_payload_cfg flex_cfg;
11201 struct rte_port *port;
11204 if (res->port_id > nb_ports) {
11205 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
11209 port = &ports[res->port_id];
11210 /** Check if the port is not started **/
11211 if (port->port_status != RTE_PORT_STOPPED) {
11212 printf("Please stop port %d first\n", res->port_id);
11216 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
11218 if (!strcmp(res->payload_layer, "raw"))
11219 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
11220 else if (!strcmp(res->payload_layer, "l2"))
11221 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
11222 else if (!strcmp(res->payload_layer, "l3"))
11223 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
11224 else if (!strcmp(res->payload_layer, "l4"))
11225 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
11227 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
11228 RTE_ETH_FDIR_MAX_FLEXLEN);
11230 printf("error: Cannot parse flex payload input.\n");
11234 fdir_set_flex_payload(res->port_id, &flex_cfg);
11235 cmd_reconfig_device_queue(res->port_id, 1, 1);
11238 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
11239 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11240 flow_director_flexpayload,
11241 "flow_director_flex_payload");
11242 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
11243 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11245 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
11246 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11247 payload_layer, "raw#l2#l3#l4");
11248 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
11249 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11250 payload_cfg, NULL);
11252 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
11253 .f = cmd_flow_director_flxpld_parsed,
11255 .help_str = "flow_director_flexpayload ... : "
11256 "Set flow director's flex payload on NIC",
11258 (void *)&cmd_flow_director_flexpayload,
11259 (void *)&cmd_flow_director_flexpayload_port_id,
11260 (void *)&cmd_flow_director_flexpayload_payload_layer,
11261 (void *)&cmd_flow_director_flexpayload_payload_cfg,
11266 /* Generic flow interface command. */
11267 extern cmdline_parse_inst_t cmd_flow;
11269 /* *** Classification Filters Control *** */
11270 /* *** Get symmetric hash enable per port *** */
11271 struct cmd_get_sym_hash_ena_per_port_result {
11272 cmdline_fixed_string_t get_sym_hash_ena_per_port;
11277 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
11278 __rte_unused struct cmdline *cl,
11279 __rte_unused void *data)
11281 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
11282 struct rte_eth_hash_filter_info info;
11285 if (rte_eth_dev_filter_supported(res->port_id,
11286 RTE_ETH_FILTER_HASH) < 0) {
11287 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11292 memset(&info, 0, sizeof(info));
11293 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11294 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11295 RTE_ETH_FILTER_GET, &info);
11298 printf("Cannot get symmetric hash enable per port "
11299 "on port %u\n", res->port_id);
11303 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
11304 "enabled" : "disabled", res->port_id);
11307 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
11308 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11309 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
11310 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
11311 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11314 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
11315 .f = cmd_get_sym_hash_per_port_parsed,
11317 .help_str = "get_sym_hash_ena_per_port <port_id>",
11319 (void *)&cmd_get_sym_hash_ena_per_port_all,
11320 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
11325 /* *** Set symmetric hash enable per port *** */
11326 struct cmd_set_sym_hash_ena_per_port_result {
11327 cmdline_fixed_string_t set_sym_hash_ena_per_port;
11328 cmdline_fixed_string_t enable;
11333 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
11334 __rte_unused struct cmdline *cl,
11335 __rte_unused void *data)
11337 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
11338 struct rte_eth_hash_filter_info info;
11341 if (rte_eth_dev_filter_supported(res->port_id,
11342 RTE_ETH_FILTER_HASH) < 0) {
11343 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11348 memset(&info, 0, sizeof(info));
11349 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11350 if (!strcmp(res->enable, "enable"))
11351 info.info.enable = 1;
11352 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11353 RTE_ETH_FILTER_SET, &info);
11355 printf("Cannot set symmetric hash enable per port on "
11356 "port %u\n", res->port_id);
11359 printf("Symmetric hash has been set to %s on port %u\n",
11360 res->enable, res->port_id);
11363 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
11364 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11365 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
11366 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
11367 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11369 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
11370 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11371 enable, "enable#disable");
11373 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
11374 .f = cmd_set_sym_hash_per_port_parsed,
11376 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
11378 (void *)&cmd_set_sym_hash_ena_per_port_all,
11379 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
11380 (void *)&cmd_set_sym_hash_ena_per_port_enable,
11385 /* Get global config of hash function */
11386 struct cmd_get_hash_global_config_result {
11387 cmdline_fixed_string_t get_hash_global_config;
11392 flowtype_to_str(uint16_t ftype)
11398 } ftype_table[] = {
11399 {"ipv4", RTE_ETH_FLOW_IPV4},
11400 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
11401 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
11402 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
11403 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
11404 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
11405 {"ipv6", RTE_ETH_FLOW_IPV6},
11406 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
11407 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
11408 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
11409 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
11410 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
11411 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
11412 {"port", RTE_ETH_FLOW_PORT},
11413 {"vxlan", RTE_ETH_FLOW_VXLAN},
11414 {"geneve", RTE_ETH_FLOW_GENEVE},
11415 {"nvgre", RTE_ETH_FLOW_NVGRE},
11418 for (i = 0; i < RTE_DIM(ftype_table); i++) {
11419 if (ftype_table[i].ftype == ftype)
11420 return ftype_table[i].str;
11427 cmd_get_hash_global_config_parsed(void *parsed_result,
11428 __rte_unused struct cmdline *cl,
11429 __rte_unused void *data)
11431 struct cmd_get_hash_global_config_result *res = parsed_result;
11432 struct rte_eth_hash_filter_info info;
11433 uint32_t idx, offset;
11438 if (rte_eth_dev_filter_supported(res->port_id,
11439 RTE_ETH_FILTER_HASH) < 0) {
11440 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11445 memset(&info, 0, sizeof(info));
11446 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11447 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11448 RTE_ETH_FILTER_GET, &info);
11450 printf("Cannot get hash global configurations by port %d\n",
11455 switch (info.info.global_conf.hash_func) {
11456 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
11457 printf("Hash function is Toeplitz\n");
11459 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
11460 printf("Hash function is Simple XOR\n");
11463 printf("Unknown hash function\n");
11467 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
11468 idx = i / UINT64_BIT;
11469 offset = i % UINT64_BIT;
11470 if (!(info.info.global_conf.valid_bit_mask[idx] &
11473 str = flowtype_to_str(i);
11476 printf("Symmetric hash is %s globally for flow type %s "
11478 ((info.info.global_conf.sym_hash_enable_mask[idx] &
11479 (1ULL << offset)) ? "enabled" : "disabled"), str,
11484 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
11485 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
11486 get_hash_global_config, "get_hash_global_config");
11487 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
11488 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
11491 cmdline_parse_inst_t cmd_get_hash_global_config = {
11492 .f = cmd_get_hash_global_config_parsed,
11494 .help_str = "get_hash_global_config <port_id>",
11496 (void *)&cmd_get_hash_global_config_all,
11497 (void *)&cmd_get_hash_global_config_port_id,
11502 /* Set global config of hash function */
11503 struct cmd_set_hash_global_config_result {
11504 cmdline_fixed_string_t set_hash_global_config;
11506 cmdline_fixed_string_t hash_func;
11507 cmdline_fixed_string_t flow_type;
11508 cmdline_fixed_string_t enable;
11512 cmd_set_hash_global_config_parsed(void *parsed_result,
11513 __rte_unused struct cmdline *cl,
11514 __rte_unused void *data)
11516 struct cmd_set_hash_global_config_result *res = parsed_result;
11517 struct rte_eth_hash_filter_info info;
11518 uint32_t ftype, idx, offset;
11521 if (rte_eth_dev_filter_supported(res->port_id,
11522 RTE_ETH_FILTER_HASH) < 0) {
11523 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11527 memset(&info, 0, sizeof(info));
11528 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11529 if (!strcmp(res->hash_func, "toeplitz"))
11530 info.info.global_conf.hash_func =
11531 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
11532 else if (!strcmp(res->hash_func, "simple_xor"))
11533 info.info.global_conf.hash_func =
11534 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
11535 else if (!strcmp(res->hash_func, "default"))
11536 info.info.global_conf.hash_func =
11537 RTE_ETH_HASH_FUNCTION_DEFAULT;
11539 ftype = str2flowtype(res->flow_type);
11540 idx = ftype / UINT64_BIT;
11541 offset = ftype % UINT64_BIT;
11542 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
11543 if (!strcmp(res->enable, "enable"))
11544 info.info.global_conf.sym_hash_enable_mask[idx] |=
11546 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11547 RTE_ETH_FILTER_SET, &info);
11549 printf("Cannot set global hash configurations by port %d\n",
11552 printf("Global hash configurations have been set "
11553 "succcessfully by port %d\n", res->port_id);
11556 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
11557 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11558 set_hash_global_config, "set_hash_global_config");
11559 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
11560 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
11562 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
11563 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11564 hash_func, "toeplitz#simple_xor#default");
11565 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
11566 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11568 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
11569 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11570 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
11571 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11572 enable, "enable#disable");
11574 cmdline_parse_inst_t cmd_set_hash_global_config = {
11575 .f = cmd_set_hash_global_config_parsed,
11577 .help_str = "set_hash_global_config <port_id> "
11578 "toeplitz|simple_xor|default "
11579 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11580 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
11581 "l2_payload enable|disable",
11583 (void *)&cmd_set_hash_global_config_all,
11584 (void *)&cmd_set_hash_global_config_port_id,
11585 (void *)&cmd_set_hash_global_config_hash_func,
11586 (void *)&cmd_set_hash_global_config_flow_type,
11587 (void *)&cmd_set_hash_global_config_enable,
11592 /* Set hash input set */
11593 struct cmd_set_hash_input_set_result {
11594 cmdline_fixed_string_t set_hash_input_set;
11596 cmdline_fixed_string_t flow_type;
11597 cmdline_fixed_string_t inset_field;
11598 cmdline_fixed_string_t select;
11601 static enum rte_eth_input_set_field
11602 str2inset(char *string)
11606 static const struct {
11608 enum rte_eth_input_set_field inset;
11609 } inset_table[] = {
11610 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
11611 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
11612 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
11613 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
11614 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
11615 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
11616 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
11617 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
11618 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
11619 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
11620 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
11621 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
11622 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
11623 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
11624 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
11625 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
11626 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
11627 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
11628 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
11629 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
11630 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
11631 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
11632 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
11633 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
11634 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
11635 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
11636 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
11637 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
11638 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
11639 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
11640 {"none", RTE_ETH_INPUT_SET_NONE},
11643 for (i = 0; i < RTE_DIM(inset_table); i++) {
11644 if (!strcmp(string, inset_table[i].str))
11645 return inset_table[i].inset;
11648 return RTE_ETH_INPUT_SET_UNKNOWN;
11652 cmd_set_hash_input_set_parsed(void *parsed_result,
11653 __rte_unused struct cmdline *cl,
11654 __rte_unused void *data)
11656 struct cmd_set_hash_input_set_result *res = parsed_result;
11657 struct rte_eth_hash_filter_info info;
11659 memset(&info, 0, sizeof(info));
11660 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
11661 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
11662 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
11663 info.info.input_set_conf.inset_size = 1;
11664 if (!strcmp(res->select, "select"))
11665 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
11666 else if (!strcmp(res->select, "add"))
11667 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
11668 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11669 RTE_ETH_FILTER_SET, &info);
11672 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
11673 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11674 set_hash_input_set, "set_hash_input_set");
11675 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
11676 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
11678 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
11679 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11681 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
11682 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11684 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
11685 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
11686 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
11687 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
11688 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
11690 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
11691 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11692 select, "select#add");
11694 cmdline_parse_inst_t cmd_set_hash_input_set = {
11695 .f = cmd_set_hash_input_set_parsed,
11697 .help_str = "set_hash_input_set <port_id> "
11698 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11699 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
11700 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
11701 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
11702 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
11703 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
11704 "fld-7th|fld-8th|none select|add",
11706 (void *)&cmd_set_hash_input_set_cmd,
11707 (void *)&cmd_set_hash_input_set_port_id,
11708 (void *)&cmd_set_hash_input_set_flow_type,
11709 (void *)&cmd_set_hash_input_set_field,
11710 (void *)&cmd_set_hash_input_set_select,
11715 /* Set flow director input set */
11716 struct cmd_set_fdir_input_set_result {
11717 cmdline_fixed_string_t set_fdir_input_set;
11719 cmdline_fixed_string_t flow_type;
11720 cmdline_fixed_string_t inset_field;
11721 cmdline_fixed_string_t select;
11725 cmd_set_fdir_input_set_parsed(void *parsed_result,
11726 __rte_unused struct cmdline *cl,
11727 __rte_unused void *data)
11729 struct cmd_set_fdir_input_set_result *res = parsed_result;
11730 struct rte_eth_fdir_filter_info info;
11732 memset(&info, 0, sizeof(info));
11733 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
11734 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
11735 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
11736 info.info.input_set_conf.inset_size = 1;
11737 if (!strcmp(res->select, "select"))
11738 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
11739 else if (!strcmp(res->select, "add"))
11740 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
11741 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11742 RTE_ETH_FILTER_SET, &info);
11745 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
11746 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11747 set_fdir_input_set, "set_fdir_input_set");
11748 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
11749 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
11751 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
11752 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11754 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
11755 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11756 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
11757 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11759 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
11760 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
11761 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
11762 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
11763 "sctp-veri-tag#none");
11764 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
11765 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11766 select, "select#add");
11768 cmdline_parse_inst_t cmd_set_fdir_input_set = {
11769 .f = cmd_set_fdir_input_set_parsed,
11771 .help_str = "set_fdir_input_set <port_id> "
11772 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11773 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
11774 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
11775 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
11776 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
11777 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
11778 "sctp-veri-tag|none select|add",
11780 (void *)&cmd_set_fdir_input_set_cmd,
11781 (void *)&cmd_set_fdir_input_set_port_id,
11782 (void *)&cmd_set_fdir_input_set_flow_type,
11783 (void *)&cmd_set_fdir_input_set_field,
11784 (void *)&cmd_set_fdir_input_set_select,
11789 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
11790 struct cmd_mcast_addr_result {
11791 cmdline_fixed_string_t mcast_addr_cmd;
11792 cmdline_fixed_string_t what;
11794 struct ether_addr mc_addr;
11797 static void cmd_mcast_addr_parsed(void *parsed_result,
11798 __attribute__((unused)) struct cmdline *cl,
11799 __attribute__((unused)) void *data)
11801 struct cmd_mcast_addr_result *res = parsed_result;
11803 if (!is_multicast_ether_addr(&res->mc_addr)) {
11804 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
11805 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
11806 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
11807 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
11810 if (strcmp(res->what, "add") == 0)
11811 mcast_addr_add(res->port_num, &res->mc_addr);
11813 mcast_addr_remove(res->port_num, &res->mc_addr);
11816 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
11817 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
11818 mcast_addr_cmd, "mcast_addr");
11819 cmdline_parse_token_string_t cmd_mcast_addr_what =
11820 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
11822 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
11823 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
11824 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
11825 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
11827 cmdline_parse_inst_t cmd_mcast_addr = {
11828 .f = cmd_mcast_addr_parsed,
11830 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
11831 "Add/Remove multicast MAC address on port_id",
11833 (void *)&cmd_mcast_addr_cmd,
11834 (void *)&cmd_mcast_addr_what,
11835 (void *)&cmd_mcast_addr_portnum,
11836 (void *)&cmd_mcast_addr_addr,
11841 /* l2 tunnel config
11842 * only support E-tag now.
11845 /* Ether type config */
11846 struct cmd_config_l2_tunnel_eth_type_result {
11847 cmdline_fixed_string_t port;
11848 cmdline_fixed_string_t config;
11849 cmdline_fixed_string_t all;
11851 cmdline_fixed_string_t l2_tunnel;
11852 cmdline_fixed_string_t l2_tunnel_type;
11853 cmdline_fixed_string_t eth_type;
11854 uint16_t eth_type_val;
11857 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
11858 TOKEN_STRING_INITIALIZER
11859 (struct cmd_config_l2_tunnel_eth_type_result,
11861 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
11862 TOKEN_STRING_INITIALIZER
11863 (struct cmd_config_l2_tunnel_eth_type_result,
11865 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
11866 TOKEN_STRING_INITIALIZER
11867 (struct cmd_config_l2_tunnel_eth_type_result,
11869 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
11870 TOKEN_NUM_INITIALIZER
11871 (struct cmd_config_l2_tunnel_eth_type_result,
11873 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
11874 TOKEN_STRING_INITIALIZER
11875 (struct cmd_config_l2_tunnel_eth_type_result,
11876 l2_tunnel, "l2-tunnel");
11877 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
11878 TOKEN_STRING_INITIALIZER
11879 (struct cmd_config_l2_tunnel_eth_type_result,
11880 l2_tunnel_type, "E-tag");
11881 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
11882 TOKEN_STRING_INITIALIZER
11883 (struct cmd_config_l2_tunnel_eth_type_result,
11884 eth_type, "ether-type");
11885 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
11886 TOKEN_NUM_INITIALIZER
11887 (struct cmd_config_l2_tunnel_eth_type_result,
11888 eth_type_val, UINT16);
11890 static enum rte_eth_tunnel_type
11891 str2fdir_l2_tunnel_type(char *string)
11895 static const struct {
11897 enum rte_eth_tunnel_type type;
11898 } l2_tunnel_type_str[] = {
11899 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
11902 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
11903 if (!strcmp(l2_tunnel_type_str[i].str, string))
11904 return l2_tunnel_type_str[i].type;
11906 return RTE_TUNNEL_TYPE_NONE;
11909 /* ether type config for all ports */
11911 cmd_config_l2_tunnel_eth_type_all_parsed
11912 (void *parsed_result,
11913 __attribute__((unused)) struct cmdline *cl,
11914 __attribute__((unused)) void *data)
11916 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
11917 struct rte_eth_l2_tunnel_conf entry;
11920 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11921 entry.ether_type = res->eth_type_val;
11923 RTE_ETH_FOREACH_DEV(pid) {
11924 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
11928 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
11929 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
11931 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
11933 (void *)&cmd_config_l2_tunnel_eth_type_port,
11934 (void *)&cmd_config_l2_tunnel_eth_type_config,
11935 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
11936 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
11937 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
11938 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
11939 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
11944 /* ether type config for a specific port */
11946 cmd_config_l2_tunnel_eth_type_specific_parsed(
11947 void *parsed_result,
11948 __attribute__((unused)) struct cmdline *cl,
11949 __attribute__((unused)) void *data)
11951 struct cmd_config_l2_tunnel_eth_type_result *res =
11953 struct rte_eth_l2_tunnel_conf entry;
11955 if (port_id_is_invalid(res->id, ENABLED_WARN))
11958 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11959 entry.ether_type = res->eth_type_val;
11961 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
11964 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
11965 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
11967 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
11969 (void *)&cmd_config_l2_tunnel_eth_type_port,
11970 (void *)&cmd_config_l2_tunnel_eth_type_config,
11971 (void *)&cmd_config_l2_tunnel_eth_type_id,
11972 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
11973 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
11974 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
11975 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
11980 /* Enable/disable l2 tunnel */
11981 struct cmd_config_l2_tunnel_en_dis_result {
11982 cmdline_fixed_string_t port;
11983 cmdline_fixed_string_t config;
11984 cmdline_fixed_string_t all;
11986 cmdline_fixed_string_t l2_tunnel;
11987 cmdline_fixed_string_t l2_tunnel_type;
11988 cmdline_fixed_string_t en_dis;
11991 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
11992 TOKEN_STRING_INITIALIZER
11993 (struct cmd_config_l2_tunnel_en_dis_result,
11995 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
11996 TOKEN_STRING_INITIALIZER
11997 (struct cmd_config_l2_tunnel_en_dis_result,
11999 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
12000 TOKEN_STRING_INITIALIZER
12001 (struct cmd_config_l2_tunnel_en_dis_result,
12003 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
12004 TOKEN_NUM_INITIALIZER
12005 (struct cmd_config_l2_tunnel_en_dis_result,
12007 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
12008 TOKEN_STRING_INITIALIZER
12009 (struct cmd_config_l2_tunnel_en_dis_result,
12010 l2_tunnel, "l2-tunnel");
12011 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
12012 TOKEN_STRING_INITIALIZER
12013 (struct cmd_config_l2_tunnel_en_dis_result,
12014 l2_tunnel_type, "E-tag");
12015 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
12016 TOKEN_STRING_INITIALIZER
12017 (struct cmd_config_l2_tunnel_en_dis_result,
12018 en_dis, "enable#disable");
12020 /* enable/disable l2 tunnel for all ports */
12022 cmd_config_l2_tunnel_en_dis_all_parsed(
12023 void *parsed_result,
12024 __attribute__((unused)) struct cmdline *cl,
12025 __attribute__((unused)) void *data)
12027 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
12028 struct rte_eth_l2_tunnel_conf entry;
12032 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12034 if (!strcmp("enable", res->en_dis))
12039 RTE_ETH_FOREACH_DEV(pid) {
12040 rte_eth_dev_l2_tunnel_offload_set(pid,
12042 ETH_L2_TUNNEL_ENABLE_MASK,
12047 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
12048 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
12050 .help_str = "port config all l2-tunnel E-tag enable|disable",
12052 (void *)&cmd_config_l2_tunnel_en_dis_port,
12053 (void *)&cmd_config_l2_tunnel_en_dis_config,
12054 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
12055 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12056 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12057 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12062 /* enable/disable l2 tunnel for a port */
12064 cmd_config_l2_tunnel_en_dis_specific_parsed(
12065 void *parsed_result,
12066 __attribute__((unused)) struct cmdline *cl,
12067 __attribute__((unused)) void *data)
12069 struct cmd_config_l2_tunnel_en_dis_result *res =
12071 struct rte_eth_l2_tunnel_conf entry;
12073 if (port_id_is_invalid(res->id, ENABLED_WARN))
12076 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12078 if (!strcmp("enable", res->en_dis))
12079 rte_eth_dev_l2_tunnel_offload_set(res->id,
12081 ETH_L2_TUNNEL_ENABLE_MASK,
12084 rte_eth_dev_l2_tunnel_offload_set(res->id,
12086 ETH_L2_TUNNEL_ENABLE_MASK,
12090 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
12091 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
12093 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
12095 (void *)&cmd_config_l2_tunnel_en_dis_port,
12096 (void *)&cmd_config_l2_tunnel_en_dis_config,
12097 (void *)&cmd_config_l2_tunnel_en_dis_id,
12098 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12099 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12100 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12105 /* E-tag configuration */
12107 /* Common result structure for all E-tag configuration */
12108 struct cmd_config_e_tag_result {
12109 cmdline_fixed_string_t e_tag;
12110 cmdline_fixed_string_t set;
12111 cmdline_fixed_string_t insertion;
12112 cmdline_fixed_string_t stripping;
12113 cmdline_fixed_string_t forwarding;
12114 cmdline_fixed_string_t filter;
12115 cmdline_fixed_string_t add;
12116 cmdline_fixed_string_t del;
12117 cmdline_fixed_string_t on;
12118 cmdline_fixed_string_t off;
12119 cmdline_fixed_string_t on_off;
12120 cmdline_fixed_string_t port_tag_id;
12121 uint32_t port_tag_id_val;
12122 cmdline_fixed_string_t e_tag_id;
12123 uint16_t e_tag_id_val;
12124 cmdline_fixed_string_t dst_pool;
12125 uint8_t dst_pool_val;
12126 cmdline_fixed_string_t port;
12128 cmdline_fixed_string_t vf;
12132 /* Common CLI fields for all E-tag configuration */
12133 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
12134 TOKEN_STRING_INITIALIZER
12135 (struct cmd_config_e_tag_result,
12137 cmdline_parse_token_string_t cmd_config_e_tag_set =
12138 TOKEN_STRING_INITIALIZER
12139 (struct cmd_config_e_tag_result,
12141 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
12142 TOKEN_STRING_INITIALIZER
12143 (struct cmd_config_e_tag_result,
12144 insertion, "insertion");
12145 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
12146 TOKEN_STRING_INITIALIZER
12147 (struct cmd_config_e_tag_result,
12148 stripping, "stripping");
12149 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
12150 TOKEN_STRING_INITIALIZER
12151 (struct cmd_config_e_tag_result,
12152 forwarding, "forwarding");
12153 cmdline_parse_token_string_t cmd_config_e_tag_filter =
12154 TOKEN_STRING_INITIALIZER
12155 (struct cmd_config_e_tag_result,
12157 cmdline_parse_token_string_t cmd_config_e_tag_add =
12158 TOKEN_STRING_INITIALIZER
12159 (struct cmd_config_e_tag_result,
12161 cmdline_parse_token_string_t cmd_config_e_tag_del =
12162 TOKEN_STRING_INITIALIZER
12163 (struct cmd_config_e_tag_result,
12165 cmdline_parse_token_string_t cmd_config_e_tag_on =
12166 TOKEN_STRING_INITIALIZER
12167 (struct cmd_config_e_tag_result,
12169 cmdline_parse_token_string_t cmd_config_e_tag_off =
12170 TOKEN_STRING_INITIALIZER
12171 (struct cmd_config_e_tag_result,
12173 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
12174 TOKEN_STRING_INITIALIZER
12175 (struct cmd_config_e_tag_result,
12177 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
12178 TOKEN_STRING_INITIALIZER
12179 (struct cmd_config_e_tag_result,
12180 port_tag_id, "port-tag-id");
12181 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
12182 TOKEN_NUM_INITIALIZER
12183 (struct cmd_config_e_tag_result,
12184 port_tag_id_val, UINT32);
12185 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
12186 TOKEN_STRING_INITIALIZER
12187 (struct cmd_config_e_tag_result,
12188 e_tag_id, "e-tag-id");
12189 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
12190 TOKEN_NUM_INITIALIZER
12191 (struct cmd_config_e_tag_result,
12192 e_tag_id_val, UINT16);
12193 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
12194 TOKEN_STRING_INITIALIZER
12195 (struct cmd_config_e_tag_result,
12196 dst_pool, "dst-pool");
12197 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
12198 TOKEN_NUM_INITIALIZER
12199 (struct cmd_config_e_tag_result,
12200 dst_pool_val, UINT8);
12201 cmdline_parse_token_string_t cmd_config_e_tag_port =
12202 TOKEN_STRING_INITIALIZER
12203 (struct cmd_config_e_tag_result,
12205 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
12206 TOKEN_NUM_INITIALIZER
12207 (struct cmd_config_e_tag_result,
12209 cmdline_parse_token_string_t cmd_config_e_tag_vf =
12210 TOKEN_STRING_INITIALIZER
12211 (struct cmd_config_e_tag_result,
12213 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
12214 TOKEN_NUM_INITIALIZER
12215 (struct cmd_config_e_tag_result,
12218 /* E-tag insertion configuration */
12220 cmd_config_e_tag_insertion_en_parsed(
12221 void *parsed_result,
12222 __attribute__((unused)) struct cmdline *cl,
12223 __attribute__((unused)) void *data)
12225 struct cmd_config_e_tag_result *res =
12227 struct rte_eth_l2_tunnel_conf entry;
12229 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12232 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12233 entry.tunnel_id = res->port_tag_id_val;
12234 entry.vf_id = res->vf_id;
12235 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12237 ETH_L2_TUNNEL_INSERTION_MASK,
12242 cmd_config_e_tag_insertion_dis_parsed(
12243 void *parsed_result,
12244 __attribute__((unused)) struct cmdline *cl,
12245 __attribute__((unused)) void *data)
12247 struct cmd_config_e_tag_result *res =
12249 struct rte_eth_l2_tunnel_conf entry;
12251 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12254 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12255 entry.vf_id = res->vf_id;
12257 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12259 ETH_L2_TUNNEL_INSERTION_MASK,
12263 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
12264 .f = cmd_config_e_tag_insertion_en_parsed,
12266 .help_str = "E-tag ... : E-tag insertion enable",
12268 (void *)&cmd_config_e_tag_e_tag,
12269 (void *)&cmd_config_e_tag_set,
12270 (void *)&cmd_config_e_tag_insertion,
12271 (void *)&cmd_config_e_tag_on,
12272 (void *)&cmd_config_e_tag_port_tag_id,
12273 (void *)&cmd_config_e_tag_port_tag_id_val,
12274 (void *)&cmd_config_e_tag_port,
12275 (void *)&cmd_config_e_tag_port_id,
12276 (void *)&cmd_config_e_tag_vf,
12277 (void *)&cmd_config_e_tag_vf_id,
12282 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
12283 .f = cmd_config_e_tag_insertion_dis_parsed,
12285 .help_str = "E-tag ... : E-tag insertion disable",
12287 (void *)&cmd_config_e_tag_e_tag,
12288 (void *)&cmd_config_e_tag_set,
12289 (void *)&cmd_config_e_tag_insertion,
12290 (void *)&cmd_config_e_tag_off,
12291 (void *)&cmd_config_e_tag_port,
12292 (void *)&cmd_config_e_tag_port_id,
12293 (void *)&cmd_config_e_tag_vf,
12294 (void *)&cmd_config_e_tag_vf_id,
12299 /* E-tag stripping configuration */
12301 cmd_config_e_tag_stripping_parsed(
12302 void *parsed_result,
12303 __attribute__((unused)) struct cmdline *cl,
12304 __attribute__((unused)) void *data)
12306 struct cmd_config_e_tag_result *res =
12308 struct rte_eth_l2_tunnel_conf entry;
12310 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12313 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12315 if (!strcmp(res->on_off, "on"))
12316 rte_eth_dev_l2_tunnel_offload_set
12319 ETH_L2_TUNNEL_STRIPPING_MASK,
12322 rte_eth_dev_l2_tunnel_offload_set
12325 ETH_L2_TUNNEL_STRIPPING_MASK,
12329 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
12330 .f = cmd_config_e_tag_stripping_parsed,
12332 .help_str = "E-tag ... : E-tag stripping enable/disable",
12334 (void *)&cmd_config_e_tag_e_tag,
12335 (void *)&cmd_config_e_tag_set,
12336 (void *)&cmd_config_e_tag_stripping,
12337 (void *)&cmd_config_e_tag_on_off,
12338 (void *)&cmd_config_e_tag_port,
12339 (void *)&cmd_config_e_tag_port_id,
12344 /* E-tag forwarding configuration */
12346 cmd_config_e_tag_forwarding_parsed(
12347 void *parsed_result,
12348 __attribute__((unused)) struct cmdline *cl,
12349 __attribute__((unused)) void *data)
12351 struct cmd_config_e_tag_result *res = parsed_result;
12352 struct rte_eth_l2_tunnel_conf entry;
12354 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12357 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12359 if (!strcmp(res->on_off, "on"))
12360 rte_eth_dev_l2_tunnel_offload_set
12363 ETH_L2_TUNNEL_FORWARDING_MASK,
12366 rte_eth_dev_l2_tunnel_offload_set
12369 ETH_L2_TUNNEL_FORWARDING_MASK,
12373 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
12374 .f = cmd_config_e_tag_forwarding_parsed,
12376 .help_str = "E-tag ... : E-tag forwarding enable/disable",
12378 (void *)&cmd_config_e_tag_e_tag,
12379 (void *)&cmd_config_e_tag_set,
12380 (void *)&cmd_config_e_tag_forwarding,
12381 (void *)&cmd_config_e_tag_on_off,
12382 (void *)&cmd_config_e_tag_port,
12383 (void *)&cmd_config_e_tag_port_id,
12388 /* E-tag filter configuration */
12390 cmd_config_e_tag_filter_add_parsed(
12391 void *parsed_result,
12392 __attribute__((unused)) struct cmdline *cl,
12393 __attribute__((unused)) void *data)
12395 struct cmd_config_e_tag_result *res = parsed_result;
12396 struct rte_eth_l2_tunnel_conf entry;
12399 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12402 if (res->e_tag_id_val > 0x3fff) {
12403 printf("e-tag-id must be equal or less than 0x3fff.\n");
12407 ret = rte_eth_dev_filter_supported(res->port_id,
12408 RTE_ETH_FILTER_L2_TUNNEL);
12410 printf("E-tag filter is not supported on port %u.\n",
12415 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12416 entry.tunnel_id = res->e_tag_id_val;
12417 entry.pool = res->dst_pool_val;
12419 ret = rte_eth_dev_filter_ctrl(res->port_id,
12420 RTE_ETH_FILTER_L2_TUNNEL,
12421 RTE_ETH_FILTER_ADD,
12424 printf("E-tag filter programming error: (%s)\n",
12428 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
12429 .f = cmd_config_e_tag_filter_add_parsed,
12431 .help_str = "E-tag ... : E-tag filter add",
12433 (void *)&cmd_config_e_tag_e_tag,
12434 (void *)&cmd_config_e_tag_set,
12435 (void *)&cmd_config_e_tag_filter,
12436 (void *)&cmd_config_e_tag_add,
12437 (void *)&cmd_config_e_tag_e_tag_id,
12438 (void *)&cmd_config_e_tag_e_tag_id_val,
12439 (void *)&cmd_config_e_tag_dst_pool,
12440 (void *)&cmd_config_e_tag_dst_pool_val,
12441 (void *)&cmd_config_e_tag_port,
12442 (void *)&cmd_config_e_tag_port_id,
12448 cmd_config_e_tag_filter_del_parsed(
12449 void *parsed_result,
12450 __attribute__((unused)) struct cmdline *cl,
12451 __attribute__((unused)) void *data)
12453 struct cmd_config_e_tag_result *res = parsed_result;
12454 struct rte_eth_l2_tunnel_conf entry;
12457 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12460 if (res->e_tag_id_val > 0x3fff) {
12461 printf("e-tag-id must be less than 0x3fff.\n");
12465 ret = rte_eth_dev_filter_supported(res->port_id,
12466 RTE_ETH_FILTER_L2_TUNNEL);
12468 printf("E-tag filter is not supported on port %u.\n",
12473 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12474 entry.tunnel_id = res->e_tag_id_val;
12476 ret = rte_eth_dev_filter_ctrl(res->port_id,
12477 RTE_ETH_FILTER_L2_TUNNEL,
12478 RTE_ETH_FILTER_DELETE,
12481 printf("E-tag filter programming error: (%s)\n",
12485 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
12486 .f = cmd_config_e_tag_filter_del_parsed,
12488 .help_str = "E-tag ... : E-tag filter delete",
12490 (void *)&cmd_config_e_tag_e_tag,
12491 (void *)&cmd_config_e_tag_set,
12492 (void *)&cmd_config_e_tag_filter,
12493 (void *)&cmd_config_e_tag_del,
12494 (void *)&cmd_config_e_tag_e_tag_id,
12495 (void *)&cmd_config_e_tag_e_tag_id_val,
12496 (void *)&cmd_config_e_tag_port,
12497 (void *)&cmd_config_e_tag_port_id,
12502 /* vf vlan anti spoof configuration */
12504 /* Common result structure for vf vlan anti spoof */
12505 struct cmd_vf_vlan_anti_spoof_result {
12506 cmdline_fixed_string_t set;
12507 cmdline_fixed_string_t vf;
12508 cmdline_fixed_string_t vlan;
12509 cmdline_fixed_string_t antispoof;
12512 cmdline_fixed_string_t on_off;
12515 /* Common CLI fields for vf vlan anti spoof enable disable */
12516 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
12517 TOKEN_STRING_INITIALIZER
12518 (struct cmd_vf_vlan_anti_spoof_result,
12520 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
12521 TOKEN_STRING_INITIALIZER
12522 (struct cmd_vf_vlan_anti_spoof_result,
12524 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
12525 TOKEN_STRING_INITIALIZER
12526 (struct cmd_vf_vlan_anti_spoof_result,
12528 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
12529 TOKEN_STRING_INITIALIZER
12530 (struct cmd_vf_vlan_anti_spoof_result,
12531 antispoof, "antispoof");
12532 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
12533 TOKEN_NUM_INITIALIZER
12534 (struct cmd_vf_vlan_anti_spoof_result,
12536 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
12537 TOKEN_NUM_INITIALIZER
12538 (struct cmd_vf_vlan_anti_spoof_result,
12540 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
12541 TOKEN_STRING_INITIALIZER
12542 (struct cmd_vf_vlan_anti_spoof_result,
12546 cmd_set_vf_vlan_anti_spoof_parsed(
12547 void *parsed_result,
12548 __attribute__((unused)) struct cmdline *cl,
12549 __attribute__((unused)) void *data)
12551 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
12552 int ret = -ENOTSUP;
12554 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12556 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12559 #ifdef RTE_LIBRTE_IXGBE_PMD
12560 if (ret == -ENOTSUP)
12561 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
12562 res->vf_id, is_on);
12564 #ifdef RTE_LIBRTE_I40E_PMD
12565 if (ret == -ENOTSUP)
12566 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
12567 res->vf_id, is_on);
12569 #ifdef RTE_LIBRTE_BNXT_PMD
12570 if (ret == -ENOTSUP)
12571 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
12572 res->vf_id, is_on);
12579 printf("invalid vf_id %d\n", res->vf_id);
12582 printf("invalid port_id %d\n", res->port_id);
12585 printf("function not implemented\n");
12588 printf("programming error: (%s)\n", strerror(-ret));
12592 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
12593 .f = cmd_set_vf_vlan_anti_spoof_parsed,
12595 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
12597 (void *)&cmd_vf_vlan_anti_spoof_set,
12598 (void *)&cmd_vf_vlan_anti_spoof_vf,
12599 (void *)&cmd_vf_vlan_anti_spoof_vlan,
12600 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
12601 (void *)&cmd_vf_vlan_anti_spoof_port_id,
12602 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
12603 (void *)&cmd_vf_vlan_anti_spoof_on_off,
12608 /* vf mac anti spoof configuration */
12610 /* Common result structure for vf mac anti spoof */
12611 struct cmd_vf_mac_anti_spoof_result {
12612 cmdline_fixed_string_t set;
12613 cmdline_fixed_string_t vf;
12614 cmdline_fixed_string_t mac;
12615 cmdline_fixed_string_t antispoof;
12618 cmdline_fixed_string_t on_off;
12621 /* Common CLI fields for vf mac anti spoof enable disable */
12622 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
12623 TOKEN_STRING_INITIALIZER
12624 (struct cmd_vf_mac_anti_spoof_result,
12626 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
12627 TOKEN_STRING_INITIALIZER
12628 (struct cmd_vf_mac_anti_spoof_result,
12630 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
12631 TOKEN_STRING_INITIALIZER
12632 (struct cmd_vf_mac_anti_spoof_result,
12634 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
12635 TOKEN_STRING_INITIALIZER
12636 (struct cmd_vf_mac_anti_spoof_result,
12637 antispoof, "antispoof");
12638 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
12639 TOKEN_NUM_INITIALIZER
12640 (struct cmd_vf_mac_anti_spoof_result,
12642 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
12643 TOKEN_NUM_INITIALIZER
12644 (struct cmd_vf_mac_anti_spoof_result,
12646 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
12647 TOKEN_STRING_INITIALIZER
12648 (struct cmd_vf_mac_anti_spoof_result,
12652 cmd_set_vf_mac_anti_spoof_parsed(
12653 void *parsed_result,
12654 __attribute__((unused)) struct cmdline *cl,
12655 __attribute__((unused)) void *data)
12657 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
12658 int ret = -ENOTSUP;
12660 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12662 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12665 #ifdef RTE_LIBRTE_IXGBE_PMD
12666 if (ret == -ENOTSUP)
12667 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
12668 res->vf_id, is_on);
12670 #ifdef RTE_LIBRTE_I40E_PMD
12671 if (ret == -ENOTSUP)
12672 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
12673 res->vf_id, is_on);
12675 #ifdef RTE_LIBRTE_BNXT_PMD
12676 if (ret == -ENOTSUP)
12677 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
12678 res->vf_id, is_on);
12685 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12688 printf("invalid port_id %d\n", res->port_id);
12691 printf("function not implemented\n");
12694 printf("programming error: (%s)\n", strerror(-ret));
12698 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
12699 .f = cmd_set_vf_mac_anti_spoof_parsed,
12701 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
12703 (void *)&cmd_vf_mac_anti_spoof_set,
12704 (void *)&cmd_vf_mac_anti_spoof_vf,
12705 (void *)&cmd_vf_mac_anti_spoof_mac,
12706 (void *)&cmd_vf_mac_anti_spoof_antispoof,
12707 (void *)&cmd_vf_mac_anti_spoof_port_id,
12708 (void *)&cmd_vf_mac_anti_spoof_vf_id,
12709 (void *)&cmd_vf_mac_anti_spoof_on_off,
12714 /* vf vlan strip queue configuration */
12716 /* Common result structure for vf mac anti spoof */
12717 struct cmd_vf_vlan_stripq_result {
12718 cmdline_fixed_string_t set;
12719 cmdline_fixed_string_t vf;
12720 cmdline_fixed_string_t vlan;
12721 cmdline_fixed_string_t stripq;
12724 cmdline_fixed_string_t on_off;
12727 /* Common CLI fields for vf vlan strip enable disable */
12728 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
12729 TOKEN_STRING_INITIALIZER
12730 (struct cmd_vf_vlan_stripq_result,
12732 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
12733 TOKEN_STRING_INITIALIZER
12734 (struct cmd_vf_vlan_stripq_result,
12736 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
12737 TOKEN_STRING_INITIALIZER
12738 (struct cmd_vf_vlan_stripq_result,
12740 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
12741 TOKEN_STRING_INITIALIZER
12742 (struct cmd_vf_vlan_stripq_result,
12744 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
12745 TOKEN_NUM_INITIALIZER
12746 (struct cmd_vf_vlan_stripq_result,
12748 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
12749 TOKEN_NUM_INITIALIZER
12750 (struct cmd_vf_vlan_stripq_result,
12752 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
12753 TOKEN_STRING_INITIALIZER
12754 (struct cmd_vf_vlan_stripq_result,
12758 cmd_set_vf_vlan_stripq_parsed(
12759 void *parsed_result,
12760 __attribute__((unused)) struct cmdline *cl,
12761 __attribute__((unused)) void *data)
12763 struct cmd_vf_vlan_stripq_result *res = parsed_result;
12764 int ret = -ENOTSUP;
12766 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12768 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12771 #ifdef RTE_LIBRTE_IXGBE_PMD
12772 if (ret == -ENOTSUP)
12773 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
12774 res->vf_id, is_on);
12776 #ifdef RTE_LIBRTE_I40E_PMD
12777 if (ret == -ENOTSUP)
12778 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
12779 res->vf_id, is_on);
12781 #ifdef RTE_LIBRTE_BNXT_PMD
12782 if (ret == -ENOTSUP)
12783 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
12784 res->vf_id, is_on);
12791 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12794 printf("invalid port_id %d\n", res->port_id);
12797 printf("function not implemented\n");
12800 printf("programming error: (%s)\n", strerror(-ret));
12804 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
12805 .f = cmd_set_vf_vlan_stripq_parsed,
12807 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
12809 (void *)&cmd_vf_vlan_stripq_set,
12810 (void *)&cmd_vf_vlan_stripq_vf,
12811 (void *)&cmd_vf_vlan_stripq_vlan,
12812 (void *)&cmd_vf_vlan_stripq_stripq,
12813 (void *)&cmd_vf_vlan_stripq_port_id,
12814 (void *)&cmd_vf_vlan_stripq_vf_id,
12815 (void *)&cmd_vf_vlan_stripq_on_off,
12820 /* vf vlan insert configuration */
12822 /* Common result structure for vf vlan insert */
12823 struct cmd_vf_vlan_insert_result {
12824 cmdline_fixed_string_t set;
12825 cmdline_fixed_string_t vf;
12826 cmdline_fixed_string_t vlan;
12827 cmdline_fixed_string_t insert;
12833 /* Common CLI fields for vf vlan insert enable disable */
12834 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
12835 TOKEN_STRING_INITIALIZER
12836 (struct cmd_vf_vlan_insert_result,
12838 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
12839 TOKEN_STRING_INITIALIZER
12840 (struct cmd_vf_vlan_insert_result,
12842 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
12843 TOKEN_STRING_INITIALIZER
12844 (struct cmd_vf_vlan_insert_result,
12846 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
12847 TOKEN_STRING_INITIALIZER
12848 (struct cmd_vf_vlan_insert_result,
12850 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
12851 TOKEN_NUM_INITIALIZER
12852 (struct cmd_vf_vlan_insert_result,
12854 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
12855 TOKEN_NUM_INITIALIZER
12856 (struct cmd_vf_vlan_insert_result,
12858 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
12859 TOKEN_NUM_INITIALIZER
12860 (struct cmd_vf_vlan_insert_result,
12864 cmd_set_vf_vlan_insert_parsed(
12865 void *parsed_result,
12866 __attribute__((unused)) struct cmdline *cl,
12867 __attribute__((unused)) void *data)
12869 struct cmd_vf_vlan_insert_result *res = parsed_result;
12870 int ret = -ENOTSUP;
12872 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12875 #ifdef RTE_LIBRTE_IXGBE_PMD
12876 if (ret == -ENOTSUP)
12877 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
12880 #ifdef RTE_LIBRTE_I40E_PMD
12881 if (ret == -ENOTSUP)
12882 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
12885 #ifdef RTE_LIBRTE_BNXT_PMD
12886 if (ret == -ENOTSUP)
12887 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
12895 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
12898 printf("invalid port_id %d\n", res->port_id);
12901 printf("function not implemented\n");
12904 printf("programming error: (%s)\n", strerror(-ret));
12908 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
12909 .f = cmd_set_vf_vlan_insert_parsed,
12911 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
12913 (void *)&cmd_vf_vlan_insert_set,
12914 (void *)&cmd_vf_vlan_insert_vf,
12915 (void *)&cmd_vf_vlan_insert_vlan,
12916 (void *)&cmd_vf_vlan_insert_insert,
12917 (void *)&cmd_vf_vlan_insert_port_id,
12918 (void *)&cmd_vf_vlan_insert_vf_id,
12919 (void *)&cmd_vf_vlan_insert_vlan_id,
12924 /* tx loopback configuration */
12926 /* Common result structure for tx loopback */
12927 struct cmd_tx_loopback_result {
12928 cmdline_fixed_string_t set;
12929 cmdline_fixed_string_t tx;
12930 cmdline_fixed_string_t loopback;
12932 cmdline_fixed_string_t on_off;
12935 /* Common CLI fields for tx loopback enable disable */
12936 cmdline_parse_token_string_t cmd_tx_loopback_set =
12937 TOKEN_STRING_INITIALIZER
12938 (struct cmd_tx_loopback_result,
12940 cmdline_parse_token_string_t cmd_tx_loopback_tx =
12941 TOKEN_STRING_INITIALIZER
12942 (struct cmd_tx_loopback_result,
12944 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
12945 TOKEN_STRING_INITIALIZER
12946 (struct cmd_tx_loopback_result,
12947 loopback, "loopback");
12948 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
12949 TOKEN_NUM_INITIALIZER
12950 (struct cmd_tx_loopback_result,
12952 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
12953 TOKEN_STRING_INITIALIZER
12954 (struct cmd_tx_loopback_result,
12958 cmd_set_tx_loopback_parsed(
12959 void *parsed_result,
12960 __attribute__((unused)) struct cmdline *cl,
12961 __attribute__((unused)) void *data)
12963 struct cmd_tx_loopback_result *res = parsed_result;
12964 int ret = -ENOTSUP;
12966 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12968 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12971 #ifdef RTE_LIBRTE_IXGBE_PMD
12972 if (ret == -ENOTSUP)
12973 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
12975 #ifdef RTE_LIBRTE_I40E_PMD
12976 if (ret == -ENOTSUP)
12977 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
12979 #ifdef RTE_LIBRTE_BNXT_PMD
12980 if (ret == -ENOTSUP)
12981 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
12983 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
12984 if (ret == -ENOTSUP)
12985 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
12992 printf("invalid is_on %d\n", is_on);
12995 printf("invalid port_id %d\n", res->port_id);
12998 printf("function not implemented\n");
13001 printf("programming error: (%s)\n", strerror(-ret));
13005 cmdline_parse_inst_t cmd_set_tx_loopback = {
13006 .f = cmd_set_tx_loopback_parsed,
13008 .help_str = "set tx loopback <port_id> on|off",
13010 (void *)&cmd_tx_loopback_set,
13011 (void *)&cmd_tx_loopback_tx,
13012 (void *)&cmd_tx_loopback_loopback,
13013 (void *)&cmd_tx_loopback_port_id,
13014 (void *)&cmd_tx_loopback_on_off,
13019 /* all queues drop enable configuration */
13021 /* Common result structure for all queues drop enable */
13022 struct cmd_all_queues_drop_en_result {
13023 cmdline_fixed_string_t set;
13024 cmdline_fixed_string_t all;
13025 cmdline_fixed_string_t queues;
13026 cmdline_fixed_string_t drop;
13028 cmdline_fixed_string_t on_off;
13031 /* Common CLI fields for tx loopback enable disable */
13032 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
13033 TOKEN_STRING_INITIALIZER
13034 (struct cmd_all_queues_drop_en_result,
13036 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
13037 TOKEN_STRING_INITIALIZER
13038 (struct cmd_all_queues_drop_en_result,
13040 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
13041 TOKEN_STRING_INITIALIZER
13042 (struct cmd_all_queues_drop_en_result,
13044 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
13045 TOKEN_STRING_INITIALIZER
13046 (struct cmd_all_queues_drop_en_result,
13048 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
13049 TOKEN_NUM_INITIALIZER
13050 (struct cmd_all_queues_drop_en_result,
13052 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
13053 TOKEN_STRING_INITIALIZER
13054 (struct cmd_all_queues_drop_en_result,
13058 cmd_set_all_queues_drop_en_parsed(
13059 void *parsed_result,
13060 __attribute__((unused)) struct cmdline *cl,
13061 __attribute__((unused)) void *data)
13063 struct cmd_all_queues_drop_en_result *res = parsed_result;
13064 int ret = -ENOTSUP;
13065 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13067 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13070 #ifdef RTE_LIBRTE_IXGBE_PMD
13071 if (ret == -ENOTSUP)
13072 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
13074 #ifdef RTE_LIBRTE_BNXT_PMD
13075 if (ret == -ENOTSUP)
13076 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
13082 printf("invalid is_on %d\n", is_on);
13085 printf("invalid port_id %d\n", res->port_id);
13088 printf("function not implemented\n");
13091 printf("programming error: (%s)\n", strerror(-ret));
13095 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
13096 .f = cmd_set_all_queues_drop_en_parsed,
13098 .help_str = "set all queues drop <port_id> on|off",
13100 (void *)&cmd_all_queues_drop_en_set,
13101 (void *)&cmd_all_queues_drop_en_all,
13102 (void *)&cmd_all_queues_drop_en_queues,
13103 (void *)&cmd_all_queues_drop_en_drop,
13104 (void *)&cmd_all_queues_drop_en_port_id,
13105 (void *)&cmd_all_queues_drop_en_on_off,
13110 /* vf split drop enable configuration */
13112 /* Common result structure for vf split drop enable */
13113 struct cmd_vf_split_drop_en_result {
13114 cmdline_fixed_string_t set;
13115 cmdline_fixed_string_t vf;
13116 cmdline_fixed_string_t split;
13117 cmdline_fixed_string_t drop;
13120 cmdline_fixed_string_t on_off;
13123 /* Common CLI fields for vf split drop enable disable */
13124 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
13125 TOKEN_STRING_INITIALIZER
13126 (struct cmd_vf_split_drop_en_result,
13128 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
13129 TOKEN_STRING_INITIALIZER
13130 (struct cmd_vf_split_drop_en_result,
13132 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
13133 TOKEN_STRING_INITIALIZER
13134 (struct cmd_vf_split_drop_en_result,
13136 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
13137 TOKEN_STRING_INITIALIZER
13138 (struct cmd_vf_split_drop_en_result,
13140 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
13141 TOKEN_NUM_INITIALIZER
13142 (struct cmd_vf_split_drop_en_result,
13144 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
13145 TOKEN_NUM_INITIALIZER
13146 (struct cmd_vf_split_drop_en_result,
13148 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
13149 TOKEN_STRING_INITIALIZER
13150 (struct cmd_vf_split_drop_en_result,
13154 cmd_set_vf_split_drop_en_parsed(
13155 void *parsed_result,
13156 __attribute__((unused)) struct cmdline *cl,
13157 __attribute__((unused)) void *data)
13159 struct cmd_vf_split_drop_en_result *res = parsed_result;
13160 int ret = -ENOTSUP;
13161 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13163 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13166 #ifdef RTE_LIBRTE_IXGBE_PMD
13167 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
13174 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13177 printf("invalid port_id %d\n", res->port_id);
13180 printf("not supported on port %d\n", res->port_id);
13183 printf("programming error: (%s)\n", strerror(-ret));
13187 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
13188 .f = cmd_set_vf_split_drop_en_parsed,
13190 .help_str = "set vf split drop <port_id> <vf_id> on|off",
13192 (void *)&cmd_vf_split_drop_en_set,
13193 (void *)&cmd_vf_split_drop_en_vf,
13194 (void *)&cmd_vf_split_drop_en_split,
13195 (void *)&cmd_vf_split_drop_en_drop,
13196 (void *)&cmd_vf_split_drop_en_port_id,
13197 (void *)&cmd_vf_split_drop_en_vf_id,
13198 (void *)&cmd_vf_split_drop_en_on_off,
13203 /* vf mac address configuration */
13205 /* Common result structure for vf mac address */
13206 struct cmd_set_vf_mac_addr_result {
13207 cmdline_fixed_string_t set;
13208 cmdline_fixed_string_t vf;
13209 cmdline_fixed_string_t mac;
13210 cmdline_fixed_string_t addr;
13213 struct ether_addr mac_addr;
13217 /* Common CLI fields for vf split drop enable disable */
13218 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
13219 TOKEN_STRING_INITIALIZER
13220 (struct cmd_set_vf_mac_addr_result,
13222 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
13223 TOKEN_STRING_INITIALIZER
13224 (struct cmd_set_vf_mac_addr_result,
13226 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
13227 TOKEN_STRING_INITIALIZER
13228 (struct cmd_set_vf_mac_addr_result,
13230 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
13231 TOKEN_STRING_INITIALIZER
13232 (struct cmd_set_vf_mac_addr_result,
13234 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
13235 TOKEN_NUM_INITIALIZER
13236 (struct cmd_set_vf_mac_addr_result,
13238 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
13239 TOKEN_NUM_INITIALIZER
13240 (struct cmd_set_vf_mac_addr_result,
13242 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
13243 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
13247 cmd_set_vf_mac_addr_parsed(
13248 void *parsed_result,
13249 __attribute__((unused)) struct cmdline *cl,
13250 __attribute__((unused)) void *data)
13252 struct cmd_set_vf_mac_addr_result *res = parsed_result;
13253 int ret = -ENOTSUP;
13255 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13258 #ifdef RTE_LIBRTE_IXGBE_PMD
13259 if (ret == -ENOTSUP)
13260 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
13263 #ifdef RTE_LIBRTE_I40E_PMD
13264 if (ret == -ENOTSUP)
13265 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
13268 #ifdef RTE_LIBRTE_BNXT_PMD
13269 if (ret == -ENOTSUP)
13270 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
13278 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
13281 printf("invalid port_id %d\n", res->port_id);
13284 printf("function not implemented\n");
13287 printf("programming error: (%s)\n", strerror(-ret));
13291 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
13292 .f = cmd_set_vf_mac_addr_parsed,
13294 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
13296 (void *)&cmd_set_vf_mac_addr_set,
13297 (void *)&cmd_set_vf_mac_addr_vf,
13298 (void *)&cmd_set_vf_mac_addr_mac,
13299 (void *)&cmd_set_vf_mac_addr_addr,
13300 (void *)&cmd_set_vf_mac_addr_port_id,
13301 (void *)&cmd_set_vf_mac_addr_vf_id,
13302 (void *)&cmd_set_vf_mac_addr_mac_addr,
13307 /* MACsec configuration */
13309 /* Common result structure for MACsec offload enable */
13310 struct cmd_macsec_offload_on_result {
13311 cmdline_fixed_string_t set;
13312 cmdline_fixed_string_t macsec;
13313 cmdline_fixed_string_t offload;
13315 cmdline_fixed_string_t on;
13316 cmdline_fixed_string_t encrypt;
13317 cmdline_fixed_string_t en_on_off;
13318 cmdline_fixed_string_t replay_protect;
13319 cmdline_fixed_string_t rp_on_off;
13322 /* Common CLI fields for MACsec offload disable */
13323 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
13324 TOKEN_STRING_INITIALIZER
13325 (struct cmd_macsec_offload_on_result,
13327 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
13328 TOKEN_STRING_INITIALIZER
13329 (struct cmd_macsec_offload_on_result,
13331 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
13332 TOKEN_STRING_INITIALIZER
13333 (struct cmd_macsec_offload_on_result,
13334 offload, "offload");
13335 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
13336 TOKEN_NUM_INITIALIZER
13337 (struct cmd_macsec_offload_on_result,
13339 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
13340 TOKEN_STRING_INITIALIZER
13341 (struct cmd_macsec_offload_on_result,
13343 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
13344 TOKEN_STRING_INITIALIZER
13345 (struct cmd_macsec_offload_on_result,
13346 encrypt, "encrypt");
13347 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
13348 TOKEN_STRING_INITIALIZER
13349 (struct cmd_macsec_offload_on_result,
13350 en_on_off, "on#off");
13351 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
13352 TOKEN_STRING_INITIALIZER
13353 (struct cmd_macsec_offload_on_result,
13354 replay_protect, "replay-protect");
13355 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
13356 TOKEN_STRING_INITIALIZER
13357 (struct cmd_macsec_offload_on_result,
13358 rp_on_off, "on#off");
13361 cmd_set_macsec_offload_on_parsed(
13362 void *parsed_result,
13363 __attribute__((unused)) struct cmdline *cl,
13364 __attribute__((unused)) void *data)
13366 struct cmd_macsec_offload_on_result *res = parsed_result;
13367 int ret = -ENOTSUP;
13368 portid_t port_id = res->port_id;
13369 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
13370 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
13371 struct rte_eth_dev_info dev_info;
13373 if (port_id_is_invalid(port_id, ENABLED_WARN))
13375 if (!port_is_stopped(port_id)) {
13376 printf("Please stop port %d first\n", port_id);
13380 rte_eth_dev_info_get(port_id, &dev_info);
13381 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13382 #ifdef RTE_LIBRTE_IXGBE_PMD
13383 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
13391 ports[port_id].dev_conf.txmode.offloads |=
13392 DEV_TX_OFFLOAD_MACSEC_INSERT;
13393 cmd_reconfig_device_queue(port_id, 1, 1);
13396 printf("invalid port_id %d\n", port_id);
13399 printf("not supported on port %d\n", port_id);
13402 printf("programming error: (%s)\n", strerror(-ret));
13406 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
13407 .f = cmd_set_macsec_offload_on_parsed,
13409 .help_str = "set macsec offload <port_id> on "
13410 "encrypt on|off replay-protect on|off",
13412 (void *)&cmd_macsec_offload_on_set,
13413 (void *)&cmd_macsec_offload_on_macsec,
13414 (void *)&cmd_macsec_offload_on_offload,
13415 (void *)&cmd_macsec_offload_on_port_id,
13416 (void *)&cmd_macsec_offload_on_on,
13417 (void *)&cmd_macsec_offload_on_encrypt,
13418 (void *)&cmd_macsec_offload_on_en_on_off,
13419 (void *)&cmd_macsec_offload_on_replay_protect,
13420 (void *)&cmd_macsec_offload_on_rp_on_off,
13425 /* Common result structure for MACsec offload disable */
13426 struct cmd_macsec_offload_off_result {
13427 cmdline_fixed_string_t set;
13428 cmdline_fixed_string_t macsec;
13429 cmdline_fixed_string_t offload;
13431 cmdline_fixed_string_t off;
13434 /* Common CLI fields for MACsec offload disable */
13435 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
13436 TOKEN_STRING_INITIALIZER
13437 (struct cmd_macsec_offload_off_result,
13439 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
13440 TOKEN_STRING_INITIALIZER
13441 (struct cmd_macsec_offload_off_result,
13443 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
13444 TOKEN_STRING_INITIALIZER
13445 (struct cmd_macsec_offload_off_result,
13446 offload, "offload");
13447 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
13448 TOKEN_NUM_INITIALIZER
13449 (struct cmd_macsec_offload_off_result,
13451 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
13452 TOKEN_STRING_INITIALIZER
13453 (struct cmd_macsec_offload_off_result,
13457 cmd_set_macsec_offload_off_parsed(
13458 void *parsed_result,
13459 __attribute__((unused)) struct cmdline *cl,
13460 __attribute__((unused)) void *data)
13462 struct cmd_macsec_offload_off_result *res = parsed_result;
13463 int ret = -ENOTSUP;
13464 struct rte_eth_dev_info dev_info;
13465 portid_t port_id = res->port_id;
13467 if (port_id_is_invalid(port_id, ENABLED_WARN))
13469 if (!port_is_stopped(port_id)) {
13470 printf("Please stop port %d first\n", port_id);
13474 rte_eth_dev_info_get(port_id, &dev_info);
13475 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13476 #ifdef RTE_LIBRTE_IXGBE_PMD
13477 ret = rte_pmd_ixgbe_macsec_disable(port_id);
13482 ports[port_id].dev_conf.txmode.offloads &=
13483 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
13484 cmd_reconfig_device_queue(port_id, 1, 1);
13487 printf("invalid port_id %d\n", port_id);
13490 printf("not supported on port %d\n", port_id);
13493 printf("programming error: (%s)\n", strerror(-ret));
13497 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
13498 .f = cmd_set_macsec_offload_off_parsed,
13500 .help_str = "set macsec offload <port_id> off",
13502 (void *)&cmd_macsec_offload_off_set,
13503 (void *)&cmd_macsec_offload_off_macsec,
13504 (void *)&cmd_macsec_offload_off_offload,
13505 (void *)&cmd_macsec_offload_off_port_id,
13506 (void *)&cmd_macsec_offload_off_off,
13511 /* Common result structure for MACsec secure connection configure */
13512 struct cmd_macsec_sc_result {
13513 cmdline_fixed_string_t set;
13514 cmdline_fixed_string_t macsec;
13515 cmdline_fixed_string_t sc;
13516 cmdline_fixed_string_t tx_rx;
13518 struct ether_addr mac;
13522 /* Common CLI fields for MACsec secure connection configure */
13523 cmdline_parse_token_string_t cmd_macsec_sc_set =
13524 TOKEN_STRING_INITIALIZER
13525 (struct cmd_macsec_sc_result,
13527 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
13528 TOKEN_STRING_INITIALIZER
13529 (struct cmd_macsec_sc_result,
13531 cmdline_parse_token_string_t cmd_macsec_sc_sc =
13532 TOKEN_STRING_INITIALIZER
13533 (struct cmd_macsec_sc_result,
13535 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
13536 TOKEN_STRING_INITIALIZER
13537 (struct cmd_macsec_sc_result,
13539 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
13540 TOKEN_NUM_INITIALIZER
13541 (struct cmd_macsec_sc_result,
13543 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
13544 TOKEN_ETHERADDR_INITIALIZER
13545 (struct cmd_macsec_sc_result,
13547 cmdline_parse_token_num_t cmd_macsec_sc_pi =
13548 TOKEN_NUM_INITIALIZER
13549 (struct cmd_macsec_sc_result,
13553 cmd_set_macsec_sc_parsed(
13554 void *parsed_result,
13555 __attribute__((unused)) struct cmdline *cl,
13556 __attribute__((unused)) void *data)
13558 struct cmd_macsec_sc_result *res = parsed_result;
13559 int ret = -ENOTSUP;
13560 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13562 #ifdef RTE_LIBRTE_IXGBE_PMD
13564 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
13565 res->mac.addr_bytes) :
13566 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
13567 res->mac.addr_bytes, res->pi);
13569 RTE_SET_USED(is_tx);
13575 printf("invalid port_id %d\n", res->port_id);
13578 printf("not supported on port %d\n", res->port_id);
13581 printf("programming error: (%s)\n", strerror(-ret));
13585 cmdline_parse_inst_t cmd_set_macsec_sc = {
13586 .f = cmd_set_macsec_sc_parsed,
13588 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
13590 (void *)&cmd_macsec_sc_set,
13591 (void *)&cmd_macsec_sc_macsec,
13592 (void *)&cmd_macsec_sc_sc,
13593 (void *)&cmd_macsec_sc_tx_rx,
13594 (void *)&cmd_macsec_sc_port_id,
13595 (void *)&cmd_macsec_sc_mac,
13596 (void *)&cmd_macsec_sc_pi,
13601 /* Common result structure for MACsec secure connection configure */
13602 struct cmd_macsec_sa_result {
13603 cmdline_fixed_string_t set;
13604 cmdline_fixed_string_t macsec;
13605 cmdline_fixed_string_t sa;
13606 cmdline_fixed_string_t tx_rx;
13611 cmdline_fixed_string_t key;
13614 /* Common CLI fields for MACsec secure connection configure */
13615 cmdline_parse_token_string_t cmd_macsec_sa_set =
13616 TOKEN_STRING_INITIALIZER
13617 (struct cmd_macsec_sa_result,
13619 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
13620 TOKEN_STRING_INITIALIZER
13621 (struct cmd_macsec_sa_result,
13623 cmdline_parse_token_string_t cmd_macsec_sa_sa =
13624 TOKEN_STRING_INITIALIZER
13625 (struct cmd_macsec_sa_result,
13627 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
13628 TOKEN_STRING_INITIALIZER
13629 (struct cmd_macsec_sa_result,
13631 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
13632 TOKEN_NUM_INITIALIZER
13633 (struct cmd_macsec_sa_result,
13635 cmdline_parse_token_num_t cmd_macsec_sa_idx =
13636 TOKEN_NUM_INITIALIZER
13637 (struct cmd_macsec_sa_result,
13639 cmdline_parse_token_num_t cmd_macsec_sa_an =
13640 TOKEN_NUM_INITIALIZER
13641 (struct cmd_macsec_sa_result,
13643 cmdline_parse_token_num_t cmd_macsec_sa_pn =
13644 TOKEN_NUM_INITIALIZER
13645 (struct cmd_macsec_sa_result,
13647 cmdline_parse_token_string_t cmd_macsec_sa_key =
13648 TOKEN_STRING_INITIALIZER
13649 (struct cmd_macsec_sa_result,
13653 cmd_set_macsec_sa_parsed(
13654 void *parsed_result,
13655 __attribute__((unused)) struct cmdline *cl,
13656 __attribute__((unused)) void *data)
13658 struct cmd_macsec_sa_result *res = parsed_result;
13659 int ret = -ENOTSUP;
13660 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13661 uint8_t key[16] = { 0 };
13667 key_len = strlen(res->key) / 2;
13671 for (i = 0; i < key_len; i++) {
13672 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
13675 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
13678 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
13681 #ifdef RTE_LIBRTE_IXGBE_PMD
13683 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
13684 res->idx, res->an, res->pn, key) :
13685 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
13686 res->idx, res->an, res->pn, key);
13688 RTE_SET_USED(is_tx);
13695 printf("invalid idx %d or an %d\n", res->idx, res->an);
13698 printf("invalid port_id %d\n", res->port_id);
13701 printf("not supported on port %d\n", res->port_id);
13704 printf("programming error: (%s)\n", strerror(-ret));
13708 cmdline_parse_inst_t cmd_set_macsec_sa = {
13709 .f = cmd_set_macsec_sa_parsed,
13711 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
13713 (void *)&cmd_macsec_sa_set,
13714 (void *)&cmd_macsec_sa_macsec,
13715 (void *)&cmd_macsec_sa_sa,
13716 (void *)&cmd_macsec_sa_tx_rx,
13717 (void *)&cmd_macsec_sa_port_id,
13718 (void *)&cmd_macsec_sa_idx,
13719 (void *)&cmd_macsec_sa_an,
13720 (void *)&cmd_macsec_sa_pn,
13721 (void *)&cmd_macsec_sa_key,
13726 /* VF unicast promiscuous mode configuration */
13728 /* Common result structure for VF unicast promiscuous mode */
13729 struct cmd_vf_promisc_result {
13730 cmdline_fixed_string_t set;
13731 cmdline_fixed_string_t vf;
13732 cmdline_fixed_string_t promisc;
13735 cmdline_fixed_string_t on_off;
13738 /* Common CLI fields for VF unicast promiscuous mode enable disable */
13739 cmdline_parse_token_string_t cmd_vf_promisc_set =
13740 TOKEN_STRING_INITIALIZER
13741 (struct cmd_vf_promisc_result,
13743 cmdline_parse_token_string_t cmd_vf_promisc_vf =
13744 TOKEN_STRING_INITIALIZER
13745 (struct cmd_vf_promisc_result,
13747 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
13748 TOKEN_STRING_INITIALIZER
13749 (struct cmd_vf_promisc_result,
13750 promisc, "promisc");
13751 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
13752 TOKEN_NUM_INITIALIZER
13753 (struct cmd_vf_promisc_result,
13755 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
13756 TOKEN_NUM_INITIALIZER
13757 (struct cmd_vf_promisc_result,
13759 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
13760 TOKEN_STRING_INITIALIZER
13761 (struct cmd_vf_promisc_result,
13765 cmd_set_vf_promisc_parsed(
13766 void *parsed_result,
13767 __attribute__((unused)) struct cmdline *cl,
13768 __attribute__((unused)) void *data)
13770 struct cmd_vf_promisc_result *res = parsed_result;
13771 int ret = -ENOTSUP;
13773 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13775 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13778 #ifdef RTE_LIBRTE_I40E_PMD
13779 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
13780 res->vf_id, is_on);
13787 printf("invalid vf_id %d\n", res->vf_id);
13790 printf("invalid port_id %d\n", res->port_id);
13793 printf("function not implemented\n");
13796 printf("programming error: (%s)\n", strerror(-ret));
13800 cmdline_parse_inst_t cmd_set_vf_promisc = {
13801 .f = cmd_set_vf_promisc_parsed,
13803 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
13804 "Set unicast promiscuous mode for a VF from the PF",
13806 (void *)&cmd_vf_promisc_set,
13807 (void *)&cmd_vf_promisc_vf,
13808 (void *)&cmd_vf_promisc_promisc,
13809 (void *)&cmd_vf_promisc_port_id,
13810 (void *)&cmd_vf_promisc_vf_id,
13811 (void *)&cmd_vf_promisc_on_off,
13816 /* VF multicast promiscuous mode configuration */
13818 /* Common result structure for VF multicast promiscuous mode */
13819 struct cmd_vf_allmulti_result {
13820 cmdline_fixed_string_t set;
13821 cmdline_fixed_string_t vf;
13822 cmdline_fixed_string_t allmulti;
13825 cmdline_fixed_string_t on_off;
13828 /* Common CLI fields for VF multicast promiscuous mode enable disable */
13829 cmdline_parse_token_string_t cmd_vf_allmulti_set =
13830 TOKEN_STRING_INITIALIZER
13831 (struct cmd_vf_allmulti_result,
13833 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
13834 TOKEN_STRING_INITIALIZER
13835 (struct cmd_vf_allmulti_result,
13837 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
13838 TOKEN_STRING_INITIALIZER
13839 (struct cmd_vf_allmulti_result,
13840 allmulti, "allmulti");
13841 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
13842 TOKEN_NUM_INITIALIZER
13843 (struct cmd_vf_allmulti_result,
13845 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
13846 TOKEN_NUM_INITIALIZER
13847 (struct cmd_vf_allmulti_result,
13849 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
13850 TOKEN_STRING_INITIALIZER
13851 (struct cmd_vf_allmulti_result,
13855 cmd_set_vf_allmulti_parsed(
13856 void *parsed_result,
13857 __attribute__((unused)) struct cmdline *cl,
13858 __attribute__((unused)) void *data)
13860 struct cmd_vf_allmulti_result *res = parsed_result;
13861 int ret = -ENOTSUP;
13863 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13865 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13868 #ifdef RTE_LIBRTE_I40E_PMD
13869 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
13870 res->vf_id, is_on);
13877 printf("invalid vf_id %d\n", res->vf_id);
13880 printf("invalid port_id %d\n", res->port_id);
13883 printf("function not implemented\n");
13886 printf("programming error: (%s)\n", strerror(-ret));
13890 cmdline_parse_inst_t cmd_set_vf_allmulti = {
13891 .f = cmd_set_vf_allmulti_parsed,
13893 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
13894 "Set multicast promiscuous mode for a VF from the PF",
13896 (void *)&cmd_vf_allmulti_set,
13897 (void *)&cmd_vf_allmulti_vf,
13898 (void *)&cmd_vf_allmulti_allmulti,
13899 (void *)&cmd_vf_allmulti_port_id,
13900 (void *)&cmd_vf_allmulti_vf_id,
13901 (void *)&cmd_vf_allmulti_on_off,
13906 /* vf broadcast mode configuration */
13908 /* Common result structure for vf broadcast */
13909 struct cmd_set_vf_broadcast_result {
13910 cmdline_fixed_string_t set;
13911 cmdline_fixed_string_t vf;
13912 cmdline_fixed_string_t broadcast;
13915 cmdline_fixed_string_t on_off;
13918 /* Common CLI fields for vf broadcast enable disable */
13919 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
13920 TOKEN_STRING_INITIALIZER
13921 (struct cmd_set_vf_broadcast_result,
13923 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
13924 TOKEN_STRING_INITIALIZER
13925 (struct cmd_set_vf_broadcast_result,
13927 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
13928 TOKEN_STRING_INITIALIZER
13929 (struct cmd_set_vf_broadcast_result,
13930 broadcast, "broadcast");
13931 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
13932 TOKEN_NUM_INITIALIZER
13933 (struct cmd_set_vf_broadcast_result,
13935 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
13936 TOKEN_NUM_INITIALIZER
13937 (struct cmd_set_vf_broadcast_result,
13939 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
13940 TOKEN_STRING_INITIALIZER
13941 (struct cmd_set_vf_broadcast_result,
13945 cmd_set_vf_broadcast_parsed(
13946 void *parsed_result,
13947 __attribute__((unused)) struct cmdline *cl,
13948 __attribute__((unused)) void *data)
13950 struct cmd_set_vf_broadcast_result *res = parsed_result;
13951 int ret = -ENOTSUP;
13953 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13955 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13958 #ifdef RTE_LIBRTE_I40E_PMD
13959 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
13960 res->vf_id, is_on);
13967 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13970 printf("invalid port_id %d\n", res->port_id);
13973 printf("function not implemented\n");
13976 printf("programming error: (%s)\n", strerror(-ret));
13980 cmdline_parse_inst_t cmd_set_vf_broadcast = {
13981 .f = cmd_set_vf_broadcast_parsed,
13983 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
13985 (void *)&cmd_set_vf_broadcast_set,
13986 (void *)&cmd_set_vf_broadcast_vf,
13987 (void *)&cmd_set_vf_broadcast_broadcast,
13988 (void *)&cmd_set_vf_broadcast_port_id,
13989 (void *)&cmd_set_vf_broadcast_vf_id,
13990 (void *)&cmd_set_vf_broadcast_on_off,
13995 /* vf vlan tag configuration */
13997 /* Common result structure for vf vlan tag */
13998 struct cmd_set_vf_vlan_tag_result {
13999 cmdline_fixed_string_t set;
14000 cmdline_fixed_string_t vf;
14001 cmdline_fixed_string_t vlan;
14002 cmdline_fixed_string_t tag;
14005 cmdline_fixed_string_t on_off;
14008 /* Common CLI fields for vf vlan tag enable disable */
14009 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
14010 TOKEN_STRING_INITIALIZER
14011 (struct cmd_set_vf_vlan_tag_result,
14013 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
14014 TOKEN_STRING_INITIALIZER
14015 (struct cmd_set_vf_vlan_tag_result,
14017 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
14018 TOKEN_STRING_INITIALIZER
14019 (struct cmd_set_vf_vlan_tag_result,
14021 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
14022 TOKEN_STRING_INITIALIZER
14023 (struct cmd_set_vf_vlan_tag_result,
14025 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
14026 TOKEN_NUM_INITIALIZER
14027 (struct cmd_set_vf_vlan_tag_result,
14029 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
14030 TOKEN_NUM_INITIALIZER
14031 (struct cmd_set_vf_vlan_tag_result,
14033 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
14034 TOKEN_STRING_INITIALIZER
14035 (struct cmd_set_vf_vlan_tag_result,
14039 cmd_set_vf_vlan_tag_parsed(
14040 void *parsed_result,
14041 __attribute__((unused)) struct cmdline *cl,
14042 __attribute__((unused)) void *data)
14044 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
14045 int ret = -ENOTSUP;
14047 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14049 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14052 #ifdef RTE_LIBRTE_I40E_PMD
14053 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
14054 res->vf_id, is_on);
14061 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14064 printf("invalid port_id %d\n", res->port_id);
14067 printf("function not implemented\n");
14070 printf("programming error: (%s)\n", strerror(-ret));
14074 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
14075 .f = cmd_set_vf_vlan_tag_parsed,
14077 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
14079 (void *)&cmd_set_vf_vlan_tag_set,
14080 (void *)&cmd_set_vf_vlan_tag_vf,
14081 (void *)&cmd_set_vf_vlan_tag_vlan,
14082 (void *)&cmd_set_vf_vlan_tag_tag,
14083 (void *)&cmd_set_vf_vlan_tag_port_id,
14084 (void *)&cmd_set_vf_vlan_tag_vf_id,
14085 (void *)&cmd_set_vf_vlan_tag_on_off,
14090 /* Common definition of VF and TC TX bandwidth configuration */
14091 struct cmd_vf_tc_bw_result {
14092 cmdline_fixed_string_t set;
14093 cmdline_fixed_string_t vf;
14094 cmdline_fixed_string_t tc;
14095 cmdline_fixed_string_t tx;
14096 cmdline_fixed_string_t min_bw;
14097 cmdline_fixed_string_t max_bw;
14098 cmdline_fixed_string_t strict_link_prio;
14103 cmdline_fixed_string_t bw_list;
14107 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
14108 TOKEN_STRING_INITIALIZER
14109 (struct cmd_vf_tc_bw_result,
14111 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
14112 TOKEN_STRING_INITIALIZER
14113 (struct cmd_vf_tc_bw_result,
14115 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
14116 TOKEN_STRING_INITIALIZER
14117 (struct cmd_vf_tc_bw_result,
14119 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
14120 TOKEN_STRING_INITIALIZER
14121 (struct cmd_vf_tc_bw_result,
14123 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
14124 TOKEN_STRING_INITIALIZER
14125 (struct cmd_vf_tc_bw_result,
14126 strict_link_prio, "strict-link-priority");
14127 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
14128 TOKEN_STRING_INITIALIZER
14129 (struct cmd_vf_tc_bw_result,
14130 min_bw, "min-bandwidth");
14131 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
14132 TOKEN_STRING_INITIALIZER
14133 (struct cmd_vf_tc_bw_result,
14134 max_bw, "max-bandwidth");
14135 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
14136 TOKEN_NUM_INITIALIZER
14137 (struct cmd_vf_tc_bw_result,
14139 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
14140 TOKEN_NUM_INITIALIZER
14141 (struct cmd_vf_tc_bw_result,
14143 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
14144 TOKEN_NUM_INITIALIZER
14145 (struct cmd_vf_tc_bw_result,
14147 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
14148 TOKEN_NUM_INITIALIZER
14149 (struct cmd_vf_tc_bw_result,
14151 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
14152 TOKEN_STRING_INITIALIZER
14153 (struct cmd_vf_tc_bw_result,
14155 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
14156 TOKEN_NUM_INITIALIZER
14157 (struct cmd_vf_tc_bw_result,
14160 /* VF max bandwidth setting */
14162 cmd_vf_max_bw_parsed(
14163 void *parsed_result,
14164 __attribute__((unused)) struct cmdline *cl,
14165 __attribute__((unused)) void *data)
14167 struct cmd_vf_tc_bw_result *res = parsed_result;
14168 int ret = -ENOTSUP;
14170 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14173 #ifdef RTE_LIBRTE_I40E_PMD
14174 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
14175 res->vf_id, res->bw);
14182 printf("invalid vf_id %d or bandwidth %d\n",
14183 res->vf_id, res->bw);
14186 printf("invalid port_id %d\n", res->port_id);
14189 printf("function not implemented\n");
14192 printf("programming error: (%s)\n", strerror(-ret));
14196 cmdline_parse_inst_t cmd_vf_max_bw = {
14197 .f = cmd_vf_max_bw_parsed,
14199 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
14201 (void *)&cmd_vf_tc_bw_set,
14202 (void *)&cmd_vf_tc_bw_vf,
14203 (void *)&cmd_vf_tc_bw_tx,
14204 (void *)&cmd_vf_tc_bw_max_bw,
14205 (void *)&cmd_vf_tc_bw_port_id,
14206 (void *)&cmd_vf_tc_bw_vf_id,
14207 (void *)&cmd_vf_tc_bw_bw,
14213 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
14218 const char *p, *p0 = str;
14225 p = strchr(p0, '(');
14227 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14231 p0 = strchr(p, ')');
14233 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14237 if (size >= sizeof(s)) {
14238 printf("The string size exceeds the internal buffer size\n");
14241 snprintf(s, sizeof(s), "%.*s", size, p);
14242 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
14244 printf("Failed to get the bandwidth list. ");
14248 for (i = 0; i < ret; i++)
14249 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
14254 /* TC min bandwidth setting */
14256 cmd_vf_tc_min_bw_parsed(
14257 void *parsed_result,
14258 __attribute__((unused)) struct cmdline *cl,
14259 __attribute__((unused)) void *data)
14261 struct cmd_vf_tc_bw_result *res = parsed_result;
14264 int ret = -ENOTSUP;
14266 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14269 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14273 #ifdef RTE_LIBRTE_I40E_PMD
14274 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
14282 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
14285 printf("invalid port_id %d\n", res->port_id);
14288 printf("function not implemented\n");
14291 printf("programming error: (%s)\n", strerror(-ret));
14295 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
14296 .f = cmd_vf_tc_min_bw_parsed,
14298 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
14299 " <bw1, bw2, ...>",
14301 (void *)&cmd_vf_tc_bw_set,
14302 (void *)&cmd_vf_tc_bw_vf,
14303 (void *)&cmd_vf_tc_bw_tc,
14304 (void *)&cmd_vf_tc_bw_tx,
14305 (void *)&cmd_vf_tc_bw_min_bw,
14306 (void *)&cmd_vf_tc_bw_port_id,
14307 (void *)&cmd_vf_tc_bw_vf_id,
14308 (void *)&cmd_vf_tc_bw_bw_list,
14314 cmd_tc_min_bw_parsed(
14315 void *parsed_result,
14316 __attribute__((unused)) struct cmdline *cl,
14317 __attribute__((unused)) void *data)
14319 struct cmd_vf_tc_bw_result *res = parsed_result;
14320 struct rte_port *port;
14323 int ret = -ENOTSUP;
14325 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14328 port = &ports[res->port_id];
14329 /** Check if the port is not started **/
14330 if (port->port_status != RTE_PORT_STOPPED) {
14331 printf("Please stop port %d first\n", res->port_id);
14335 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14339 #ifdef RTE_LIBRTE_IXGBE_PMD
14340 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
14347 printf("invalid bandwidth\n");
14350 printf("invalid port_id %d\n", res->port_id);
14353 printf("function not implemented\n");
14356 printf("programming error: (%s)\n", strerror(-ret));
14360 cmdline_parse_inst_t cmd_tc_min_bw = {
14361 .f = cmd_tc_min_bw_parsed,
14363 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
14365 (void *)&cmd_vf_tc_bw_set,
14366 (void *)&cmd_vf_tc_bw_tc,
14367 (void *)&cmd_vf_tc_bw_tx,
14368 (void *)&cmd_vf_tc_bw_min_bw,
14369 (void *)&cmd_vf_tc_bw_port_id,
14370 (void *)&cmd_vf_tc_bw_bw_list,
14375 /* TC max bandwidth setting */
14377 cmd_vf_tc_max_bw_parsed(
14378 void *parsed_result,
14379 __attribute__((unused)) struct cmdline *cl,
14380 __attribute__((unused)) void *data)
14382 struct cmd_vf_tc_bw_result *res = parsed_result;
14383 int ret = -ENOTSUP;
14385 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14388 #ifdef RTE_LIBRTE_I40E_PMD
14389 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
14390 res->tc_no, res->bw);
14397 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
14398 res->vf_id, res->tc_no, res->bw);
14401 printf("invalid port_id %d\n", res->port_id);
14404 printf("function not implemented\n");
14407 printf("programming error: (%s)\n", strerror(-ret));
14411 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
14412 .f = cmd_vf_tc_max_bw_parsed,
14414 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
14417 (void *)&cmd_vf_tc_bw_set,
14418 (void *)&cmd_vf_tc_bw_vf,
14419 (void *)&cmd_vf_tc_bw_tc,
14420 (void *)&cmd_vf_tc_bw_tx,
14421 (void *)&cmd_vf_tc_bw_max_bw,
14422 (void *)&cmd_vf_tc_bw_port_id,
14423 (void *)&cmd_vf_tc_bw_vf_id,
14424 (void *)&cmd_vf_tc_bw_tc_no,
14425 (void *)&cmd_vf_tc_bw_bw,
14431 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
14433 /* *** Set Port default Traffic Management Hierarchy *** */
14434 struct cmd_set_port_tm_hierarchy_default_result {
14435 cmdline_fixed_string_t set;
14436 cmdline_fixed_string_t port;
14437 cmdline_fixed_string_t tm;
14438 cmdline_fixed_string_t hierarchy;
14439 cmdline_fixed_string_t def;
14443 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
14444 TOKEN_STRING_INITIALIZER(
14445 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
14446 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
14447 TOKEN_STRING_INITIALIZER(
14448 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
14449 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
14450 TOKEN_STRING_INITIALIZER(
14451 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
14452 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
14453 TOKEN_STRING_INITIALIZER(
14454 struct cmd_set_port_tm_hierarchy_default_result,
14455 hierarchy, "hierarchy");
14456 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
14457 TOKEN_STRING_INITIALIZER(
14458 struct cmd_set_port_tm_hierarchy_default_result,
14460 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
14461 TOKEN_NUM_INITIALIZER(
14462 struct cmd_set_port_tm_hierarchy_default_result,
14465 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
14466 __attribute__((unused)) struct cmdline *cl,
14467 __attribute__((unused)) void *data)
14469 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
14470 struct rte_port *p;
14471 portid_t port_id = res->port_id;
14473 if (port_id_is_invalid(port_id, ENABLED_WARN))
14476 p = &ports[port_id];
14479 if (p->softport.tm_flag == 0) {
14480 printf(" tm not enabled on port %u (error)\n", port_id);
14484 /* Forward mode: tm */
14485 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "tm")) {
14486 printf(" tm mode not enabled(error)\n");
14490 /* Set the default tm hierarchy */
14491 p->softport.tm.default_hierarchy_enable = 1;
14494 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
14495 .f = cmd_set_port_tm_hierarchy_default_parsed,
14497 .help_str = "set port tm hierarchy default <port_id>",
14499 (void *)&cmd_set_port_tm_hierarchy_default_set,
14500 (void *)&cmd_set_port_tm_hierarchy_default_port,
14501 (void *)&cmd_set_port_tm_hierarchy_default_tm,
14502 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
14503 (void *)&cmd_set_port_tm_hierarchy_default_default,
14504 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
14510 /* Strict link priority scheduling mode setting */
14512 cmd_strict_link_prio_parsed(
14513 void *parsed_result,
14514 __attribute__((unused)) struct cmdline *cl,
14515 __attribute__((unused)) void *data)
14517 struct cmd_vf_tc_bw_result *res = parsed_result;
14518 int ret = -ENOTSUP;
14520 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14523 #ifdef RTE_LIBRTE_I40E_PMD
14524 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
14531 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
14534 printf("invalid port_id %d\n", res->port_id);
14537 printf("function not implemented\n");
14540 printf("programming error: (%s)\n", strerror(-ret));
14544 cmdline_parse_inst_t cmd_strict_link_prio = {
14545 .f = cmd_strict_link_prio_parsed,
14547 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
14549 (void *)&cmd_vf_tc_bw_set,
14550 (void *)&cmd_vf_tc_bw_tx,
14551 (void *)&cmd_vf_tc_bw_strict_link_prio,
14552 (void *)&cmd_vf_tc_bw_port_id,
14553 (void *)&cmd_vf_tc_bw_tc_map,
14558 /* Load dynamic device personalization*/
14559 struct cmd_ddp_add_result {
14560 cmdline_fixed_string_t ddp;
14561 cmdline_fixed_string_t add;
14566 cmdline_parse_token_string_t cmd_ddp_add_ddp =
14567 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
14568 cmdline_parse_token_string_t cmd_ddp_add_add =
14569 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
14570 cmdline_parse_token_num_t cmd_ddp_add_port_id =
14571 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
14572 cmdline_parse_token_string_t cmd_ddp_add_filepath =
14573 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
14576 cmd_ddp_add_parsed(
14577 void *parsed_result,
14578 __attribute__((unused)) struct cmdline *cl,
14579 __attribute__((unused)) void *data)
14581 struct cmd_ddp_add_result *res = parsed_result;
14587 int ret = -ENOTSUP;
14589 if (res->port_id > nb_ports) {
14590 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14594 if (!all_ports_stopped()) {
14595 printf("Please stop all ports first\n");
14599 filepath = strdup(res->filepath);
14600 if (filepath == NULL) {
14601 printf("Failed to allocate memory\n");
14604 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
14606 buff = open_file(file_fld[0], &size);
14608 free((void *)filepath);
14612 #ifdef RTE_LIBRTE_I40E_PMD
14613 if (ret == -ENOTSUP)
14614 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14616 RTE_PMD_I40E_PKG_OP_WR_ADD);
14619 if (ret == -EEXIST)
14620 printf("Profile has already existed.\n");
14622 printf("Failed to load profile.\n");
14623 else if (file_num == 2)
14624 save_file(file_fld[1], buff, size);
14627 free((void *)filepath);
14630 cmdline_parse_inst_t cmd_ddp_add = {
14631 .f = cmd_ddp_add_parsed,
14633 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
14635 (void *)&cmd_ddp_add_ddp,
14636 (void *)&cmd_ddp_add_add,
14637 (void *)&cmd_ddp_add_port_id,
14638 (void *)&cmd_ddp_add_filepath,
14643 /* Delete dynamic device personalization*/
14644 struct cmd_ddp_del_result {
14645 cmdline_fixed_string_t ddp;
14646 cmdline_fixed_string_t del;
14651 cmdline_parse_token_string_t cmd_ddp_del_ddp =
14652 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
14653 cmdline_parse_token_string_t cmd_ddp_del_del =
14654 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
14655 cmdline_parse_token_num_t cmd_ddp_del_port_id =
14656 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
14657 cmdline_parse_token_string_t cmd_ddp_del_filepath =
14658 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
14661 cmd_ddp_del_parsed(
14662 void *parsed_result,
14663 __attribute__((unused)) struct cmdline *cl,
14664 __attribute__((unused)) void *data)
14666 struct cmd_ddp_del_result *res = parsed_result;
14669 int ret = -ENOTSUP;
14671 if (res->port_id > nb_ports) {
14672 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14676 if (!all_ports_stopped()) {
14677 printf("Please stop all ports first\n");
14681 buff = open_file(res->filepath, &size);
14685 #ifdef RTE_LIBRTE_I40E_PMD
14686 if (ret == -ENOTSUP)
14687 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14689 RTE_PMD_I40E_PKG_OP_WR_DEL);
14692 if (ret == -EACCES)
14693 printf("Profile does not exist.\n");
14695 printf("Failed to delete profile.\n");
14700 cmdline_parse_inst_t cmd_ddp_del = {
14701 .f = cmd_ddp_del_parsed,
14703 .help_str = "ddp del <port_id> <backup_profile_path>",
14705 (void *)&cmd_ddp_del_ddp,
14706 (void *)&cmd_ddp_del_del,
14707 (void *)&cmd_ddp_del_port_id,
14708 (void *)&cmd_ddp_del_filepath,
14713 /* Get dynamic device personalization profile info */
14714 struct cmd_ddp_info_result {
14715 cmdline_fixed_string_t ddp;
14716 cmdline_fixed_string_t get;
14717 cmdline_fixed_string_t info;
14721 cmdline_parse_token_string_t cmd_ddp_info_ddp =
14722 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
14723 cmdline_parse_token_string_t cmd_ddp_info_get =
14724 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
14725 cmdline_parse_token_string_t cmd_ddp_info_info =
14726 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
14727 cmdline_parse_token_string_t cmd_ddp_info_filepath =
14728 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
14731 cmd_ddp_info_parsed(
14732 void *parsed_result,
14733 __attribute__((unused)) struct cmdline *cl,
14734 __attribute__((unused)) void *data)
14736 struct cmd_ddp_info_result *res = parsed_result;
14739 int ret = -ENOTSUP;
14740 #ifdef RTE_LIBRTE_I40E_PMD
14743 uint32_t buff_size = 0;
14744 struct rte_pmd_i40e_profile_info info;
14745 uint32_t dev_num = 0;
14746 struct rte_pmd_i40e_ddp_device_id *devs;
14747 uint32_t proto_num = 0;
14748 struct rte_pmd_i40e_proto_info *proto = NULL;
14749 uint32_t pctype_num = 0;
14750 struct rte_pmd_i40e_ptype_info *pctype;
14751 uint32_t ptype_num = 0;
14752 struct rte_pmd_i40e_ptype_info *ptype;
14757 pkg = open_file(res->filepath, &pkg_size);
14761 #ifdef RTE_LIBRTE_I40E_PMD
14762 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14763 (uint8_t *)&info, sizeof(info),
14764 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
14766 printf("Global Track id: 0x%x\n", info.track_id);
14767 printf("Global Version: %d.%d.%d.%d\n",
14768 info.version.major,
14769 info.version.minor,
14770 info.version.update,
14771 info.version.draft);
14772 printf("Global Package name: %s\n\n", info.name);
14775 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14776 (uint8_t *)&info, sizeof(info),
14777 RTE_PMD_I40E_PKG_INFO_HEADER);
14779 printf("i40e Profile Track id: 0x%x\n", info.track_id);
14780 printf("i40e Profile Version: %d.%d.%d.%d\n",
14781 info.version.major,
14782 info.version.minor,
14783 info.version.update,
14784 info.version.draft);
14785 printf("i40e Profile name: %s\n\n", info.name);
14788 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14789 (uint8_t *)&buff_size, sizeof(buff_size),
14790 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
14791 if (!ret && buff_size) {
14792 buff = (uint8_t *)malloc(buff_size);
14794 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14796 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
14798 printf("Package Notes:\n%s\n\n", buff);
14803 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14804 (uint8_t *)&dev_num, sizeof(dev_num),
14805 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
14806 if (!ret && dev_num) {
14807 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
14808 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
14810 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14811 (uint8_t *)devs, buff_size,
14812 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
14814 printf("List of supported devices:\n");
14815 for (i = 0; i < dev_num; i++) {
14816 printf(" %04X:%04X %04X:%04X\n",
14817 devs[i].vendor_dev_id >> 16,
14818 devs[i].vendor_dev_id & 0xFFFF,
14819 devs[i].sub_vendor_dev_id >> 16,
14820 devs[i].sub_vendor_dev_id & 0xFFFF);
14828 /* get information about protocols and packet types */
14829 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14830 (uint8_t *)&proto_num, sizeof(proto_num),
14831 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
14832 if (ret || !proto_num)
14833 goto no_print_return;
14835 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
14836 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
14838 goto no_print_return;
14840 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
14842 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
14844 printf("List of used protocols:\n");
14845 for (i = 0; i < proto_num; i++)
14846 printf(" %2u: %s\n", proto[i].proto_id,
14850 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14851 (uint8_t *)&pctype_num, sizeof(pctype_num),
14852 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
14853 if (ret || !pctype_num)
14854 goto no_print_pctypes;
14856 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14857 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14859 goto no_print_pctypes;
14861 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
14863 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
14866 goto no_print_pctypes;
14869 printf("List of defined packet classification types:\n");
14870 for (i = 0; i < pctype_num; i++) {
14871 printf(" %2u:", pctype[i].ptype_id);
14872 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14873 proto_id = pctype[i].protocols[j];
14874 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14875 for (n = 0; n < proto_num; n++) {
14876 if (proto[n].proto_id == proto_id) {
14877 printf(" %s", proto[n].name);
14890 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
14892 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
14893 if (ret || !ptype_num)
14894 goto no_print_return;
14896 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14897 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14899 goto no_print_return;
14901 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
14903 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
14906 goto no_print_return;
14908 printf("List of defined packet types:\n");
14909 for (i = 0; i < ptype_num; i++) {
14910 printf(" %2u:", ptype[i].ptype_id);
14911 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14912 proto_id = ptype[i].protocols[j];
14913 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14914 for (n = 0; n < proto_num; n++) {
14915 if (proto[n].proto_id == proto_id) {
14916 printf(" %s", proto[n].name);
14932 if (ret == -ENOTSUP)
14933 printf("Function not supported in PMD driver\n");
14937 cmdline_parse_inst_t cmd_ddp_get_info = {
14938 .f = cmd_ddp_info_parsed,
14940 .help_str = "ddp get info <profile_path>",
14942 (void *)&cmd_ddp_info_ddp,
14943 (void *)&cmd_ddp_info_get,
14944 (void *)&cmd_ddp_info_info,
14945 (void *)&cmd_ddp_info_filepath,
14950 /* Get dynamic device personalization profile info list*/
14951 #define PROFILE_INFO_SIZE 48
14952 #define MAX_PROFILE_NUM 16
14954 struct cmd_ddp_get_list_result {
14955 cmdline_fixed_string_t ddp;
14956 cmdline_fixed_string_t get;
14957 cmdline_fixed_string_t list;
14961 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
14962 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
14963 cmdline_parse_token_string_t cmd_ddp_get_list_get =
14964 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
14965 cmdline_parse_token_string_t cmd_ddp_get_list_list =
14966 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
14967 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
14968 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
14971 cmd_ddp_get_list_parsed(
14972 void *parsed_result,
14973 __attribute__((unused)) struct cmdline *cl,
14974 __attribute__((unused)) void *data)
14976 struct cmd_ddp_get_list_result *res = parsed_result;
14977 #ifdef RTE_LIBRTE_I40E_PMD
14978 struct rte_pmd_i40e_profile_list *p_list;
14979 struct rte_pmd_i40e_profile_info *p_info;
14984 int ret = -ENOTSUP;
14986 if (res->port_id > nb_ports) {
14987 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14991 #ifdef RTE_LIBRTE_I40E_PMD
14992 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
14993 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
14995 printf("%s: Failed to malloc buffer\n", __func__);
14997 if (ret == -ENOTSUP)
14998 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
14999 (uint8_t *)p_list, size);
15002 p_num = p_list->p_count;
15003 printf("Profile number is: %d\n\n", p_num);
15005 for (i = 0; i < p_num; i++) {
15006 p_info = &p_list->p_info[i];
15007 printf("Profile %d:\n", i);
15008 printf("Track id: 0x%x\n", p_info->track_id);
15009 printf("Version: %d.%d.%d.%d\n",
15010 p_info->version.major,
15011 p_info->version.minor,
15012 p_info->version.update,
15013 p_info->version.draft);
15014 printf("Profile name: %s\n\n", p_info->name);
15022 printf("Failed to get ddp list\n");
15025 cmdline_parse_inst_t cmd_ddp_get_list = {
15026 .f = cmd_ddp_get_list_parsed,
15028 .help_str = "ddp get list <port_id>",
15030 (void *)&cmd_ddp_get_list_ddp,
15031 (void *)&cmd_ddp_get_list_get,
15032 (void *)&cmd_ddp_get_list_list,
15033 (void *)&cmd_ddp_get_list_port_id,
15038 /* Configure input set */
15039 struct cmd_cfg_input_set_result {
15040 cmdline_fixed_string_t port;
15041 cmdline_fixed_string_t cfg;
15043 cmdline_fixed_string_t pctype;
15045 cmdline_fixed_string_t inset_type;
15046 cmdline_fixed_string_t opt;
15047 cmdline_fixed_string_t field;
15052 cmd_cfg_input_set_parsed(
15053 void *parsed_result,
15054 __attribute__((unused)) struct cmdline *cl,
15055 __attribute__((unused)) void *data)
15057 struct cmd_cfg_input_set_result *res = parsed_result;
15058 #ifdef RTE_LIBRTE_I40E_PMD
15059 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
15060 struct rte_pmd_i40e_inset inset;
15062 int ret = -ENOTSUP;
15064 if (res->port_id > nb_ports) {
15065 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
15069 if (!all_ports_stopped()) {
15070 printf("Please stop all ports first\n");
15074 #ifdef RTE_LIBRTE_I40E_PMD
15075 if (!strcmp(res->inset_type, "hash_inset"))
15076 inset_type = INSET_HASH;
15077 else if (!strcmp(res->inset_type, "fdir_inset"))
15078 inset_type = INSET_FDIR;
15079 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
15080 inset_type = INSET_FDIR_FLX;
15081 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
15082 &inset, inset_type);
15084 printf("Failed to get input set.\n");
15088 if (!strcmp(res->opt, "get")) {
15089 ret = rte_pmd_i40e_inset_field_get(inset.inset,
15092 printf("Field index %d is enabled.\n", res->field_idx);
15094 printf("Field index %d is disabled.\n", res->field_idx);
15096 } else if (!strcmp(res->opt, "set"))
15097 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
15099 else if (!strcmp(res->opt, "clear"))
15100 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
15103 printf("Failed to configure input set field.\n");
15107 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15108 &inset, inset_type);
15110 printf("Failed to set input set.\n");
15115 if (ret == -ENOTSUP)
15116 printf("Function not supported\n");
15119 cmdline_parse_token_string_t cmd_cfg_input_set_port =
15120 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15122 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
15123 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15125 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
15126 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15128 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
15129 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15131 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
15132 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15134 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
15135 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15137 "hash_inset#fdir_inset#fdir_flx_inset");
15138 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
15139 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15140 opt, "get#set#clear");
15141 cmdline_parse_token_string_t cmd_cfg_input_set_field =
15142 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15144 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
15145 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15148 cmdline_parse_inst_t cmd_cfg_input_set = {
15149 .f = cmd_cfg_input_set_parsed,
15151 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15152 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
15154 (void *)&cmd_cfg_input_set_port,
15155 (void *)&cmd_cfg_input_set_cfg,
15156 (void *)&cmd_cfg_input_set_port_id,
15157 (void *)&cmd_cfg_input_set_pctype,
15158 (void *)&cmd_cfg_input_set_pctype_id,
15159 (void *)&cmd_cfg_input_set_inset_type,
15160 (void *)&cmd_cfg_input_set_opt,
15161 (void *)&cmd_cfg_input_set_field,
15162 (void *)&cmd_cfg_input_set_field_idx,
15167 /* Clear input set */
15168 struct cmd_clear_input_set_result {
15169 cmdline_fixed_string_t port;
15170 cmdline_fixed_string_t cfg;
15172 cmdline_fixed_string_t pctype;
15174 cmdline_fixed_string_t inset_type;
15175 cmdline_fixed_string_t clear;
15176 cmdline_fixed_string_t all;
15180 cmd_clear_input_set_parsed(
15181 void *parsed_result,
15182 __attribute__((unused)) struct cmdline *cl,
15183 __attribute__((unused)) void *data)
15185 struct cmd_clear_input_set_result *res = parsed_result;
15186 #ifdef RTE_LIBRTE_I40E_PMD
15187 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
15188 struct rte_pmd_i40e_inset inset;
15190 int ret = -ENOTSUP;
15192 if (res->port_id > nb_ports) {
15193 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
15197 if (!all_ports_stopped()) {
15198 printf("Please stop all ports first\n");
15202 #ifdef RTE_LIBRTE_I40E_PMD
15203 if (!strcmp(res->inset_type, "hash_inset"))
15204 inset_type = INSET_HASH;
15205 else if (!strcmp(res->inset_type, "fdir_inset"))
15206 inset_type = INSET_FDIR;
15207 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
15208 inset_type = INSET_FDIR_FLX;
15210 memset(&inset, 0, sizeof(inset));
15212 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15213 &inset, inset_type);
15215 printf("Failed to clear input set.\n");
15221 if (ret == -ENOTSUP)
15222 printf("Function not supported\n");
15225 cmdline_parse_token_string_t cmd_clear_input_set_port =
15226 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15228 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
15229 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15231 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
15232 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15234 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
15235 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15237 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
15238 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15240 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
15241 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15243 "hash_inset#fdir_inset#fdir_flx_inset");
15244 cmdline_parse_token_string_t cmd_clear_input_set_clear =
15245 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15247 cmdline_parse_token_string_t cmd_clear_input_set_all =
15248 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15251 cmdline_parse_inst_t cmd_clear_input_set = {
15252 .f = cmd_clear_input_set_parsed,
15254 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15255 "fdir_inset|fdir_flx_inset clear all",
15257 (void *)&cmd_clear_input_set_port,
15258 (void *)&cmd_clear_input_set_cfg,
15259 (void *)&cmd_clear_input_set_port_id,
15260 (void *)&cmd_clear_input_set_pctype,
15261 (void *)&cmd_clear_input_set_pctype_id,
15262 (void *)&cmd_clear_input_set_inset_type,
15263 (void *)&cmd_clear_input_set_clear,
15264 (void *)&cmd_clear_input_set_all,
15269 /* show vf stats */
15271 /* Common result structure for show vf stats */
15272 struct cmd_show_vf_stats_result {
15273 cmdline_fixed_string_t show;
15274 cmdline_fixed_string_t vf;
15275 cmdline_fixed_string_t stats;
15280 /* Common CLI fields show vf stats*/
15281 cmdline_parse_token_string_t cmd_show_vf_stats_show =
15282 TOKEN_STRING_INITIALIZER
15283 (struct cmd_show_vf_stats_result,
15285 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
15286 TOKEN_STRING_INITIALIZER
15287 (struct cmd_show_vf_stats_result,
15289 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
15290 TOKEN_STRING_INITIALIZER
15291 (struct cmd_show_vf_stats_result,
15293 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
15294 TOKEN_NUM_INITIALIZER
15295 (struct cmd_show_vf_stats_result,
15297 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
15298 TOKEN_NUM_INITIALIZER
15299 (struct cmd_show_vf_stats_result,
15303 cmd_show_vf_stats_parsed(
15304 void *parsed_result,
15305 __attribute__((unused)) struct cmdline *cl,
15306 __attribute__((unused)) void *data)
15308 struct cmd_show_vf_stats_result *res = parsed_result;
15309 struct rte_eth_stats stats;
15310 int ret = -ENOTSUP;
15311 static const char *nic_stats_border = "########################";
15313 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15316 memset(&stats, 0, sizeof(stats));
15318 #ifdef RTE_LIBRTE_I40E_PMD
15319 if (ret == -ENOTSUP)
15320 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
15324 #ifdef RTE_LIBRTE_BNXT_PMD
15325 if (ret == -ENOTSUP)
15326 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
15335 printf("invalid vf_id %d\n", res->vf_id);
15338 printf("invalid port_id %d\n", res->port_id);
15341 printf("function not implemented\n");
15344 printf("programming error: (%s)\n", strerror(-ret));
15347 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
15348 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
15350 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
15352 stats.ipackets, stats.imissed, stats.ibytes);
15353 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
15354 printf(" RX-nombuf: %-10"PRIu64"\n",
15356 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
15358 stats.opackets, stats.oerrors, stats.obytes);
15360 printf(" %s############################%s\n",
15361 nic_stats_border, nic_stats_border);
15364 cmdline_parse_inst_t cmd_show_vf_stats = {
15365 .f = cmd_show_vf_stats_parsed,
15367 .help_str = "show vf stats <port_id> <vf_id>",
15369 (void *)&cmd_show_vf_stats_show,
15370 (void *)&cmd_show_vf_stats_vf,
15371 (void *)&cmd_show_vf_stats_stats,
15372 (void *)&cmd_show_vf_stats_port_id,
15373 (void *)&cmd_show_vf_stats_vf_id,
15378 /* clear vf stats */
15380 /* Common result structure for clear vf stats */
15381 struct cmd_clear_vf_stats_result {
15382 cmdline_fixed_string_t clear;
15383 cmdline_fixed_string_t vf;
15384 cmdline_fixed_string_t stats;
15389 /* Common CLI fields clear vf stats*/
15390 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
15391 TOKEN_STRING_INITIALIZER
15392 (struct cmd_clear_vf_stats_result,
15394 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
15395 TOKEN_STRING_INITIALIZER
15396 (struct cmd_clear_vf_stats_result,
15398 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
15399 TOKEN_STRING_INITIALIZER
15400 (struct cmd_clear_vf_stats_result,
15402 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
15403 TOKEN_NUM_INITIALIZER
15404 (struct cmd_clear_vf_stats_result,
15406 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
15407 TOKEN_NUM_INITIALIZER
15408 (struct cmd_clear_vf_stats_result,
15412 cmd_clear_vf_stats_parsed(
15413 void *parsed_result,
15414 __attribute__((unused)) struct cmdline *cl,
15415 __attribute__((unused)) void *data)
15417 struct cmd_clear_vf_stats_result *res = parsed_result;
15418 int ret = -ENOTSUP;
15420 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15423 #ifdef RTE_LIBRTE_I40E_PMD
15424 if (ret == -ENOTSUP)
15425 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
15428 #ifdef RTE_LIBRTE_BNXT_PMD
15429 if (ret == -ENOTSUP)
15430 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
15438 printf("invalid vf_id %d\n", res->vf_id);
15441 printf("invalid port_id %d\n", res->port_id);
15444 printf("function not implemented\n");
15447 printf("programming error: (%s)\n", strerror(-ret));
15451 cmdline_parse_inst_t cmd_clear_vf_stats = {
15452 .f = cmd_clear_vf_stats_parsed,
15454 .help_str = "clear vf stats <port_id> <vf_id>",
15456 (void *)&cmd_clear_vf_stats_clear,
15457 (void *)&cmd_clear_vf_stats_vf,
15458 (void *)&cmd_clear_vf_stats_stats,
15459 (void *)&cmd_clear_vf_stats_port_id,
15460 (void *)&cmd_clear_vf_stats_vf_id,
15465 /* port config pctype mapping reset */
15467 /* Common result structure for port config pctype mapping reset */
15468 struct cmd_pctype_mapping_reset_result {
15469 cmdline_fixed_string_t port;
15470 cmdline_fixed_string_t config;
15472 cmdline_fixed_string_t pctype;
15473 cmdline_fixed_string_t mapping;
15474 cmdline_fixed_string_t reset;
15477 /* Common CLI fields for port config pctype mapping reset*/
15478 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
15479 TOKEN_STRING_INITIALIZER
15480 (struct cmd_pctype_mapping_reset_result,
15482 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
15483 TOKEN_STRING_INITIALIZER
15484 (struct cmd_pctype_mapping_reset_result,
15486 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
15487 TOKEN_NUM_INITIALIZER
15488 (struct cmd_pctype_mapping_reset_result,
15490 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
15491 TOKEN_STRING_INITIALIZER
15492 (struct cmd_pctype_mapping_reset_result,
15494 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
15495 TOKEN_STRING_INITIALIZER
15496 (struct cmd_pctype_mapping_reset_result,
15497 mapping, "mapping");
15498 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
15499 TOKEN_STRING_INITIALIZER
15500 (struct cmd_pctype_mapping_reset_result,
15504 cmd_pctype_mapping_reset_parsed(
15505 void *parsed_result,
15506 __attribute__((unused)) struct cmdline *cl,
15507 __attribute__((unused)) void *data)
15509 struct cmd_pctype_mapping_reset_result *res = parsed_result;
15510 int ret = -ENOTSUP;
15512 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15515 #ifdef RTE_LIBRTE_I40E_PMD
15516 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
15523 printf("invalid port_id %d\n", res->port_id);
15526 printf("function not implemented\n");
15529 printf("programming error: (%s)\n", strerror(-ret));
15533 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
15534 .f = cmd_pctype_mapping_reset_parsed,
15536 .help_str = "port config <port_id> pctype mapping reset",
15538 (void *)&cmd_pctype_mapping_reset_port,
15539 (void *)&cmd_pctype_mapping_reset_config,
15540 (void *)&cmd_pctype_mapping_reset_port_id,
15541 (void *)&cmd_pctype_mapping_reset_pctype,
15542 (void *)&cmd_pctype_mapping_reset_mapping,
15543 (void *)&cmd_pctype_mapping_reset_reset,
15548 /* show port pctype mapping */
15550 /* Common result structure for show port pctype mapping */
15551 struct cmd_pctype_mapping_get_result {
15552 cmdline_fixed_string_t show;
15553 cmdline_fixed_string_t port;
15555 cmdline_fixed_string_t pctype;
15556 cmdline_fixed_string_t mapping;
15559 /* Common CLI fields for pctype mapping get */
15560 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
15561 TOKEN_STRING_INITIALIZER
15562 (struct cmd_pctype_mapping_get_result,
15564 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
15565 TOKEN_STRING_INITIALIZER
15566 (struct cmd_pctype_mapping_get_result,
15568 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
15569 TOKEN_NUM_INITIALIZER
15570 (struct cmd_pctype_mapping_get_result,
15572 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
15573 TOKEN_STRING_INITIALIZER
15574 (struct cmd_pctype_mapping_get_result,
15576 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
15577 TOKEN_STRING_INITIALIZER
15578 (struct cmd_pctype_mapping_get_result,
15579 mapping, "mapping");
15582 cmd_pctype_mapping_get_parsed(
15583 void *parsed_result,
15584 __attribute__((unused)) struct cmdline *cl,
15585 __attribute__((unused)) void *data)
15587 struct cmd_pctype_mapping_get_result *res = parsed_result;
15588 int ret = -ENOTSUP;
15589 #ifdef RTE_LIBRTE_I40E_PMD
15590 struct rte_pmd_i40e_flow_type_mapping
15591 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
15592 int i, j, first_pctype;
15595 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15598 #ifdef RTE_LIBRTE_I40E_PMD
15599 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
15606 printf("invalid port_id %d\n", res->port_id);
15609 printf("function not implemented\n");
15612 printf("programming error: (%s)\n", strerror(-ret));
15616 #ifdef RTE_LIBRTE_I40E_PMD
15617 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
15618 if (mapping[i].pctype != 0ULL) {
15621 printf("pctype: ");
15622 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
15623 if (mapping[i].pctype & (1ULL << j)) {
15624 printf(first_pctype ?
15625 "%02d" : ",%02d", j);
15629 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
15635 cmdline_parse_inst_t cmd_pctype_mapping_get = {
15636 .f = cmd_pctype_mapping_get_parsed,
15638 .help_str = "show port <port_id> pctype mapping",
15640 (void *)&cmd_pctype_mapping_get_show,
15641 (void *)&cmd_pctype_mapping_get_port,
15642 (void *)&cmd_pctype_mapping_get_port_id,
15643 (void *)&cmd_pctype_mapping_get_pctype,
15644 (void *)&cmd_pctype_mapping_get_mapping,
15649 /* port config pctype mapping update */
15651 /* Common result structure for port config pctype mapping update */
15652 struct cmd_pctype_mapping_update_result {
15653 cmdline_fixed_string_t port;
15654 cmdline_fixed_string_t config;
15656 cmdline_fixed_string_t pctype;
15657 cmdline_fixed_string_t mapping;
15658 cmdline_fixed_string_t update;
15659 cmdline_fixed_string_t pctype_list;
15660 uint16_t flow_type;
15663 /* Common CLI fields for pctype mapping update*/
15664 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
15665 TOKEN_STRING_INITIALIZER
15666 (struct cmd_pctype_mapping_update_result,
15668 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
15669 TOKEN_STRING_INITIALIZER
15670 (struct cmd_pctype_mapping_update_result,
15672 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
15673 TOKEN_NUM_INITIALIZER
15674 (struct cmd_pctype_mapping_update_result,
15676 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
15677 TOKEN_STRING_INITIALIZER
15678 (struct cmd_pctype_mapping_update_result,
15680 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
15681 TOKEN_STRING_INITIALIZER
15682 (struct cmd_pctype_mapping_update_result,
15683 mapping, "mapping");
15684 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
15685 TOKEN_STRING_INITIALIZER
15686 (struct cmd_pctype_mapping_update_result,
15688 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
15689 TOKEN_STRING_INITIALIZER
15690 (struct cmd_pctype_mapping_update_result,
15691 pctype_list, NULL);
15692 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
15693 TOKEN_NUM_INITIALIZER
15694 (struct cmd_pctype_mapping_update_result,
15695 flow_type, UINT16);
15698 cmd_pctype_mapping_update_parsed(
15699 void *parsed_result,
15700 __attribute__((unused)) struct cmdline *cl,
15701 __attribute__((unused)) void *data)
15703 struct cmd_pctype_mapping_update_result *res = parsed_result;
15704 int ret = -ENOTSUP;
15705 #ifdef RTE_LIBRTE_I40E_PMD
15706 struct rte_pmd_i40e_flow_type_mapping mapping;
15708 unsigned int nb_item;
15709 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
15712 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15715 #ifdef RTE_LIBRTE_I40E_PMD
15716 nb_item = parse_item_list(res->pctype_list, "pctypes",
15717 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
15718 mapping.flow_type = res->flow_type;
15719 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
15720 mapping.pctype |= (1ULL << pctype_list[i]);
15721 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
15731 printf("invalid pctype or flow type\n");
15734 printf("invalid port_id %d\n", res->port_id);
15737 printf("function not implemented\n");
15740 printf("programming error: (%s)\n", strerror(-ret));
15744 cmdline_parse_inst_t cmd_pctype_mapping_update = {
15745 .f = cmd_pctype_mapping_update_parsed,
15747 .help_str = "port config <port_id> pctype mapping update"
15748 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
15750 (void *)&cmd_pctype_mapping_update_port,
15751 (void *)&cmd_pctype_mapping_update_config,
15752 (void *)&cmd_pctype_mapping_update_port_id,
15753 (void *)&cmd_pctype_mapping_update_pctype,
15754 (void *)&cmd_pctype_mapping_update_mapping,
15755 (void *)&cmd_pctype_mapping_update_update,
15756 (void *)&cmd_pctype_mapping_update_pc_type,
15757 (void *)&cmd_pctype_mapping_update_flow_type,
15762 /* ptype mapping get */
15764 /* Common result structure for ptype mapping get */
15765 struct cmd_ptype_mapping_get_result {
15766 cmdline_fixed_string_t ptype;
15767 cmdline_fixed_string_t mapping;
15768 cmdline_fixed_string_t get;
15770 uint8_t valid_only;
15773 /* Common CLI fields for ptype mapping get */
15774 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
15775 TOKEN_STRING_INITIALIZER
15776 (struct cmd_ptype_mapping_get_result,
15778 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
15779 TOKEN_STRING_INITIALIZER
15780 (struct cmd_ptype_mapping_get_result,
15781 mapping, "mapping");
15782 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
15783 TOKEN_STRING_INITIALIZER
15784 (struct cmd_ptype_mapping_get_result,
15786 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
15787 TOKEN_NUM_INITIALIZER
15788 (struct cmd_ptype_mapping_get_result,
15790 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
15791 TOKEN_NUM_INITIALIZER
15792 (struct cmd_ptype_mapping_get_result,
15793 valid_only, UINT8);
15796 cmd_ptype_mapping_get_parsed(
15797 void *parsed_result,
15798 __attribute__((unused)) struct cmdline *cl,
15799 __attribute__((unused)) void *data)
15801 struct cmd_ptype_mapping_get_result *res = parsed_result;
15802 int ret = -ENOTSUP;
15803 #ifdef RTE_LIBRTE_I40E_PMD
15804 int max_ptype_num = 256;
15805 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
15810 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15813 #ifdef RTE_LIBRTE_I40E_PMD
15814 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
15825 printf("invalid port_id %d\n", res->port_id);
15828 printf("function not implemented\n");
15831 printf("programming error: (%s)\n", strerror(-ret));
15834 #ifdef RTE_LIBRTE_I40E_PMD
15836 for (i = 0; i < count; i++)
15837 printf("%3d\t0x%08x\n",
15838 mapping[i].hw_ptype, mapping[i].sw_ptype);
15843 cmdline_parse_inst_t cmd_ptype_mapping_get = {
15844 .f = cmd_ptype_mapping_get_parsed,
15846 .help_str = "ptype mapping get <port_id> <valid_only>",
15848 (void *)&cmd_ptype_mapping_get_ptype,
15849 (void *)&cmd_ptype_mapping_get_mapping,
15850 (void *)&cmd_ptype_mapping_get_get,
15851 (void *)&cmd_ptype_mapping_get_port_id,
15852 (void *)&cmd_ptype_mapping_get_valid_only,
15857 /* ptype mapping replace */
15859 /* Common result structure for ptype mapping replace */
15860 struct cmd_ptype_mapping_replace_result {
15861 cmdline_fixed_string_t ptype;
15862 cmdline_fixed_string_t mapping;
15863 cmdline_fixed_string_t replace;
15870 /* Common CLI fields for ptype mapping replace */
15871 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
15872 TOKEN_STRING_INITIALIZER
15873 (struct cmd_ptype_mapping_replace_result,
15875 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
15876 TOKEN_STRING_INITIALIZER
15877 (struct cmd_ptype_mapping_replace_result,
15878 mapping, "mapping");
15879 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
15880 TOKEN_STRING_INITIALIZER
15881 (struct cmd_ptype_mapping_replace_result,
15882 replace, "replace");
15883 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
15884 TOKEN_NUM_INITIALIZER
15885 (struct cmd_ptype_mapping_replace_result,
15887 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
15888 TOKEN_NUM_INITIALIZER
15889 (struct cmd_ptype_mapping_replace_result,
15891 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
15892 TOKEN_NUM_INITIALIZER
15893 (struct cmd_ptype_mapping_replace_result,
15895 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
15896 TOKEN_NUM_INITIALIZER
15897 (struct cmd_ptype_mapping_replace_result,
15901 cmd_ptype_mapping_replace_parsed(
15902 void *parsed_result,
15903 __attribute__((unused)) struct cmdline *cl,
15904 __attribute__((unused)) void *data)
15906 struct cmd_ptype_mapping_replace_result *res = parsed_result;
15907 int ret = -ENOTSUP;
15909 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15912 #ifdef RTE_LIBRTE_I40E_PMD
15913 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
15923 printf("invalid ptype 0x%8x or 0x%8x\n",
15924 res->target, res->pkt_type);
15927 printf("invalid port_id %d\n", res->port_id);
15930 printf("function not implemented\n");
15933 printf("programming error: (%s)\n", strerror(-ret));
15937 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
15938 .f = cmd_ptype_mapping_replace_parsed,
15941 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
15943 (void *)&cmd_ptype_mapping_replace_ptype,
15944 (void *)&cmd_ptype_mapping_replace_mapping,
15945 (void *)&cmd_ptype_mapping_replace_replace,
15946 (void *)&cmd_ptype_mapping_replace_port_id,
15947 (void *)&cmd_ptype_mapping_replace_target,
15948 (void *)&cmd_ptype_mapping_replace_mask,
15949 (void *)&cmd_ptype_mapping_replace_pkt_type,
15954 /* ptype mapping reset */
15956 /* Common result structure for ptype mapping reset */
15957 struct cmd_ptype_mapping_reset_result {
15958 cmdline_fixed_string_t ptype;
15959 cmdline_fixed_string_t mapping;
15960 cmdline_fixed_string_t reset;
15964 /* Common CLI fields for ptype mapping reset*/
15965 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
15966 TOKEN_STRING_INITIALIZER
15967 (struct cmd_ptype_mapping_reset_result,
15969 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
15970 TOKEN_STRING_INITIALIZER
15971 (struct cmd_ptype_mapping_reset_result,
15972 mapping, "mapping");
15973 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
15974 TOKEN_STRING_INITIALIZER
15975 (struct cmd_ptype_mapping_reset_result,
15977 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
15978 TOKEN_NUM_INITIALIZER
15979 (struct cmd_ptype_mapping_reset_result,
15983 cmd_ptype_mapping_reset_parsed(
15984 void *parsed_result,
15985 __attribute__((unused)) struct cmdline *cl,
15986 __attribute__((unused)) void *data)
15988 struct cmd_ptype_mapping_reset_result *res = parsed_result;
15989 int ret = -ENOTSUP;
15991 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15994 #ifdef RTE_LIBRTE_I40E_PMD
15995 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
16002 printf("invalid port_id %d\n", res->port_id);
16005 printf("function not implemented\n");
16008 printf("programming error: (%s)\n", strerror(-ret));
16012 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
16013 .f = cmd_ptype_mapping_reset_parsed,
16015 .help_str = "ptype mapping reset <port_id>",
16017 (void *)&cmd_ptype_mapping_reset_ptype,
16018 (void *)&cmd_ptype_mapping_reset_mapping,
16019 (void *)&cmd_ptype_mapping_reset_reset,
16020 (void *)&cmd_ptype_mapping_reset_port_id,
16025 /* ptype mapping update */
16027 /* Common result structure for ptype mapping update */
16028 struct cmd_ptype_mapping_update_result {
16029 cmdline_fixed_string_t ptype;
16030 cmdline_fixed_string_t mapping;
16031 cmdline_fixed_string_t reset;
16037 /* Common CLI fields for ptype mapping update*/
16038 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
16039 TOKEN_STRING_INITIALIZER
16040 (struct cmd_ptype_mapping_update_result,
16042 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
16043 TOKEN_STRING_INITIALIZER
16044 (struct cmd_ptype_mapping_update_result,
16045 mapping, "mapping");
16046 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
16047 TOKEN_STRING_INITIALIZER
16048 (struct cmd_ptype_mapping_update_result,
16050 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
16051 TOKEN_NUM_INITIALIZER
16052 (struct cmd_ptype_mapping_update_result,
16054 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
16055 TOKEN_NUM_INITIALIZER
16056 (struct cmd_ptype_mapping_update_result,
16058 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
16059 TOKEN_NUM_INITIALIZER
16060 (struct cmd_ptype_mapping_update_result,
16064 cmd_ptype_mapping_update_parsed(
16065 void *parsed_result,
16066 __attribute__((unused)) struct cmdline *cl,
16067 __attribute__((unused)) void *data)
16069 struct cmd_ptype_mapping_update_result *res = parsed_result;
16070 int ret = -ENOTSUP;
16071 #ifdef RTE_LIBRTE_I40E_PMD
16072 struct rte_pmd_i40e_ptype_mapping mapping;
16074 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16077 #ifdef RTE_LIBRTE_I40E_PMD
16078 mapping.hw_ptype = res->hw_ptype;
16079 mapping.sw_ptype = res->sw_ptype;
16080 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
16090 printf("invalid ptype 0x%8x\n", res->sw_ptype);
16093 printf("invalid port_id %d\n", res->port_id);
16096 printf("function not implemented\n");
16099 printf("programming error: (%s)\n", strerror(-ret));
16103 cmdline_parse_inst_t cmd_ptype_mapping_update = {
16104 .f = cmd_ptype_mapping_update_parsed,
16106 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
16108 (void *)&cmd_ptype_mapping_update_ptype,
16109 (void *)&cmd_ptype_mapping_update_mapping,
16110 (void *)&cmd_ptype_mapping_update_update,
16111 (void *)&cmd_ptype_mapping_update_port_id,
16112 (void *)&cmd_ptype_mapping_update_hw_ptype,
16113 (void *)&cmd_ptype_mapping_update_sw_ptype,
16118 /* Common result structure for file commands */
16119 struct cmd_cmdfile_result {
16120 cmdline_fixed_string_t load;
16121 cmdline_fixed_string_t filename;
16124 /* Common CLI fields for file commands */
16125 cmdline_parse_token_string_t cmd_load_cmdfile =
16126 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
16127 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
16128 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
16131 cmd_load_from_file_parsed(
16132 void *parsed_result,
16133 __attribute__((unused)) struct cmdline *cl,
16134 __attribute__((unused)) void *data)
16136 struct cmd_cmdfile_result *res = parsed_result;
16138 cmdline_read_from_file(res->filename);
16141 cmdline_parse_inst_t cmd_load_from_file = {
16142 .f = cmd_load_from_file_parsed,
16144 .help_str = "load <filename>",
16146 (void *)&cmd_load_cmdfile,
16147 (void *)&cmd_load_cmdfile_filename,
16152 /* ******************************************************************************** */
16154 /* list of instructions */
16155 cmdline_parse_ctx_t main_ctx[] = {
16156 (cmdline_parse_inst_t *)&cmd_help_brief,
16157 (cmdline_parse_inst_t *)&cmd_help_long,
16158 (cmdline_parse_inst_t *)&cmd_quit,
16159 (cmdline_parse_inst_t *)&cmd_load_from_file,
16160 (cmdline_parse_inst_t *)&cmd_showport,
16161 (cmdline_parse_inst_t *)&cmd_showqueue,
16162 (cmdline_parse_inst_t *)&cmd_showportall,
16163 (cmdline_parse_inst_t *)&cmd_showcfg,
16164 (cmdline_parse_inst_t *)&cmd_start,
16165 (cmdline_parse_inst_t *)&cmd_start_tx_first,
16166 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
16167 (cmdline_parse_inst_t *)&cmd_set_link_up,
16168 (cmdline_parse_inst_t *)&cmd_set_link_down,
16169 (cmdline_parse_inst_t *)&cmd_reset,
16170 (cmdline_parse_inst_t *)&cmd_set_numbers,
16171 (cmdline_parse_inst_t *)&cmd_set_log,
16172 (cmdline_parse_inst_t *)&cmd_set_txpkts,
16173 (cmdline_parse_inst_t *)&cmd_set_txsplit,
16174 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
16175 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
16176 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
16177 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
16178 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
16179 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
16180 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
16181 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
16182 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
16183 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
16184 (cmdline_parse_inst_t *)&cmd_set_link_check,
16185 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
16186 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
16187 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
16188 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
16189 #ifdef RTE_LIBRTE_PMD_BOND
16190 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
16191 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
16192 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
16193 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
16194 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
16195 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
16196 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
16197 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
16198 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
16199 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
16200 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
16202 (cmdline_parse_inst_t *)&cmd_vlan_offload,
16203 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
16204 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
16205 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
16206 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
16207 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
16208 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
16209 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
16210 (cmdline_parse_inst_t *)&cmd_csum_set,
16211 (cmdline_parse_inst_t *)&cmd_csum_show,
16212 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
16213 (cmdline_parse_inst_t *)&cmd_tso_set,
16214 (cmdline_parse_inst_t *)&cmd_tso_show,
16215 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
16216 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
16217 (cmdline_parse_inst_t *)&cmd_gro_enable,
16218 (cmdline_parse_inst_t *)&cmd_gro_flush,
16219 (cmdline_parse_inst_t *)&cmd_gro_show,
16220 (cmdline_parse_inst_t *)&cmd_gso_enable,
16221 (cmdline_parse_inst_t *)&cmd_gso_size,
16222 (cmdline_parse_inst_t *)&cmd_gso_show,
16223 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
16224 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
16225 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
16226 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
16227 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
16228 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
16229 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
16230 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
16231 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
16232 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
16233 (cmdline_parse_inst_t *)&cmd_config_dcb,
16234 (cmdline_parse_inst_t *)&cmd_read_reg,
16235 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
16236 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
16237 (cmdline_parse_inst_t *)&cmd_write_reg,
16238 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
16239 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
16240 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
16241 (cmdline_parse_inst_t *)&cmd_stop,
16242 (cmdline_parse_inst_t *)&cmd_mac_addr,
16243 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
16244 (cmdline_parse_inst_t *)&cmd_set_qmap,
16245 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
16246 (cmdline_parse_inst_t *)&cmd_operate_port,
16247 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
16248 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
16249 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
16250 (cmdline_parse_inst_t *)&cmd_config_speed_all,
16251 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
16252 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
16253 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
16254 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
16255 (cmdline_parse_inst_t *)&cmd_config_mtu,
16256 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
16257 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
16258 (cmdline_parse_inst_t *)&cmd_config_rss,
16259 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
16260 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
16261 (cmdline_parse_inst_t *)&cmd_showport_reta,
16262 (cmdline_parse_inst_t *)&cmd_config_burst,
16263 (cmdline_parse_inst_t *)&cmd_config_thresh,
16264 (cmdline_parse_inst_t *)&cmd_config_threshold,
16265 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
16266 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
16267 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
16268 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
16269 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
16270 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
16271 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
16272 (cmdline_parse_inst_t *)&cmd_global_config,
16273 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
16274 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
16275 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
16276 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
16277 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
16278 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
16279 (cmdline_parse_inst_t *)&cmd_dump,
16280 (cmdline_parse_inst_t *)&cmd_dump_one,
16281 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
16282 (cmdline_parse_inst_t *)&cmd_syn_filter,
16283 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
16284 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
16285 (cmdline_parse_inst_t *)&cmd_flex_filter,
16286 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
16287 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
16288 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
16289 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
16290 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
16291 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
16292 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
16293 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
16294 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
16295 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
16296 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
16297 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
16298 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
16299 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
16300 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
16301 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
16302 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
16303 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
16304 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
16305 (cmdline_parse_inst_t *)&cmd_flow,
16306 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
16307 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
16308 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
16309 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
16310 (cmdline_parse_inst_t *)&cmd_create_port_meter,
16311 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
16312 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
16313 (cmdline_parse_inst_t *)&cmd_del_port_meter,
16314 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
16315 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
16316 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
16317 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
16318 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
16319 (cmdline_parse_inst_t *)&cmd_mcast_addr,
16320 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
16321 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
16322 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
16323 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
16324 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
16325 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
16326 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
16327 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
16328 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
16329 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
16330 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
16331 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
16332 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
16333 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
16334 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
16335 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
16336 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
16337 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
16338 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
16339 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
16340 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
16341 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
16342 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
16343 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
16344 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
16345 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
16346 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
16347 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
16348 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
16349 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
16350 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
16351 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
16352 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
16353 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
16354 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
16355 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
16356 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
16358 (cmdline_parse_inst_t *)&cmd_ddp_add,
16359 (cmdline_parse_inst_t *)&cmd_ddp_del,
16360 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
16361 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
16362 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
16363 (cmdline_parse_inst_t *)&cmd_clear_input_set,
16364 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
16365 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
16366 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
16367 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
16368 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
16369 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
16371 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
16372 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
16373 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
16374 (cmdline_parse_inst_t *)&cmd_queue_region,
16375 (cmdline_parse_inst_t *)&cmd_region_flowtype,
16376 (cmdline_parse_inst_t *)&cmd_user_priority_region,
16377 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
16378 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
16379 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
16380 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
16381 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
16382 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
16383 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
16384 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
16385 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
16386 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
16387 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
16388 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
16389 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
16390 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
16391 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
16392 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
16393 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
16394 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
16395 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
16399 /* read cmdline commands from file */
16401 cmdline_read_from_file(const char *filename)
16403 struct cmdline *cl;
16405 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
16407 printf("Failed to create file based cmdline context: %s\n",
16412 cmdline_interact(cl);
16417 printf("Read CLI commands from %s\n", filename);
16420 /* prompt function, called from main on MASTER lcore */
16424 /* initialize non-constant commands */
16425 cmd_set_fwd_mode_init();
16426 cmd_set_fwd_retry_mode_init();
16428 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
16429 if (testpmd_cl == NULL)
16431 cmdline_interact(testpmd_cl);
16432 cmdline_stdin_exit(testpmd_cl);
16438 if (testpmd_cl != NULL)
16439 cmdline_quit(testpmd_cl);
16443 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
16445 if (id == (portid_t)RTE_PORT_ALL) {
16448 RTE_ETH_FOREACH_DEV(pid) {
16449 /* check if need_reconfig has been set to 1 */
16450 if (ports[pid].need_reconfig == 0)
16451 ports[pid].need_reconfig = dev;
16452 /* check if need_reconfig_queues has been set to 1 */
16453 if (ports[pid].need_reconfig_queues == 0)
16454 ports[pid].need_reconfig_queues = queue;
16456 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
16457 /* check if need_reconfig has been set to 1 */
16458 if (ports[id].need_reconfig == 0)
16459 ports[id].need_reconfig = dev;
16460 /* check if need_reconfig_queues has been set to 1 */
16461 if (ports[id].need_reconfig_queues == 0)
16462 ports[id].need_reconfig_queues = queue;